diff options
author | 2014-12-22 17:18:56 +0900 | |
---|---|---|
committer | 2014-12-22 17:47:33 +0900 | |
commit | 8e235191dd3501fc3562fe0654d41501ec9760d0 (patch) | |
tree | 217e998021ab7de6cf3b99beecaf4fb6e192fac0 /java | |
parent | 3e35b8712c3df40291e6ff8ec2889b53f6dd8371 (diff) | |
download | latinime-8e235191dd3501fc3562fe0654d41501ec9760d0.tar.gz latinime-8e235191dd3501fc3562fe0654d41501ec9760d0.tar.xz latinime-8e235191dd3501fc3562fe0654d41501ec9760d0.zip |
Fix moving the cursor inside composition in lang w/o spaces
Also introduce the cursor move event, which we needed to do
anyway
Bug: 18827118
Change-Id: I30e994764c095b4423b874dc05d1bbedc0de592f
Diffstat (limited to 'java')
-rw-r--r-- | java/src/com/android/inputmethod/event/Event.java | 15 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/WordComposer.java | 4 |
2 files changed, 17 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/event/Event.java b/java/src/com/android/inputmethod/event/Event.java index a1226dc93..e3b1afc53 100644 --- a/java/src/com/android/inputmethod/event/Event.java +++ b/java/src/com/android/inputmethod/event/Event.java @@ -58,6 +58,8 @@ public class Event { final public static int EVENT_TYPE_SUGGESTION_PICKED = 5; // An event corresponding to a string generated by some software process. final public static int EVENT_TYPE_SOFTWARE_GENERATED_STRING = 6; + // An event corresponding to a cursor move + final public static int EVENT_TYPE_CURSOR_MOVE = 7; // 0 is a valid code point, so we use -1 here. final public static int NOT_A_CODE_POINT = -1; @@ -234,6 +236,18 @@ public class Event { } /** + * Creates an input event representing moving the cursor. The relative move amount is stored + * in mX. + * @param moveAmount the relative move amount. + * @return an event for this cursor move. + */ + @Nonnull + public static Event createCursorMovedEvent(final int moveAmount) { + return new Event(EVENT_TYPE_CURSOR_MOVE, null, NOT_A_CODE_POINT, NOT_A_KEY_CODE, + moveAmount, Constants.NOT_A_COORDINATE, null, FLAG_NONE, null); + } + + /** * Creates an event identical to the passed event, but that has already been consumed. * @param source the event to copy the properties of. * @return an identical event marked as consumed. @@ -291,6 +305,7 @@ public class Event { case EVENT_TYPE_MODE_KEY: case EVENT_TYPE_NOT_HANDLED: case EVENT_TYPE_TOGGLE: + case EVENT_TYPE_CURSOR_MOVE: return ""; case EVENT_TYPE_INPUT_KEYPRESS: return StringUtils.newSingleCodePointString(mCodePoint); diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java index 78860d87d..e605bfe78 100644 --- a/java/src/com/android/inputmethod/latin/WordComposer.java +++ b/java/src/com/android/inputmethod/latin/WordComposer.java @@ -231,8 +231,6 @@ public final class WordComposer { * @return true if the cursor is still inside the composing word, false otherwise. */ public boolean moveCursorByAndReturnIfInsideComposingWord(final int expectedMoveAmount) { - // TODO: should uncommit the composing feedback - mCombinerChain.reset(); int actualMoveAmountWithinWord = 0; int cursorPos = mCursorPositionWithinWord; // TODO: Don't make that copy. We can do this directly from mTypedWordCache. @@ -256,6 +254,8 @@ public final class WordComposer { // so the result would not be inside the composing word. if (actualMoveAmountWithinWord != expectedMoveAmount) return false; mCursorPositionWithinWord = cursorPos; + mCombinerChain.applyProcessedEvent(mCombinerChain.processEvent(mEvents, + Event.createCursorMovedEvent(cursorPos))); return true; } |