ctlIME // Make ctlCandidateCurrent static.
This commit is contained in:
parent
922a0d0345
commit
ce6a7ce553
|
@ -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()
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue