InputHandler // Handle results returned by compositor.insertKey().

This commit is contained in:
ShikiSuen 2022-10-24 12:46:33 +08:00
parent 32e462af43
commit b8de232c3f
3 changed files with 22 additions and 13 deletions

View File

@ -108,7 +108,10 @@ extension InputHandler {
}
//
compositor.insertKey(readingKey)
if !compositor.insertKey(readingKey) {
delegate.callError("3CF278C9: 得檢查對應的語言模組的 hasUnigramsFor() 是否有誤判之情形。")
return true
}
//
walk()
@ -223,7 +226,10 @@ extension InputHandler {
}
//
compositor.insertKey(calligrapher)
if !compositor.insertKey(calligrapher) {
delegate.callError("61F6B11F: 得檢查對應的語言模組的 hasUnigramsFor() 是否有誤判之情形。")
return true
}
//
walk()

View File

@ -120,20 +120,19 @@ extension InputHandler {
if input.isSpace {
/// Space
if !prefs.chooseCandidateUsingSpace {
if compositor.cursor >= compositor.length {
let displayedText = state.displayedText
if !displayedText.isEmpty {
delegate.switchState(IMEState.ofCommitting(textToCommit: displayedText))
}
delegate.switchState(IMEState.ofCommitting(textToCommit: " "))
} else if currentLM.hasUnigramsFor(key: " ") {
compositor.insertKey(" ")
if compositor.cursor < compositor.length, compositor.insertKey(" ") {
walk()
// App
let textToCommit = commitOverflownComposition
var inputting = generateStateOfInputting()
inputting.textToCommit = textToCommit
delegate.switchState(inputting)
} else {
let displayedText = state.displayedText
if !displayedText.isEmpty {
delegate.switchState(IMEState.ofCommitting(textToCommit: displayedText))
}
delegate.switchState(IMEState.ofCommitting(textToCommit: " "))
}
return true
} else if input.isShiftHold { // Tab Shift+Command+Space /
@ -182,8 +181,7 @@ extension InputHandler {
if input.isSymbolMenuPhysicalKey, !input.isShiftHold, !input.isControlHold, state.type != .ofDeactivated {
if input.isOptionHold {
if currentLM.hasUnigramsFor(key: "_punctuation_list") {
if isComposerOrCalligrapherEmpty {
compositor.insertKey("_punctuation_list")
if isComposerOrCalligrapherEmpty, compositor.insertKey("_punctuation_list") {
walk()
// App
let textToCommit = commitOverflownComposition

View File

@ -235,7 +235,12 @@ extension InputHandler {
return true
}
compositor.insertKey(customPunctuation)
guard compositor.insertKey(customPunctuation) else {
delegate.callError("C0793A6D: 得檢查對應的語言模組的 hasUnigramsFor() 是否有誤判之情形。")
delegate.switchState(state)
return true
}
walk()
// App
let textToCommit = commitOverflownComposition