Skip to content
Permalink
Browse files

Swift5

  • Loading branch information...
youknowone committed May 20, 2019
1 parent fdda5eb commit 66112ed40d8e20168102047bf45fbcc1fe81eb0e
@@ -843,7 +843,7 @@
TargetAttributes = {
38162DF2141263270077AA2D = {
CreatedOnToolsVersion = 9.4.1;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
SystemCapabilities = {
com.apple.ApplicationGroups.Mac = {
enabled = 1;
@@ -855,7 +855,7 @@
};
382E68631A1314D900031D1D = {
CreatedOnToolsVersion = 9.4.1;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
SystemCapabilities = {
com.apple.ApplicationGroups.Mac = {
enabled = 1;
@@ -879,11 +879,11 @@
};
3881867921EB2D7D004B7FDB = {
CreatedOnToolsVersion = 10.1;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
38BFE7F918B45419004B2B2E = {
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
SystemCapabilities = {
com.apple.ApplicationGroups.Mac = {
enabled = 1;
@@ -1377,6 +1377,7 @@
PRODUCT_BUNDLE_IDENTIFIER = org.youknowone.inputmethod.Gureum;
PRODUCT_NAME = Gureum;
SWIFT_OBJC_BRIDGING_HEADER = OSX/Bridge.h;
SWIFT_VERSION = 5.0;
WRAPPER_EXTENSION = app;
};
name = Debug;
@@ -1398,6 +1399,7 @@
PRODUCT_BUNDLE_IDENTIFIER = org.youknowone.inputmethod.Gureum;
PRODUCT_NAME = Gureum;
SWIFT_OBJC_BRIDGING_HEADER = OSX/Bridge.h;
SWIFT_VERSION = 5.0;
WRAPPER_EXTENSION = app;
};
name = Release;
@@ -1419,6 +1421,7 @@
SDKROOT = macosx;
SWIFT_OBJC_BRIDGING_HEADER = "Preferences/Preferences-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
WRAPPER_EXTENSION = prefPane;
};
name = Debug;
@@ -1438,6 +1441,7 @@
PRODUCT_NAME = "${TARGET_NAME}";
SDKROOT = macosx;
SWIFT_OBJC_BRIDGING_HEADER = "Preferences/Preferences-Bridging-Header.h";
SWIFT_VERSION = 5.0;
WRAPPER_EXTENSION = prefPane;
};
name = Release;
@@ -1505,7 +1509,7 @@
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
@@ -1535,7 +1539,7 @@
PRODUCT_NAME = GureumCore;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
@@ -1689,7 +1693,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.youknowone.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = GureumTests/Bridge.h;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUNDLE_LOADER)";
WRAPPER_EXTENSION = xctest;
};
@@ -1722,7 +1726,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.youknowone.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = GureumTests/Bridge.h;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUNDLE_LOADER)";
WRAPPER_EXTENSION = xctest;
};
@@ -438,7 +438,7 @@ class GureumTests: XCTestCase {
app.client.string = ""
app.controller.setValue(GureumInputSourceIdentifier.qwerty.rawValue, forTag: kTextServiceInputModePropertyTag, client: app.client)

let composer = app.controller.receiver.composer as! GureumComposer
let composer = app.controller.receiver.composer
let emoticonComposer = composer.emoticonComposer
emoticonComposer.delegate = composer.delegate // roman?
composer.delegate = emoticonComposer
@@ -35,7 +35,7 @@ class NotificationCenterDelegate: NSObject, NSUserNotificationCenterDelegate {
}

class GureumAppDelegate: NSObject, NSApplicationDelegate, GureumApplicationDelegate {
@IBOutlet @objc var menu: NSMenu!
@IBOutlet var menu: NSMenu!

let configuration = Configuration.shared
let notificationCenterDelegate = NotificationCenterDelegate()
@@ -113,7 +113,7 @@ class HangulComposer: NSObject, ComposerDelegate {
@param identifier libhangul의 @ref hangul_ic_select_keyboard 를 참고한다.
*/
func setKeyboard(identifier: String) {
if configuration.hangulForceStrictCombinationRule, (identifier == "39" || identifier == "3f") {
if configuration.hangulForceStrictCombinationRule, identifier == "39" || identifier == "3f" {
let strictCombinationIdentifier = "\(identifier)s"
inputContext.setKeyboardWithIdentifier(strictCombinationIdentifier)
} else {
@@ -209,7 +209,7 @@ class HanjaComposer: DelegatedComposer {
if candidates.count > 0, Configuration.shared.showsInputForHanjaCandidates {
candidates.insert(keyword, at: 0)
}
return candidates.map({ s in NSAttributedString(string: s) })
return candidates.map { s in NSAttributedString(string: s) }
}

func searchCandidates(fromTable table: HGHanjaTable, byPrefixSearching keyword: String) -> [String] {
@@ -109,15 +109,15 @@ class IOService {
}

public extension IOHIDValueScaleType {
public static let Calibrated = kIOHIDValueScaleTypeCalibrated
public static let Physical = kIOHIDValueScaleTypePhysical
public static let Exponent = kIOHIDValueScaleTypeExponent
static let Calibrated = kIOHIDValueScaleTypeCalibrated
static let Physical = kIOHIDValueScaleTypePhysical
static let Exponent = kIOHIDValueScaleTypeExponent
}

public extension IOHIDValue {
public typealias ScaleType = IOHIDValueScaleType
public typealias Callback = IOHIDValueCallback
public typealias MultipleCallback = IOHIDValueMultipleCallback
typealias ScaleType = IOHIDValueScaleType
typealias Callback = IOHIDValueCallback
typealias MultipleCallback = IOHIDValueMultipleCallback

var element: IOHIDElement {
return IOHIDValueGetElement(self)
@@ -141,67 +141,67 @@ public extension IOHIDValue {
}

public extension IOHIDManager {
public class func create(options: IOOptionBits) -> IOHIDManager {
class func create(options: IOOptionBits) -> IOHIDManager {
return IOHIDManagerCreate(kCFAllocatorDefault, options)
}

public class func create() -> IOHIDManager {
class func create() -> IOHIDManager {
return create(options: IOOptionBits(kIOHIDOptionsTypeNone))
}

public func open() -> IOReturn {
func open() -> IOReturn {
return open(options: IOOptionBits(kIOHIDOptionsTypeNone))
}

public func open(options: IOOptionBits) -> IOReturn {
func open(options: IOOptionBits) -> IOReturn {
return IOHIDManagerOpen(self, options)
}

public func close() -> IOReturn {
func close() -> IOReturn {
return close(options: IOOptionBits(kIOHIDOptionsTypeNone))
}

public func close(options: IOOptionBits) -> IOReturn {
func close(options: IOOptionBits) -> IOReturn {
return IOHIDManagerClose(self, options)
}

public func schedule(runloop: RunLoop, mode: RunLoop.Mode) {
func schedule(runloop: RunLoop, mode: RunLoop.Mode) {
IOHIDManagerScheduleWithRunLoop(self, runloop.getCFRunLoop(), mode.rawValue as CFString)
}

public func unschedule(runloop: RunLoop, mode: RunLoop.Mode) {
func unschedule(runloop: RunLoop, mode: RunLoop.Mode) {
IOHIDManagerUnscheduleFromRunLoop(self, runloop.getCFRunLoop(), mode.rawValue as CFString)
}

public class func deviceMatching(page: Int, usage: Int) -> NSDictionary {
class func deviceMatching(page: Int, usage: Int) -> NSDictionary {
return [
kIOHIDDeviceUsagePageKey as NSString: NSNumber(value: page),
kIOHIDDeviceUsageKey as NSString: NSNumber(value: usage),
]
}

public class func inputValueMatching(min: Int, max: Int) -> NSDictionary {
class func inputValueMatching(min: Int, max: Int) -> NSDictionary {
return [
kIOHIDElementUsageMinKey as NSString: NSNumber(value: min),
kIOHIDElementUsageMaxKey as NSString: NSNumber(value: max),
]
}

public func setDeviceMatching(page: Int, usage: Int) {
func setDeviceMatching(page: Int, usage: Int) {
let deviceMatching = IOHIDManager.deviceMatching(page: page, usage: usage)
IOHIDManagerSetDeviceMatching(self, deviceMatching)
}

public func setInputValueMatching(min: Int, max: Int) {
func setInputValueMatching(min: Int, max: Int) {
let inputValueMatching = IOHIDManager.inputValueMatching(min: min, max: max)
IOHIDManagerSetInputValueMatching(self, inputValueMatching)
}

public func registerInputValueCallback(_ callback: @escaping IOHIDValue.Callback, context: UnsafeMutableRawPointer?) {
func registerInputValueCallback(_ callback: @escaping IOHIDValue.Callback, context: UnsafeMutableRawPointer?) {
IOHIDManagerRegisterInputValueCallback(self, callback, context)
}

public func unregisterInputValueCallback() {
func unregisterInputValueCallback() {
IOHIDManagerRegisterInputValueCallback(self, nil, nil)
}
}
@@ -113,7 +113,7 @@ extension InputController {
public extension InputController { // IMKServerInputHandleEvent
// Receiving Events Directly from the Text Services Manager
public override func handle(_ event: NSEvent, client sender: Any) -> Bool {
override func handle(_ event: NSEvent, client sender: Any) -> Bool {
// dlog(DEBUG_INPUTCONTROLLER, "event: \(event)")
// sender is (IMKTextInput & IMKUnicodeTextInput & IMTSMSupport)
let client = asClient(sender)
@@ -328,7 +328,7 @@ public extension InputController { // IMKServerInput
// COMMIT triggered
}

public override func updateComposition() {
override func updateComposition() {
receiver.updateCompositionEvent()

let client = receiver.inputClient
@@ -338,7 +338,7 @@ public extension InputController { // IMKServerInput
view.setMarkedText(composed, selectedRange: NSRange(location: 0, length: composed.count), replacementRange: markedRange)
}

public override func cancelComposition() {
override func cancelComposition() {
receiver.cancelCompositionEvent()

let client = receiver.inputClient
@@ -349,39 +349,39 @@ public extension InputController { // IMKServerInput

// Getting Input Strings and Candidates
// 현재 입력 중인 글자를 반환한다. -updateComposition: 이 사용
public override func composedString(_ sender: Any) -> Any {
override func composedString(_ sender: Any) -> Any {
let client = asClient(sender)
return receiver.composedString(client)
}

public override func originalString(_ sender: Any) -> NSAttributedString {
override func originalString(_ sender: Any) -> NSAttributedString {
let client = asClient(sender)
return receiver.originalString(client)
}

public override func candidates(_ sender: Any) -> [Any]? {
override func candidates(_ sender: Any) -> [Any]? {
let client = asClient(sender)
return receiver.candidates(client)
}

public override func candidateSelected(_ candidateString: NSAttributedString!) {
override func candidateSelected(_ candidateString: NSAttributedString!) {
receiver.candidateSelected(candidateString)
}

public override func candidateSelectionChanged(_ candidateString: NSAttributedString!) {
override func candidateSelectionChanged(_ candidateString: NSAttributedString!) {
receiver.candidateSelectionChanged(candidateString)
}
}

public extension MockInputController { // IMKStateSetting
//! @brief 마우스 이벤트를 잡을 수 있게 한다.
public override func recognizedEvents(_ sender: Any) -> Int {
override func recognizedEvents(_ sender: Any) -> Int {
let client = asClient(sender)
return Int(receiver.recognizedEvents(client).rawValue)
}

//! @brief 자판 전환을 감지한다.
public override func setValue(_ value: Any, forTag tag: Int, client sender: Any) {
override func setValue(_ value: Any, forTag tag: Int, client sender: Any) {
let client = asClient(sender)
receiver.setValue(value, forTag: tag, client: client)
}
@@ -70,7 +70,7 @@ class IOKitty {

ref = self
// Set input value callback
withUnsafeMutablePointer(to: &ref, {
withUnsafeMutablePointer(to: &ref) {
_self in
manager.registerInputValueCallback({
inContext, _, _, value in
@@ -97,7 +97,7 @@ class IOKitty {
}
// NSEvent.otherEvent(with: .applicationDefined, location: .zero, modifierFlags: .capsLock, timestamp: 0, windowNumber: 0, context: nil, subtype: 0, data1: 0, data2: 0)!
}, context: _self)
})
}
manager.schedule(runloop: .current, mode: .default)
let r = manager.open()
if r != kIOReturnSuccess {
@@ -167,7 +167,7 @@ public class InputMethodServer {

var description: String {
return """
<InputMethodServer server: "\(String(describing: self.server))" candidates: "\(String(describing: self.candidates))">
<InputMethodServer server: "\(String(describing: server))" candidates: "\(String(describing: candidates))">
"""
}

@@ -141,7 +141,7 @@ public class InputReceiver: InputTextDelegate {
if result.action != .cancel {
commitCompositionEvent(sender)
if case let .layout(mode) = result.action, layout != .toggleByCapsLock {
(sender as! IMKTextInput).selectMode(mode)
(sender as IMKTextInput).selectMode(mode)
}
} else {
updateComposition() // 조합 중인 문자 반영
@@ -53,7 +53,7 @@ class QwertyComposer: DelegatedComposer {
if !string.isEmpty, keyCode < 0x33, !flags.contains(.option) {
var newString = string
let chr = string.first!
if flags.contains(.capsLock), "a" <= chr, chr <= "z" {
if flags.contains(.capsLock), chr >= "a", chr <= "z" {
let newChr = Character(UnicodeScalar(String(chr).unicodeScalars.first!.value - 0x20)!)
newString = String(newChr)
_commitString = newString
@@ -146,7 +146,7 @@ class RomanDataComposer: DelegatedComposer {
if !string.isEmpty, keyCode < 0x33, !flags.contains(.option) {
let newChr: Character
let chr = string.first!
if flags.contains(.capsLock), "a" <= chr, chr <= "z" {
if flags.contains(.capsLock), chr >= "a", chr <= "z" {
newChr = Character(UnicodeScalar(String(chr).unicodeScalars.first!.value - 0x20)!)
} else {
newChr = chr

0 comments on commit 66112ed

Please sign in to comment.
You can’t perform that action at this time.