ctlIME // Make ctlCandidateCurrent static.

This commit is contained in:
ShikiSuen 2022-07-21 17:31:12 +08:00
parent 922a0d0345
commit ce6a7ce553
4 changed files with 20 additions and 20 deletions

View File

@ -41,7 +41,7 @@ class ctlInputMethod: IMKInputController {
static var areWeDeleting = false static var areWeDeleting = false
/// ///
var ctlCandidateCurrent = ctlCandidateUniversal.init(.horizontal) static var ctlCandidateCurrent = ctlCandidateUniversal.init(.horizontal)
/// ///
static let tooltipController = TooltipController() static let tooltipController = TooltipController()

View File

@ -29,7 +29,7 @@ import Foundation
// MARK: - KeyHandler Delegate // MARK: - KeyHandler Delegate
extension ctlInputMethod: KeyHandlerDelegate { extension ctlInputMethod: KeyHandlerDelegate {
func ctlCandidate() -> ctlCandidate { ctlCandidateCurrent } func ctlCandidate() -> ctlCandidate { ctlInputMethod.ctlCandidateCurrent }
func keyHandler( func keyHandler(
_: KeyHandler, didSelectCandidateAt index: Int, _: KeyHandler, didSelectCandidateAt index: Int,

View File

@ -72,7 +72,7 @@ extension ctlInputMethod {
// true // true
} }
ctlCandidateCurrent.delegate = nil ctlInputMethod.ctlCandidateCurrent.delegate = nil
/// currentLayout /// currentLayout
/// ctlCandidate() SymbolTable /// ctlCandidate() SymbolTable
@ -81,11 +81,11 @@ extension ctlInputMethod {
/// macOS 10.x SwiftUI /// macOS 10.x SwiftUI
if isCandidateWindowVertical { // 使 if isCandidateWindowVertical { // 使
ctlCandidateCurrent = .init(.vertical) ctlInputMethod.ctlCandidateCurrent = .init(.vertical)
} else if mgrPrefs.useHorizontalCandidateList { } else if mgrPrefs.useHorizontalCandidateList {
ctlCandidateCurrent = .init(.horizontal) ctlInputMethod.ctlCandidateCurrent = .init(.horizontal)
} else { } else {
ctlCandidateCurrent = .init(.vertical) ctlInputMethod.ctlCandidateCurrent = .init(.vertical)
} }
// set the attributes for the candidate panel (which uses NSAttributedString) // set the attributes for the candidate panel (which uses NSAttributedString)
@ -113,10 +113,10 @@ extension ctlInputMethod {
return finalReturnFont return finalReturnFont
} }
ctlCandidateCurrent.keyLabelFont = labelFont( ctlInputMethod.ctlCandidateCurrent.keyLabelFont = labelFont(
name: mgrPrefs.candidateKeyLabelFontName, size: keyLabelSize name: mgrPrefs.candidateKeyLabelFontName, size: keyLabelSize
) )
ctlCandidateCurrent.candidateFont = candidateFont( ctlInputMethod.ctlCandidateCurrent.candidateFont = candidateFont(
name: mgrPrefs.candidateTextFontName, size: textSize name: mgrPrefs.candidateTextFontName, size: textSize
) )
@ -124,14 +124,14 @@ extension ctlInputMethod {
let keyLabels = let keyLabels =
candidateKeys.count > 4 ? Array(candidateKeys) : Array(mgrPrefs.defaultCandidateKeys) candidateKeys.count > 4 ? Array(candidateKeys) : Array(mgrPrefs.defaultCandidateKeys)
let keyLabelSuffix = state is InputState.AssociatedPhrases ? "^" : "" let keyLabelSuffix = state is InputState.AssociatedPhrases ? "^" : ""
ctlCandidateCurrent.keyLabels = keyLabels.map { ctlInputMethod.ctlCandidateCurrent.keyLabels = keyLabels.map {
CandidateKeyLabel(key: String($0), displayedText: String($0) + keyLabelSuffix) CandidateKeyLabel(key: String($0), displayedText: String($0) + keyLabelSuffix)
} }
ctlCandidateCurrent.delegate = self ctlInputMethod.ctlCandidateCurrent.delegate = self
ctlCandidateCurrent.reloadData() ctlInputMethod.ctlCandidateCurrent.reloadData()
ctlCandidateCurrent.visible = true ctlInputMethod.ctlCandidateCurrent.visible = true
var lineHeightRect = NSRect(x: 0.0, y: 0.0, width: 16.0, height: 16.0) var lineHeightRect = NSRect(x: 0.0, y: 0.0, width: 16.0, height: 16.0)
var cursor = 0 var cursor = 0
@ -151,14 +151,14 @@ extension ctlInputMethod {
} }
if isTypingVertical { if isTypingVertical {
ctlCandidateCurrent.set( ctlInputMethod.ctlCandidateCurrent.set(
windowTopLeftPoint: NSPoint( windowTopLeftPoint: NSPoint(
x: lineHeightRect.origin.x + lineHeightRect.size.width + 4.0, y: lineHeightRect.origin.y - 4.0 x: lineHeightRect.origin.x + lineHeightRect.size.width + 4.0, y: lineHeightRect.origin.y - 4.0
), ),
bottomOutOfScreenAdjustmentHeight: lineHeightRect.size.height + 4.0 bottomOutOfScreenAdjustmentHeight: lineHeightRect.size.height + 4.0
) )
} else { } else {
ctlCandidateCurrent.set( ctlInputMethod.ctlCandidateCurrent.set(
windowTopLeftPoint: NSPoint(x: lineHeightRect.origin.x, y: lineHeightRect.origin.y - 4.0), windowTopLeftPoint: NSPoint(x: lineHeightRect.origin.x, y: lineHeightRect.origin.y - 4.0),
bottomOutOfScreenAdjustmentHeight: lineHeightRect.size.height + 4.0 bottomOutOfScreenAdjustmentHeight: lineHeightRect.size.height + 4.0
) )

View File

@ -132,8 +132,8 @@ extension ctlInputMethod {
private func handle(state: InputState.Deactivated, previous: InputStateProtocol) { private func handle(state: InputState.Deactivated, previous: InputStateProtocol) {
_ = state // _ = state //
ctlCandidateCurrent.delegate = nil ctlInputMethod.ctlCandidateCurrent.delegate = nil
ctlCandidateCurrent.visible = false ctlInputMethod.ctlCandidateCurrent.visible = false
ctlInputMethod.tooltipController.hide() ctlInputMethod.tooltipController.hide()
if let previous = previous as? InputState.NotEmpty { if let previous = previous as? InputState.NotEmpty {
commit(text: previous.composingBuffer) commit(text: previous.composingBuffer)
@ -143,7 +143,7 @@ extension ctlInputMethod {
private func handle(state: InputState.Empty, previous: InputStateProtocol) { private func handle(state: InputState.Empty, previous: InputStateProtocol) {
_ = state // _ = state //
ctlCandidateCurrent.visible = false ctlInputMethod.ctlCandidateCurrent.visible = false
ctlInputMethod.tooltipController.hide() ctlInputMethod.tooltipController.hide()
// .EmptyIgnoringPreviousState // .EmptyIgnoringPreviousState
if let previous = previous as? InputState.NotEmpty, if let previous = previous as? InputState.NotEmpty,
@ -165,7 +165,7 @@ extension ctlInputMethod {
private func handle(state: InputState.Committing, previous: InputStateProtocol) { private func handle(state: InputState.Committing, previous: InputStateProtocol) {
_ = previous // _ = previous //
ctlCandidateCurrent.visible = false ctlInputMethod.ctlCandidateCurrent.visible = false
ctlInputMethod.tooltipController.hide() ctlInputMethod.tooltipController.hide()
let textToCommit = state.textToCommit let textToCommit = state.textToCommit
if !textToCommit.isEmpty { if !textToCommit.isEmpty {
@ -176,7 +176,7 @@ extension ctlInputMethod {
private func handle(state: InputState.Inputting, previous: InputStateProtocol) { private func handle(state: InputState.Inputting, previous: InputStateProtocol) {
_ = previous // _ = previous //
ctlCandidateCurrent.visible = false ctlInputMethod.ctlCandidateCurrent.visible = false
ctlInputMethod.tooltipController.hide() ctlInputMethod.tooltipController.hide()
let textToCommit = state.textToCommit let textToCommit = state.textToCommit
if !textToCommit.isEmpty { if !textToCommit.isEmpty {
@ -193,7 +193,7 @@ extension ctlInputMethod {
private func handle(state: InputState.Marking, previous: InputStateProtocol) { private func handle(state: InputState.Marking, previous: InputStateProtocol) {
_ = previous // _ = previous //
ctlCandidateCurrent.visible = false ctlInputMethod.ctlCandidateCurrent.visible = false
setInlineDisplayWithCursor() setInlineDisplayWithCursor()
if state.tooltip.isEmpty { if state.tooltip.isEmpty {
ctlInputMethod.tooltipController.hide() ctlInputMethod.tooltipController.hide()