InputHandler // Simplify CapsLock input handling.

This commit is contained in:
ShikiSuen 2022-10-14 14:37:35 +08:00
parent 1324e0a077
commit 70e0044179
1 changed files with 4 additions and 13 deletions

View File

@ -34,9 +34,7 @@ extension InputHandler {
if input.isInvalid { if input.isInvalid {
// .Empty(IgnoringPreviousState) .Deactivated // .Empty(IgnoringPreviousState) .Deactivated
// .Abortion.Empty // .Abortion.Empty
if state.type == .ofEmpty || state.type == .ofDeactivated { if state.type == .ofEmpty || state.type == .ofDeactivated { return false }
return false
}
delegate.callError("550BCF7B: InputHandler just refused an invalid input.") delegate.callError("550BCF7B: InputHandler just refused an invalid input.")
delegate.switchState(state) delegate.switchState(state)
return true return true
@ -53,13 +51,8 @@ extension InputHandler {
/// Caps Lock /// Caps Lock
/// Caps Lock /// Caps Lock
if input.isBackSpace || input.isEnter if input.isCapsLockOn || state.isASCIIMode {
|| input.isCursorClockLeft || input.isCursorClockRight // macOS 12 CapsLock .ofEmpty()
|| input.isCursorForward || input.isCursorBackward
{
// BackSpace
} else if input.isCapsLockOn || state.isASCIIMode {
//
delegate.switchState(IMEState.ofEmpty()) delegate.switchState(IMEState.ofEmpty())
// Shift // Shift
@ -71,9 +64,7 @@ extension InputHandler {
/// ASCII 使insertText:replacementRange: /// ASCII 使insertText:replacementRange:
/// ASCII /// ASCII
if input.isASCII, !input.charCode.isPrintableASCII { if input.isASCII, !input.charCode.isPrintableASCII { return false }
return false
}
// //
delegate.switchState(IMEState.ofCommitting(textToCommit: inputText.lowercased())) delegate.switchState(IMEState.ofCommitting(textToCommit: inputText.lowercased()))