mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-28 18:48:09 +00:00
fix some issues with korean input
This commit is contained in:
parent
48ad8efff5
commit
1640b53dfc
2 changed files with 13 additions and 9 deletions
|
@ -434,12 +434,14 @@ public final class InputLogic {
|
||||||
mWordBeingCorrectedByCursor = null;
|
mWordBeingCorrectedByCursor = null;
|
||||||
mJustRevertedACommit = false;
|
mJustRevertedACommit = false;
|
||||||
final Event processedEvent;
|
final Event processedEvent;
|
||||||
|
Log.i("test", "cp "+event.getMCodePoint()+", code "+event.getMKeyCode());
|
||||||
if (currentKeyboardScriptId == ScriptUtils.SCRIPT_HANGUL
|
if (currentKeyboardScriptId == ScriptUtils.SCRIPT_HANGUL
|
||||||
// only use the Hangul chain if codepoint may actually be Hangul
|
// only use the Hangul chain if codepoint may actually be Hangul
|
||||||
// todo: this whole hangul-related logic should probably be somewhere else
|
// todo: this whole hangul-related logic should probably be somewhere else
|
||||||
// need to use hangul combiner for whitespace, because otherwise the current word
|
// need to use hangul combiner for whitespace, because otherwise the current word
|
||||||
// seems to get deleted / replaced by space during mConnection.endBatchEdit()
|
// seems to get deleted / replaced by space during mConnection.endBatchEdit()
|
||||||
&& (event.getMCodePoint() >= 0x1100 || Character.isWhitespace(event.getMCodePoint()))) {
|
// similar for functional keys (codePoint -1)
|
||||||
|
&& (event.getMCodePoint() >= 0x1100 || Character.isWhitespace(event.getMCodePoint()) || event.getMCodePoint() == -1)) {
|
||||||
mWordComposer.setHangul(true);
|
mWordComposer.setHangul(true);
|
||||||
final Event hangulDecodedEvent = HangulEventDecoder.decodeSoftwareKeyEvent(event);
|
final Event hangulDecodedEvent = HangulEventDecoder.decodeSoftwareKeyEvent(event);
|
||||||
// todo: here hangul combiner does already consume the event, and appends typed codepoint
|
// todo: here hangul combiner does already consume the event, and appends typed codepoint
|
||||||
|
|
|
@ -136,12 +136,12 @@ class InputLogicTest {
|
||||||
@Test fun insertLetterIntoWordHangul() {
|
@Test fun insertLetterIntoWordHangul() {
|
||||||
reset()
|
reset()
|
||||||
currentScript = ScriptUtils.SCRIPT_HANGUL
|
currentScript = ScriptUtils.SCRIPT_HANGUL
|
||||||
setText("ㅛㅎㄹㅎㅕㅛ")
|
chainInput("ㅛㅎㄹㅎㅕㅛ")
|
||||||
setCursorPosition(3)
|
setCursorPosition(3)
|
||||||
input('ㄲ') // fails, as expected from the hangul issue when processing the event in onCodeInput
|
input('ㄲ') // fails, as expected from the hangul issue when processing the event in onCodeInput
|
||||||
assertEquals("ㅛㅎㄹㄲㅎㅕㅛ", getWordAtCursor())
|
assertEquals("ㅛㅎㄹㄲ혀ㅛ", getWordAtCursor())
|
||||||
assertEquals("ㅛㅎㄹㄲㅎㅕㅛ", getText())
|
assertEquals("ㅛㅎㄹㄲ혀ㅛ", getText())
|
||||||
assertEquals("ㅛㅎㄹㄲㅎㅕㅛ", textBeforeCursor + textAfterCursor)
|
assertEquals("ㅛㅎㄹㄲ혀ㅛ", textBeforeCursor + textAfterCursor)
|
||||||
assertEquals(4, getCursorPosition())
|
assertEquals(4, getCursorPosition())
|
||||||
assertEquals(4, cursor)
|
assertEquals(4, cursor)
|
||||||
}
|
}
|
||||||
|
@ -525,10 +525,12 @@ class InputLogicTest {
|
||||||
latinIME.onEvent(Event.createEventForCodePointFromUnknownSource(codePoint))
|
latinIME.onEvent(Event.createEventForCodePointFromUnknownSource(codePoint))
|
||||||
handleMessages()
|
handleMessages()
|
||||||
|
|
||||||
if (phantomSpaceToInsert.isEmpty())
|
if (currentScript != ScriptUtils.SCRIPT_HANGUL) { // check fails if hangul combiner merges symbols
|
||||||
assertEquals(oldBefore + insert, textBeforeCursor)
|
if (phantomSpaceToInsert.isEmpty())
|
||||||
else // in some cases autospace might be suppressed
|
assertEquals(oldBefore + insert, textBeforeCursor)
|
||||||
assert(oldBefore + phantomSpaceToInsert + insert == textBeforeCursor || oldBefore + insert == textBeforeCursor)
|
else // in some cases autospace might be suppressed
|
||||||
|
assert(oldBefore + phantomSpaceToInsert + insert == textBeforeCursor || oldBefore + insert == textBeforeCursor)
|
||||||
|
}
|
||||||
assertEquals(oldAfter, textAfterCursor)
|
assertEquals(oldAfter, textAfterCursor)
|
||||||
assertEquals(textBeforeCursor + textAfterCursor, getText())
|
assertEquals(textBeforeCursor + textAfterCursor, getText())
|
||||||
checkConnectionConsistency()
|
checkConnectionConsistency()
|
||||||
|
|
Loading…
Add table
Reference in a new issue