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