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
///
var ctlCandidateCurrent = ctlCandidateUniversal.init(.horizontal)
static var ctlCandidateCurrent = ctlCandidateUniversal.init(.horizontal)
///
static let tooltipController = TooltipController()

View File

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

View File

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

View File

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