InputHandler // Correct the handling of tone1, etc. (#217)

This commit is contained in:
ShikiSuen 2022-10-28 13:54:41 +08:00
parent cf2cefa754
commit 2a320ee095
1 changed files with 6 additions and 4 deletions

View File

@ -33,11 +33,12 @@ extension InputHandler {
let skipPhoneticHandling = let skipPhoneticHandling =
input.isReservedKey || input.isNumericPadKey || input.isNonLaptopFunctionKey input.isReservedKey || input.isNumericPadKey || input.isNonLaptopFunctionKey
|| input.isControlHold || input.isOptionHold || input.isShiftHold || input.isCommandHold || input.isControlHold || input.isOptionHold || input.isShiftHold || input.isCommandHold
let confirmCombination = input.isSpace || input.isEnter
// inputValidityCheck() charCode UniChar // inputValidityCheck() charCode UniChar
// keyConsumedByReading // keyConsumedByReading
// composer.receiveKey() String UniChar // composer.receiveKey() String UniChar
if !skipPhoneticHandling && composer.inputValidityCheck(key: input.charCode) { if (!skipPhoneticHandling && composer.inputValidityCheck(key: input.charCode)) || confirmCombination {
// macOS 調 // macOS 調
// //
proc: if [0, 1].contains(prefs.specifyIntonationKeyBehavior), composer.isEmpty, !input.isSpace { proc: if [0, 1].contains(prefs.specifyIntonationKeyBehavior), composer.isEmpty, !input.isSpace {
@ -64,7 +65,7 @@ extension InputHandler {
} }
// Enter (CR / LF) // Enter (CR / LF)
composer.receiveKey(fromString: input.isEnter ? " " : input.text) composer.receiveKey(fromString: confirmCombination ? " " : input.text)
keyConsumedByReading = true keyConsumedByReading = true
// 調 setInlineDisplayWithCursor() return true // 調 setInlineDisplayWithCursor() return true
@ -81,7 +82,7 @@ extension InputHandler {
// Enter Space composer // Enter Space composer
// |= // |=
// 使 composer.value.isEmpty composer 調 // 使 composer.value.isEmpty composer 調
composeReading = composeReading || (!composer.isEmpty && (input.isSpace || input.isEnter)) composeReading = composeReading || (!composer.isEmpty && confirmCombination)
// readingKey // readingKey
composeReading = composeReading && !readingKey.isEmpty composeReading = composeReading && !readingKey.isEmpty
if composeReading { if composeReading {
@ -183,6 +184,7 @@ extension InputHandler {
let skipStrokeHandling = let skipStrokeHandling =
input.isReservedKey || input.isNumericPadKey || input.isNonLaptopFunctionKey input.isReservedKey || input.isNumericPadKey || input.isNonLaptopFunctionKey
|| input.isControlHold || input.isOptionHold || input.isShiftHold || input.isCommandHold || input.isControlHold || input.isOptionHold || input.isShiftHold || input.isCommandHold
let confirmCombination = input.isSpace || input.isEnter
var isLongestPossibleKeyFormed: Bool { var isLongestPossibleKeyFormed: Bool {
guard !isWildcardKeyInput, prefs.autoCompositeWithLongestPossibleCassetteKey else { return false } guard !isWildcardKeyInput, prefs.autoCompositeWithLongestPossibleCassetteKey else { return false }
@ -225,7 +227,7 @@ extension InputHandler {
// Enter Space calligrapher // Enter Space calligrapher
// |= // |=
combineStrokes = combineStrokes || (!calligrapher.isEmpty && (input.isSpace || input.isEnter)) combineStrokes = combineStrokes || (!calligrapher.isEmpty && confirmCombination)
if combineStrokes { if combineStrokes {
// //
if !currentLM.hasUnigramsFor(key: calligrapher) { if !currentLM.hasUnigramsFor(key: calligrapher) {