Little fixes towards swift code formats.

This commit is contained in:
ShikiSuen 2022-01-18 23:25:09 +08:00
parent 738de129f5
commit 237db28963
8 changed files with 22 additions and 22 deletions

View File

@ -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 {

View File

@ -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<CFBoolean>.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

View File

@ -14,7 +14,7 @@ import Cocoa
}
class NonModalAlertWindowController: NSWindowController {
@objc (sharedInstance)
@objc(sharedInstance)
static let shared = NonModalAlertWindowController(windowNibName: "NonModalAlertWindowController")

View File

@ -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
}
}

View File

@ -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!

View File

@ -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..<count])
@ -60,7 +60,7 @@ fileprivate class HorizontalCandidateView: NSView {
elementWidths = newWidths
}
@objc (setKeyLabelFont:candidateFont:)
@objc(setKeyLabelFont:candidateFont:)
func set(keyLabelFont labelFont: NSFont, candidateFont: NSFont) {
let paraStyle = NSMutableParagraphStyle()
paraStyle.setParagraphStyle(NSParagraphStyle.default)
@ -176,7 +176,7 @@ fileprivate class HorizontalCandidateView: NSView {
}
}
@objc (VTHorizontalCandidateController)
@objc(VTHorizontalCandidateController)
public class HorizontalCandidateController: CandidateController {
private var candidateView: HorizontalCandidateView
private var prevPageButton: NSButton

View File

@ -8,14 +8,14 @@
import Cocoa
@objc (VTCandidateControllerDelegate)
@objc(VTCandidateControllerDelegate)
public protocol CandidateControllerDelegate: AnyObject {
func candidateCountForController(_ controller: CandidateController) -> 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)

View File

@ -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