Loading java/src/com/android/inputmethod/event/CombinerChain.java +15 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,9 @@ package com.android.inputmethod.event; import android.text.SpannableStringBuilder; import android.text.TextUtils; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.utils.CollectionUtils; import java.util.ArrayList; Loading Loading @@ -84,7 +86,19 @@ public class CombinerChain { } } if (null != event) { mCombinedText.append(event.getTextToCommit()); // TODO: figure out the generic way of doing this if (Constants.CODE_DELETE == event.mKeyCode) { final int length = mCombinedText.length(); if (length > 0) { final int lastCodePoint = mCombinedText.codePointBefore(length); mCombinedText.delete(length - Character.charCount(lastCodePoint), length); } } else { final CharSequence textToCommit = event.getTextToCommit(); if (!TextUtils.isEmpty(textToCommit)) { mCombinedText.append(textToCommit); } } } mStateFeedback.clear(); for (int i = mCombiners.size() - 1; i >= 0; --i) { Loading java/src/com/android/inputmethod/event/Event.java +1 −1 Original line number Diff line number Diff line Loading @@ -229,9 +229,9 @@ public class Event { switch (mType) { case EVENT_MODE_KEY: case EVENT_NOT_HANDLED: case EVENT_TOGGLE: return ""; case EVENT_INPUT_KEYPRESS: case EVENT_TOGGLE: return StringUtils.newSingleCodePointString(mCodePoint); case EVENT_GESTURE: case EVENT_SOFTWARE_GENERATED_STRING: Loading java/src/com/android/inputmethod/latin/Suggest.java +6 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.inputmethod.latin; import android.text.TextUtils; import com.android.inputmethod.event.Event; import com.android.inputmethod.keyboard.ProximityInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.define.ProductionFlag; Loading Loading @@ -104,7 +105,11 @@ public final class Suggest { if (trailingSingleQuotesCount > 0) { wordComposerForLookup = new WordComposer(wordComposer); for (int i = trailingSingleQuotesCount - 1; i >= 0; --i) { wordComposerForLookup.deleteLast(); // TODO: do not create a fake event for this. Ideally the word composer should know // how to give out the word without trailing quotes and we can remove this entirely wordComposerForLookup.deleteLast(Event.createSoftwareKeypressEvent( Event.NOT_A_CODE_POINT, Constants.CODE_DELETE, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE)); } } else { wordComposerForLookup = wordComposer; Loading java/src/com/android/inputmethod/latin/WordComposer.java +7 −22 Original line number Diff line number Diff line Loading @@ -314,29 +314,14 @@ public final class WordComposer { } /** * Delete the last keystroke as a result of hitting backspace. * Delete the last composing unit as a result of hitting backspace. */ public void deleteLast() { final int size = size(); if (size > 0) { // Note: mTypedWord.length() and mCodes.length differ when there are surrogate pairs final int stringBuilderLength = mTypedWord.length(); if (stringBuilderLength < size) { throw new RuntimeException( "In WordComposer: mCodes and mTypedWords have non-matching lengths"); } final int lastChar = mTypedWord.codePointBefore(stringBuilderLength); // TODO: with events and composition, this is absolutely not necessarily true. mEvents.remove(mEvents.size() - 1); if (Character.isSupplementaryCodePoint(lastChar)) { mTypedWord.delete(stringBuilderLength - 2, stringBuilderLength); } else { mTypedWord.deleteCharAt(stringBuilderLength - 1); } if (Character.isUpperCase(lastChar)) mCapsCount--; if (Character.isDigit(lastChar)) mDigitsCount--; public void deleteLast(final Event event) { mCombinerChain.processEvent(mEvents, event); mTypedWord.replace(0, mTypedWord.length(), mCombinerChain.getComposingWordWithCombiningFeedback().toString()); mEvents.add(event); refreshSize(); } // We may have deleted the last one. if (0 == size()) { mIsFirstCharCapitalized = false; Loading java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +1 −1 Original line number Diff line number Diff line Loading @@ -908,7 +908,7 @@ public final class InputLogic { mWordComposer.reset(); mWordComposer.setRejectedBatchModeSuggestion(rejectedSuggestion); } else { mWordComposer.deleteLast(); mWordComposer.deleteLast(inputTransaction.mEvent); } mConnection.setComposingText(getTextWithUnderline(mWordComposer.getTypedWord()), 1); handler.postUpdateSuggestionStrip(); Loading Loading
java/src/com/android/inputmethod/event/CombinerChain.java +15 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,9 @@ package com.android.inputmethod.event; import android.text.SpannableStringBuilder; import android.text.TextUtils; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.utils.CollectionUtils; import java.util.ArrayList; Loading Loading @@ -84,7 +86,19 @@ public class CombinerChain { } } if (null != event) { mCombinedText.append(event.getTextToCommit()); // TODO: figure out the generic way of doing this if (Constants.CODE_DELETE == event.mKeyCode) { final int length = mCombinedText.length(); if (length > 0) { final int lastCodePoint = mCombinedText.codePointBefore(length); mCombinedText.delete(length - Character.charCount(lastCodePoint), length); } } else { final CharSequence textToCommit = event.getTextToCommit(); if (!TextUtils.isEmpty(textToCommit)) { mCombinedText.append(textToCommit); } } } mStateFeedback.clear(); for (int i = mCombiners.size() - 1; i >= 0; --i) { Loading
java/src/com/android/inputmethod/event/Event.java +1 −1 Original line number Diff line number Diff line Loading @@ -229,9 +229,9 @@ public class Event { switch (mType) { case EVENT_MODE_KEY: case EVENT_NOT_HANDLED: case EVENT_TOGGLE: return ""; case EVENT_INPUT_KEYPRESS: case EVENT_TOGGLE: return StringUtils.newSingleCodePointString(mCodePoint); case EVENT_GESTURE: case EVENT_SOFTWARE_GENERATED_STRING: Loading
java/src/com/android/inputmethod/latin/Suggest.java +6 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.inputmethod.latin; import android.text.TextUtils; import com.android.inputmethod.event.Event; import com.android.inputmethod.keyboard.ProximityInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.define.ProductionFlag; Loading Loading @@ -104,7 +105,11 @@ public final class Suggest { if (trailingSingleQuotesCount > 0) { wordComposerForLookup = new WordComposer(wordComposer); for (int i = trailingSingleQuotesCount - 1; i >= 0; --i) { wordComposerForLookup.deleteLast(); // TODO: do not create a fake event for this. Ideally the word composer should know // how to give out the word without trailing quotes and we can remove this entirely wordComposerForLookup.deleteLast(Event.createSoftwareKeypressEvent( Event.NOT_A_CODE_POINT, Constants.CODE_DELETE, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE)); } } else { wordComposerForLookup = wordComposer; Loading
java/src/com/android/inputmethod/latin/WordComposer.java +7 −22 Original line number Diff line number Diff line Loading @@ -314,29 +314,14 @@ public final class WordComposer { } /** * Delete the last keystroke as a result of hitting backspace. * Delete the last composing unit as a result of hitting backspace. */ public void deleteLast() { final int size = size(); if (size > 0) { // Note: mTypedWord.length() and mCodes.length differ when there are surrogate pairs final int stringBuilderLength = mTypedWord.length(); if (stringBuilderLength < size) { throw new RuntimeException( "In WordComposer: mCodes and mTypedWords have non-matching lengths"); } final int lastChar = mTypedWord.codePointBefore(stringBuilderLength); // TODO: with events and composition, this is absolutely not necessarily true. mEvents.remove(mEvents.size() - 1); if (Character.isSupplementaryCodePoint(lastChar)) { mTypedWord.delete(stringBuilderLength - 2, stringBuilderLength); } else { mTypedWord.deleteCharAt(stringBuilderLength - 1); } if (Character.isUpperCase(lastChar)) mCapsCount--; if (Character.isDigit(lastChar)) mDigitsCount--; public void deleteLast(final Event event) { mCombinerChain.processEvent(mEvents, event); mTypedWord.replace(0, mTypedWord.length(), mCombinerChain.getComposingWordWithCombiningFeedback().toString()); mEvents.add(event); refreshSize(); } // We may have deleted the last one. if (0 == size()) { mIsFirstCharCapitalized = false; Loading
java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +1 −1 Original line number Diff line number Diff line Loading @@ -908,7 +908,7 @@ public final class InputLogic { mWordComposer.reset(); mWordComposer.setRejectedBatchModeSuggestion(rejectedSuggestion); } else { mWordComposer.deleteLast(); mWordComposer.deleteLast(inputTransaction.mEvent); } mConnection.setComposingText(getTextWithUnderline(mWordComposer.getTypedWord()), 1); handler.postUpdateSuggestionStrip(); Loading