InputHandler // Handle inputs for `%quick`.

This commit is contained in:
ShikiSuen 2023-06-14 16:24:36 +08:00
parent b0c2bfc54e
commit ba98ebf0a7
3 changed files with 31 additions and 5 deletions

View File

@ -99,7 +99,7 @@ extension InputHandler {
: ctlCandidate.highlightNextCandidate())
_ = updated ? {}() : delegate.callError("9B691919")
return true
case .kSpace:
case .kSpace where state.type != .ofInputting:
let updated: Bool =
prefs.specifyShiftSpaceKeyBehavior
? (input.isShiftHold
@ -168,7 +168,8 @@ extension InputHandler {
// MARK: (SCPC Mode Processing)
if prefs.useSCPCTypingMode {
// .ofInputting `%quick` /
if prefs.useSCPCTypingMode, state.type != .ofInputting {
///
/// - /
/// -
@ -244,6 +245,8 @@ extension InputHandler {
}
}
if state.type == .ofInputting { return false } // `%quick`
delegate.callError("172A0F81")
return true
}

View File

@ -212,14 +212,16 @@ extension InputHandler {
/// - Returns: IMK
private func handleCassetteComposition(input: InputSignalProtocol) -> Bool? {
guard let delegate = delegate else { return nil }
let state = delegate.state
var wildcardKey: String { currentLM.cassetteWildcardKey } //
let inputText = input.text
let isWildcardKeyInput: Bool = (inputText == wildcardKey && !wildcardKey.isEmpty)
let calligrapherBackup = calligrapher
let skipStrokeHandling =
input.isReservedKey || input.isNumericPadKey || input.isNonLaptopFunctionKey
|| input.isControlHold || input.isOptionHold || input.isCommandHold // || input.isShiftHold
let confirmCombination = input.isSpace || input.isEnter
var confirmCombination = input.isSpace
var isLongestPossibleKeyFormed: Bool {
guard !isWildcardKeyInput, prefs.autoCompositeWithLongestPossibleCassetteKey else { return false }
@ -251,11 +253,22 @@ extension InputHandler {
}
if !isStrokesFull {
delegate.switchState(generateStateOfInputting())
var result = generateStateOfInputting()
// IMK `%quick`
if !prefs.useIMKCandidateWindow, !calligrapher.isEmpty,
let fetched = currentLM.cassetteQuickSetsFor(key: calligrapher)
{
result.candidates = fetched.map { (keyArray: [""], value: $0.description) }
}
delegate.switchState(result)
return true
}
}
if !(state.type == .ofInputting && state.isCandidateContainer) {
confirmCombination = confirmCombination || input.isEnter
}
var combineStrokes =
(isStrokesFull && prefs.autoCompositeWithLongestPossibleCassetteKey)
|| (isWildcardKeyInput && !calligrapher.isEmpty)
@ -273,8 +286,14 @@ extension InputHandler {
}
//
if !currentLM.hasUnigramsFor(keyArray: [calligrapher]) {
delegate.callError("B49C0979_Cassette語彙庫內無「\(calligrapher)」的匹配記錄。")
// `%quick`
let quickCandidates: Bool = state.type == .ofInputting && state.isCandidateContainer
if quickCandidates, handleCandidate(input: input) {
if !calligrapher.isEmpty { calligrapher = calligrapherBackup }
return true
}
delegate.callError("B49C0979_Cassette語彙庫內無「\(calligrapher)」的匹配記錄。")
calligrapher.removeAll()
//
switch compositor.isEmpty {

View File

@ -146,6 +146,10 @@ extension InputHandler {
return handleHaninKeyboardSymbolModeToggle()
}
// `%quick`
let quickCandidates: Bool = state.type == .ofInputting && state.isCandidateContainer
guard !(quickCandidates && handleCandidate(input: input)) else { return true }
//
if isHaninKeyboardSymbolMode, [[], .shift].contains(input.modifierFlags) {
return handleHaninKeyboardSymbolModeInput(input: input)