Skip to content

Commit

Permalink
Merge pull request #525 from youknowone/beta8-fix
Browse files Browse the repository at this point in the history
자판전환 단축키 제거하고 Swift5
  • Loading branch information
youknowone committed May 20, 2019
2 parents 028ae2b + 66112ed commit 9582320
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 49 deletions.
20 changes: 12 additions & 8 deletions Gureum.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@
TargetAttributes = {
38162DF2141263270077AA2D = {
CreatedOnToolsVersion = 9.4.1;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
SystemCapabilities = {
com.apple.ApplicationGroups.Mac = {
enabled = 1;
Expand All @@ -855,7 +855,7 @@
};
382E68631A1314D900031D1D = {
CreatedOnToolsVersion = 9.4.1;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
SystemCapabilities = {
com.apple.ApplicationGroups.Mac = {
enabled = 1;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 = "";
};
Expand Down Expand Up @@ -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 = "";
};
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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;
};
Expand Down
3 changes: 2 additions & 1 deletion GureumTests/GureumTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class GureumTests: XCTestCase {
}

func testLayoutChange() {
Configuration.shared.inputModeExchangeKey = Configuration.Shortcut(UInt(kVK_Space), .shift)
for app in apps {
app.client.string = ""
app.controller.setValue("org.youknowone.inputmethod.Gureum.qwerty", forTag: kTextServiceInputModePropertyTag, client: app.client)
Expand Down Expand Up @@ -437,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
Expand Down
2 changes: 1 addition & 1 deletion OSX/GureumAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion OSXCore/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public class Configuration: UserDefaults {
ConfigurationName.lastHangulInputMode.rawValue: "org.youknowone.inputmethod.Gureum.han2",
ConfigurationName.lastRomanInputMode.rawValue: "org.youknowone.inputmethod.Gureum.qwerty",

ConfigurationName.inputModeExchangeKey.rawValue: Configuration.convertShortcutToConfiguration((0x31, .shift)),
ConfigurationName.inputModeEmoticonKey.rawValue: Configuration.convertShortcutToConfiguration((0x24, [.shift, .option])),
ConfigurationName.inputModeHanjaKey.rawValue: Configuration.convertShortcutToConfiguration((0x24, .option)),
ConfigurationName.optionKeyBehavior.rawValue: 0,
Expand Down
2 changes: 1 addition & 1 deletion OSXCore/HangulComposer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion OSXCore/HanjaComposer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down
40 changes: 20 additions & 20 deletions OSXCore/IOKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
}
24 changes: 14 additions & 10 deletions OSXCore/InputController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public class InputController: IMKInputController {
super.init()
}

public override func inputControllerWillClose() {
super.inputControllerWillClose()
}

func asClient(_ sender: Any) -> IMKTextInput & IMKUnicodeTextInput {
#if DEBUG
return sender as! (IMKTextInput & IMKUnicodeTextInput)
Expand Down Expand Up @@ -109,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)
Expand Down Expand Up @@ -324,7 +328,7 @@ public extension InputController { // IMKServerInput
// COMMIT triggered
}

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

let client = receiver.inputClient
Expand All @@ -334,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
Expand All @@ -345,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)
}
Expand Down
6 changes: 3 additions & 3 deletions OSXCore/InputMethodServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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))">
"""
}

Expand Down
2 changes: 1 addition & 1 deletion OSXCore/InputReceiver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() // 조합 중인 문자 반영
Expand Down
4 changes: 2 additions & 2 deletions OSXCore/RomanComposer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9582320

Please sign in to comment.