IMEState // Ensure lowerCamelCase.

This commit is contained in:
ShikiSuen 2022-09-05 17:51:03 +08:00
parent 75193a32fd
commit e85e3382fe
8 changed files with 85 additions and 85 deletions

View File

@ -51,7 +51,7 @@ public protocol IMEStateProtocol {
/// ///
/// ///
/// IMEState /// IMEState
/// IMEState.Marking IMEState.Inputting /// IMEState.ofMarking IMEState.ofInputting
/// ///
/// (Constructor) /// (Constructor)
/// ///
@ -91,23 +91,23 @@ public struct IMEState: IMEStateProtocol {
// MARK: - // MARK: -
extension IMEState { extension IMEState {
public static func Deactivated() -> IMEState { .init(type: .ofDeactivated) } public static func ofDeactivated() -> IMEState { .init(type: .ofDeactivated) }
public static func Empty() -> IMEState { .init(type: .ofEmpty) } public static func ofEmpty() -> IMEState { .init(type: .ofEmpty) }
public static func Abortion() -> IMEState { .init(type: .ofAbortion) } public static func ofAbortion() -> IMEState { .init(type: .ofAbortion) }
public static func Committing(textToCommit: String) -> IMEState { public static func ofCommitting(textToCommit: String) -> IMEState {
var result = IMEState(type: .ofCommitting) var result = IMEState(type: .ofCommitting)
result.data.textToCommit = textToCommit result.data.textToCommit = textToCommit
ChineseConverter.ensureCurrencyNumerals(target: &result.data.textToCommit) ChineseConverter.ensureCurrencyNumerals(target: &result.data.textToCommit)
return result return result
} }
public static func Associates(candidates: [(String, String)]) -> IMEState { public static func ofAssociates(candidates: [(String, String)]) -> IMEState {
var result = IMEState(type: .ofAssociates) var result = IMEState(type: .ofAssociates)
result.data.candidates = candidates result.data.candidates = candidates
return result return result
} }
public static func NotEmpty(displayTextSegments: [String], cursor: Int) -> IMEState { public static func ofNotEmpty(displayTextSegments: [String], cursor: Int) -> IMEState {
var result = IMEState(type: .ofNotEmpty) var result = IMEState(type: .ofNotEmpty)
// displayTextSegments // displayTextSegments
result.data.displayTextSegments = displayTextSegments result.data.displayTextSegments = displayTextSegments
@ -115,18 +115,18 @@ extension IMEState {
return result return result
} }
public static func Inputting(displayTextSegments: [String], cursor: Int) -> IMEState { public static func ofInputting(displayTextSegments: [String], cursor: Int) -> IMEState {
var result = IMEState.NotEmpty(displayTextSegments: displayTextSegments, cursor: cursor) var result = IMEState.ofNotEmpty(displayTextSegments: displayTextSegments, cursor: cursor)
result.type = .ofInputting result.type = .ofInputting
return result return result
} }
public static func Marking( public static func ofMarking(
displayTextSegments: [String], markedReadings: [String], cursor: Int, marker: Int displayTextSegments: [String], markedReadings: [String], cursor: Int, marker: Int
) )
-> IMEState -> IMEState
{ {
var result = IMEState.NotEmpty(displayTextSegments: displayTextSegments, cursor: cursor) var result = IMEState.ofNotEmpty(displayTextSegments: displayTextSegments, cursor: cursor)
result.type = .ofMarking result.type = .ofMarking
result.data.marker = marker result.data.marker = marker
result.data.markedReadings = markedReadings result.data.markedReadings = markedReadings
@ -134,15 +134,15 @@ extension IMEState {
return result return result
} }
public static func Candidates(candidates: [(String, String)], displayTextSegments: [String], cursor: Int) -> IMEState public static func ofCandidates(candidates: [(String, String)], displayTextSegments: [String], cursor: Int) -> IMEState
{ {
var result = IMEState.NotEmpty(displayTextSegments: displayTextSegments, cursor: cursor) var result = IMEState.ofNotEmpty(displayTextSegments: displayTextSegments, cursor: cursor)
result.type = .ofCandidates result.type = .ofCandidates
result.data.candidates = candidates result.data.candidates = candidates
return result return result
} }
public static func SymbolTable(node: SymbolNode) -> IMEState { public static func ofSymbolTable(node: SymbolNode) -> IMEState {
var result = IMEState(type: .ofNotEmpty, node: node) var result = IMEState(type: .ofNotEmpty, node: node)
result.type = .ofSymbolTable result.type = .ofSymbolTable
return result return result
@ -156,7 +156,7 @@ extension IMEState {
public var candidates: [(String, String)] { data.candidates } public var candidates: [(String, String)] { data.candidates }
public var convertedToInputting: IMEState { public var convertedToInputting: IMEState {
if type == .ofInputting { return self } if type == .ofInputting { return self }
var result = IMEState.Inputting(displayTextSegments: data.displayTextSegments, cursor: data.cursor) var result = IMEState.ofInputting(displayTextSegments: data.displayTextSegments, cursor: data.cursor)
result.tooltip = data.tooltipBackupForInputting result.tooltip = data.tooltipBackupForInputting
return result return result
} }

View File

@ -49,12 +49,12 @@ extension KeyHandler {
// //
// 使 BackSpace // 使 BackSpace
// compositor.isEmpty // compositor.isEmpty
stateCallback(IMEState.Abortion()) stateCallback(IMEState.ofAbortion())
} else { } else {
stateCallback(buildInputtingState) stateCallback(buildInputtingState)
} }
if state.type == .ofSymbolTable, let nodePrevious = state.node.previous, let _ = nodePrevious.children { if state.type == .ofSymbolTable, let nodePrevious = state.node.previous, let _ = nodePrevious.children {
stateCallback(IMEState.SymbolTable(node: nodePrevious)) stateCallback(IMEState.ofSymbolTable(node: nodePrevious))
} }
return true return true
} }
@ -63,7 +63,7 @@ extension KeyHandler {
if input.isEnter { if input.isEnter {
if state.type == .ofAssociates, !mgrPrefs.alsoConfirmAssociatedCandidatesByEnter { if state.type == .ofAssociates, !mgrPrefs.alsoConfirmAssociatedCandidatesByEnter {
stateCallback(IMEState.Abortion()) stateCallback(IMEState.ofAbortion())
return true return true
} }
delegate?.keyHandler( delegate?.keyHandler(
@ -323,9 +323,9 @@ extension KeyHandler {
didSelectCandidateAt: candidateIndex, didSelectCandidateAt: candidateIndex,
ctlCandidate: ctlCandidateCurrent ctlCandidate: ctlCandidateCurrent
) )
stateCallback(IMEState.Abortion()) stateCallback(IMEState.ofAbortion())
return handle( return handle(
input: input, state: IMEState.Empty(), stateCallback: stateCallback, errorCallback: errorCallback input: input, state: IMEState.ofEmpty(), stateCallback: stateCallback, errorCallback: errorCallback
) )
} }
return true return true

View File

@ -100,7 +100,7 @@ extension KeyHandler {
switch compositor.isEmpty { switch compositor.isEmpty {
case false: stateCallback(buildInputtingState) case false: stateCallback(buildInputtingState)
case true: case true:
stateCallback(IMEState.Abortion()) stateCallback(IMEState.ofAbortion())
} }
return true // IMK return true // IMK
} }
@ -130,16 +130,16 @@ extension KeyHandler {
if candidateState.candidates.count == 1, let firstCandidate = candidateState.candidates.first { if candidateState.candidates.count == 1, let firstCandidate = candidateState.candidates.first {
let reading: String = firstCandidate.0 let reading: String = firstCandidate.0
let text: String = firstCandidate.1 let text: String = firstCandidate.1
stateCallback(IMEState.Committing(textToCommit: text)) stateCallback(IMEState.ofCommitting(textToCommit: text))
if !mgrPrefs.associatedPhrasesEnabled { if !mgrPrefs.associatedPhrasesEnabled {
stateCallback(IMEState.Empty()) stateCallback(IMEState.ofEmpty())
} else { } else {
let associatedPhrases = let associatedPhrases =
buildAssociatePhraseState( buildAssociatePhraseState(
withPair: .init(key: reading, value: text) withPair: .init(key: reading, value: text)
) )
stateCallback(associatedPhrases.candidates.isEmpty ? IMEState.Empty() : associatedPhrases) stateCallback(associatedPhrases.candidates.isEmpty ? IMEState.ofEmpty() : associatedPhrases)
} }
} else { } else {
stateCallback(candidateState) stateCallback(candidateState)

View File

@ -68,7 +68,7 @@ extension KeyHandler {
// BackSpace // BackSpace
} else if input.isCapsLockOn || input.isASCIIModeInput { } else if input.isCapsLockOn || input.isASCIIModeInput {
// //
stateCallback(IMEState.Empty()) stateCallback(IMEState.ofEmpty())
// Shift // Shift
if input.isUpperCaseASCIILetterKey { if input.isUpperCaseASCIILetterKey {
@ -82,8 +82,8 @@ extension KeyHandler {
} }
// //
stateCallback(IMEState.Committing(textToCommit: inputText.lowercased())) stateCallback(IMEState.ofCommitting(textToCommit: inputText.lowercased()))
stateCallback(IMEState.Empty()) stateCallback(IMEState.ofEmpty())
return true return true
} }
@ -97,9 +97,9 @@ extension KeyHandler {
if !(state.type == .ofCandidates || state.type == .ofAssociates if !(state.type == .ofCandidates || state.type == .ofAssociates
|| state.type == .ofSymbolTable) || state.type == .ofSymbolTable)
{ {
stateCallback(IMEState.Empty()) stateCallback(IMEState.ofEmpty())
stateCallback(IMEState.Committing(textToCommit: inputText.lowercased())) stateCallback(IMEState.ofCommitting(textToCommit: inputText.lowercased()))
stateCallback(IMEState.Empty()) stateCallback(IMEState.ofEmpty())
return true return true
} }
} }
@ -120,7 +120,7 @@ extension KeyHandler {
) { ) {
return true return true
} else { } else {
stateCallback(IMEState.Empty()) stateCallback(IMEState.ofEmpty())
} }
} }
@ -157,10 +157,10 @@ extension KeyHandler {
if compositor.cursor >= compositor.length { if compositor.cursor >= compositor.length {
let displayedText = state.displayedText let displayedText = state.displayedText
if !displayedText.isEmpty { if !displayedText.isEmpty {
stateCallback(IMEState.Committing(textToCommit: displayedText)) stateCallback(IMEState.ofCommitting(textToCommit: displayedText))
} }
stateCallback(IMEState.Committing(textToCommit: " ")) stateCallback(IMEState.ofCommitting(textToCommit: " "))
stateCallback(IMEState.Empty()) stateCallback(IMEState.ofEmpty())
} else if currentLM.hasUnigramsFor(key: " ") { } else if currentLM.hasUnigramsFor(key: " ") {
compositor.insertKey(" ") compositor.insertKey(" ")
walk() walk()
@ -297,7 +297,7 @@ extension KeyHandler {
// Enter 使 commit buffer // Enter 使 commit buffer
// bool _ = // bool _ =
_ = handleEnter(state: state, stateCallback: stateCallback) _ = handleEnter(state: state, stateCallback: stateCallback)
stateCallback(IMEState.SymbolTable(node: SymbolNode.root)) stateCallback(IMEState.ofSymbolTable(node: SymbolNode.root))
return true return true
} }
} }
@ -312,9 +312,9 @@ extension KeyHandler {
let string = NSMutableString(string: stringRAW) let string = NSMutableString(string: stringRAW)
CFStringTransform(string, nil, kCFStringTransformFullwidthHalfwidth, true) CFStringTransform(string, nil, kCFStringTransformFullwidthHalfwidth, true)
stateCallback( stateCallback(
IMEState.Committing(textToCommit: mgrPrefs.halfWidthPunctuationEnabled ? stringRAW : string as String) IMEState.ofCommitting(textToCommit: mgrPrefs.halfWidthPunctuationEnabled ? stringRAW : string as String)
) )
stateCallback(IMEState.Empty()) stateCallback(IMEState.ofEmpty())
return true return true
} }
} }
@ -359,8 +359,8 @@ extension KeyHandler {
/// 使 /// 使
if state.type == .ofEmpty { if state.type == .ofEmpty {
if input.isSpace, !input.isOptionHold, !input.isControlHold, !input.isCommandHold { if input.isSpace, !input.isOptionHold, !input.isControlHold, !input.isCommandHold {
stateCallback(IMEState.Committing(textToCommit: input.isShiftHold ? " " : " ")) stateCallback(IMEState.ofCommitting(textToCommit: input.isShiftHold ? " " : " "))
stateCallback(IMEState.Empty()) stateCallback(IMEState.ofEmpty())
return true return true
} }
} }
@ -371,14 +371,14 @@ extension KeyHandler {
if input.isShiftHold { // isOptionHold if input.isShiftHold { // isOptionHold
switch mgrPrefs.upperCaseLetterKeyBehavior { switch mgrPrefs.upperCaseLetterKeyBehavior {
case 1: case 1:
stateCallback(IMEState.Empty()) stateCallback(IMEState.ofEmpty())
stateCallback(IMEState.Committing(textToCommit: inputText.lowercased())) stateCallback(IMEState.ofCommitting(textToCommit: inputText.lowercased()))
stateCallback(IMEState.Empty()) stateCallback(IMEState.ofEmpty())
return true return true
case 2: case 2:
stateCallback(IMEState.Empty()) stateCallback(IMEState.ofEmpty())
stateCallback(IMEState.Committing(textToCommit: inputText.uppercased())) stateCallback(IMEState.ofCommitting(textToCommit: inputText.uppercased()))
stateCallback(IMEState.Empty()) stateCallback(IMEState.ofEmpty())
return true return true
default: // case 0 default: // case 0
let letter = "_letter_\(inputText)" let letter = "_letter_\(inputText)"

View File

@ -52,7 +52,7 @@ extension KeyHandler {
cursor += reading.count cursor += reading.count
} }
/// 使 /// 使
return IMEState.Inputting(displayTextSegments: displayTextSegments, cursor: cursor) return IMEState.ofInputting(displayTextSegments: displayTextSegments, cursor: cursor)
} }
/// ///
@ -97,7 +97,7 @@ extension KeyHandler {
state currentState: IMEStateProtocol, state currentState: IMEStateProtocol,
isTypingVertical _: Bool = false isTypingVertical _: Bool = false
) -> IMEState { ) -> IMEState {
IMEState.Candidates( IMEState.ofCandidates(
candidates: getCandidatesArray(fixOrder: mgrPrefs.useFixecCandidateOrderOnSelection), candidates: getCandidatesArray(fixOrder: mgrPrefs.useFixecCandidateOrderOnSelection),
displayTextSegments: compositor.walkedNodes.values, displayTextSegments: compositor.walkedNodes.values,
cursor: currentState.data.cursor cursor: currentState.data.cursor
@ -122,7 +122,7 @@ extension KeyHandler {
withPair pair: Megrez.Compositor.KeyValuePaired withPair pair: Megrez.Compositor.KeyValuePaired
) -> IMEState { ) -> IMEState {
//  Xcode //  Xcode
IMEState.Associates( IMEState.ofAssociates(
candidates: buildAssociatePhraseArray(withPair: pair)) candidates: buildAssociatePhraseArray(withPair: pair))
} }
@ -196,7 +196,7 @@ extension KeyHandler {
if isCursorCuttingChar(isMarker: true) { if isCursorCuttingChar(isMarker: true) {
compositor.jumpCursorBySpan(to: .rear, isMarker: true) compositor.jumpCursorBySpan(to: .rear, isMarker: true)
} }
var marking = IMEState.Marking( var marking = IMEState.ofMarking(
displayTextSegments: state.data.displayTextSegments, displayTextSegments: state.data.displayTextSegments,
markedReadings: Array(compositor.keys[currentMarkedRange()]), markedReadings: Array(compositor.keys[currentMarkedRange()]),
cursor: convertCursorForDisplay(compositor.cursor), cursor: convertCursorForDisplay(compositor.cursor),
@ -219,7 +219,7 @@ extension KeyHandler {
if isCursorCuttingChar(isMarker: true) { if isCursorCuttingChar(isMarker: true) {
compositor.jumpCursorBySpan(to: .front, isMarker: true) compositor.jumpCursorBySpan(to: .front, isMarker: true)
} }
var marking = IMEState.Marking( var marking = IMEState.ofMarking(
displayTextSegments: state.data.displayTextSegments, displayTextSegments: state.data.displayTextSegments,
markedReadings: Array(compositor.keys[currentMarkedRange()]), markedReadings: Array(compositor.keys[currentMarkedRange()]),
cursor: convertCursorForDisplay(compositor.cursor), cursor: convertCursorForDisplay(compositor.cursor),
@ -281,8 +281,8 @@ extension KeyHandler {
if candidateState.candidates.count == 1 { if candidateState.candidates.count == 1 {
clear() // candidateState clear() // candidateState
if let candidateToCommit: (String, String) = candidateState.candidates.first, !candidateToCommit.1.isEmpty { if let candidateToCommit: (String, String) = candidateState.candidates.first, !candidateToCommit.1.isEmpty {
stateCallback(IMEState.Committing(textToCommit: candidateToCommit.1)) stateCallback(IMEState.ofCommitting(textToCommit: candidateToCommit.1))
stateCallback(IMEState.Empty()) stateCallback(IMEState.ofEmpty())
} else { } else {
stateCallback(candidateState) stateCallback(candidateState)
} }
@ -305,8 +305,8 @@ extension KeyHandler {
) -> Bool { ) -> Bool {
guard state.type == .ofInputting else { return false } guard state.type == .ofInputting else { return false }
stateCallback(IMEState.Committing(textToCommit: state.displayedText)) stateCallback(IMEState.ofCommitting(textToCommit: state.displayedText))
stateCallback(IMEState.Empty()) stateCallback(IMEState.ofEmpty())
return true return true
} }
@ -333,8 +333,8 @@ extension KeyHandler {
displayedText = displayedText.replacingOccurrences(of: "-", with: " ") displayedText = displayedText.replacingOccurrences(of: "-", with: " ")
} }
stateCallback(IMEState.Committing(textToCommit: displayedText)) stateCallback(IMEState.ofCommitting(textToCommit: displayedText))
stateCallback(IMEState.Empty()) stateCallback(IMEState.ofEmpty())
return true return true
} }
@ -369,8 +369,8 @@ extension KeyHandler {
composed += key.contains("_") ? value : "<ruby>\(value)<rp>(</rp><rt>\(key)</rt><rp>)</rp></ruby>" composed += key.contains("_") ? value : "<ruby>\(value)<rp>(</rp><rt>\(key)</rt><rp>)</rp></ruby>"
} }
stateCallback(IMEState.Committing(textToCommit: composed)) stateCallback(IMEState.ofCommitting(textToCommit: composed))
stateCallback(IMEState.Empty()) stateCallback(IMEState.ofEmpty())
return true return true
} }
@ -403,13 +403,13 @@ extension KeyHandler {
stateCallback(buildInputtingState) stateCallback(buildInputtingState)
return true return true
case 1: case 1:
stateCallback(IMEState.Abortion()) stateCallback(IMEState.ofAbortion())
return true return true
default: break default: break
} }
if input.isShiftHold, input.isOptionHold { if input.isShiftHold, input.isOptionHold {
stateCallback(IMEState.Abortion()) stateCallback(IMEState.ofAbortion())
return true return true
} }
@ -432,7 +432,7 @@ extension KeyHandler {
switch composer.isEmpty && compositor.isEmpty { switch composer.isEmpty && compositor.isEmpty {
case false: stateCallback(buildInputtingState) case false: stateCallback(buildInputtingState)
case true: case true:
stateCallback(IMEState.Abortion()) stateCallback(IMEState.ofAbortion())
} }
return true return true
} }
@ -455,7 +455,7 @@ extension KeyHandler {
guard state.type == .ofInputting else { return false } guard state.type == .ofInputting else { return false }
if input.isShiftHold { if input.isShiftHold {
stateCallback(IMEState.Abortion()) stateCallback(IMEState.ofAbortion())
return true return true
} }
@ -478,7 +478,7 @@ extension KeyHandler {
switch inputting.displayedText.isEmpty { switch inputting.displayedText.isEmpty {
case false: stateCallback(inputting) case false: stateCallback(inputting)
case true: case true:
stateCallback(IMEState.Abortion()) stateCallback(IMEState.ofAbortion())
} }
return true return true
} }
@ -589,7 +589,7 @@ extension KeyHandler {
if mgrPrefs.escToCleanInputBuffer { if mgrPrefs.escToCleanInputBuffer {
/// ///
/// macOS Windows 使 /// macOS Windows 使
stateCallback(IMEState.Abortion()) stateCallback(IMEState.ofAbortion())
} else { } else {
if composer.isEmpty { return true } if composer.isEmpty { return true }
/// ///
@ -597,7 +597,7 @@ extension KeyHandler {
switch compositor.isEmpty { switch compositor.isEmpty {
case false: stateCallback(buildInputtingState) case false: stateCallback(buildInputtingState)
case true: case true:
stateCallback(IMEState.Abortion()) stateCallback(IMEState.ofAbortion())
} }
} }
return true return true
@ -634,7 +634,7 @@ extension KeyHandler {
if isCursorCuttingChar(isMarker: true) { if isCursorCuttingChar(isMarker: true) {
compositor.jumpCursorBySpan(to: .front, isMarker: true) compositor.jumpCursorBySpan(to: .front, isMarker: true)
} }
var marking = IMEState.Marking( var marking = IMEState.ofMarking(
displayTextSegments: compositor.walkedNodes.values, displayTextSegments: compositor.walkedNodes.values,
markedReadings: Array(compositor.keys[currentMarkedRange()]), markedReadings: Array(compositor.keys[currentMarkedRange()]),
cursor: convertCursorForDisplay(compositor.cursor), cursor: convertCursorForDisplay(compositor.cursor),
@ -707,7 +707,7 @@ extension KeyHandler {
if isCursorCuttingChar(isMarker: true) { if isCursorCuttingChar(isMarker: true) {
compositor.jumpCursorBySpan(to: .rear, isMarker: true) compositor.jumpCursorBySpan(to: .rear, isMarker: true)
} }
var marking = IMEState.Marking( var marking = IMEState.ofMarking(
displayTextSegments: compositor.walkedNodes.values, displayTextSegments: compositor.walkedNodes.values,
markedReadings: Array(compositor.keys[currentMarkedRange()]), markedReadings: Array(compositor.keys[currentMarkedRange()]),
cursor: convertCursorForDisplay(compositor.cursor), cursor: convertCursorForDisplay(compositor.cursor),

View File

@ -41,7 +41,7 @@ class ctlInputMethod: IMKInputController {
/// 調 /// 調
var keyHandler: KeyHandler = .init() var keyHandler: KeyHandler = .init()
/// ///
var state: IMEStateProtocol = IMEState.Empty() { var state: IMEStateProtocol = IMEState.ofEmpty() {
didSet { didSet {
IME.prtDebugIntel("Current State: \(state.type.rawValue)") IME.prtDebugIntel("Current State: \(state.type.rawValue)")
} }
@ -75,9 +75,9 @@ class ctlInputMethod: IMKInputController {
} }
if state.hasComposition { if state.hasComposition {
/// 調 /// 調
handle(state: IMEState.Committing(textToCommit: state.displayedText)) handle(state: IMEState.ofCommitting(textToCommit: state.displayedText))
} }
handle(state: IMEState.Empty()) handle(state: IMEState.ofEmpty())
} }
// MARK: - IMKInputController // MARK: - IMKInputController
@ -131,7 +131,7 @@ class ctlInputMethod: IMKInputController {
if let client = client(), client.bundleIdentifier() != Bundle.main.bundleIdentifier { if let client = client(), client.bundleIdentifier() != Bundle.main.bundleIdentifier {
// 使 // 使
setKeyLayout() setKeyLayout()
handle(state: IMEState.Empty()) handle(state: IMEState.ofEmpty())
} // } //
(NSApp.delegate as? AppDelegate)?.checkForUpdate() (NSApp.delegate as? AppDelegate)?.checkForUpdate()
} }
@ -141,7 +141,7 @@ class ctlInputMethod: IMKInputController {
override func deactivateServer(_ sender: Any!) { override func deactivateServer(_ sender: Any!) {
_ = sender // _ = sender //
resetKeyHandler() // Empty resetKeyHandler() // Empty
handle(state: IMEState.Deactivated()) handle(state: IMEState.ofDeactivated())
} }
/// ///
@ -172,7 +172,7 @@ class ctlInputMethod: IMKInputController {
if let client = client(), client.bundleIdentifier() != Bundle.main.bundleIdentifier { if let client = client(), client.bundleIdentifier() != Bundle.main.bundleIdentifier {
// 使 // 使
setKeyLayout() setKeyLayout()
handle(state: IMEState.Empty()) handle(state: IMEState.ofEmpty())
} // } //
} }
@ -367,7 +367,7 @@ class ctlInputMethod: IMKInputController {
let candidateString: NSAttributedString = candidateString ?? .init(string: "") let candidateString: NSAttributedString = candidateString ?? .init(string: "")
if state.type == .ofAssociates { if state.type == .ofAssociates {
if !mgrPrefs.alsoConfirmAssociatedCandidatesByEnter { if !mgrPrefs.alsoConfirmAssociatedCandidatesByEnter {
handle(state: IMEState.Abortion()) handle(state: IMEState.ofAbortion())
return return
} }
} }

View File

@ -111,11 +111,11 @@ extension ctlInputMethod: ctlCandidateDelegate {
let node = state.node.children?[index] let node = state.node.children?[index]
{ {
if let children = node.children, !children.isEmpty { if let children = node.children, !children.isEmpty {
handle(state: IMEState.Empty()) // handle(state: IMEState.ofEmpty()) //
handle(state: IMEState.SymbolTable(node: node)) handle(state: IMEState.ofSymbolTable(node: node))
} else { } else {
handle(state: IMEState.Committing(textToCommit: node.title)) handle(state: IMEState.ofCommitting(textToCommit: node.title))
handle(state: IMEState.Empty()) handle(state: IMEState.ofEmpty())
} }
return return
} }
@ -130,15 +130,15 @@ extension ctlInputMethod: ctlCandidateDelegate {
let inputting = keyHandler.buildInputtingState let inputting = keyHandler.buildInputtingState
if mgrPrefs.useSCPCTypingMode { if mgrPrefs.useSCPCTypingMode {
handle(state: IMEState.Committing(textToCommit: inputting.displayedText)) handle(state: IMEState.ofCommitting(textToCommit: inputting.displayedText))
// selectedValue.1 // selectedValue.1
if mgrPrefs.associatedPhrasesEnabled { if mgrPrefs.associatedPhrasesEnabled {
let associates = keyHandler.buildAssociatePhraseState( let associates = keyHandler.buildAssociatePhraseState(
withPair: .init(key: selectedValue.0, value: selectedValue.1) withPair: .init(key: selectedValue.0, value: selectedValue.1)
) )
handle(state: associates.candidates.isEmpty ? IMEState.Empty() : associates) handle(state: associates.candidates.isEmpty ? IMEState.ofEmpty() : associates)
} else { } else {
handle(state: IMEState.Empty()) handle(state: IMEState.ofEmpty())
} }
} else { } else {
handle(state: inputting) handle(state: inputting)
@ -148,11 +148,11 @@ extension ctlInputMethod: ctlCandidateDelegate {
if state.type == .ofAssociates { if state.type == .ofAssociates {
let selectedValue = state.candidates[index] let selectedValue = state.candidates[index]
handle(state: IMEState.Committing(textToCommit: selectedValue.1)) handle(state: IMEState.ofCommitting(textToCommit: selectedValue.1))
// selectedValue.1 // selectedValue.1
// //
guard let valueKept = selectedValue.1.last else { guard let valueKept = selectedValue.1.last else {
handle(state: IMEState.Empty()) handle(state: IMEState.ofEmpty())
return return
} }
if mgrPrefs.associatedPhrasesEnabled { if mgrPrefs.associatedPhrasesEnabled {
@ -164,7 +164,7 @@ extension ctlInputMethod: ctlCandidateDelegate {
return return
} }
} }
handle(state: IMEState.Empty()) handle(state: IMEState.ofEmpty())
} }
} }
} }

View File

@ -35,7 +35,7 @@ extension ctlInputMethod {
case .ofEmpty, .ofAbortion: case .ofEmpty, .ofAbortion:
var previous = previous var previous = previous
if state.type == .ofAbortion { if state.type == .ofAbortion {
state = IMEState.Empty() state = IMEState.ofEmpty()
previous = state previous = state
} }
ctlInputMethod.ctlCandidateCurrent.visible = false ctlInputMethod.ctlCandidateCurrent.visible = false