aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/event
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-05-13 14:22:26 +0900
committerJean Chalard <jchalard@google.com>2014-05-14 16:09:33 +0900
commitd23d1970b050733807ce6c04c359b77ffbc1e988 (patch)
treede18889f357d8bdb5deab27111ed0cb4b67a7c9e /java/src/com/android/inputmethod/event
parent61ddac28de56861aa77a7f06e5607ddec7ce8ccd (diff)
downloadlatinime-d23d1970b050733807ce6c04c359b77ffbc1e988.tar.gz
latinime-d23d1970b050733807ce6c04c359b77ffbc1e988.tar.xz
latinime-d23d1970b050733807ce6c04c359b77ffbc1e988.zip
Implement backspace in the current cluster for Myanmar
Bug: 13945569 Change-Id: I738b01ede25fd731a2e10c4775f5511ce9bb54c8
Diffstat (limited to 'java/src/com/android/inputmethod/event')
-rw-r--r--java/src/com/android/inputmethod/event/MyanmarReordering.java30
1 files changed, 27 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/event/MyanmarReordering.java b/java/src/com/android/inputmethod/event/MyanmarReordering.java
index 27b8c14bb..da0228bd2 100644
--- a/java/src/com/android/inputmethod/event/MyanmarReordering.java
+++ b/java/src/com/android/inputmethod/event/MyanmarReordering.java
@@ -207,9 +207,33 @@ public class MyanmarReordering implements Combiner {
return clearAndGetResultingEvent(newEvent);
}
} else if (Constants.CODE_DELETE == newEvent.mKeyCode) {
- if (mCurrentEvents.size() > 0) {
- mCurrentEvents.remove(mCurrentEvents.size() - 1);
- return null;
+ final Event lastEvent = getLastEvent();
+ final int eventSize = mCurrentEvents.size();
+ if (null != lastEvent) {
+ if (VOWEL_E == lastEvent.mCodePoint) {
+ // We have a VOWEL_E at the end. There are four cases.
+ // - The vowel is the only code point in the buffer. Remove it.
+ // - The vowel is preceded by a ZWNJ. Remove both vowel E and ZWNJ.
+ // - The vowel is preceded by a consonant/medial, remove the consonant/medial.
+ // - In all other cases, it's strange, so just remove the last code point.
+ if (eventSize <= 1) {
+ mCurrentEvents.clear();
+ } else { // eventSize >= 2
+ final int previousCodePoint = mCurrentEvents.get(eventSize - 2).mCodePoint;
+ if (previousCodePoint == ZERO_WIDTH_NON_JOINER) {
+ mCurrentEvents.remove(eventSize - 1);
+ mCurrentEvents.remove(eventSize - 2);
+ } else if (isConsonantOrMedial(previousCodePoint)) {
+ mCurrentEvents.remove(eventSize - 2);
+ } else {
+ mCurrentEvents.remove(eventSize - 1);
+ }
+ }
+ return null;
+ } else if (eventSize > 0) {
+ mCurrentEvents.remove(eventSize - 1);
+ return null;
+ }
}
}
// This character is not part of the combining scheme, so we should reset everything.