UPR: ctlIME // Reset KeyHandler when toggling funcModes.
- Also fixing a typo inherited from the upstream.
This commit is contained in:
parent
de37f391b2
commit
5fe5e2a0b0
|
@ -49,7 +49,7 @@ class ctlInputMethod: IMKInputController {
|
||||||
|
|
||||||
// MARK: -
|
// MARK: -
|
||||||
|
|
||||||
private var currentCandidateClient: Any?
|
private var currentClient: Any?
|
||||||
|
|
||||||
private var keyHandler: KeyHandler = KeyHandler()
|
private var keyHandler: KeyHandler = KeyHandler()
|
||||||
private var state: InputState = InputState.Empty()
|
private var state: InputState = InputState.Empty()
|
||||||
|
@ -76,6 +76,15 @@ class ctlInputMethod: IMKInputController {
|
||||||
keyHandler.delegate = self
|
keyHandler.delegate = self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - KeyHandler Reset Command
|
||||||
|
|
||||||
|
func resetKeyHandler() {
|
||||||
|
if let currentClient = currentClient {
|
||||||
|
keyHandler.clear()
|
||||||
|
self.handle(state: InputState.Empty(), client: currentClient)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - IMKStateSetting protocol methods
|
// MARK: - IMKStateSetting protocol methods
|
||||||
|
|
||||||
override func activateServer(_ client: Any!) {
|
override func activateServer(_ client: Any!) {
|
||||||
|
@ -84,7 +93,7 @@ class ctlInputMethod: IMKInputController {
|
||||||
// Override the keyboard layout to the basic one.
|
// Override the keyboard layout to the basic one.
|
||||||
setKeyLayout()
|
setKeyLayout()
|
||||||
// reset the state
|
// reset the state
|
||||||
currentCandidateClient = nil
|
currentClient = client
|
||||||
|
|
||||||
keyHandler.clear()
|
keyHandler.clear()
|
||||||
keyHandler.syncWithPreferences()
|
keyHandler.syncWithPreferences()
|
||||||
|
@ -94,6 +103,7 @@ class ctlInputMethod: IMKInputController {
|
||||||
|
|
||||||
override func deactivateServer(_ client: Any!) {
|
override func deactivateServer(_ client: Any!) {
|
||||||
keyHandler.clear()
|
keyHandler.clear()
|
||||||
|
currentClient = nil
|
||||||
self.handle(state: .Empty(), client: client)
|
self.handle(state: .Empty(), client: client)
|
||||||
self.handle(state: .Deactivated(), client: client)
|
self.handle(state: .Deactivated(), client: client)
|
||||||
}
|
}
|
||||||
|
@ -225,7 +235,7 @@ extension ctlInputMethod {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func handle(state: InputState.Deactivated, previous: InputState, client: Any?) {
|
private func handle(state: InputState.Deactivated, previous: InputState, client: Any?) {
|
||||||
currentCandidateClient = nil
|
currentClient = nil
|
||||||
|
|
||||||
ctlCandidateCurrent?.delegate = nil
|
ctlCandidateCurrent?.delegate = nil
|
||||||
ctlCandidateCurrent?.visible = false
|
ctlCandidateCurrent?.visible = false
|
||||||
|
@ -441,7 +451,7 @@ extension ctlInputMethod {
|
||||||
|
|
||||||
ctlCandidateCurrent?.delegate = self
|
ctlCandidateCurrent?.delegate = self
|
||||||
ctlCandidateCurrent?.reloadData()
|
ctlCandidateCurrent?.reloadData()
|
||||||
currentCandidateClient = client
|
currentClient = client
|
||||||
|
|
||||||
ctlCandidateCurrent?.visible = true
|
ctlCandidateCurrent?.visible = true
|
||||||
|
|
||||||
|
@ -558,7 +568,7 @@ extension ctlInputMethod: ctlCandidateDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ctlCandidate(_ controller: ctlCandidate, didSelectCandidateAtIndex index: UInt) {
|
func ctlCandidate(_ controller: ctlCandidate, didSelectCandidateAtIndex index: UInt) {
|
||||||
let client = currentCandidateClient
|
let client = currentClient
|
||||||
|
|
||||||
if let state = state as? InputState.SymbolTable,
|
if let state = state as? InputState.SymbolTable,
|
||||||
let node = state.node.children?[Int(index)]
|
let node = state.node.children?[Int(index)]
|
||||||
|
@ -566,7 +576,7 @@ extension ctlInputMethod: ctlCandidateDelegate {
|
||||||
if let children = node.children, !children.isEmpty {
|
if let children = node.children, !children.isEmpty {
|
||||||
self.handle(
|
self.handle(
|
||||||
state: .SymbolTable(node: node, useVerticalMode: state.useVerticalMode),
|
state: .SymbolTable(node: node, useVerticalMode: state.useVerticalMode),
|
||||||
client: currentCandidateClient)
|
client: currentClient)
|
||||||
} else {
|
} else {
|
||||||
self.handle(state: .Committing(poppedText: node.title), client: client)
|
self.handle(state: .Committing(poppedText: node.title), client: client)
|
||||||
self.handle(state: .Empty(), client: client)
|
self.handle(state: .Empty(), client: client)
|
||||||
|
@ -603,7 +613,7 @@ extension ctlInputMethod: ctlCandidateDelegate {
|
||||||
|
|
||||||
if let state = state as? InputState.AssociatedPhrases {
|
if let state = state as? InputState.AssociatedPhrases {
|
||||||
let selectedValue = state.candidates[Int(index)]
|
let selectedValue = state.candidates[Int(index)]
|
||||||
handle(state: .Committing(poppedText: selectedValue), client: currentCandidateClient)
|
handle(state: .Committing(poppedText: selectedValue), client: currentClient)
|
||||||
if mgrPrefs.associatedPhrasesEnabled,
|
if mgrPrefs.associatedPhrasesEnabled,
|
||||||
let associatePhrases = keyHandler.buildAssociatePhraseState(
|
let associatePhrases = keyHandler.buildAssociatePhraseState(
|
||||||
withKey: selectedValue, useVerticalMode: state.useVerticalMode)
|
withKey: selectedValue, useVerticalMode: state.useVerticalMode)
|
||||||
|
|
|
@ -163,6 +163,7 @@ extension ctlInputMethod {
|
||||||
mgrPrefs.toggleSCPCTypingModeEnabled()
|
mgrPrefs.toggleSCPCTypingModeEnabled()
|
||||||
? NSLocalizedString("NotificationSwitchON", comment: "")
|
? NSLocalizedString("NotificationSwitchON", comment: "")
|
||||||
: NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
: NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||||
|
resetKeyHandler()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func toggleChineseConverter(_ sender: Any?) {
|
@objc func toggleChineseConverter(_ sender: Any?) {
|
||||||
|
@ -172,6 +173,7 @@ extension ctlInputMethod {
|
||||||
mgrPrefs.toggleChineseConversionEnabled()
|
mgrPrefs.toggleChineseConversionEnabled()
|
||||||
? NSLocalizedString("NotificationSwitchON", comment: "")
|
? NSLocalizedString("NotificationSwitchON", comment: "")
|
||||||
: NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
: NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||||
|
resetKeyHandler()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func toggleShiftJISShinjitaiOutput(_ sender: Any?) {
|
@objc func toggleShiftJISShinjitaiOutput(_ sender: Any?) {
|
||||||
|
@ -181,6 +183,7 @@ extension ctlInputMethod {
|
||||||
mgrPrefs.toggleShiftJISShinjitaiOutputEnabled()
|
mgrPrefs.toggleShiftJISShinjitaiOutputEnabled()
|
||||||
? NSLocalizedString("NotificationSwitchON", comment: "")
|
? NSLocalizedString("NotificationSwitchON", comment: "")
|
||||||
: NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
: NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||||
|
resetKeyHandler()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func toggleHalfWidthPunctuation(_ sender: Any?) {
|
@objc func toggleHalfWidthPunctuation(_ sender: Any?) {
|
||||||
|
@ -191,6 +194,7 @@ extension ctlInputMethod {
|
||||||
mgrPrefs.toggleHalfWidthPunctuationEnabled()
|
mgrPrefs.toggleHalfWidthPunctuationEnabled()
|
||||||
? NSLocalizedString("NotificationSwitchON", comment: "")
|
? NSLocalizedString("NotificationSwitchON", comment: "")
|
||||||
: NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
: NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||||
|
resetKeyHandler()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func toggleCNS11643Enabled(_ sender: Any?) {
|
@objc func toggleCNS11643Enabled(_ sender: Any?) {
|
||||||
|
@ -200,6 +204,7 @@ extension ctlInputMethod {
|
||||||
mgrPrefs.toggleCNS11643Enabled()
|
mgrPrefs.toggleCNS11643Enabled()
|
||||||
? NSLocalizedString("NotificationSwitchON", comment: "")
|
? NSLocalizedString("NotificationSwitchON", comment: "")
|
||||||
: NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
: NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||||
|
resetKeyHandler()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func toggleSymbolEnabled(_ sender: Any?) {
|
@objc func toggleSymbolEnabled(_ sender: Any?) {
|
||||||
|
@ -209,6 +214,7 @@ extension ctlInputMethod {
|
||||||
mgrPrefs.toggleSymbolInputEnabled()
|
mgrPrefs.toggleSymbolInputEnabled()
|
||||||
? NSLocalizedString("NotificationSwitchON", comment: "")
|
? NSLocalizedString("NotificationSwitchON", comment: "")
|
||||||
: NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
: NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||||
|
resetKeyHandler()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func toggleAssociatedPhrasesEnabled(_ sender: Any?) {
|
@objc func toggleAssociatedPhrasesEnabled(_ sender: Any?) {
|
||||||
|
@ -219,6 +225,7 @@ extension ctlInputMethod {
|
||||||
mgrPrefs.toggleAssociatedPhrasesEnabled()
|
mgrPrefs.toggleAssociatedPhrasesEnabled()
|
||||||
? NSLocalizedString("NotificationSwitchON", comment: "")
|
? NSLocalizedString("NotificationSwitchON", comment: "")
|
||||||
: NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
: NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||||
|
resetKeyHandler()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func togglePhraseReplacement(_ sender: Any?) {
|
@objc func togglePhraseReplacement(_ sender: Any?) {
|
||||||
|
@ -228,6 +235,7 @@ extension ctlInputMethod {
|
||||||
mgrPrefs.togglePhraseReplacementEnabled()
|
mgrPrefs.togglePhraseReplacementEnabled()
|
||||||
? NSLocalizedString("NotificationSwitchON", comment: "")
|
? NSLocalizedString("NotificationSwitchON", comment: "")
|
||||||
: NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
: NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||||
|
resetKeyHandler()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func selfUninstall(_ sender: Any?) {
|
@objc func selfUninstall(_ sender: Any?) {
|
||||||
|
|
Loading…
Reference in New Issue