SessionCtl // Update composition buffer for .ofSymbolTable().

This commit is contained in:
ShikiSuen 2023-06-20 01:48:14 +08:00
parent 0a711697bb
commit d271ec1a14
2 changed files with 24 additions and 2 deletions

View File

@ -196,7 +196,10 @@ public extension IMEState {
func attributedString(for session: IMKInputController) -> NSAttributedString { func attributedString(for session: IMKInputController) -> NSAttributedString {
switch type { switch type {
case .ofMarking: return data.attributedStringMarking(for: session) case .ofMarking: return data.attributedStringMarking(for: session)
case .ofAssociates, .ofSymbolTable: return data.attributedStringPlaceholder(for: session) case .ofAssociates: return data.attributedStringPlaceholder(for: session)
case .ofSymbolTable:
guard !displayedText.isEmpty else { return data.attributedStringPlaceholder(for: session) }
return data.attributedStringNormal(for: session)
default: return data.attributedStringNormal(for: session) default: return data.attributedStringNormal(for: session)
} }
} }

View File

@ -125,7 +125,26 @@ extension SessionCtl: CtlCandidateDelegate {
} }
public func candidatePairHighlightChanged(at theIndex: Int) { public func candidatePairHighlightChanged(at theIndex: Int) {
inputHandler?.previewCompositionBufferForCandidate(at: theIndex) guard let inputHandler = inputHandler else { return }
guard state.isCandidateContainer else { return }
switch state.type {
case .ofCandidates where (0 ..< state.candidates.count).contains(theIndex):
inputHandler.previewCompositionBufferForCandidate(at: theIndex)
case .ofSymbolTable where (0 ..< state.node.members.count).contains(theIndex):
let node = state.node.members[theIndex]
if node.members.isEmpty {
state.data.displayedText = node.name
state.data.cursor = node.name.count
} else {
state.data.displayedText.removeAll()
state.data.cursor = 0
}
setInlineDisplayWithCursor()
if clientMitigationLevel >= 2, state.hasComposition {
updatePopupDisplayWithCursor()
}
default: break
}
} }
public func candidatePairSelectionConfirmed(at index: Int) { public func candidatePairSelectionConfirmed(at index: Int) {