InputHandler // Ensure commission of existing contents in certain cases. (#198)

- This fixes #194 and #195.
This commit is contained in:
ShikiSuen 2022-10-27 11:56:45 +08:00
parent 56a955c47c
commit 5465fe16d2
2 changed files with 9 additions and 0 deletions

View File

@ -69,6 +69,12 @@ extension IMEState {
public static func ofDeactivated() -> IMEState { .init(type: .ofDeactivated) }
public static func ofEmpty() -> IMEState { .init(type: .ofEmpty) }
public static func ofAbortion() -> IMEState { .init(type: .ofAbortion) }
///
/// - Remark:
/// `.ofEmpty()` `.ofCommitting()`
/// - Parameter textToCommit:
/// - Returns:
public static func ofCommitting(textToCommit: String) -> IMEState {
var result = IMEState(type: .ofCommitting)
result.textToCommit = textToCommit

View File

@ -80,6 +80,7 @@ extension InputHandler {
//
if input.isNumericPadKey {
if ![.ofCandidates, .ofAssociates, .ofSymbolTable].contains(state.type) {
delegate.switchState(IMEState.ofEmpty())
delegate.switchState(IMEState.ofCommitting(textToCommit: inputText.lowercased()))
return true
}
@ -247,9 +248,11 @@ extension InputHandler {
if input.isShiftHold { // isOptionHold
switch prefs.upperCaseLetterKeyBehavior {
case 1:
delegate.switchState(IMEState.ofEmpty())
delegate.switchState(IMEState.ofCommitting(textToCommit: inputText.lowercased()))
return true
case 2:
delegate.switchState(IMEState.ofEmpty())
delegate.switchState(IMEState.ofCommitting(textToCommit: inputText.uppercased()))
return true
default: // case 0