mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-17 15:32:48 +00:00
fix hangul issue, some formatting
This commit is contained in:
parent
c4781e3da0
commit
c7751423a1
2 changed files with 27 additions and 19 deletions
|
@ -185,12 +185,19 @@ public final class WordComposer {
|
|||
* @param event the event to apply. Must not be null.
|
||||
*/
|
||||
public void applyProcessedEvent(final Event event) {
|
||||
applyProcessedEvent(event, false);
|
||||
}
|
||||
|
||||
// specifically for that Constants.CODE_OUTPUT_TEXT Hangul event: try keeping cursor position
|
||||
// because typically nothing changes, todo: if really nothing changes maybe there is a better way to do it
|
||||
public void applyProcessedEvent(final Event event, final boolean keepCursorPosition) {
|
||||
mCombinerChain.applyProcessedEvent(event);
|
||||
final int primaryCode = event.getMCodePoint();
|
||||
final int keyX = event.getMX();
|
||||
final int keyY = event.getMY();
|
||||
final int newIndex = size();
|
||||
refreshTypedWordCache();
|
||||
if (!keepCursorPosition || newIndex == mCodePointSize)
|
||||
mCursorPositionWithinWord = mCodePointSize;
|
||||
// We may have deleted the last one.
|
||||
if (0 == mCodePointSize) {
|
||||
|
|
|
@ -441,7 +441,9 @@ public final class InputLogic {
|
|||
if (currentKeyboardScriptId == ScriptUtils.SCRIPT_HANGUL
|
||||
// only use the Hangul chain if codepoint may actually be Hangul
|
||||
// todo: this whole hangul-related logic should probably be somewhere else
|
||||
&& event.getMCodePoint() >= 0x1100) {
|
||||
// need to use hangul combiner for whitespace, because otherwise the current word
|
||||
// seems to get deleted / replaced by space during mConnection.endBatchEdit()
|
||||
&& (event.getMCodePoint() >= 0x1100 || Character.isWhitespace(event.getMCodePoint()))) {
|
||||
mWordComposer.setHangul(true);
|
||||
final Event hangulDecodedEvent = HangulEventDecoder.decodeSoftwareKeyEvent(event);
|
||||
processedEvent = mWordComposer.processEvent(hangulDecodedEvent);
|
||||
|
@ -739,9 +741,10 @@ public final class InputLogic {
|
|||
inputTransaction.setDidAffectContents();
|
||||
break;
|
||||
case Constants.CODE_OUTPUT_TEXT:
|
||||
// added in the hangul branch, but without this a space after a period crashes
|
||||
// -> where is the change?
|
||||
mWordComposer.applyProcessedEvent(event);
|
||||
// added in the hangul branch, createEventChainFromSequence
|
||||
// this introduces issues like space being added behind cursor, or input deleting
|
||||
// a word, but the keepCursorPosition applyProcessedEvent seems to help here
|
||||
mWordComposer.applyProcessedEvent(event, true);
|
||||
break;
|
||||
case Constants.CODE_START_ONE_HANDED_MODE:
|
||||
case Constants.CODE_STOP_ONE_HANDED_MODE:
|
||||
|
@ -1494,8 +1497,7 @@ public final class InputLogic {
|
|||
ngramContext, timeStampInSeconds, settingsValues.mBlockPotentiallyOffensive);
|
||||
}
|
||||
|
||||
public void performUpdateSuggestionStripSync(final SettingsValues settingsValues,
|
||||
final int inputStyle) {
|
||||
public void performUpdateSuggestionStripSync(final SettingsValues settingsValues, final int inputStyle) {
|
||||
long startTimeMillis = 0;
|
||||
if (DebugFlags.DEBUG_ENABLED) {
|
||||
startTimeMillis = System.currentTimeMillis();
|
||||
|
@ -1585,12 +1587,13 @@ public final class InputLogic {
|
|||
mConnection.finishComposingText();
|
||||
return;
|
||||
}
|
||||
final TextRange range = mConnection.getWordRangeAtCursor(
|
||||
settingsValues.mSpacingAndPunctuations, currentKeyboardScriptId, true);
|
||||
final TextRange range =
|
||||
mConnection.getWordRangeAtCursor(settingsValues.mSpacingAndPunctuations, currentKeyboardScriptId, true);
|
||||
if (null == range) return; // Happens if we don't have an input connection at all
|
||||
if (range.length() <= 0) {
|
||||
// Race condition, or touching a word in a non-supported script.
|
||||
mLatinIME.setNeutralSuggestionStrip();
|
||||
mConnection.finishComposingText();
|
||||
return;
|
||||
}
|
||||
// If for some strange reason (editor bug or so) we measure the text before the cursor as
|
||||
|
@ -1631,10 +1634,8 @@ public final class InputLogic {
|
|||
}
|
||||
}
|
||||
final int[] codePoints = StringUtils.toCodePointArray(typedWordString);
|
||||
mWordComposer.setComposingWord(codePoints,
|
||||
mLatinIME.getCoordinatesForCurrentKeyboard(codePoints));
|
||||
mWordComposer.setCursorPositionWithinWord(
|
||||
typedWordString.codePointCount(0, numberOfCharsInWordBeforeCursor));
|
||||
mWordComposer.setComposingWord(codePoints, mLatinIME.getCoordinatesForCurrentKeyboard(codePoints));
|
||||
mWordComposer.setCursorPositionWithinWord(typedWordString.codePointCount(0, numberOfCharsInWordBeforeCursor));
|
||||
mConnection.setComposingRegion(expectedCursorPosition - numberOfCharsInWordBeforeCursor,
|
||||
expectedCursorPosition + range.getNumberOfCharsInWordAfterCursor());
|
||||
if (suggestions.size() <= 1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue