From 2692e2c941b02358b80c792935db8169be9aea43 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 18 Jan 2022 23:25:09 +0800 Subject: [PATCH] Little fixes towards swift code formats. --- Source/AppDelegate.swift | 6 +++--- Source/InputSourceHelper.swift | 16 ++++++++-------- Source/NonModalAlertWindowController.swift | 2 +- Source/PreferencesModule.swift | 4 ++-- Source/PreferencesWindowController.swift | 2 +- .../HorizontalCandidateController.swift | 6 +++--- .../UI/CandidateUI/VTCandidateController.swift | 6 +++--- .../VerticalCandidateController.swift | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Source/AppDelegate.swift b/Source/AppDelegate.swift index 342857e0..0738f97a 100644 --- a/Source/AppDelegate.swift +++ b/Source/AppDelegate.swift @@ -16,7 +16,7 @@ private let kUpdateInfoSiteKey = "UpdateInfoSite" private let kNextCheckInterval: TimeInterval = 86400.0 private let kTimeoutInterval: TimeInterval = 60.0 -@objc (AppDelegate) +@objc(AppDelegate) class AppDelegate: NSObject, NSApplicationDelegate, NonModalAlertWindowControllerDelegate { @@ -64,12 +64,12 @@ class AppDelegate: NSObject, NSApplicationDelegate, aboutWindowController?.window?.orderFrontRegardless() // 逼著關於視窗往最前方顯示 } - @objc (checkForUpdate) + @objc(checkForUpdate) func checkForUpdate() { checkForUpdate(forced: false) } - @objc (checkForUpdateForced:) + @objc(checkForUpdateForced:) func checkForUpdate(forced: Bool) { if checkTask != nil { diff --git a/Source/InputSourceHelper.swift b/Source/InputSourceHelper.swift index 1715c25f..4660bf71 100644 --- a/Source/InputSourceHelper.swift +++ b/Source/InputSourceHelper.swift @@ -20,7 +20,7 @@ public class InputSourceHelper: NSObject { TISCreateInputSourceList(nil, true).takeRetainedValue() as! [TISInputSource] } - @objc (inputSourceForProperty:stringValue:) + @objc(inputSourceForProperty:stringValue:) public static func inputSource(for propertyKey: CFString, stringValue: String) -> TISInputSource? { let stringID = CFStringGetTypeID() for source in allInstalledInputSources() { @@ -38,12 +38,12 @@ public class InputSourceHelper: NSObject { return nil } - @objc (inputSourceForInputSourceID:) + @objc(inputSourceForInputSourceID:) public static func inputSource(for sourceID: String) -> TISInputSource? { inputSource(for: kTISPropertyInputSourceID, stringValue: sourceID) } - @objc (inputSourceEnabled:) + @objc(inputSourceEnabled:) public static func inputSourceEnabled(for source: TISInputSource) -> Bool { if let valuePts = TISGetInputSourceProperty(source, kTISPropertyInputSourceIsEnabled) { let value = Unmanaged.fromOpaque(valuePts).takeUnretainedValue() @@ -52,13 +52,13 @@ public class InputSourceHelper: NSObject { return false } - @objc (enableInputSource:) + @objc(enableInputSource:) public static func enable(inputSource: TISInputSource) -> Bool { let status = TISEnableInputSource(inputSource) return status == noErr } - @objc (enableAllInputModesForInputSourceBundleID:) + @objc(enableAllInputModesForInputSourceBundleID:) public static func enableAllInputMode(for inputSourceBundleD: String) -> Bool { var enabled = false for source in allInstalledInputSources() { @@ -79,7 +79,7 @@ public class InputSourceHelper: NSObject { return enabled } - @objc (enableInputMode:forInputSourceBundleID:) + @objc(enableInputMode:forInputSourceBundleID:) public static func enable(inputMode modeID: String, for bundleID: String) -> Bool { for source in allInstalledInputSources() { guard let bundleIDPtr = TISGetInputSourceProperty(source, kTISPropertyBundleID), @@ -100,13 +100,13 @@ public class InputSourceHelper: NSObject { } - @objc (disableInputSource:) + @objc(disableInputSource:) public static func disable(inputSource: TISInputSource) -> Bool { let status = TISDisableInputSource(inputSource) return status == noErr } - @objc (registerInputSource:) + @objc(registerInputSource:) public static func registerTnputSource(at url: URL) -> Bool { let status = TISRegisterInputSource(url as CFURL) return status == noErr diff --git a/Source/NonModalAlertWindowController.swift b/Source/NonModalAlertWindowController.swift index e6e369a8..1b79ec8c 100644 --- a/Source/NonModalAlertWindowController.swift +++ b/Source/NonModalAlertWindowController.swift @@ -14,7 +14,7 @@ import Cocoa } class NonModalAlertWindowController: NSWindowController { - @objc (sharedInstance) + @objc(sharedInstance) static let shared = NonModalAlertWindowController(windowNibName: "NonModalAlertWindowController") diff --git a/Source/PreferencesModule.swift b/Source/PreferencesModule.swift index 406df11b..779fb1f5 100644 --- a/Source/PreferencesModule.swift +++ b/Source/PreferencesModule.swift @@ -220,7 +220,7 @@ struct ComposingBufferSize { @objc static func toogleHalfWidthPunctuationEnabled() -> Bool { halfWidthPunctuationEnabled = !halfWidthPunctuationEnabled - return halfWidthPunctuationEnabled; + return halfWidthPunctuationEnabled } @UserDefault(key: kEscToCleanInputBufferKey, defaultValue: false) @@ -306,6 +306,6 @@ struct ComposingBufferSize { @objc static func tooglePhraseReplacementEnabled() -> Bool { phraseReplacementEnabled = !phraseReplacementEnabled UserDefaults.standard.set(phraseReplacementEnabled, forKey: kPhraseReplacementEnabledKey) - return phraseReplacementEnabled; + return phraseReplacementEnabled } } diff --git a/Source/PreferencesWindowController.swift b/Source/PreferencesWindowController.swift index b8a76058..d2f41522 100644 --- a/Source/PreferencesWindowController.swift +++ b/Source/PreferencesWindowController.swift @@ -20,7 +20,7 @@ extension RangeReplaceableCollection where Element: Hashable { // Please note that the class should be exposed as "PreferencesWindowController" // in Objective-C in order to let IMK to see the same class name as // the "InputMethodServerPreferencesWindowControllerClass" in Info.plist. -@objc (PreferencesWindowController) class PreferencesWindowController: NSWindowController { +@objc(PreferencesWindowController) class PreferencesWindowController: NSWindowController { @IBOutlet weak var fontSizePopUpButton: NSPopUpButton! @IBOutlet weak var basisKeyboardLayoutButton: NSPopUpButton! @IBOutlet weak var selectionKeyComboBox: NSComboBox! diff --git a/Source/UI/CandidateUI/HorizontalCandidateController.swift b/Source/UI/CandidateUI/HorizontalCandidateController.swift index 1ece2658..32f7ebd7 100644 --- a/Source/UI/CandidateUI/HorizontalCandidateController.swift +++ b/Source/UI/CandidateUI/HorizontalCandidateController.swift @@ -42,7 +42,7 @@ fileprivate class HorizontalCandidateView: NSView { return result } - @objc (setKeyLabels:displayedCandidates:) + @objc(setKeyLabels:displayedCandidates:) func set(keyLabels labels: [String], displayedCandidates candidates: [String]) { let count = min(labels.count, candidates.count) keyLabels = Array(labels[0.. UInt func candidateController(_ controller: CandidateController, candidateAtIndex index: UInt) -> String func candidateController(_ controller: CandidateController, didSelectCandidateAtIndex index: UInt) } -@objc (VTCandidateController) +@objc(VTCandidateController) public class CandidateController: NSWindowController { @objc public weak var delegate: CandidateControllerDelegate? @objc public var selectedCandidateIndex: UInt = UInt.max @@ -69,7 +69,7 @@ public class CandidateController: NSWindowController { UInt.max } - @objc (setWindowTopLeftPoint:bottomOutOfScreenAdjustmentHeight:) + @objc(setWindowTopLeftPoint:bottomOutOfScreenAdjustmentHeight:) public func set(windowTopLeftPoint: NSPoint, bottomOutOfScreenAdjustmentHeight height: CGFloat) { DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()) { self.doSet(windowTopLeftPoint: windowTopLeftPoint, bottomOutOfScreenAdjustmentHeight: height) diff --git a/Source/UI/CandidateUI/VerticalCandidateController.swift b/Source/UI/CandidateUI/VerticalCandidateController.swift index b57a78b7..87aa31fa 100644 --- a/Source/UI/CandidateUI/VerticalCandidateController.swift +++ b/Source/UI/CandidateUI/VerticalCandidateController.swift @@ -71,7 +71,7 @@ private let kCandidateTextLeftMargin:CGFloat = 8.0 -@objc (VTVerticalCandidateController) +@objc(VTVerticalCandidateController) public class VerticalCandidateController: CandidateController { private var keyLabelStripView: VerticalKeyLabelStripView private var scrollView: NSScrollView