Project // Reduce the usage of [at]objc.
This commit is contained in:
parent
25b3a1b766
commit
b8bb5e18d6
|
@ -46,7 +46,7 @@ public class OpenCCBridge: NSObject {
|
|||
///
|
||||
/// - Parameter string: Text in Original Script.
|
||||
/// - Returns: Text converted to Different Script.
|
||||
@objc public static func crossConvert(_ string: String) -> String? {
|
||||
public static func crossConvert(_ string: String) -> String? {
|
||||
switch ctlInputMethod.currentKeyHandler.inputMode {
|
||||
case InputMode.imeModeCHS:
|
||||
return shared.traditionalize?.convert(string)
|
||||
|
|
|
@ -76,7 +76,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega
|
|||
}
|
||||
}
|
||||
|
||||
@objc func showPreferences() {
|
||||
func showPreferences() {
|
||||
if ctlPrefWindowInstance == nil {
|
||||
ctlPrefWindowInstance = ctlPrefWindow.init(windowNibName: "frmPrefWindow")
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega
|
|||
}
|
||||
|
||||
// New About Window
|
||||
@objc func showAbout() {
|
||||
func showAbout() {
|
||||
if ctlAboutWindowInstance == nil {
|
||||
ctlAboutWindowInstance = ctlAboutWindow.init(windowNibName: "frmAboutWindow")
|
||||
}
|
||||
|
@ -98,12 +98,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega
|
|||
NSApp.setActivationPolicy(.accessory)
|
||||
}
|
||||
|
||||
@objc(checkForUpdate)
|
||||
func checkForUpdate() {
|
||||
checkForUpdate(forced: false)
|
||||
}
|
||||
|
||||
@objc(checkForUpdateForced:)
|
||||
func checkForUpdate(forced: Bool) {
|
||||
if checkTask != nil {
|
||||
// busy
|
||||
|
|
|
@ -39,12 +39,12 @@ class AppleKeyboardConverter: NSObject {
|
|||
"org.unknown.keylayout.vChewingIBM",
|
||||
"org.unknown.keylayout.vChewingMiTAC",
|
||||
]
|
||||
@objc class func isDynamicBasicKeyboardLayoutEnabled() -> Bool {
|
||||
class func isDynamicBasicKeyboardLayoutEnabled() -> Bool {
|
||||
AppleKeyboardConverter.arrDynamicBasicKeyLayout.contains(mgrPrefs.basicKeyboardLayout)
|
||||
}
|
||||
|
||||
// 處理 Apple 注音鍵盤佈局類型。
|
||||
@objc class func cnvApple2ABC(_ charCode: UniChar) -> UniChar {
|
||||
class func cnvApple2ABC(_ charCode: UniChar) -> UniChar {
|
||||
var charCode = charCode
|
||||
// 在按鍵資訊被送往 OVMandarin 之前,先轉換為可以被 OVMandarin 正常處理的資訊。
|
||||
if isDynamicBasicKeyboardLayoutEnabled() {
|
||||
|
@ -185,7 +185,7 @@ class AppleKeyboardConverter: NSObject {
|
|||
return charCode
|
||||
}
|
||||
|
||||
@objc class func cnvStringApple2ABC(_ strProcessed: String) -> String {
|
||||
class func cnvStringApple2ABC(_ strProcessed: String) -> String {
|
||||
var strProcessed = strProcessed
|
||||
if isDynamicBasicKeyboardLayoutEnabled() {
|
||||
// 針對不同的 Apple 動態鍵盤佈局糾正大寫英文輸入。
|
||||
|
|
|
@ -29,7 +29,7 @@ import Cocoa
|
|||
// Use KeyCodes as much as possible since its recognition won't be affected by macOS Base Keyboard Layouts.
|
||||
// KeyCodes: https://eastmanreference.com/complete-list-of-applescript-key-codes
|
||||
// Also: HIToolbox.framework/Versions/A/Headers/Events.h
|
||||
@objc enum KeyCode: UInt16 {
|
||||
enum KeyCode: UInt16 {
|
||||
case kNone = 0
|
||||
case kCarriageReturn = 36 // Renamed from "kReturn" to avoid nomenclatural confusions.
|
||||
case kTab = 48
|
||||
|
@ -91,11 +91,11 @@ enum CharCode: UInt /* 16 */ {
|
|||
}
|
||||
|
||||
class InputHandler: NSObject {
|
||||
@objc private(set) var useVerticalMode: Bool
|
||||
@objc private(set) var inputText: String?
|
||||
@objc private(set) var inputTextIgnoringModifiers: String?
|
||||
@objc private(set) var charCode: UInt16
|
||||
@objc private(set) var keyCode: UInt16
|
||||
private(set) var useVerticalMode: Bool
|
||||
private(set) var inputText: String?
|
||||
private(set) var inputTextIgnoringModifiers: String?
|
||||
private(set) var charCode: UInt16
|
||||
private(set) var keyCode: UInt16
|
||||
private var isFlagChanged: Bool
|
||||
private var flags: NSEvent.ModifierFlags
|
||||
private var cursorForwardKey: KeyCode
|
||||
|
@ -104,9 +104,9 @@ class InputHandler: NSObject {
|
|||
private var extraChooseCandidateKeyReverse: KeyCode
|
||||
private var absorbedArrowKey: KeyCode
|
||||
private var verticalModeOnlyChooseCandidateKey: KeyCode
|
||||
@objc private(set) var emacsKey: vChewingEmacsKey
|
||||
private(set) var emacsKey: vChewingEmacsKey
|
||||
|
||||
@objc init(
|
||||
init(
|
||||
inputText: String?, keyCode: UInt16, charCode: UInt16, flags: NSEvent.ModifierFlags,
|
||||
isVerticalMode: Bool, inputTextIgnoringModifiers: String? = nil
|
||||
) {
|
||||
|
@ -133,7 +133,7 @@ class InputHandler: NSObject {
|
|||
super.init()
|
||||
}
|
||||
|
||||
@objc init(event: NSEvent, isVerticalMode: Bool) {
|
||||
init(event: NSEvent, isVerticalMode: Bool) {
|
||||
inputText = AppleKeyboardConverter.cnvStringApple2ABC(event.characters ?? "")
|
||||
inputTextIgnoringModifiers = AppleKeyboardConverter.cnvStringApple2ABC(
|
||||
event.charactersIgnoringModifiers ?? "")
|
||||
|
@ -172,143 +172,143 @@ class InputHandler: NSObject {
|
|||
"<\(super.description) inputText:\(String(describing: inputText)), inputTextIgnoringModifiers:\(String(describing: inputTextIgnoringModifiers)) charCode:\(charCode), keyCode:\(keyCode), flags:\(flags), cursorForwardKey:\(cursorForwardKey), cursorBackwardKey:\(cursorBackwardKey), extraChooseCandidateKey:\(extraChooseCandidateKey), extraChooseCandidateKeyReverse:\(extraChooseCandidateKeyReverse), absorbedArrowKey:\(absorbedArrowKey), verticalModeOnlyChooseCandidateKey:\(verticalModeOnlyChooseCandidateKey), emacsKey:\(emacsKey), useVerticalMode:\(useVerticalMode)>"
|
||||
}
|
||||
|
||||
@objc var isShiftHold: Bool {
|
||||
var isShiftHold: Bool {
|
||||
flags.contains([.shift])
|
||||
}
|
||||
|
||||
@objc var isCommandHold: Bool {
|
||||
var isCommandHold: Bool {
|
||||
flags.contains([.command])
|
||||
}
|
||||
|
||||
@objc var isControlHold: Bool {
|
||||
var isControlHold: Bool {
|
||||
flags.contains([.control])
|
||||
}
|
||||
|
||||
@objc var isControlHotKey: Bool {
|
||||
var isControlHotKey: Bool {
|
||||
flags.contains([.control]) && inputText?.first?.isLetter ?? false
|
||||
}
|
||||
|
||||
@objc var isOptionHotKey: Bool {
|
||||
var isOptionHotKey: Bool {
|
||||
flags.contains([.option]) && inputText?.first?.isLetter ?? false
|
||||
}
|
||||
|
||||
@objc var isOptionHold: Bool {
|
||||
var isOptionHold: Bool {
|
||||
flags.contains([.option])
|
||||
}
|
||||
|
||||
@objc var isCapsLockOn: Bool {
|
||||
var isCapsLockOn: Bool {
|
||||
flags.contains([.capsLock])
|
||||
}
|
||||
|
||||
@objc var isNumericPad: Bool {
|
||||
var isNumericPad: Bool {
|
||||
flags.contains([.numericPad])
|
||||
}
|
||||
|
||||
@objc var isFunctionKeyHold: Bool {
|
||||
var isFunctionKeyHold: Bool {
|
||||
flags.contains([.function])
|
||||
}
|
||||
|
||||
@objc var isReservedKey: Bool {
|
||||
var isReservedKey: Bool {
|
||||
guard let code = KeyCode(rawValue: keyCode) else {
|
||||
return false
|
||||
}
|
||||
return code.rawValue != KeyCode.kNone.rawValue
|
||||
}
|
||||
|
||||
@objc var isTab: Bool {
|
||||
var isTab: Bool {
|
||||
KeyCode(rawValue: keyCode) == KeyCode.kTab
|
||||
}
|
||||
|
||||
@objc var isEnter: Bool {
|
||||
var isEnter: Bool {
|
||||
(KeyCode(rawValue: keyCode) == KeyCode.kCarriageReturn)
|
||||
|| (KeyCode(rawValue: keyCode) == KeyCode.kLineFeed)
|
||||
}
|
||||
|
||||
@objc var isUp: Bool {
|
||||
var isUp: Bool {
|
||||
KeyCode(rawValue: keyCode) == KeyCode.kUpArrow
|
||||
}
|
||||
|
||||
@objc var isDown: Bool {
|
||||
var isDown: Bool {
|
||||
KeyCode(rawValue: keyCode) == KeyCode.kDownArrow
|
||||
}
|
||||
|
||||
@objc var isLeft: Bool {
|
||||
var isLeft: Bool {
|
||||
KeyCode(rawValue: keyCode) == KeyCode.kLeftArrow
|
||||
}
|
||||
|
||||
@objc var isRight: Bool {
|
||||
var isRight: Bool {
|
||||
KeyCode(rawValue: keyCode) == KeyCode.kRightArrow
|
||||
}
|
||||
|
||||
@objc var isPageUp: Bool {
|
||||
var isPageUp: Bool {
|
||||
KeyCode(rawValue: keyCode) == KeyCode.kPageUp
|
||||
}
|
||||
|
||||
@objc var isPageDown: Bool {
|
||||
var isPageDown: Bool {
|
||||
KeyCode(rawValue: keyCode) == KeyCode.kPageDown
|
||||
}
|
||||
|
||||
@objc var isSpace: Bool {
|
||||
var isSpace: Bool {
|
||||
KeyCode(rawValue: keyCode) == KeyCode.kSpace
|
||||
}
|
||||
|
||||
@objc var isBackSpace: Bool {
|
||||
var isBackSpace: Bool {
|
||||
KeyCode(rawValue: keyCode) == KeyCode.kBackSpace
|
||||
}
|
||||
|
||||
@objc var isESC: Bool {
|
||||
var isESC: Bool {
|
||||
KeyCode(rawValue: keyCode) == KeyCode.kEscape
|
||||
}
|
||||
|
||||
@objc var isHome: Bool {
|
||||
var isHome: Bool {
|
||||
KeyCode(rawValue: keyCode) == KeyCode.kHome
|
||||
}
|
||||
|
||||
@objc var isEnd: Bool {
|
||||
var isEnd: Bool {
|
||||
KeyCode(rawValue: keyCode) == KeyCode.kEnd
|
||||
}
|
||||
|
||||
@objc var isDelete: Bool {
|
||||
var isDelete: Bool {
|
||||
KeyCode(rawValue: keyCode) == KeyCode.kWindowDelete
|
||||
}
|
||||
|
||||
@objc var isCursorBackward: Bool {
|
||||
var isCursorBackward: Bool {
|
||||
KeyCode(rawValue: keyCode) == cursorBackwardKey
|
||||
}
|
||||
|
||||
@objc var isCursorForward: Bool {
|
||||
var isCursorForward: Bool {
|
||||
KeyCode(rawValue: keyCode) == cursorForwardKey
|
||||
}
|
||||
|
||||
@objc var isAbsorbedArrowKey: Bool {
|
||||
var isAbsorbedArrowKey: Bool {
|
||||
KeyCode(rawValue: keyCode) == absorbedArrowKey
|
||||
}
|
||||
|
||||
@objc var isExtraChooseCandidateKey: Bool {
|
||||
var isExtraChooseCandidateKey: Bool {
|
||||
KeyCode(rawValue: keyCode) == extraChooseCandidateKey
|
||||
}
|
||||
|
||||
@objc var isExtraChooseCandidateKeyReverse: Bool {
|
||||
var isExtraChooseCandidateKeyReverse: Bool {
|
||||
KeyCode(rawValue: keyCode) == extraChooseCandidateKeyReverse
|
||||
}
|
||||
|
||||
@objc var isVerticalModeOnlyChooseCandidateKey: Bool {
|
||||
var isVerticalModeOnlyChooseCandidateKey: Bool {
|
||||
KeyCode(rawValue: keyCode) == verticalModeOnlyChooseCandidateKey
|
||||
}
|
||||
|
||||
@objc var isUpperCaseASCIILetterKey: Bool {
|
||||
var isUpperCaseASCIILetterKey: Bool {
|
||||
// 這裡必須加上「flags == .shift」,否則會出現某些情況下輸入法「誤判當前鍵入的非 Shift 字符為大寫」的問題。
|
||||
charCode >= 65 && charCode <= 90 && flags == .shift
|
||||
}
|
||||
|
||||
@objc var isSymbolMenuPhysicalKey: Bool {
|
||||
var isSymbolMenuPhysicalKey: Bool {
|
||||
// 這裡必須用 KeyCode,這樣才不會受隨 macOS 版本更動的 Apple 動態注音鍵盤排列內容的影響。
|
||||
// 只是必須得與 ![input isShift] 搭配使用才可以(也就是僅判定 Shift 沒被摁下的情形)。
|
||||
KeyCode(rawValue: keyCode) == KeyCode.kSymbolMenuPhysicalKey
|
||||
}
|
||||
}
|
||||
|
||||
@objc enum vChewingEmacsKey: UInt16 {
|
||||
enum vChewingEmacsKey: UInt16 {
|
||||
case none = 0
|
||||
case forward = 6 // F
|
||||
case backward = 2 // B
|
||||
|
@ -319,7 +319,7 @@ class InputHandler: NSObject {
|
|||
}
|
||||
|
||||
class EmacsKeyHelper: NSObject {
|
||||
@objc static func detect(charCode: UniChar, flags: NSEvent.ModifierFlags) -> vChewingEmacsKey {
|
||||
static func detect(charCode: UniChar, flags: NSEvent.ModifierFlags) -> vChewingEmacsKey {
|
||||
let charCode = AppleKeyboardConverter.cnvApple2ABC(charCode)
|
||||
if flags.contains(.control) {
|
||||
return vChewingEmacsKey(rawValue: charCode) ?? .none
|
||||
|
|
|
@ -59,7 +59,6 @@ import Cocoa
|
|||
/// one among the candidates.
|
||||
class InputState: NSObject {
|
||||
/// Represents that the input controller is deactivated.
|
||||
@objc(InputStateDeactivated)
|
||||
class Deactivated: InputState {
|
||||
override var description: String {
|
||||
"<InputState.Deactivated>"
|
||||
|
@ -69,9 +68,8 @@ class InputState: NSObject {
|
|||
// MARK: -
|
||||
|
||||
/// Represents that the composing buffer is empty.
|
||||
@objc(InputStateEmpty)
|
||||
class Empty: InputState {
|
||||
@objc var composingBuffer: String {
|
||||
var composingBuffer: String {
|
||||
""
|
||||
}
|
||||
|
||||
|
@ -83,9 +81,8 @@ class InputState: NSObject {
|
|||
// MARK: -
|
||||
|
||||
/// Represents that the composing buffer is empty.
|
||||
@objc(InputStateEmptyIgnoringPreviousState)
|
||||
class EmptyIgnoringPreviousState: InputState {
|
||||
@objc var composingBuffer: String {
|
||||
var composingBuffer: String {
|
||||
""
|
||||
}
|
||||
|
||||
|
@ -97,11 +94,10 @@ class InputState: NSObject {
|
|||
// MARK: -
|
||||
|
||||
/// Represents that the input controller is committing text into client app.
|
||||
@objc(InputStateCommitting)
|
||||
class Committing: InputState {
|
||||
@objc private(set) var poppedText: String = ""
|
||||
private(set) var poppedText: String = ""
|
||||
|
||||
@objc convenience init(poppedText: String) {
|
||||
convenience init(poppedText: String) {
|
||||
self.init()
|
||||
self.poppedText = poppedText
|
||||
}
|
||||
|
@ -114,12 +110,11 @@ class InputState: NSObject {
|
|||
// MARK: -
|
||||
|
||||
/// Represents that the composing buffer is not empty.
|
||||
@objc(InputStateNotEmpty)
|
||||
class NotEmpty: InputState {
|
||||
@objc private(set) var composingBuffer: String
|
||||
@objc private(set) var cursorIndex: UInt
|
||||
private(set) var composingBuffer: String
|
||||
private(set) var cursorIndex: UInt
|
||||
|
||||
@objc init(composingBuffer: String, cursorIndex: UInt) {
|
||||
init(composingBuffer: String, cursorIndex: UInt) {
|
||||
self.composingBuffer = composingBuffer
|
||||
self.cursorIndex = cursorIndex
|
||||
}
|
||||
|
@ -132,16 +127,15 @@ class InputState: NSObject {
|
|||
// MARK: -
|
||||
|
||||
/// Represents that the user is inputting text.
|
||||
@objc(InputStateInputting)
|
||||
class Inputting: NotEmpty {
|
||||
@objc var poppedText: String = ""
|
||||
@objc var tooltip: String = ""
|
||||
var poppedText: String = ""
|
||||
var tooltip: String = ""
|
||||
|
||||
@objc override init(composingBuffer: String, cursorIndex: UInt) {
|
||||
override init(composingBuffer: String, cursorIndex: UInt) {
|
||||
super.init(composingBuffer: composingBuffer, cursorIndex: cursorIndex)
|
||||
}
|
||||
|
||||
@objc var attributedString: NSAttributedString {
|
||||
var attributedString: NSAttributedString {
|
||||
let attributedSting = NSAttributedString(
|
||||
string: composingBuffer,
|
||||
attributes: [
|
||||
|
@ -163,12 +157,11 @@ class InputState: NSObject {
|
|||
private let kMaxMarkRangeLength = mgrPrefs.maxCandidateLength
|
||||
|
||||
/// Represents that the user is marking a range in the composing buffer.
|
||||
@objc(InputStateMarking)
|
||||
class Marking: NotEmpty {
|
||||
@objc private(set) var markerIndex: UInt
|
||||
@objc private(set) var markedRange: NSRange
|
||||
@objc private var deleteTargetExists = false
|
||||
@objc var tooltip: String {
|
||||
private(set) var markerIndex: UInt
|
||||
private(set) var markedRange: NSRange
|
||||
private var deleteTargetExists = false
|
||||
var tooltip: String {
|
||||
if composingBuffer.count != readings.count {
|
||||
TooltipController.backgroundColor = NSColor(
|
||||
red: 0.55, green: 0.00, blue: 0.00, alpha: 1.00
|
||||
|
@ -251,10 +244,10 @@ class InputState: NSObject {
|
|||
)
|
||||
}
|
||||
|
||||
@objc var tooltipForInputting: String = ""
|
||||
@objc private(set) var readings: [String]
|
||||
var tooltipForInputting: String = ""
|
||||
private(set) var readings: [String]
|
||||
|
||||
@objc init(composingBuffer: String, cursorIndex: UInt, markerIndex: UInt, readings: [String]) {
|
||||
init(composingBuffer: String, cursorIndex: UInt, markerIndex: UInt, readings: [String]) {
|
||||
self.markerIndex = markerIndex
|
||||
let begin = min(cursorIndex, markerIndex)
|
||||
let end = max(cursorIndex, markerIndex)
|
||||
|
@ -263,7 +256,7 @@ class InputState: NSObject {
|
|||
super.init(composingBuffer: composingBuffer, cursorIndex: cursorIndex)
|
||||
}
|
||||
|
||||
@objc var attributedString: NSAttributedString {
|
||||
var attributedString: NSAttributedString {
|
||||
let attributedSting = NSMutableAttributedString(string: composingBuffer)
|
||||
let end = markedRange.location + markedRange.length
|
||||
|
||||
|
@ -296,13 +289,13 @@ class InputState: NSObject {
|
|||
"<InputState.Marking, composingBuffer:\(composingBuffer), cursorIndex:\(cursorIndex), markedRange:\(markedRange)>"
|
||||
}
|
||||
|
||||
@objc func convertToInputting() -> Inputting {
|
||||
func convertToInputting() -> Inputting {
|
||||
let state = Inputting(composingBuffer: composingBuffer, cursorIndex: cursorIndex)
|
||||
state.tooltip = tooltipForInputting
|
||||
return state
|
||||
}
|
||||
|
||||
@objc var validToWrite: Bool {
|
||||
var validToWrite: Bool {
|
||||
/// vChewing allows users to input a string whose length differs
|
||||
/// from the amount of Bopomofo readings. In this case, the range
|
||||
/// in the composing buffer and the readings could not match, so
|
||||
|
@ -323,7 +316,7 @@ class InputState: NSObject {
|
|||
&& markedRange.length <= kMaxMarkRangeLength
|
||||
}
|
||||
|
||||
@objc var chkIfUserPhraseExists: Bool {
|
||||
var chkIfUserPhraseExists: Bool {
|
||||
let text = (composingBuffer as NSString).substring(with: markedRange)
|
||||
let (exactBegin, _) = (composingBuffer as NSString).characterIndex(
|
||||
from: markedRange.location)
|
||||
|
@ -337,7 +330,7 @@ class InputState: NSObject {
|
|||
== true
|
||||
}
|
||||
|
||||
@objc var userPhrase: String {
|
||||
var userPhrase: String {
|
||||
let text = (composingBuffer as NSString).substring(with: markedRange)
|
||||
let (exactBegin, _) = (composingBuffer as NSString).characterIndex(
|
||||
from: markedRange.location)
|
||||
|
@ -348,7 +341,7 @@ class InputState: NSObject {
|
|||
return "\(text) \(joined)"
|
||||
}
|
||||
|
||||
@objc var userPhraseConverted: String {
|
||||
var userPhraseConverted: String {
|
||||
let text =
|
||||
OpenCCBridge.crossConvert(
|
||||
(composingBuffer as NSString).substring(with: markedRange)) ?? ""
|
||||
|
@ -366,18 +359,17 @@ class InputState: NSObject {
|
|||
// MARK: -
|
||||
|
||||
/// Represents that the user is choosing in a candidates list.
|
||||
@objc(InputStateChoosingCandidate)
|
||||
class ChoosingCandidate: NotEmpty {
|
||||
@objc private(set) var candidates: [String]
|
||||
@objc private(set) var useVerticalMode: Bool
|
||||
private(set) var candidates: [String]
|
||||
private(set) var useVerticalMode: Bool
|
||||
|
||||
@objc init(composingBuffer: String, cursorIndex: UInt, candidates: [String], useVerticalMode: Bool) {
|
||||
init(composingBuffer: String, cursorIndex: UInt, candidates: [String], useVerticalMode: Bool) {
|
||||
self.candidates = candidates
|
||||
self.useVerticalMode = useVerticalMode
|
||||
super.init(composingBuffer: composingBuffer, cursorIndex: cursorIndex)
|
||||
}
|
||||
|
||||
@objc var attributedString: NSAttributedString {
|
||||
var attributedString: NSAttributedString {
|
||||
let attributedSting = NSAttributedString(
|
||||
string: composingBuffer,
|
||||
attributes: [
|
||||
|
@ -397,11 +389,10 @@ class InputState: NSObject {
|
|||
|
||||
/// Represents that the user is choosing in a candidates list
|
||||
/// in the associated phrases mode.
|
||||
@objc(InputStateAssociatedPhrases)
|
||||
class AssociatedPhrases: InputState {
|
||||
@objc private(set) var candidates: [String] = []
|
||||
@objc private(set) var useVerticalMode: Bool = false
|
||||
@objc init(candidates: [String], useVerticalMode: Bool) {
|
||||
private(set) var candidates: [String] = []
|
||||
private(set) var useVerticalMode: Bool = false
|
||||
init(candidates: [String], useVerticalMode: Bool) {
|
||||
self.candidates = candidates
|
||||
self.useVerticalMode = useVerticalMode
|
||||
super.init()
|
||||
|
@ -412,11 +403,10 @@ class InputState: NSObject {
|
|||
}
|
||||
}
|
||||
|
||||
@objc(InputStateSymbolTable)
|
||||
class SymbolTable: ChoosingCandidate {
|
||||
@objc var node: SymbolNode
|
||||
var node: SymbolNode
|
||||
|
||||
@objc init(node: SymbolNode, useVerticalMode: Bool) {
|
||||
init(node: SymbolNode, useVerticalMode: Bool) {
|
||||
self.node = node
|
||||
let candidates = node.children?.map(\.title) ?? [String]()
|
||||
super.init(
|
||||
|
@ -432,53 +422,53 @@ class InputState: NSObject {
|
|||
}
|
||||
|
||||
class SymbolNode: NSObject {
|
||||
@objc var title: String
|
||||
@objc var children: [SymbolNode]?
|
||||
var title: String
|
||||
var children: [SymbolNode]?
|
||||
|
||||
@objc init(_ title: String, _ children: [SymbolNode]? = nil) {
|
||||
init(_ title: String, _ children: [SymbolNode]? = nil) {
|
||||
self.title = title
|
||||
self.children = children
|
||||
super.init()
|
||||
}
|
||||
|
||||
@objc init(_ title: String, symbols: String) {
|
||||
init(_ title: String, symbols: String) {
|
||||
self.title = title
|
||||
children = Array(symbols).map { SymbolNode(String($0), nil) }
|
||||
super.init()
|
||||
}
|
||||
|
||||
@objc static let catCommonSymbols = String(
|
||||
static let catCommonSymbols = String(
|
||||
format: NSLocalizedString("catCommonSymbols", comment: ""))
|
||||
@objc static let catHoriBrackets = String(
|
||||
static let catHoriBrackets = String(
|
||||
format: NSLocalizedString("catHoriBrackets", comment: ""))
|
||||
@objc static let catVertBrackets = String(
|
||||
static let catVertBrackets = String(
|
||||
format: NSLocalizedString("catVertBrackets", comment: ""))
|
||||
@objc static let catGreekLetters = String(
|
||||
static let catGreekLetters = String(
|
||||
format: NSLocalizedString("catGreekLetters", comment: ""))
|
||||
@objc static let catMathSymbols = String(
|
||||
static let catMathSymbols = String(
|
||||
format: NSLocalizedString("catMathSymbols", comment: ""))
|
||||
@objc static let catCurrencyUnits = String(
|
||||
static let catCurrencyUnits = String(
|
||||
format: NSLocalizedString("catCurrencyUnits", comment: ""))
|
||||
@objc static let catSpecialSymbols = String(
|
||||
static let catSpecialSymbols = String(
|
||||
format: NSLocalizedString("catSpecialSymbols", comment: ""))
|
||||
@objc static let catUnicodeSymbols = String(
|
||||
static let catUnicodeSymbols = String(
|
||||
format: NSLocalizedString("catUnicodeSymbols", comment: ""))
|
||||
@objc static let catCircledKanjis = String(
|
||||
static let catCircledKanjis = String(
|
||||
format: NSLocalizedString("catCircledKanjis", comment: ""))
|
||||
@objc static let catCircledKataKana = String(
|
||||
static let catCircledKataKana = String(
|
||||
format: NSLocalizedString("catCircledKataKana", comment: ""))
|
||||
@objc static let catBracketKanjis = String(
|
||||
static let catBracketKanjis = String(
|
||||
format: NSLocalizedString("catBracketKanjis", comment: ""))
|
||||
@objc static let catSingleTableLines = String(
|
||||
static let catSingleTableLines = String(
|
||||
format: NSLocalizedString("catSingleTableLines", comment: ""))
|
||||
@objc static let catDoubleTableLines = String(
|
||||
static let catDoubleTableLines = String(
|
||||
format: NSLocalizedString("catDoubleTableLines", comment: ""))
|
||||
@objc static let catFillingBlocks = String(
|
||||
static let catFillingBlocks = String(
|
||||
format: NSLocalizedString("catFillingBlocks", comment: ""))
|
||||
@objc static let catLineSegments = String(
|
||||
static let catLineSegments = String(
|
||||
format: NSLocalizedString("catLineSegments", comment: ""))
|
||||
|
||||
@objc static let root: SymbolNode = .init(
|
||||
static let root: SymbolNode = .init(
|
||||
"/",
|
||||
[
|
||||
SymbolNode("`"),
|
||||
|
|
|
@ -84,7 +84,7 @@ class KeyHandler: NSObject {
|
|||
}
|
||||
|
||||
// 這個函數得獨立出來給 ObjC 使用。
|
||||
@objc func setInputMode(_ value: String) {
|
||||
func setInputMode(_ value: String) {
|
||||
// 下面這句的「isKindOfClass」是做類型檢查,
|
||||
// 為了應對出現輸入法 plist 被改壞掉這樣的極端情況。
|
||||
let isCHS: Bool = (value == InputMode.imeModeCHS.rawValue)
|
||||
|
|
|
@ -47,7 +47,7 @@ extension NSString {
|
|||
return (string.count, string)
|
||||
}
|
||||
|
||||
@objc public func nextUtf16Position(for index: Int) -> Int {
|
||||
public func nextUtf16Position(for index: Int) -> Int {
|
||||
var (fixedIndex, string) = characterIndex(from: index)
|
||||
if fixedIndex < string.count {
|
||||
fixedIndex += 1
|
||||
|
@ -55,7 +55,7 @@ extension NSString {
|
|||
return string[..<string.index(string.startIndex, offsetBy: fixedIndex)].utf16.count
|
||||
}
|
||||
|
||||
@objc public func previousUtf16Position(for index: Int) -> Int {
|
||||
public func previousUtf16Position(for index: Int) -> Int {
|
||||
var (fixedIndex, string) = characterIndex(from: index)
|
||||
if fixedIndex > 0 {
|
||||
fixedIndex -= 1
|
||||
|
@ -63,11 +63,11 @@ extension NSString {
|
|||
return string[..<string.index(string.startIndex, offsetBy: fixedIndex)].utf16.count
|
||||
}
|
||||
|
||||
@objc public var count: Int {
|
||||
public var count: Int {
|
||||
(self as String).count
|
||||
}
|
||||
|
||||
@objc public func split() -> [NSString] {
|
||||
public func split() -> [NSString] {
|
||||
Array(self as String).map {
|
||||
NSString(string: String($0))
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ extension String {
|
|||
}
|
||||
|
||||
class vChewingKanjiConverter: NSObject {
|
||||
@objc class func cnvTradToKangXi(_ strObj: String) -> String {
|
||||
class func cnvTradToKangXi(_ strObj: String) -> String {
|
||||
var strObj = strObj
|
||||
strObj.selfReplace("偽", "僞")
|
||||
strObj.selfReplace("啟", "啓")
|
||||
|
@ -217,7 +217,7 @@ class vChewingKanjiConverter: NSObject {
|
|||
return strObj
|
||||
}
|
||||
|
||||
@objc class func cnvTradToJIS(_ strObj: String) -> String {
|
||||
class func cnvTradToJIS(_ strObj: String) -> String {
|
||||
// 該轉換是由康熙繁體轉換至日語當用漢字的,所以需要先跑一遍康熙轉換。
|
||||
var strObj = cnvTradToKangXi(strObj)
|
||||
strObj.selfReplace("兩", "両")
|
||||
|
|
|
@ -34,7 +34,7 @@ public class IME: NSObject {
|
|||
|
||||
// MARK: - 開關判定當前應用究竟是?
|
||||
|
||||
@objc static var areWeUsingOurOwnPhraseEditor: Bool = false
|
||||
static var areWeUsingOurOwnPhraseEditor: Bool = false
|
||||
|
||||
// MARK: - 自 ctlInputMethod 讀取當前輸入法的簡繁體模式
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class IME: NSObject {
|
|||
|
||||
// MARK: - Print debug information to the console.
|
||||
|
||||
@objc static func prtDebugIntel(_ strPrint: String) {
|
||||
static func prtDebugIntel(_ strPrint: String) {
|
||||
if mgrPrefs.isDebugModeEnabled {
|
||||
NSLog("vChewingErrorCallback: %@", strPrint)
|
||||
}
|
||||
|
@ -57,13 +57,13 @@ public class IME: NSObject {
|
|||
|
||||
// MARK: - Tell whether this IME is running with Root privileges.
|
||||
|
||||
@objc static var isSudoMode: Bool {
|
||||
static var isSudoMode: Bool {
|
||||
NSUserName() == "root"
|
||||
}
|
||||
|
||||
// MARK: - Initializing Language Models.
|
||||
|
||||
@objc static func initLangModels(userOnly: Bool) {
|
||||
static func initLangModels(userOnly: Bool) {
|
||||
if !userOnly {
|
||||
mgrLangModel.loadDataModels() // 這句還是不要砍了。
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class IME: NSObject {
|
|||
|
||||
// MARK: - System Dark Mode Status Detector.
|
||||
|
||||
@objc static func isDarkMode() -> Bool {
|
||||
static func isDarkMode() -> Bool {
|
||||
if #available(macOS 10.15, *) {
|
||||
let appearanceDescription = NSApplication.shared.effectiveAppearance.debugDescription
|
||||
.lowercased()
|
||||
|
|
|
@ -37,7 +37,6 @@ public class InputSourceHelper: NSObject {
|
|||
TISCreateInputSourceList(nil, true).takeRetainedValue() as! [TISInputSource]
|
||||
}
|
||||
|
||||
@objc(inputSourceForProperty:stringValue:)
|
||||
public static func inputSource(for propertyKey: CFString, stringValue: String)
|
||||
-> TISInputSource?
|
||||
{
|
||||
|
@ -57,12 +56,10 @@ public class InputSourceHelper: NSObject {
|
|||
return nil
|
||||
}
|
||||
|
||||
@objc(inputSourceForInputSourceID:)
|
||||
public static func inputSource(for sourceID: String) -> TISInputSource? {
|
||||
inputSource(for: kTISPropertyInputSourceID, stringValue: sourceID)
|
||||
}
|
||||
|
||||
@objc(inputSourceEnabled:)
|
||||
public static func inputSourceEnabled(for source: TISInputSource) -> Bool {
|
||||
if let valuePts = TISGetInputSourceProperty(source, kTISPropertyInputSourceIsEnabled) {
|
||||
let value = Unmanaged<CFBoolean>.fromOpaque(valuePts).takeUnretainedValue()
|
||||
|
@ -71,13 +68,11 @@ public class InputSourceHelper: NSObject {
|
|||
return false
|
||||
}
|
||||
|
||||
@objc(enableInputSource:)
|
||||
public static func enable(inputSource: TISInputSource) -> Bool {
|
||||
let status = TISEnableInputSource(inputSource)
|
||||
return status == noErr
|
||||
}
|
||||
|
||||
@objc(enableAllInputModesForInputSourceBundleID:)
|
||||
public static func enableAllInputMode(for inputSourceBundleD: String) -> Bool {
|
||||
var enabled = false
|
||||
for source in allInstalledInputSources() {
|
||||
|
@ -99,7 +94,6 @@ public class InputSourceHelper: NSObject {
|
|||
return enabled
|
||||
}
|
||||
|
||||
@objc(enableInputMode:forInputSourceBundleID:)
|
||||
public static func enable(inputMode modeID: String, for bundleID: String) -> Bool {
|
||||
for source in allInstalledInputSources() {
|
||||
guard let bundleIDPtr = TISGetInputSourceProperty(source, kTISPropertyBundleID),
|
||||
|
@ -122,13 +116,11 @@ public class InputSourceHelper: NSObject {
|
|||
return false
|
||||
}
|
||||
|
||||
@objc(disableInputSource:)
|
||||
public static func disable(inputSource: TISInputSource) -> Bool {
|
||||
let status = TISDisableInputSource(inputSource)
|
||||
return status == noErr
|
||||
}
|
||||
|
||||
@objc(registerInputSource:)
|
||||
public static func registerTnputSource(at url: URL) -> Bool {
|
||||
let status = TISRegisterInputSource(url as CFURL)
|
||||
return status == noErr
|
||||
|
|
|
@ -80,7 +80,7 @@ private let kDefaultKeys = "123456789"
|
|||
|
||||
// MARK: - UserDefaults extension.
|
||||
|
||||
@objc extension UserDefaults {
|
||||
extension UserDefaults {
|
||||
func setDefault(_ value: Any?, forKey defaultName: String) {
|
||||
if object(forKey: defaultName) == nil {
|
||||
set(value, forKey: defaultName)
|
||||
|
@ -236,7 +236,7 @@ public class mgrPrefs: NSObject {
|
|||
|
||||
// MARK: - 既然 Preferences Module 的預設屬性不自動寫入 plist,那這邊就先寫入了。
|
||||
|
||||
@objc public static func setMissingDefaults() {
|
||||
public static func setMissingDefaults() {
|
||||
UserDefaults.standard.setDefault(mgrPrefs.isDebugModeEnabled, forKey: UserDef.kIsDebugModeEnabled)
|
||||
UserDefaults.standard.setDefault(mgrPrefs.mostRecentInputMode, forKey: UserDef.kMostRecentInputMode)
|
||||
UserDefaults.standard.setDefault(mgrPrefs.checkUpdateAutomatically, forKey: UserDef.kCheckUpdateAutomatically)
|
||||
|
@ -278,90 +278,90 @@ public class mgrPrefs: NSObject {
|
|||
}
|
||||
|
||||
@UserDefault(key: UserDef.kIsDebugModeEnabled, defaultValue: false)
|
||||
@objc static var isDebugModeEnabled: Bool
|
||||
static var isDebugModeEnabled: Bool
|
||||
|
||||
@UserDefault(key: UserDef.kMostRecentInputMode, defaultValue: "")
|
||||
@objc static var mostRecentInputMode: String
|
||||
static var mostRecentInputMode: String
|
||||
|
||||
@UserDefault(key: UserDef.kCheckUpdateAutomatically, defaultValue: false)
|
||||
@objc static var checkUpdateAutomatically: Bool
|
||||
static var checkUpdateAutomatically: Bool
|
||||
|
||||
@UserDefault(key: UserDef.kUserDataFolderSpecified, defaultValue: "")
|
||||
@objc static var userDataFolderSpecified: String
|
||||
static var userDataFolderSpecified: String
|
||||
|
||||
@objc static func ifSpecifiedUserDataPathExistsInPlist() -> Bool {
|
||||
static func ifSpecifiedUserDataPathExistsInPlist() -> Bool {
|
||||
UserDefaults.standard.object(forKey: UserDef.kUserDataFolderSpecified) != nil
|
||||
}
|
||||
|
||||
@objc static func resetSpecifiedUserDataFolder() {
|
||||
static func resetSpecifiedUserDataFolder() {
|
||||
UserDefaults.standard.removeObject(forKey: "UserDataFolderSpecified")
|
||||
IME.initLangModels(userOnly: true)
|
||||
}
|
||||
|
||||
@UserDefault(key: UserDef.kAppleLanguages, defaultValue: [])
|
||||
@objc static var appleLanguages: [String]
|
||||
static var appleLanguages: [String]
|
||||
|
||||
@UserDefault(key: UserDef.kMandarinParser, defaultValue: 0)
|
||||
@objc static var mandarinParser: Int
|
||||
|
||||
@objc static var mandarinParserName: String {
|
||||
static var mandarinParserName: String {
|
||||
(MandarinParser(rawValue: mandarinParser) ?? MandarinParser.ofStandard).name
|
||||
}
|
||||
|
||||
@UserDefault(
|
||||
key: UserDef.kBasicKeyboardLayout, defaultValue: "com.apple.keylayout.ZhuyinBopomofo"
|
||||
)
|
||||
@objc static var basicKeyboardLayout: String
|
||||
static var basicKeyboardLayout: String
|
||||
|
||||
@UserDefault(key: UserDef.kShowPageButtonsInCandidateWindow, defaultValue: true)
|
||||
@objc static var showPageButtonsInCandidateWindow: Bool
|
||||
static var showPageButtonsInCandidateWindow: Bool
|
||||
|
||||
@CandidateListTextSize(key: UserDef.kCandidateListTextSize)
|
||||
@objc static var candidateListTextSize: CGFloat
|
||||
static var candidateListTextSize: CGFloat
|
||||
|
||||
@UserDefault(key: UserDef.kShouldAutoReloadUserDataFiles, defaultValue: true)
|
||||
@objc static var shouldAutoReloadUserDataFiles: Bool
|
||||
static var shouldAutoReloadUserDataFiles: Bool
|
||||
|
||||
@UserDefault(key: UserDef.kSetRearCursorMode, defaultValue: false)
|
||||
@objc static var setRearCursorMode: Bool
|
||||
static var setRearCursorMode: Bool
|
||||
|
||||
@UserDefault(key: UserDef.kMoveCursorAfterSelectingCandidate, defaultValue: true)
|
||||
@objc static var moveCursorAfterSelectingCandidate: Bool
|
||||
static var moveCursorAfterSelectingCandidate: Bool
|
||||
|
||||
@UserDefault(key: UserDef.kUseHorizontalCandidateList, defaultValue: true)
|
||||
@objc static var useHorizontalCandidateList: Bool
|
||||
static var useHorizontalCandidateList: Bool
|
||||
|
||||
@ComposingBufferSize(key: UserDef.kComposingBufferSize)
|
||||
@objc static var composingBufferSize: Int
|
||||
static var composingBufferSize: Int
|
||||
|
||||
@UserDefault(key: UserDef.kChooseCandidateUsingSpace, defaultValue: true)
|
||||
@objc static var chooseCandidateUsingSpace: Bool
|
||||
static var chooseCandidateUsingSpace: Bool
|
||||
|
||||
@UserDefault(key: UserDef.kUseSCPCTypingMode, defaultValue: false)
|
||||
@objc static var useSCPCTypingMode: Bool
|
||||
static var useSCPCTypingMode: Bool
|
||||
|
||||
@objc static func toggleSCPCTypingModeEnabled() -> Bool {
|
||||
static func toggleSCPCTypingModeEnabled() -> Bool {
|
||||
useSCPCTypingMode = !useSCPCTypingMode
|
||||
UserDefaults.standard.set(useSCPCTypingMode, forKey: UserDef.kUseSCPCTypingMode)
|
||||
return useSCPCTypingMode
|
||||
}
|
||||
|
||||
@UserDefault(key: UserDef.kMaxCandidateLength, defaultValue: kDefaultComposingBufferSize * 2)
|
||||
@objc static var maxCandidateLength: Int
|
||||
static var maxCandidateLength: Int
|
||||
|
||||
@UserDefault(key: UserDef.kShouldNotFartInLieuOfBeep, defaultValue: true)
|
||||
@objc static var shouldNotFartInLieuOfBeep: Bool
|
||||
static var shouldNotFartInLieuOfBeep: Bool
|
||||
|
||||
@objc static func toggleShouldNotFartInLieuOfBeep() -> Bool {
|
||||
static func toggleShouldNotFartInLieuOfBeep() -> Bool {
|
||||
shouldNotFartInLieuOfBeep = !shouldNotFartInLieuOfBeep
|
||||
UserDefaults.standard.set(shouldNotFartInLieuOfBeep, forKey: UserDef.kShouldNotFartInLieuOfBeep)
|
||||
return shouldNotFartInLieuOfBeep
|
||||
}
|
||||
|
||||
@UserDefault(key: UserDef.kCNS11643Enabled, defaultValue: false)
|
||||
@objc static var cns11643Enabled: Bool
|
||||
static var cns11643Enabled: Bool
|
||||
|
||||
@objc static func toggleCNS11643Enabled() -> Bool {
|
||||
static func toggleCNS11643Enabled() -> Bool {
|
||||
cns11643Enabled = !cns11643Enabled
|
||||
mgrLangModel.setCNSEnabled(cns11643Enabled) // 很重要
|
||||
UserDefaults.standard.set(cns11643Enabled, forKey: UserDef.kCNS11643Enabled)
|
||||
|
@ -369,9 +369,9 @@ public class mgrPrefs: NSObject {
|
|||
}
|
||||
|
||||
@UserDefault(key: UserDef.kSymbolInputEnabled, defaultValue: true)
|
||||
@objc static var symbolInputEnabled: Bool
|
||||
static var symbolInputEnabled: Bool
|
||||
|
||||
@objc static func toggleSymbolInputEnabled() -> Bool {
|
||||
static func toggleSymbolInputEnabled() -> Bool {
|
||||
symbolInputEnabled = !symbolInputEnabled
|
||||
mgrLangModel.setSymbolEnabled(symbolInputEnabled) // 很重要
|
||||
UserDefaults.standard.set(symbolInputEnabled, forKey: UserDef.kSymbolInputEnabled)
|
||||
|
@ -379,9 +379,9 @@ public class mgrPrefs: NSObject {
|
|||
}
|
||||
|
||||
@UserDefault(key: UserDef.kChineseConversionEnabled, defaultValue: false)
|
||||
@objc static var chineseConversionEnabled: Bool
|
||||
static var chineseConversionEnabled: Bool
|
||||
|
||||
@objc @discardableResult static func toggleChineseConversionEnabled() -> Bool {
|
||||
@discardableResult static func toggleChineseConversionEnabled() -> Bool {
|
||||
chineseConversionEnabled = !chineseConversionEnabled
|
||||
// 康熙轉換與 JIS 轉換不能同時開啟,否則會出現某些奇奇怪怪的情況
|
||||
if chineseConversionEnabled, shiftJISShinjitaiOutputEnabled {
|
||||
|
@ -395,9 +395,9 @@ public class mgrPrefs: NSObject {
|
|||
}
|
||||
|
||||
@UserDefault(key: UserDef.kShiftJISShinjitaiOutputEnabled, defaultValue: false)
|
||||
@objc static var shiftJISShinjitaiOutputEnabled: Bool
|
||||
static var shiftJISShinjitaiOutputEnabled: Bool
|
||||
|
||||
@objc @discardableResult static func toggleShiftJISShinjitaiOutputEnabled() -> Bool {
|
||||
@discardableResult static func toggleShiftJISShinjitaiOutputEnabled() -> Bool {
|
||||
shiftJISShinjitaiOutputEnabled = !shiftJISShinjitaiOutputEnabled
|
||||
// 康熙轉換與 JIS 轉換不能同時開啟,否則會出現某些奇奇怪怪的情況
|
||||
if shiftJISShinjitaiOutputEnabled, chineseConversionEnabled {
|
||||
|
@ -410,42 +410,42 @@ public class mgrPrefs: NSObject {
|
|||
}
|
||||
|
||||
@UserDefault(key: UserDef.kHalfWidthPunctuationEnabled, defaultValue: false)
|
||||
@objc static var halfWidthPunctuationEnabled: Bool
|
||||
static var halfWidthPunctuationEnabled: Bool
|
||||
|
||||
@objc static func toggleHalfWidthPunctuationEnabled() -> Bool {
|
||||
static func toggleHalfWidthPunctuationEnabled() -> Bool {
|
||||
halfWidthPunctuationEnabled = !halfWidthPunctuationEnabled
|
||||
return halfWidthPunctuationEnabled
|
||||
}
|
||||
|
||||
@UserDefault(key: UserDef.kEscToCleanInputBuffer, defaultValue: true)
|
||||
@objc static var escToCleanInputBuffer: Bool
|
||||
static var escToCleanInputBuffer: Bool
|
||||
|
||||
@UserDefault(key: UserDef.kSpecifyShiftTabKeyBehavior, defaultValue: false)
|
||||
@objc static var specifyShiftTabKeyBehavior: Bool
|
||||
static var specifyShiftTabKeyBehavior: Bool
|
||||
|
||||
@UserDefault(key: UserDef.kSpecifyShiftSpaceKeyBehavior, defaultValue: false)
|
||||
@objc static var specifyShiftSpaceKeyBehavior: Bool
|
||||
static var specifyShiftSpaceKeyBehavior: Bool
|
||||
|
||||
// MARK: - Optional settings
|
||||
|
||||
@UserDefault(key: UserDef.kCandidateTextFontName, defaultValue: nil)
|
||||
@objc static var candidateTextFontName: String?
|
||||
static var candidateTextFontName: String?
|
||||
|
||||
@UserDefault(key: UserDef.kCandidateKeyLabelFontName, defaultValue: nil)
|
||||
@objc static var candidateKeyLabelFontName: String?
|
||||
static var candidateKeyLabelFontName: String?
|
||||
|
||||
@UserDefault(key: UserDef.kCandidateKeys, defaultValue: kDefaultKeys)
|
||||
@objc static var candidateKeys: String
|
||||
static var candidateKeys: String
|
||||
|
||||
@objc static var defaultCandidateKeys: String {
|
||||
static var defaultCandidateKeys: String {
|
||||
kDefaultKeys
|
||||
}
|
||||
|
||||
@objc static var suggestedCandidateKeys: [String] {
|
||||
static var suggestedCandidateKeys: [String] {
|
||||
[kDefaultKeys, "234567890", "QWERTYUIO", "QWERTASDF", "ASDFGHJKL", "ASDFZXCVB"]
|
||||
}
|
||||
|
||||
@objc static func validate(candidateKeys: String) throws {
|
||||
static func validate(candidateKeys: String) throws {
|
||||
let trimmed = candidateKeys.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if trimmed.isEmpty {
|
||||
throw CandidateKeyError.empty
|
||||
|
@ -500,9 +500,9 @@ public class mgrPrefs: NSObject {
|
|||
}
|
||||
|
||||
@UserDefault(key: UserDef.kPhraseReplacementEnabled, defaultValue: false)
|
||||
@objc static var phraseReplacementEnabled: Bool
|
||||
static var phraseReplacementEnabled: Bool
|
||||
|
||||
@objc static func togglePhraseReplacementEnabled() -> Bool {
|
||||
static func togglePhraseReplacementEnabled() -> Bool {
|
||||
phraseReplacementEnabled = !phraseReplacementEnabled
|
||||
mgrLangModel.setPhraseReplacementEnabled(phraseReplacementEnabled)
|
||||
UserDefaults.standard.set(phraseReplacementEnabled, forKey: UserDef.kPhraseReplacementEnabled)
|
||||
|
@ -510,9 +510,9 @@ public class mgrPrefs: NSObject {
|
|||
}
|
||||
|
||||
@UserDefault(key: UserDef.kAssociatedPhrasesEnabled, defaultValue: false)
|
||||
@objc static var associatedPhrasesEnabled: Bool
|
||||
static var associatedPhrasesEnabled: Bool
|
||||
|
||||
@objc static func toggleAssociatedPhrasesEnabled() -> Bool {
|
||||
static func toggleAssociatedPhrasesEnabled() -> Bool {
|
||||
associatedPhrasesEnabled = !associatedPhrasesEnabled
|
||||
UserDefaults.standard.set(associatedPhrasesEnabled, forKey: UserDef.kAssociatedPhrasesEnabled)
|
||||
return associatedPhrasesEnabled
|
||||
|
|
|
@ -59,11 +59,11 @@ public class clsSFX: NSObject, NSSoundDelegate {
|
|||
currentBeep = beep
|
||||
}
|
||||
|
||||
@objc public func sound(_: NSSound, didFinishPlaying _: Bool) {
|
||||
public func sound(_: NSSound, didFinishPlaying _: Bool) {
|
||||
currentBeep = nil
|
||||
}
|
||||
|
||||
@objc static func beep() {
|
||||
static func beep() {
|
||||
shared.beep()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
import Cocoa
|
||||
|
||||
@objc(VTCandidateKeyLabel)
|
||||
public class CandidateKeyLabel: NSObject {
|
||||
@objc public private(set) var key: String
|
||||
@objc public private(set) var displayedText: String
|
||||
public private(set) var key: String
|
||||
public private(set) var displayedText: String
|
||||
|
||||
public init(key: String, displayedText: String) {
|
||||
self.key = key
|
||||
|
@ -38,7 +37,6 @@ public class CandidateKeyLabel: NSObject {
|
|||
}
|
||||
}
|
||||
|
||||
@objc(ctlCandidateDelegate)
|
||||
public protocol ctlCandidateDelegate: AnyObject {
|
||||
func candidateCountForController(_ controller: ctlCandidate) -> UInt
|
||||
func ctlCandidate(_ controller: ctlCandidate, candidateAtIndex index: UInt)
|
||||
|
@ -48,16 +46,15 @@ public protocol ctlCandidateDelegate: AnyObject {
|
|||
)
|
||||
}
|
||||
|
||||
@objc(ctlCandidate)
|
||||
public class ctlCandidate: NSWindowController {
|
||||
@objc public weak var delegate: ctlCandidateDelegate? {
|
||||
public weak var delegate: ctlCandidateDelegate? {
|
||||
didSet {
|
||||
reloadData()
|
||||
}
|
||||
}
|
||||
|
||||
@objc public var selectedCandidateIndex: UInt = .max
|
||||
@objc public var visible: Bool = false {
|
||||
public var selectedCandidateIndex: UInt = .max
|
||||
public var visible: Bool = false {
|
||||
didSet {
|
||||
NSObject.cancelPreviousPerformRequests(withTarget: self)
|
||||
if visible {
|
||||
|
@ -68,7 +65,7 @@ public class ctlCandidate: NSWindowController {
|
|||
}
|
||||
}
|
||||
|
||||
@objc public var windowTopLeftPoint: NSPoint {
|
||||
public var windowTopLeftPoint: NSPoint {
|
||||
get {
|
||||
guard let frameRect = window?.frame else {
|
||||
return NSPoint.zero
|
||||
|
@ -82,36 +79,36 @@ public class ctlCandidate: NSWindowController {
|
|||
}
|
||||
}
|
||||
|
||||
@objc public var keyLabels: [CandidateKeyLabel] = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
|
||||
public var keyLabels: [CandidateKeyLabel] = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
|
||||
.map {
|
||||
CandidateKeyLabel(key: $0, displayedText: $0)
|
||||
}
|
||||
|
||||
@objc public var keyLabelFont: NSFont = NSFont.monospacedDigitSystemFont(
|
||||
public var keyLabelFont: NSFont = NSFont.monospacedDigitSystemFont(
|
||||
ofSize: 14, weight: .medium
|
||||
)
|
||||
@objc public var candidateFont: NSFont = NSFont.systemFont(ofSize: 18)
|
||||
@objc public var tooltip: String = ""
|
||||
public var candidateFont: NSFont = NSFont.systemFont(ofSize: 18)
|
||||
public var tooltip: String = ""
|
||||
|
||||
@objc public func reloadData() {}
|
||||
public func reloadData() {}
|
||||
|
||||
@objc public func showNextPage() -> Bool {
|
||||
public func showNextPage() -> Bool {
|
||||
false
|
||||
}
|
||||
|
||||
@objc public func showPreviousPage() -> Bool {
|
||||
public func showPreviousPage() -> Bool {
|
||||
false
|
||||
}
|
||||
|
||||
@objc public func highlightNextCandidate() -> Bool {
|
||||
public func highlightNextCandidate() -> Bool {
|
||||
false
|
||||
}
|
||||
|
||||
@objc public func highlightPreviousCandidate() -> Bool {
|
||||
public func highlightPreviousCandidate() -> Bool {
|
||||
false
|
||||
}
|
||||
|
||||
@objc public func candidateIndexAtKeyLabelIndex(_: UInt) -> UInt {
|
||||
public func candidateIndexAtKeyLabelIndex(_: UInt) -> UInt {
|
||||
UInt.max
|
||||
}
|
||||
|
||||
|
@ -125,7 +122,6 @@ public class ctlCandidate: NSWindowController {
|
|||
/// - windowTopLeftPoint: The given location.
|
||||
/// - height: The height that helps the window not to be out of the bottom
|
||||
/// of a screen.
|
||||
@objc(setWindowTopLeftPoint:bottomOutOfScreenAdjustmentHeight:)
|
||||
public func set(windowTopLeftPoint: NSPoint, bottomOutOfScreenAdjustmentHeight height: CGFloat) {
|
||||
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()) {
|
||||
self.doSet(
|
||||
|
|
|
@ -87,7 +87,7 @@ public class NotifierController: NSWindowController, NotifierWindowDelegate {
|
|||
private static var instanceCount = 0
|
||||
private static var lastLocation = NSPoint.zero
|
||||
|
||||
@objc public static func notify(message: String, stay: Bool = false) {
|
||||
public static func notify(message: String, stay: Bool = false) {
|
||||
let controller = NotifierController()
|
||||
controller.message = message
|
||||
controller.shouldStay = stay
|
||||
|
|
|
@ -64,7 +64,6 @@ public class TooltipController: NSWindowController {
|
|||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
@objc(showTooltip:atPoint:)
|
||||
public func show(tooltip: String, at point: NSPoint) {
|
||||
messageTextField.textColor = TooltipController.textColor
|
||||
messageTextField.backgroundColor = TooltipController.backgroundColor
|
||||
|
|
|
@ -26,7 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
import Cocoa
|
||||
|
||||
@objc(AboutWindow) class ctlAboutWindow: NSWindowController {
|
||||
class ctlAboutWindow: NSWindowController {
|
||||
@IBOutlet var appVersionLabel: NSTextField!
|
||||
@IBOutlet var appCopyrightLabel: NSTextField!
|
||||
@IBOutlet var appEULAContent: NSTextView!
|
||||
|
|
|
@ -26,13 +26,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
import Cocoa
|
||||
|
||||
@objc protocol ctlNonModalAlertWindowDelegate: AnyObject {
|
||||
protocol ctlNonModalAlertWindowDelegate: AnyObject {
|
||||
func ctlNonModalAlertWindowDidConfirm(_ controller: ctlNonModalAlertWindow)
|
||||
func ctlNonModalAlertWindowDidCancel(_ controller: ctlNonModalAlertWindow)
|
||||
}
|
||||
|
||||
class ctlNonModalAlertWindow: NSWindowController {
|
||||
@objc(sharedInstance)
|
||||
static let shared = ctlNonModalAlertWindow(windowNibName: "frmNonModalAlertWindow")
|
||||
|
||||
@IBOutlet var titleTextField: NSTextField!
|
||||
|
@ -41,7 +40,7 @@ class ctlNonModalAlertWindow: NSWindowController {
|
|||
@IBOutlet var cancelButton: NSButton!
|
||||
weak var delegate: ctlNonModalAlertWindowDelegate?
|
||||
|
||||
@objc func show(
|
||||
func show(
|
||||
title: String, content: String, confirmButtonTitle: String, cancelButtonTitle: String?,
|
||||
cancelAsDefault: Bool, delegate: ctlNonModalAlertWindowDelegate?
|
||||
) {
|
||||
|
|
|
@ -30,7 +30,7 @@ import Cocoa
|
|||
// Please note that the class should be exposed using the same class name
|
||||
// in Objective-C in order to let IMK to see the same class name as
|
||||
// the "InputMethodServerPreferencesWindowControllerClass" in Info.plist.
|
||||
@objc(ctlPrefWindow) class ctlPrefWindow: NSWindowController {
|
||||
class ctlPrefWindow: NSWindowController {
|
||||
@IBOutlet var fontSizePopUpButton: NSPopUpButton!
|
||||
@IBOutlet var uiLanguageButton: NSPopUpButton!
|
||||
@IBOutlet var basicKeyboardLayoutButton: NSPopUpButton!
|
||||
|
|
Loading…
Reference in New Issue