Repo // Remove NSObject(Protocol) wherever it's safe to remove.

This commit is contained in:
ShikiSuen 2022-05-16 23:50:51 +08:00
parent 461f94fec4
commit 2c23ba3a11
7 changed files with 17 additions and 20 deletions

View File

@ -57,10 +57,10 @@ import Cocoa
/// create a new user phrase. /// create a new user phrase.
/// - Choosing Candidate: The candidate window is open to let the user to choose /// - Choosing Candidate: The candidate window is open to let the user to choose
/// one among the candidates. /// one among the candidates.
class InputState: NSObject { class InputState {
/// Represents that the input controller is deactivated. /// Represents that the input controller is deactivated.
class Deactivated: InputState { class Deactivated: InputState {
override var description: String { var description: String {
"<InputState.Deactivated>" "<InputState.Deactivated>"
} }
} }
@ -73,7 +73,7 @@ class InputState: NSObject {
"" ""
} }
override var description: String { var description: String {
"<InputState.Empty>" "<InputState.Empty>"
} }
} }
@ -86,7 +86,7 @@ class InputState: NSObject {
"" ""
} }
override var description: String { var description: String {
"<InputState.EmptyIgnoringPreviousState>" "<InputState.EmptyIgnoringPreviousState>"
} }
} }
@ -102,7 +102,7 @@ class InputState: NSObject {
self.poppedText = poppedText self.poppedText = poppedText
} }
override var description: String { var description: String {
"<InputState.Committing poppedText:\(poppedText)>" "<InputState.Committing poppedText:\(poppedText)>"
} }
} }
@ -119,7 +119,7 @@ class InputState: NSObject {
self.cursorIndex = cursorIndex self.cursorIndex = cursorIndex
} }
override var description: String { var description: String {
"<InputState.NotEmpty, composingBuffer:\(composingBuffer), cursorIndex:\(cursorIndex)>" "<InputState.NotEmpty, composingBuffer:\(composingBuffer), cursorIndex:\(cursorIndex)>"
} }
} }
@ -398,7 +398,7 @@ class InputState: NSObject {
super.init() super.init()
} }
override var description: String { var description: String {
"<InputState.AssociatedPhrases, candidates:\(candidates), useVerticalMode:\(useVerticalMode)>" "<InputState.AssociatedPhrases, candidates:\(candidates), useVerticalMode:\(useVerticalMode)>"
} }
} }
@ -421,20 +421,18 @@ class InputState: NSObject {
} }
} }
class SymbolNode: NSObject { class SymbolNode {
var title: String var title: String
var children: [SymbolNode]? var children: [SymbolNode]?
init(_ title: String, _ children: [SymbolNode]? = nil) { init(_ title: String, _ children: [SymbolNode]? = nil) {
self.title = title self.title = title
self.children = children self.children = children
super.init()
} }
init(_ title: String, symbols: String) { init(_ title: String, symbols: String) {
self.title = title self.title = title
children = Array(symbols).map { SymbolNode(String($0), nil) } children = Array(symbols).map { SymbolNode(String($0), nil) }
super.init()
} }
static let catCommonSymbols = String( static let catCommonSymbols = String(

View File

@ -34,7 +34,7 @@ public enum InputMode: String {
// MARK: - Delegate. // MARK: - Delegate.
protocol KeyHandlerDelegate: NSObjectProtocol { protocol KeyHandlerDelegate {
func ctlCandidate(for _: KeyHandler) -> Any func ctlCandidate(for _: KeyHandler) -> Any
func keyHandler( func keyHandler(
_: KeyHandler, didSelectCandidateAt index: Int, _: KeyHandler, didSelectCandidateAt index: Int,
@ -46,7 +46,7 @@ protocol KeyHandlerDelegate: NSObjectProtocol {
// MARK: - Kernel. // MARK: - Kernel.
class KeyHandler: NSObject { class KeyHandler {
let kEpsilon: Double = 0.000001 let kEpsilon: Double = 0.000001
var _composer: Tekkon.Composer = .init() var _composer: Tekkon.Composer = .init()
var _inputMode: String = "" var _inputMode: String = ""
@ -55,7 +55,7 @@ class KeyHandler: NSObject {
var _builder: Megrez.BlockReadingBuilder var _builder: Megrez.BlockReadingBuilder
var _walkedNodes: [Megrez.NodeAnchor] = [] var _walkedNodes: [Megrez.NodeAnchor] = []
weak var delegate: KeyHandlerDelegate? var delegate: KeyHandlerDelegate?
var inputMode: InputMode { var inputMode: InputMode {
get { get {
@ -71,9 +71,8 @@ class KeyHandler: NSObject {
set { setInputMode(newValue.rawValue) } set { setInputMode(newValue.rawValue) }
} }
override init() { public init() {
_builder = Megrez.BlockReadingBuilder(lm: _languageModel) _builder = Megrez.BlockReadingBuilder(lm: _languageModel)
super.init()
ensureParser() ensureParser()
setInputMode(ctlInputMethod.currentInputMode) setInputMode(ctlInputMethod.currentInputMode)
} }

View File

@ -30,7 +30,7 @@ extension String {
} }
} }
class vChewingKanjiConverter: NSObject { class vChewingKanjiConverter {
class func cnvTradToKangXi(_ strObj: String) -> String { class func cnvTradToKangXi(_ strObj: String) -> String {
var strObj = strObj var strObj = strObj
strObj.selfReplace("", "") strObj.selfReplace("", "")

View File

@ -30,7 +30,7 @@ public protocol FSEventStreamHelperDelegate: AnyObject {
func helper(_ helper: FSEventStreamHelper, didReceive events: [FSEventStreamHelper.Event]) func helper(_ helper: FSEventStreamHelper, didReceive events: [FSEventStreamHelper.Event])
} }
public class FSEventStreamHelper: NSObject { public class FSEventStreamHelper {
public struct Event { public struct Event {
var path: String var path: String
var flags: FSEventStreamEventFlags var flags: FSEventStreamEventFlags

View File

@ -28,7 +28,7 @@ import Cocoa
// The namespace of this input method. // The namespace of this input method.
public enum vChewing {} public enum vChewing {}
public class IME: NSObject { public class IME {
static let arrSupportedLocales = ["en", "zh-Hant", "zh-Hans", "ja"] static let arrSupportedLocales = ["en", "zh-Hant", "zh-Hans", "ja"]
static let dlgOpenPath = NSOpenPanel() static let dlgOpenPath = NSOpenPanel()

View File

@ -215,7 +215,7 @@ struct ComposingBufferSize {
// MARK: - // MARK: -
public class mgrPrefs: NSObject { public class mgrPrefs {
static var allKeys: [String] { static var allKeys: [String] {
[ [
UserDef.kIsDebugModeEnabled, UserDef.kIsDebugModeEnabled,

View File

@ -36,7 +36,7 @@ private var gLangModelCHT = vChewing.LMInstantiator()
private var gUserOverrideModelCHS = vChewing.LMUserOverride() private var gUserOverrideModelCHS = vChewing.LMUserOverride()
private var gUserOverrideModelCHT = vChewing.LMUserOverride() private var gUserOverrideModelCHT = vChewing.LMUserOverride()
class mgrLangModel: NSObject { class mgrLangModel {
/// fileprivate /// fileprivate
public static var lmCHS: vChewing.LMInstantiator { gLangModelCHS } public static var lmCHS: vChewing.LMInstantiator { gLangModelCHS }
public static var lmCHT: vChewing.LMInstantiator { gLangModelCHT } public static var lmCHT: vChewing.LMInstantiator { gLangModelCHT }