SymbolNode // Add and call previous node references.
This commit is contained in:
parent
b0cde41126
commit
0e8b027674
|
@ -440,8 +440,11 @@ enum InputState {
|
|||
override public var type: StateType { .ofSymbolTable }
|
||||
var node: SymbolNode
|
||||
|
||||
init(node: SymbolNode, isTypingVertical: Bool) {
|
||||
init(node: SymbolNode, previous: SymbolNode? = nil, isTypingVertical: Bool) {
|
||||
self.node = node
|
||||
if let previous = previous {
|
||||
self.node.previous = previous
|
||||
}
|
||||
let candidates = node.children?.map(\.title) ?? [String]()
|
||||
super.init(
|
||||
composingBuffer: "", cursorIndex: 0, candidates: candidates.map { ("", $0) },
|
||||
|
|
|
@ -59,7 +59,7 @@ extension KeyHandler {
|
|||
|| ((input.isCursorBackward || input.isCursorForward) && input.isShiftHold)
|
||||
|
||||
if cancelCandidateKey {
|
||||
if (state is InputState.AssociatedPhrases)
|
||||
if state is InputState.AssociatedPhrases
|
||||
|| mgrPrefs.useSCPCTypingMode
|
||||
|| compositor.isEmpty
|
||||
{
|
||||
|
@ -72,6 +72,9 @@ extension KeyHandler {
|
|||
} else {
|
||||
stateCallback(buildInputtingState)
|
||||
}
|
||||
if let state = state as? InputState.SymbolTable, let nodePrevious = state.node.previous {
|
||||
stateCallback(InputState.SymbolTable(node: nodePrevious, isTypingVertical: state.isTypingVertical))
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ extension ctlInputMethod: ctlCandidateDelegate {
|
|||
if let children = node.children, !children.isEmpty {
|
||||
handle(state: InputState.Empty()) // 防止縱橫排選字窗同時出現
|
||||
handle(
|
||||
state: InputState.SymbolTable(node: node, isTypingVertical: state.isTypingVertical)
|
||||
state: InputState.SymbolTable(node: node, previous: state.node, isTypingVertical: state.isTypingVertical)
|
||||
)
|
||||
} else {
|
||||
handle(state: InputState.Committing(textToCommit: node.title))
|
||||
|
|
|
@ -29,6 +29,7 @@ import Foundation
|
|||
class SymbolNode {
|
||||
var title: String
|
||||
var children: [SymbolNode]?
|
||||
var previous: SymbolNode?
|
||||
|
||||
init(_ title: String, _ children: [SymbolNode]? = nil) {
|
||||
self.title = title
|
||||
|
|
Loading…
Reference in New Issue