mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-03 21:24:46 +00:00
Use software string event for HangulCombiner composing word processing to fix auto spacing problem
This commit is contained in:
parent
1616c89bd4
commit
a5f773619b
4 changed files with 18 additions and 19 deletions
|
@ -206,6 +206,13 @@ class Event private constructor(// The type of event - one of the constants abov
|
||||||
null /* suggestedWordInfo */, FLAG_NONE, null /* next */)
|
null /* suggestedWordInfo */, FLAG_NONE, null /* next */)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun createSoftwareTextEvent(text: CharSequence?, keyCode: Int, next: Event): Event {
|
||||||
|
return Event(EVENT_TYPE_SOFTWARE_GENERATED_STRING, text, NOT_A_CODE_POINT, keyCode,
|
||||||
|
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE,
|
||||||
|
null /* suggestedWordInfo */, FLAG_NONE, next)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an input event representing the manual pick of a punctuation suggestion.
|
* Creates an input event representing the manual pick of a punctuation suggestion.
|
||||||
* @return an event for this suggestion pick.
|
* @return an event for this suggestion pick.
|
||||||
|
|
|
@ -43,9 +43,7 @@ class HangulCombiner : Combiner {
|
||||||
val currentSyllable = syllable ?: HangulSyllable()
|
val currentSyllable = syllable ?: HangulSyllable()
|
||||||
val jamo = HangulJamo.of(event.mCodePoint)
|
val jamo = HangulJamo.of(event.mCodePoint)
|
||||||
if(!event.isCombining || jamo is HangulJamo.NonHangul) {
|
if(!event.isCombining || jamo is HangulJamo.NonHangul) {
|
||||||
val text = combiningStateFeedback
|
composingWord.append(jamo.string)
|
||||||
reset()
|
|
||||||
return createEventChainFromSequence(text, event)
|
|
||||||
} else {
|
} else {
|
||||||
when(jamo) {
|
when(jamo) {
|
||||||
is HangulJamo.Consonant -> {
|
is HangulJamo.Consonant -> {
|
||||||
|
@ -316,19 +314,8 @@ class HangulCombiner : Combiner {
|
||||||
0x11b8 to 0x11ba to 0x11b9, // ㅄ
|
0x11b8 to 0x11ba to 0x11b9, // ㅄ
|
||||||
0x11ba to 0x11ba to 0x11bb // ㅆ
|
0x11ba to 0x11ba to 0x11bb // ㅆ
|
||||||
)
|
)
|
||||||
private fun createEventChainFromSequence(text: CharSequence, originalEvent: Event?): Event? {
|
private fun createEventChainFromSequence(text: CharSequence, originalEvent: Event): Event {
|
||||||
var index = text.length
|
return Event.createSoftwareTextEvent(text, Constants.CODE_OUTPUT_TEXT, originalEvent);
|
||||||
if (index <= 0) {
|
|
||||||
return originalEvent
|
|
||||||
}
|
|
||||||
var lastEvent: Event? = originalEvent
|
|
||||||
do {
|
|
||||||
val codePoint = Character.codePointBefore(text, index)
|
|
||||||
lastEvent = Event.Companion.createHardwareKeypressEvent(codePoint,
|
|
||||||
originalEvent!!.mKeyCode, lastEvent, false /* isKeyRepeat */)
|
|
||||||
index -= Character.charCount(codePoint)
|
|
||||||
} while (index > 0)
|
|
||||||
return lastEvent
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,8 @@ public class KoreanDictionary extends Dictionary {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean same(char[] word, int length, String typedWord) {
|
protected boolean same(char[] word, int length, String typedWord) {
|
||||||
|
word = processInput(new String(word)).toCharArray();
|
||||||
|
typedWord = processInput(typedWord);
|
||||||
return mDictionary.same(word, length, typedWord);
|
return mDictionary.same(word, length, typedWord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -702,6 +702,9 @@ public final class InputLogic {
|
||||||
// line, so that does affect the contents of the editor.
|
// line, so that does affect the contents of the editor.
|
||||||
inputTransaction.setDidAffectContents();
|
inputTransaction.setDidAffectContents();
|
||||||
break;
|
break;
|
||||||
|
case Constants.CODE_OUTPUT_TEXT:
|
||||||
|
mWordComposer.applyProcessedEvent(event);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unknown key code : " + event.getMKeyCode());
|
throw new RuntimeException("Unknown key code : " + event.getMKeyCode());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue