SessionCtl // Publicization.

This commit is contained in:
ShikiSuen 2022-10-10 12:08:30 +08:00
parent b43d4b8993
commit c95a55dc60
7 changed files with 69 additions and 68 deletions

View File

@ -23,12 +23,12 @@ import TooltipUI
/// - Remark: IMKServer /// - Remark: IMKServer
/// IMKInputController /// IMKInputController
@objc(SessionCtl) // ObjC IMK ObjC @objc(SessionCtl) // ObjC IMK ObjC
class SessionCtl: IMKInputController { public class SessionCtl: IMKInputController {
/// ///
static var areWeNerfing = false public static var areWeNerfing = false
/// ///
var ctlCandidateCurrent: CtlCandidateProtocol = { public var ctlCandidateCurrent: CtlCandidateProtocol = {
let direction: NSUserInterfaceLayoutOrientation = let direction: NSUserInterfaceLayoutOrientation =
PrefMgr.shared.useHorizontalCandidateList ? .horizontal : .vertical PrefMgr.shared.useHorizontalCandidateList ? .horizontal : .vertical
if #available(macOS 10.15, *) { if #available(macOS 10.15, *) {
@ -40,18 +40,18 @@ class SessionCtl: IMKInputController {
}() }()
/// ///
var tooltipInstance = TooltipUI() public var tooltipInstance = TooltipUI()
/// ///
var popupCompositionBuffer = PopupCompositionBuffer() public var popupCompositionBuffer = PopupCompositionBuffer()
// MARK: - // MARK: -
/// Caps Lock /// Caps Lock
var isCapsLocked: Bool { NSEvent.modifierFlags.intersection(.deviceIndependentFlagsMask).contains(.capsLock) } public var isCapsLocked: Bool { NSEvent.modifierFlags.intersection(.deviceIndependentFlagsMask).contains(.capsLock) }
/// SessionCtl /// SessionCtl
var isASCIIMode = false { public var isASCIIMode = false {
didSet { didSet {
resetKeyHandler() resetKeyHandler()
setKeyLayout() setKeyLayout()
@ -61,7 +61,7 @@ class SessionCtl: IMKInputController {
/// 調 /// 調
var keyHandler = KeyHandler(lm: LMMgr.currentLM(), uom: LMMgr.currentUOM(), pref: PrefMgr.shared) var keyHandler = KeyHandler(lm: LMMgr.currentLM(), uom: LMMgr.currentUOM(), pref: PrefMgr.shared)
/// ///
var state: IMEStateProtocol = IMEState.ofEmpty() { public var state: IMEStateProtocol = IMEState.ofEmpty() {
didSet { didSet {
guard oldValue.type != state.type else { return } guard oldValue.type != state.type else { return }
vCLog("Current State: \(state.type.rawValue), client: \(clientBundleIdentifier)") vCLog("Current State: \(state.type.rawValue), client: \(clientBundleIdentifier)")
@ -73,10 +73,11 @@ class SessionCtl: IMKInputController {
/// Shift /// Shift
/// - Remark: Struct Caps Lock Shift /// - Remark: Struct Caps Lock Shift
static var theShiftKeyDetector = ShiftKeyUpChecker(useLShift: PrefMgr.shared.togglingAlphanumericalModeWithLShift) public static var theShiftKeyDetector = ShiftKeyUpChecker(
useLShift: PrefMgr.shared.togglingAlphanumericalModeWithLShift)
/// `handle(event:)` Shift /// `handle(event:)` Shift
var rencentKeyHandledByKeyHandlerEtc = false public var rencentKeyHandledByKeyHandlerEtc = false
/// ///
public static var isVerticalTyping: Bool = false public static var isVerticalTyping: Bool = false
@ -93,7 +94,7 @@ class SessionCtl: IMKInputController {
/// InputMode /// InputMode
/// IME UserPrefs /// IME UserPrefs
var inputMode: Shared.InputMode = IMEApp.currentInputMode { public var inputMode: Shared.InputMode = IMEApp.currentInputMode {
willSet { willSet {
/// Prefs IMEApp /// Prefs IMEApp
PrefMgr.shared.mostRecentInputMode = newValue.rawValue PrefMgr.shared.mostRecentInputMode = newValue.rawValue
@ -126,7 +127,7 @@ class SessionCtl: IMKInputController {
/// - server: IMKServer /// - server: IMKServer
/// - delegate: /// - delegate:
/// - inputClient: /// - inputClient:
override init!(server: IMKServer!, delegate: Any!, client inputClient: Any!) { override public init!(server: IMKServer!, delegate: Any!, client inputClient: Any!) {
super.init(server: server, delegate: delegate, client: inputClient) super.init(server: server, delegate: delegate, client: inputClient)
keyHandler.delegate = self keyHandler.delegate = self
syncBaseLMPrefs() syncBaseLMPrefs()
@ -137,7 +138,7 @@ class SessionCtl: IMKInputController {
extension SessionCtl { extension SessionCtl {
/// ///
func setKeyLayout() { public func setKeyLayout() {
guard let client = client() else { return } guard let client = client() else { return }
func doSetKeyLayout() { func doSetKeyLayout() {
@ -154,7 +155,7 @@ extension SessionCtl {
} }
/// 調 /// 調
func resetKeyHandler() { public func resetKeyHandler() {
// //
if state.type == .ofInputting, PrefMgr.shared.trimUnfinishedReadingsOnCommit { if state.type == .ofInputting, PrefMgr.shared.trimUnfinishedReadingsOnCommit {
keyHandler.composer.clear() keyHandler.composer.clear()
@ -174,7 +175,7 @@ extension SessionCtl {
extension SessionCtl { extension SessionCtl {
/// ///
/// - Parameter sender: 使 /// - Parameter sender: 使
override func activateServer(_ sender: Any!) { public override func activateServer(_ sender: Any!) {
_ = sender // _ = sender //
UserDefaults.standard.synchronize() UserDefaults.standard.synchronize()
@ -200,7 +201,7 @@ extension SessionCtl {
/// ///
/// - Parameter sender: 使 /// - Parameter sender: 使
override func deactivateServer(_ sender: Any!) { public override func deactivateServer(_ sender: Any!) {
_ = sender // _ = sender //
resetKeyHandler() // Empty resetKeyHandler() // Empty
handle(state: IMEState.ofDeactivated()) handle(state: IMEState.ofDeactivated())
@ -211,7 +212,7 @@ extension SessionCtl {
/// - value: identifier bundle identifier info.plist /// - value: identifier bundle identifier info.plist
/// - tag: 使 /// - tag: 使
/// - sender: 使 /// - sender: 使
override func setValue(_ value: Any!, forTag tag: Int, client sender: Any!) { public override func setValue(_ value: Any!, forTag tag: Int, client sender: Any!) {
_ = tag // _ = tag //
_ = sender // _ = sender //
let newInputMode = Shared.InputMode(rawValue: value as? String ?? "") ?? Shared.InputMode.imeModeNULL let newInputMode = Shared.InputMode(rawValue: value as? String ?? "") ?? Shared.InputMode.imeModeNULL
@ -225,7 +226,7 @@ extension SessionCtl {
} }
/// ///
func syncBaseLMPrefs() { public func syncBaseLMPrefs() {
LMMgr.currentLM().isPhraseReplacementEnabled = PrefMgr.shared.phraseReplacementEnabled LMMgr.currentLM().isPhraseReplacementEnabled = PrefMgr.shared.phraseReplacementEnabled
LMMgr.currentLM().isCNSEnabled = PrefMgr.shared.cns11643Enabled LMMgr.currentLM().isCNSEnabled = PrefMgr.shared.cns11643Enabled
LMMgr.currentLM().isSymbolEnabled = PrefMgr.shared.symbolInputEnabled LMMgr.currentLM().isSymbolEnabled = PrefMgr.shared.symbolInputEnabled
@ -248,7 +249,7 @@ extension SessionCtl {
/// `commitComposition(_ message)` /// `commitComposition(_ message)`
/// - Parameter sender: 使 /// - Parameter sender: 使
/// - Returns: uint NSEvent NSEvent.h /// - Returns: uint NSEvent NSEvent.h
override func recognizedEvents(_ sender: Any!) -> Int { public override func recognizedEvents(_ sender: Any!) -> Int {
_ = sender // _ = sender //
let events: NSEvent.EventTypeMask = [.keyDown, .flagsChanged] let events: NSEvent.EventTypeMask = [.keyDown, .flagsChanged]
return Int(events.rawValue) return Int(events.rawValue)
@ -258,7 +259,7 @@ extension SessionCtl {
/// handle(event:) Event /// handle(event:) Event
/// commitComposition /// commitComposition
/// - Parameter sender: 使 /// - Parameter sender: 使
override func commitComposition(_ sender: Any!) { public override func commitComposition(_ sender: Any!) {
_ = sender // _ = sender //
resetKeyHandler() resetKeyHandler()
// super.commitComposition(sender) // // super.commitComposition(sender) //
@ -267,7 +268,7 @@ extension SessionCtl {
/// InputMethodKit /// InputMethodKit
/// - Parameter sender: 使 /// - Parameter sender: 使
/// - Returns: nil /// - Returns: nil
override func composedString(_ sender: Any!) -> Any! { public override func composedString(_ sender: Any!) -> Any! {
_ = sender // _ = sender //
guard state.hasComposition else { return "" } guard state.hasComposition else { return "" }
return state.displayedTextConverted return state.displayedTextConverted
@ -275,7 +276,7 @@ extension SessionCtl {
/// ///
/// IMK Bug /// IMK Bug
override func inputControllerWillClose() { public override func inputControllerWillClose() {
// //
resetKeyHandler() resetKeyHandler()
super.inputControllerWillClose() super.inputControllerWillClose()

View File

@ -11,18 +11,18 @@ import Shared
// MARK: - KeyHandler Delegate // MARK: - KeyHandler Delegate
extension SessionCtl: KeyHandlerDelegate { extension SessionCtl: KeyHandlerDelegate {
var clientBundleIdentifier: String { public var clientBundleIdentifier: String {
guard let client = client() else { return "" } guard let client = client() else { return "" }
return client.bundleIdentifier() ?? "" return client.bundleIdentifier() ?? ""
} }
func candidateController() -> CtlCandidateProtocol { ctlCandidateCurrent } public func candidateController() -> CtlCandidateProtocol { ctlCandidateCurrent }
func candidateSelectionCalledByKeyHandler(at index: Int) { public func candidateSelectionCalledByKeyHandler(at index: Int) {
candidatePairSelected(at: index) candidatePairSelected(at: index)
} }
func performUserPhraseOperation(with state: IMEStateProtocol, addToFilter: Bool) public func performUserPhraseOperation(with state: IMEStateProtocol, addToFilter: Bool)
-> Bool -> Bool
{ {
guard state.type == .ofMarking else { return false } guard state.type == .ofMarking else { return false }
@ -53,11 +53,11 @@ extension SessionCtl: KeyHandlerDelegate {
// MARK: - Candidate Controller Delegate // MARK: - Candidate Controller Delegate
extension SessionCtl: CtlCandidateDelegate { extension SessionCtl: CtlCandidateDelegate {
var selectionKeys: String { public var selectionKeys: String {
PrefMgr.shared.useIMKCandidateWindow ? "123456789" : PrefMgr.shared.candidateKeys PrefMgr.shared.useIMKCandidateWindow ? "123456789" : PrefMgr.shared.candidateKeys
} }
func candidatePairs(conv: Bool = false) -> [(String, String)] { public func candidatePairs(conv: Bool = false) -> [(String, String)] {
if !state.isCandidateContainer || state.candidates.isEmpty { return [] } if !state.isCandidateContainer || state.candidates.isEmpty { return [] }
if !conv || PrefMgr.shared.cns11643Enabled || state.candidates[0].0.contains("_punctuation") { if !conv || PrefMgr.shared.cns11643Enabled || state.candidates[0].0.contains("_punctuation") {
return state.candidates return state.candidates
@ -71,7 +71,7 @@ extension SessionCtl: CtlCandidateDelegate {
return convertedCandidates return convertedCandidates
} }
func candidatePairSelected(at index: Int) { public func candidatePairSelected(at index: Int) {
if state.type == .ofSymbolTable, (0..<state.node.members.count).contains(index) { if state.type == .ofSymbolTable, (0..<state.node.members.count).contains(index) {
let node = state.node.members[index] let node = state.node.members[index]
if !node.members.isEmpty { if !node.members.isEmpty {

View File

@ -16,13 +16,13 @@ extension SessionCtl {
// App 使 // App 使
// App App // App App
// 使 20 // 使 20
var attributedStringSecured: (NSAttributedString, NSRange) { public var attributedStringSecured: (NSAttributedString, NSRange) {
PrefMgr.shared.clientsIMKTextInputIncapable.contains(clientBundleIdentifier) PrefMgr.shared.clientsIMKTextInputIncapable.contains(clientBundleIdentifier)
? (state.data.attributedStringPlaceholder, NSRange(location: 0, length: 0)) ? (state.data.attributedStringPlaceholder, NSRange(location: 0, length: 0))
: (state.attributedString, NSRange(state.u16MarkedRange)) : (state.attributedString, NSRange(state.u16MarkedRange))
} }
func lineHeightRect(zeroCursor: Bool = false) -> NSRect { public func lineHeightRect(zeroCursor: Bool = false) -> NSRect {
var lineHeightRect = NSRect.seniorTheBeast var lineHeightRect = NSRect.seniorTheBeast
guard let client = client() else { guard let client = client() else {
return lineHeightRect return lineHeightRect
@ -40,7 +40,7 @@ extension SessionCtl {
return lineHeightRect return lineHeightRect
} }
func show(tooltip: String) { public func show(tooltip: String) {
guard client() != nil else { return } guard client() != nil else { return }
let lineHeightRect = lineHeightRect() let lineHeightRect = lineHeightRect()
var finalOrigin: NSPoint = lineHeightRect.origin var finalOrigin: NSPoint = lineHeightRect.origin
@ -69,7 +69,7 @@ extension SessionCtl {
) )
} }
func showCandidates() { public func showCandidates() {
guard let client = client() else { return } guard let client = client() else { return }
state.isVerticalCandidateWindow = (isVerticalTyping || !PrefMgr.shared.useHorizontalCandidateList) state.isVerticalCandidateWindow = (isVerticalTyping || !PrefMgr.shared.useHorizontalCandidateList)
@ -159,7 +159,7 @@ extension SessionCtl {
/// 5) Do NOT enable either KangXi conversion mode nor JIS conversion mode. They are disabled by default. /// 5) Do NOT enable either KangXi conversion mode nor JIS conversion mode. They are disabled by default.
/// 6) Expecting the glyph differences of the candidate "" between PingFang SC and PingFang TC when rendering /// 6) Expecting the glyph differences of the candidate "" between PingFang SC and PingFang TC when rendering
/// the candidate window in different "vChewing-CHS" and "vChewing-CHT" input modes. /// the candidate window in different "vChewing-CHS" and "vChewing-CHT" input modes.
static func candidateFont(name: String? = nil, size: Double) -> NSFont { public static func candidateFont(name: String? = nil, size: Double) -> NSFont {
let finalReturnFont: NSFont = let finalReturnFont: NSFont =
{ {
switch IMEApp.currentInputMode { switch IMEApp.currentInputMode {

View File

@ -20,7 +20,7 @@ extension SessionCtl {
/// - event: nil /// - event: nil
/// - sender: 使 /// - sender: 使
/// - Returns: `true` IMK`false` /// - Returns: `true` IMK`false`
@objc(handleEvent:client:) override func handle(_ event: NSEvent!, client sender: Any!) -> Bool { @objc(handleEvent:client:) public override func handle(_ event: NSEvent!, client sender: Any!) -> Bool {
_ = sender // _ = sender //
// MARK: // MARK:

View File

@ -21,7 +21,7 @@ extension SessionCtl {
/// 使 SessionCtl /// 使 SessionCtl
/// ///
/// - Parameter newState: /// - Parameter newState:
func handle(state newState: IMEStateProtocol) { public func handle(state newState: IMEStateProtocol) {
let previous = state let previous = state
state = newState state = newState
switch state.type { switch state.type {
@ -97,7 +97,7 @@ extension SessionCtl {
} }
/// .NotEmpty() /// .NotEmpty()
func setInlineDisplayWithCursor() { public func setInlineDisplayWithCursor() {
if state.type == .ofAssociates { if state.type == .ofAssociates {
doSetMarkedText( doSetMarkedText(
state.data.attributedStringPlaceholder, selectionRange: NSRange(location: 0, length: 0), state.data.attributedStringPlaceholder, selectionRange: NSRange(location: 0, length: 0),
@ -152,7 +152,7 @@ extension SessionCtl {
} }
/// setMarkedText GCD /// setMarkedText GCD
func doSetMarkedText(_ string: Any!, selectionRange: NSRange, replacementRange: NSRange) { public func doSetMarkedText(_ string: Any!, selectionRange: NSRange, replacementRange: NSRange) {
guard let client = client() else { return } guard let client = client() else { return }
if let myID = Bundle.main.bundleIdentifier, let clientID = client.bundleIdentifier(), myID == clientID { if let myID = Bundle.main.bundleIdentifier, let clientID = client.bundleIdentifier(), myID == clientID {
DispatchQueue.main.async { DispatchQueue.main.async {

View File

@ -15,7 +15,7 @@ extension SessionCtl {
/// IMK /// IMK
/// - Parameter sender: 使 /// - Parameter sender: 使
/// - Returns: IMK /// - Returns: IMK
override func candidates(_ sender: Any!) -> [Any]! { public override func candidates(_ sender: Any!) -> [Any]! {
_ = sender // _ = sender //
var arrResult = [String]() var arrResult = [String]()
@ -54,7 +54,7 @@ extension SessionCtl {
/// IMK /// IMK
/// - Parameter _: /// - Parameter _:
override open func candidateSelectionChanged(_: NSAttributedString!) { public override func candidateSelectionChanged(_: NSAttributedString!) {
// //
// IMKServer.commitCompositionWithReply() commitComposition() // IMKServer.commitCompositionWithReply() commitComposition()
// keyHandler // keyHandler
@ -71,7 +71,7 @@ extension SessionCtl {
/// IMK /// IMK
/// - Parameter candidateString: /// - Parameter candidateString:
override open func candidateSelected(_ candidateString: NSAttributedString!) { public override func candidateSelected(_ candidateString: NSAttributedString!) {
let candidateString: String = candidateString?.string ?? "" let candidateString: String = candidateString?.string ?? ""
if state.type == .ofAssociates { if state.type == .ofAssociates {
if !PrefMgr.shared.alsoConfirmAssociatedCandidatesByEnter { if !PrefMgr.shared.alsoConfirmAssociatedCandidatesByEnter {

View File

@ -20,7 +20,7 @@ extension Bool {
// //
extension SessionCtl { extension SessionCtl {
override func menu() -> NSMenu! { public override func menu() -> NSMenu! {
let optionKeyPressed = NSEvent.modifierFlags.contains(.option) let optionKeyPressed = NSEvent.modifierFlags.contains(.option)
let menu = NSMenu(title: "Input Method Menu") let menu = NSMenu(title: "Input Method Menu")
@ -191,7 +191,7 @@ extension SessionCtl {
// MARK: - IME Menu Items // MARK: - IME Menu Items
extension SessionCtl { extension SessionCtl {
@objc override func showPreferences(_: Any?) { @objc public override func showPreferences(_: Any?) {
if #unavailable(macOS 10.15) { if #unavailable(macOS 10.15) {
showLegacyPreferences() showLegacyPreferences()
} else if NSEvent.modifierFlags.contains(.option) { } else if NSEvent.modifierFlags.contains(.option) {
@ -203,24 +203,24 @@ extension SessionCtl {
} }
} }
func showLegacyPreferences() { public func showLegacyPreferences() {
(NSApp.delegate as? AppDelegate)?.showPreferences() (NSApp.delegate as? AppDelegate)?.showPreferences()
NSApp.activate(ignoringOtherApps: true) NSApp.activate(ignoringOtherApps: true)
} }
@objc func showCheatSheet(_: Any?) { @objc public func showCheatSheet(_: Any?) {
guard let url = Bundle.main.url(forResource: "shortcuts", withExtension: "html") else { return } guard let url = Bundle.main.url(forResource: "shortcuts", withExtension: "html") else { return }
DispatchQueue.main.async { DispatchQueue.main.async {
NSWorkspace.shared.openFile(url.path, withApplication: "Safari") NSWorkspace.shared.openFile(url.path, withApplication: "Safari")
} }
} }
@objc func showClientListMgr(_: Any?) { @objc public func showClientListMgr(_: Any?) {
(NSApp.delegate as? AppDelegate)?.showClientListMgr() (NSApp.delegate as? AppDelegate)?.showClientListMgr()
NSApp.activate(ignoringOtherApps: true) NSApp.activate(ignoringOtherApps: true)
} }
@objc func toggleSCPCTypingMode(_: Any? = nil) { @objc public func toggleSCPCTypingMode(_: Any? = nil) {
resetKeyHandler() resetKeyHandler()
Notifier.notify( Notifier.notify(
message: NSLocalizedString("Per-Char Select Mode", comment: "") + "\n" message: NSLocalizedString("Per-Char Select Mode", comment: "") + "\n"
@ -230,7 +230,7 @@ extension SessionCtl {
) )
} }
@objc func toggleChineseConverter(_: Any?) { @objc public func toggleChineseConverter(_: Any?) {
resetKeyHandler() resetKeyHandler()
Notifier.notify( Notifier.notify(
message: NSLocalizedString("Force KangXi Writing", comment: "") + "\n" message: NSLocalizedString("Force KangXi Writing", comment: "") + "\n"
@ -240,7 +240,7 @@ extension SessionCtl {
) )
} }
@objc func toggleShiftJISShinjitaiOutput(_: Any?) { @objc public func toggleShiftJISShinjitaiOutput(_: Any?) {
resetKeyHandler() resetKeyHandler()
Notifier.notify( Notifier.notify(
message: NSLocalizedString("JIS Shinjitai Output", comment: "") + "\n" message: NSLocalizedString("JIS Shinjitai Output", comment: "") + "\n"
@ -250,7 +250,7 @@ extension SessionCtl {
) )
} }
@objc func toggleCurrencyNumerals(_: Any?) { @objc public func toggleCurrencyNumerals(_: Any?) {
resetKeyHandler() resetKeyHandler()
Notifier.notify( Notifier.notify(
message: NSLocalizedString("Currency Numeral Output", comment: "") + "\n" message: NSLocalizedString("Currency Numeral Output", comment: "") + "\n"
@ -260,7 +260,7 @@ extension SessionCtl {
) )
} }
@objc func toggleHalfWidthPunctuation(_: Any?) { @objc public func toggleHalfWidthPunctuation(_: Any?) {
resetKeyHandler() resetKeyHandler()
Notifier.notify( Notifier.notify(
message: NSLocalizedString("Half-Width Punctuation Mode", comment: "") + "\n" message: NSLocalizedString("Half-Width Punctuation Mode", comment: "") + "\n"
@ -270,7 +270,7 @@ extension SessionCtl {
) )
} }
@objc func toggleCNS11643Enabled(_: Any?) { @objc public func toggleCNS11643Enabled(_: Any?) {
resetKeyHandler() resetKeyHandler()
Notifier.notify( Notifier.notify(
message: NSLocalizedString("CNS11643 Mode", comment: "") + "\n" message: NSLocalizedString("CNS11643 Mode", comment: "") + "\n"
@ -280,7 +280,7 @@ extension SessionCtl {
) )
} }
@objc func toggleSymbolEnabled(_: Any?) { @objc public func toggleSymbolEnabled(_: Any?) {
resetKeyHandler() resetKeyHandler()
Notifier.notify( Notifier.notify(
message: NSLocalizedString("Symbol & Emoji Input", comment: "") + "\n" message: NSLocalizedString("Symbol & Emoji Input", comment: "") + "\n"
@ -290,7 +290,7 @@ extension SessionCtl {
) )
} }
@objc func toggleAssociatedPhrasesEnabled(_: Any?) { @objc public func toggleAssociatedPhrasesEnabled(_: Any?) {
resetKeyHandler() resetKeyHandler()
Notifier.notify( Notifier.notify(
message: NSLocalizedString("Per-Char Associated Phrases", comment: "") + "\n" message: NSLocalizedString("Per-Char Associated Phrases", comment: "") + "\n"
@ -300,7 +300,7 @@ extension SessionCtl {
) )
} }
@objc func togglePhraseReplacement(_: Any?) { @objc public func togglePhraseReplacement(_: Any?) {
resetKeyHandler() resetKeyHandler()
Notifier.notify( Notifier.notify(
message: NSLocalizedString("Use Phrase Replacement", comment: "") + "\n" message: NSLocalizedString("Use Phrase Replacement", comment: "") + "\n"
@ -310,20 +310,20 @@ extension SessionCtl {
) )
} }
@objc func selfUninstall(_: Any?) { @objc public func selfUninstall(_: Any?) {
(NSApp.delegate as? AppDelegate)?.selfUninstall() (NSApp.delegate as? AppDelegate)?.selfUninstall()
} }
@objc func selfTerminate(_: Any?) { @objc public func selfTerminate(_: Any?) {
NSApp.activate(ignoringOtherApps: true) NSApp.activate(ignoringOtherApps: true)
NSApp.terminate(nil) NSApp.terminate(nil)
} }
@objc func checkForUpdate(_: Any?) { @objc public func checkForUpdate(_: Any?) {
(NSApp.delegate as? AppDelegate)?.updateSputnik.checkForUpdate(forced: true, url: kUpdateInfoSourceURL) (NSApp.delegate as? AppDelegate)?.updateSputnik.checkForUpdate(forced: true, url: kUpdateInfoSourceURL)
} }
@objc func openUserDataFolder(_: Any?) { @objc public func openUserDataFolder(_: Any?) {
if !LMMgr.userDataFolderExists { if !LMMgr.userDataFolderExists {
return return
} }
@ -332,35 +332,35 @@ extension SessionCtl {
) )
} }
@objc func openUserPhrases(_: Any?) { @objc public func openUserPhrases(_: Any?) {
LMMgr.openPhraseFile(fromURL: LMMgr.userPhrasesDataURL(IMEApp.currentInputMode)) LMMgr.openPhraseFile(fromURL: LMMgr.userPhrasesDataURL(IMEApp.currentInputMode))
if NSEvent.modifierFlags.contains(.option) { if NSEvent.modifierFlags.contains(.option) {
LMMgr.openPhraseFile(fromURL: LMMgr.userPhrasesDataURL(IMEApp.currentInputMode.reversed)) LMMgr.openPhraseFile(fromURL: LMMgr.userPhrasesDataURL(IMEApp.currentInputMode.reversed))
} }
} }
@objc func openExcludedPhrases(_: Any?) { @objc public func openExcludedPhrases(_: Any?) {
LMMgr.openPhraseFile(fromURL: LMMgr.userFilteredDataURL(IMEApp.currentInputMode)) LMMgr.openPhraseFile(fromURL: LMMgr.userFilteredDataURL(IMEApp.currentInputMode))
if NSEvent.modifierFlags.contains(.option) { if NSEvent.modifierFlags.contains(.option) {
LMMgr.openPhraseFile(fromURL: LMMgr.userFilteredDataURL(IMEApp.currentInputMode.reversed)) LMMgr.openPhraseFile(fromURL: LMMgr.userFilteredDataURL(IMEApp.currentInputMode.reversed))
} }
} }
@objc func openUserSymbols(_: Any?) { @objc public func openUserSymbols(_: Any?) {
LMMgr.openPhraseFile(fromURL: LMMgr.userSymbolDataURL(IMEApp.currentInputMode)) LMMgr.openPhraseFile(fromURL: LMMgr.userSymbolDataURL(IMEApp.currentInputMode))
if NSEvent.modifierFlags.contains(.option) { if NSEvent.modifierFlags.contains(.option) {
LMMgr.openPhraseFile(fromURL: LMMgr.userSymbolDataURL(IMEApp.currentInputMode.reversed)) LMMgr.openPhraseFile(fromURL: LMMgr.userSymbolDataURL(IMEApp.currentInputMode.reversed))
} }
} }
@objc func openPhraseReplacement(_: Any?) { @objc public func openPhraseReplacement(_: Any?) {
LMMgr.openPhraseFile(fromURL: LMMgr.userReplacementsDataURL(IMEApp.currentInputMode)) LMMgr.openPhraseFile(fromURL: LMMgr.userReplacementsDataURL(IMEApp.currentInputMode))
if NSEvent.modifierFlags.contains(.option) { if NSEvent.modifierFlags.contains(.option) {
LMMgr.openPhraseFile(fromURL: LMMgr.userReplacementsDataURL(IMEApp.currentInputMode.reversed)) LMMgr.openPhraseFile(fromURL: LMMgr.userReplacementsDataURL(IMEApp.currentInputMode.reversed))
} }
} }
@objc func openAssociatedPhrases(_: Any?) { @objc public func openAssociatedPhrases(_: Any?) {
LMMgr.openPhraseFile(fromURL: LMMgr.userAssociatesDataURL(IMEApp.currentInputMode)) LMMgr.openPhraseFile(fromURL: LMMgr.userAssociatesDataURL(IMEApp.currentInputMode))
if NSEvent.modifierFlags.contains(.option) { if NSEvent.modifierFlags.contains(.option) {
LMMgr.openPhraseFile( LMMgr.openPhraseFile(
@ -368,25 +368,25 @@ extension SessionCtl {
} }
} }
@objc func reloadUserPhrasesData(_: Any?) { @objc public func reloadUserPhrasesData(_: Any?) {
LMMgr.initUserLangModels() LMMgr.initUserLangModels()
} }
@objc func removeUnigramsFromUOM(_: Any?) { @objc public func removeUnigramsFromUOM(_: Any?) {
LMMgr.removeUnigramsFromUserOverrideModel(IMEApp.currentInputMode) LMMgr.removeUnigramsFromUserOverrideModel(IMEApp.currentInputMode)
if NSEvent.modifierFlags.contains(.option) { if NSEvent.modifierFlags.contains(.option) {
LMMgr.removeUnigramsFromUserOverrideModel(IMEApp.currentInputMode.reversed) LMMgr.removeUnigramsFromUserOverrideModel(IMEApp.currentInputMode.reversed)
} }
} }
@objc func clearUOM(_: Any?) { @objc public func clearUOM(_: Any?) {
LMMgr.clearUserOverrideModelData(IMEApp.currentInputMode) LMMgr.clearUserOverrideModelData(IMEApp.currentInputMode)
if NSEvent.modifierFlags.contains(.option) { if NSEvent.modifierFlags.contains(.option) {
LMMgr.clearUserOverrideModelData(IMEApp.currentInputMode.reversed) LMMgr.clearUserOverrideModelData(IMEApp.currentInputMode.reversed)
} }
} }
@objc func showAbout(_: Any?) { @objc public func showAbout(_: Any?) {
(NSApp.delegate as? AppDelegate)?.showAbout() (NSApp.delegate as? AppDelegate)?.showAbout()
NSApp.activate(ignoringOtherApps: true) NSApp.activate(ignoringOtherApps: true)
} }