KeyHandler // Suppressing EmptyIgnoringPreviousState().

This commit is contained in:
ShikiSuen 2022-07-31 21:40:19 +08:00
parent 7d6ac3cd5f
commit 7ea221f7ec
4 changed files with 31 additions and 13 deletions

View File

@ -69,6 +69,7 @@ extension KeyHandler {
// compositor.isEmpty
clear()
stateCallback(InputState.EmptyIgnoringPreviousState())
stateCallback(InputState.Empty())
} else {
stateCallback(buildInputtingState)
}
@ -84,6 +85,7 @@ extension KeyHandler {
if state is InputState.AssociatedPhrases, !mgrPrefs.alsoConfirmAssociatedCandidatesByEnter {
clear()
stateCallback(InputState.EmptyIgnoringPreviousState())
stateCallback(InputState.Empty())
return true
}
delegate?.keyHandler(
@ -350,10 +352,10 @@ extension KeyHandler {
ctlCandidate: ctlCandidateCurrent
)
clear()
let empty = InputState.EmptyIgnoringPreviousState()
stateCallback(empty)
stateCallback(InputState.EmptyIgnoringPreviousState())
stateCallback(InputState.Empty())
return handle(
input: input, state: empty, stateCallback: stateCallback, errorCallback: errorCallback
input: input, state: InputState.Empty(), stateCallback: stateCallback, errorCallback: errorCallback
)
}
return true

View File

@ -30,18 +30,14 @@ extension KeyHandler {
/// KeyHandler.HandleInput()
/// - Parameters:
/// - input:
/// - state:
/// - stateCallback:
/// - errorCallback:
/// - Returns: IMK
func handleComposition(
input: InputSignal,
state: InputStateProtocol,
stateCallback: @escaping (InputStateProtocol) -> Void,
errorCallback: @escaping () -> Void
) -> Bool? {
guard [.ofInputting, .ofEmpty, .ofEmptyIgnoringPreviousState].contains(state.type) else { return nil }
// MARK: (Handle BPMF Keys)
var keyConsumedByReading = false
@ -84,7 +80,12 @@ extension KeyHandler {
errorCallback()
composer.clear()
//
stateCallback((compositor.isEmpty) ? InputState.EmptyIgnoringPreviousState() : buildInputtingState)
switch compositor.isEmpty {
case false: stateCallback(buildInputtingState)
case true:
stateCallback(InputState.EmptyIgnoringPreviousState())
stateCallback(InputState.Empty())
}
return true // IMK
}

View File

@ -159,7 +159,7 @@ extension KeyHandler {
// MARK: (Handle BPMF Keys)
if let compositionHandled = handleComposition(
input: input, state: state, stateCallback: stateCallback, errorCallback: errorCallback
input: input, stateCallback: stateCallback, errorCallback: errorCallback
) {
return compositionHandled
}

View File

@ -419,8 +419,12 @@ extension KeyHandler {
composer.doBackSpace()
}
stateCallback(
composer.isEmpty && compositor.isEmpty ? InputState.EmptyIgnoringPreviousState() : buildInputtingState)
switch composer.isEmpty && compositor.isEmpty {
case false: stateCallback(buildInputtingState)
case true:
stateCallback(InputState.EmptyIgnoringPreviousState())
stateCallback(InputState.Empty())
}
return true
}
@ -457,7 +461,12 @@ extension KeyHandler {
walk()
let inputting = buildInputtingState
// count > 0!isEmpty滿
stateCallback(inputting.composingBuffer.isEmpty ? InputState.EmptyIgnoringPreviousState() : inputting)
switch inputting.composingBuffer.isEmpty {
case false: stateCallback(inputting)
case true:
stateCallback(InputState.EmptyIgnoringPreviousState())
stateCallback(InputState.Empty())
}
return true
}
@ -569,11 +578,17 @@ extension KeyHandler {
/// macOS Windows 使
clear()
stateCallback(InputState.EmptyIgnoringPreviousState())
stateCallback(InputState.Empty())
} else {
if composer.isEmpty { return true }
///
composer.clear()
stateCallback(compositor.isEmpty ? InputState.EmptyIgnoringPreviousState() : buildInputtingState)
switch compositor.isEmpty {
case false: stateCallback(buildInputtingState)
case true:
stateCallback(InputState.EmptyIgnoringPreviousState())
stateCallback(InputState.Empty())
}
}
return true
}