Little fixes towards swift code formats.
This commit is contained in:
parent
d33b9f8b62
commit
2692e2c941
|
@ -16,7 +16,7 @@ private let kUpdateInfoSiteKey = "UpdateInfoSite"
|
||||||
private let kNextCheckInterval: TimeInterval = 86400.0
|
private let kNextCheckInterval: TimeInterval = 86400.0
|
||||||
private let kTimeoutInterval: TimeInterval = 60.0
|
private let kTimeoutInterval: TimeInterval = 60.0
|
||||||
|
|
||||||
@objc (AppDelegate)
|
@objc(AppDelegate)
|
||||||
class AppDelegate: NSObject, NSApplicationDelegate,
|
class AppDelegate: NSObject, NSApplicationDelegate,
|
||||||
NonModalAlertWindowControllerDelegate {
|
NonModalAlertWindowControllerDelegate {
|
||||||
|
|
||||||
|
@ -64,12 +64,12 @@ class AppDelegate: NSObject, NSApplicationDelegate,
|
||||||
aboutWindowController?.window?.orderFrontRegardless() // 逼著關於視窗往最前方顯示
|
aboutWindowController?.window?.orderFrontRegardless() // 逼著關於視窗往最前方顯示
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc (checkForUpdate)
|
@objc(checkForUpdate)
|
||||||
func checkForUpdate() {
|
func checkForUpdate() {
|
||||||
checkForUpdate(forced: false)
|
checkForUpdate(forced: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc (checkForUpdateForced:)
|
@objc(checkForUpdateForced:)
|
||||||
func checkForUpdate(forced: Bool) {
|
func checkForUpdate(forced: Bool) {
|
||||||
|
|
||||||
if checkTask != nil {
|
if checkTask != nil {
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class InputSourceHelper: NSObject {
|
||||||
TISCreateInputSourceList(nil, true).takeRetainedValue() as! [TISInputSource]
|
TISCreateInputSourceList(nil, true).takeRetainedValue() as! [TISInputSource]
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc (inputSourceForProperty:stringValue:)
|
@objc(inputSourceForProperty:stringValue:)
|
||||||
public static func inputSource(for propertyKey: CFString, stringValue: String) -> TISInputSource? {
|
public static func inputSource(for propertyKey: CFString, stringValue: String) -> TISInputSource? {
|
||||||
let stringID = CFStringGetTypeID()
|
let stringID = CFStringGetTypeID()
|
||||||
for source in allInstalledInputSources() {
|
for source in allInstalledInputSources() {
|
||||||
|
@ -38,12 +38,12 @@ public class InputSourceHelper: NSObject {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc (inputSourceForInputSourceID:)
|
@objc(inputSourceForInputSourceID:)
|
||||||
public static func inputSource(for sourceID: String) -> TISInputSource? {
|
public static func inputSource(for sourceID: String) -> TISInputSource? {
|
||||||
inputSource(for: kTISPropertyInputSourceID, stringValue: sourceID)
|
inputSource(for: kTISPropertyInputSourceID, stringValue: sourceID)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc (inputSourceEnabled:)
|
@objc(inputSourceEnabled:)
|
||||||
public static func inputSourceEnabled(for source: TISInputSource) -> Bool {
|
public static func inputSourceEnabled(for source: TISInputSource) -> Bool {
|
||||||
if let valuePts = TISGetInputSourceProperty(source, kTISPropertyInputSourceIsEnabled) {
|
if let valuePts = TISGetInputSourceProperty(source, kTISPropertyInputSourceIsEnabled) {
|
||||||
let value = Unmanaged<CFBoolean>.fromOpaque(valuePts).takeUnretainedValue()
|
let value = Unmanaged<CFBoolean>.fromOpaque(valuePts).takeUnretainedValue()
|
||||||
|
@ -52,13 +52,13 @@ public class InputSourceHelper: NSObject {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc (enableInputSource:)
|
@objc(enableInputSource:)
|
||||||
public static func enable(inputSource: TISInputSource) -> Bool {
|
public static func enable(inputSource: TISInputSource) -> Bool {
|
||||||
let status = TISEnableInputSource(inputSource)
|
let status = TISEnableInputSource(inputSource)
|
||||||
return status == noErr
|
return status == noErr
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc (enableAllInputModesForInputSourceBundleID:)
|
@objc(enableAllInputModesForInputSourceBundleID:)
|
||||||
public static func enableAllInputMode(for inputSourceBundleD: String) -> Bool {
|
public static func enableAllInputMode(for inputSourceBundleD: String) -> Bool {
|
||||||
var enabled = false
|
var enabled = false
|
||||||
for source in allInstalledInputSources() {
|
for source in allInstalledInputSources() {
|
||||||
|
@ -79,7 +79,7 @@ public class InputSourceHelper: NSObject {
|
||||||
return enabled
|
return enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc (enableInputMode:forInputSourceBundleID:)
|
@objc(enableInputMode:forInputSourceBundleID:)
|
||||||
public static func enable(inputMode modeID: String, for bundleID: String) -> Bool {
|
public static func enable(inputMode modeID: String, for bundleID: String) -> Bool {
|
||||||
for source in allInstalledInputSources() {
|
for source in allInstalledInputSources() {
|
||||||
guard let bundleIDPtr = TISGetInputSourceProperty(source, kTISPropertyBundleID),
|
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 {
|
public static func disable(inputSource: TISInputSource) -> Bool {
|
||||||
let status = TISDisableInputSource(inputSource)
|
let status = TISDisableInputSource(inputSource)
|
||||||
return status == noErr
|
return status == noErr
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc (registerInputSource:)
|
@objc(registerInputSource:)
|
||||||
public static func registerTnputSource(at url: URL) -> Bool {
|
public static func registerTnputSource(at url: URL) -> Bool {
|
||||||
let status = TISRegisterInputSource(url as CFURL)
|
let status = TISRegisterInputSource(url as CFURL)
|
||||||
return status == noErr
|
return status == noErr
|
||||||
|
|
|
@ -14,7 +14,7 @@ import Cocoa
|
||||||
}
|
}
|
||||||
|
|
||||||
class NonModalAlertWindowController: NSWindowController {
|
class NonModalAlertWindowController: NSWindowController {
|
||||||
@objc (sharedInstance)
|
@objc(sharedInstance)
|
||||||
|
|
||||||
static let shared = NonModalAlertWindowController(windowNibName: "NonModalAlertWindowController")
|
static let shared = NonModalAlertWindowController(windowNibName: "NonModalAlertWindowController")
|
||||||
|
|
||||||
|
|
|
@ -220,7 +220,7 @@ struct ComposingBufferSize {
|
||||||
|
|
||||||
@objc static func toogleHalfWidthPunctuationEnabled() -> Bool {
|
@objc static func toogleHalfWidthPunctuationEnabled() -> Bool {
|
||||||
halfWidthPunctuationEnabled = !halfWidthPunctuationEnabled
|
halfWidthPunctuationEnabled = !halfWidthPunctuationEnabled
|
||||||
return halfWidthPunctuationEnabled;
|
return halfWidthPunctuationEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserDefault(key: kEscToCleanInputBufferKey, defaultValue: false)
|
@UserDefault(key: kEscToCleanInputBufferKey, defaultValue: false)
|
||||||
|
@ -306,6 +306,6 @@ struct ComposingBufferSize {
|
||||||
@objc static func tooglePhraseReplacementEnabled() -> Bool {
|
@objc static func tooglePhraseReplacementEnabled() -> Bool {
|
||||||
phraseReplacementEnabled = !phraseReplacementEnabled
|
phraseReplacementEnabled = !phraseReplacementEnabled
|
||||||
UserDefaults.standard.set(phraseReplacementEnabled, forKey: kPhraseReplacementEnabledKey)
|
UserDefaults.standard.set(phraseReplacementEnabled, forKey: kPhraseReplacementEnabledKey)
|
||||||
return phraseReplacementEnabled;
|
return phraseReplacementEnabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ extension RangeReplaceableCollection where Element: Hashable {
|
||||||
// Please note that the class should be exposed as "PreferencesWindowController"
|
// 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
|
// in Objective-C in order to let IMK to see the same class name as
|
||||||
// the "InputMethodServerPreferencesWindowControllerClass" in Info.plist.
|
// the "InputMethodServerPreferencesWindowControllerClass" in Info.plist.
|
||||||
@objc (PreferencesWindowController) class PreferencesWindowController: NSWindowController {
|
@objc(PreferencesWindowController) class PreferencesWindowController: NSWindowController {
|
||||||
@IBOutlet weak var fontSizePopUpButton: NSPopUpButton!
|
@IBOutlet weak var fontSizePopUpButton: NSPopUpButton!
|
||||||
@IBOutlet weak var basisKeyboardLayoutButton: NSPopUpButton!
|
@IBOutlet weak var basisKeyboardLayoutButton: NSPopUpButton!
|
||||||
@IBOutlet weak var selectionKeyComboBox: NSComboBox!
|
@IBOutlet weak var selectionKeyComboBox: NSComboBox!
|
||||||
|
|
|
@ -42,7 +42,7 @@ fileprivate class HorizontalCandidateView: NSView {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc (setKeyLabels:displayedCandidates:)
|
@objc(setKeyLabels:displayedCandidates:)
|
||||||
func set(keyLabels labels: [String], displayedCandidates candidates: [String]) {
|
func set(keyLabels labels: [String], displayedCandidates candidates: [String]) {
|
||||||
let count = min(labels.count, candidates.count)
|
let count = min(labels.count, candidates.count)
|
||||||
keyLabels = Array(labels[0..<count])
|
keyLabels = Array(labels[0..<count])
|
||||||
|
@ -60,7 +60,7 @@ fileprivate class HorizontalCandidateView: NSView {
|
||||||
elementWidths = newWidths
|
elementWidths = newWidths
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc (setKeyLabelFont:candidateFont:)
|
@objc(setKeyLabelFont:candidateFont:)
|
||||||
func set(keyLabelFont labelFont: NSFont, candidateFont: NSFont) {
|
func set(keyLabelFont labelFont: NSFont, candidateFont: NSFont) {
|
||||||
let paraStyle = NSMutableParagraphStyle()
|
let paraStyle = NSMutableParagraphStyle()
|
||||||
paraStyle.setParagraphStyle(NSParagraphStyle.default)
|
paraStyle.setParagraphStyle(NSParagraphStyle.default)
|
||||||
|
@ -176,7 +176,7 @@ fileprivate class HorizontalCandidateView: NSView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc (VTHorizontalCandidateController)
|
@objc(VTHorizontalCandidateController)
|
||||||
public class HorizontalCandidateController: CandidateController {
|
public class HorizontalCandidateController: CandidateController {
|
||||||
private var candidateView: HorizontalCandidateView
|
private var candidateView: HorizontalCandidateView
|
||||||
private var prevPageButton: NSButton
|
private var prevPageButton: NSButton
|
||||||
|
|
|
@ -8,14 +8,14 @@
|
||||||
|
|
||||||
import Cocoa
|
import Cocoa
|
||||||
|
|
||||||
@objc (VTCandidateControllerDelegate)
|
@objc(VTCandidateControllerDelegate)
|
||||||
public protocol CandidateControllerDelegate: AnyObject {
|
public protocol CandidateControllerDelegate: AnyObject {
|
||||||
func candidateCountForController(_ controller: CandidateController) -> UInt
|
func candidateCountForController(_ controller: CandidateController) -> UInt
|
||||||
func candidateController(_ controller: CandidateController, candidateAtIndex index: UInt) -> String
|
func candidateController(_ controller: CandidateController, candidateAtIndex index: UInt) -> String
|
||||||
func candidateController(_ controller: CandidateController, didSelectCandidateAtIndex index: UInt)
|
func candidateController(_ controller: CandidateController, didSelectCandidateAtIndex index: UInt)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc (VTCandidateController)
|
@objc(VTCandidateController)
|
||||||
public class CandidateController: NSWindowController {
|
public class CandidateController: NSWindowController {
|
||||||
@objc public weak var delegate: CandidateControllerDelegate?
|
@objc public weak var delegate: CandidateControllerDelegate?
|
||||||
@objc public var selectedCandidateIndex: UInt = UInt.max
|
@objc public var selectedCandidateIndex: UInt = UInt.max
|
||||||
|
@ -69,7 +69,7 @@ public class CandidateController: NSWindowController {
|
||||||
UInt.max
|
UInt.max
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc (setWindowTopLeftPoint:bottomOutOfScreenAdjustmentHeight:)
|
@objc(setWindowTopLeftPoint:bottomOutOfScreenAdjustmentHeight:)
|
||||||
public func set(windowTopLeftPoint: NSPoint, bottomOutOfScreenAdjustmentHeight height: CGFloat) {
|
public func set(windowTopLeftPoint: NSPoint, bottomOutOfScreenAdjustmentHeight height: CGFloat) {
|
||||||
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()) {
|
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()) {
|
||||||
self.doSet(windowTopLeftPoint: windowTopLeftPoint, bottomOutOfScreenAdjustmentHeight: height)
|
self.doSet(windowTopLeftPoint: windowTopLeftPoint, bottomOutOfScreenAdjustmentHeight: height)
|
||||||
|
|
|
@ -71,7 +71,7 @@ private let kCandidateTextLeftMargin:CGFloat = 8.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@objc (VTVerticalCandidateController)
|
@objc(VTVerticalCandidateController)
|
||||||
public class VerticalCandidateController: CandidateController {
|
public class VerticalCandidateController: CandidateController {
|
||||||
private var keyLabelStripView: VerticalKeyLabelStripView
|
private var keyLabelStripView: VerticalKeyLabelStripView
|
||||||
private var scrollView: NSScrollView
|
private var scrollView: NSScrollView
|
||||||
|
|
Loading…
Reference in New Issue