Skip to content

Commit

Permalink
GureumInputSourceIdentifier
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowone committed Sep 15, 2018
1 parent 440414e commit 80acd74
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 91 deletions.
2 changes: 0 additions & 2 deletions Gureum.xcodeproj/project.pbxproj
Expand Up @@ -325,7 +325,6 @@
38F1524C16ECF87E00FE1B4A /* hanroman@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "hanroman@2x.png"; path = "Icons/hanroman@2x.png"; sourceTree = "<group>"; };
38F1524D16ECF87E00FE1B4A /* qwerty@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "qwerty@2x.png"; path = "Icons/qwerty@2x.png"; sourceTree = "<group>"; };
38F220A3142C79710064FAC3 /* libhangul_logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = libhangul_logo.png; path = Icons/libhangul_logo.png; sourceTree = "<group>"; };
38FA21D814230E1000444D67 /* GureumComposer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GureumComposer.h; sourceTree = "<group>"; };
38FA220114233FD900444D67 /* Hangul.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Hangul.xcodeproj; path = "../libhangul-objc/Hangul.xcodeproj"; sourceTree = "<group>"; };
3B994C498AB6F1C414B12608 /* libPods-OSX.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OSX.a"; sourceTree = BUILT_PRODUCTS_DIR; };
4CAB632CA8BB927B15D0FF2A /* Pods-OSX.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OSX.debug.xcconfig"; path = "Pods/Target Support Files/Pods-OSX/Pods-OSX.debug.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -634,7 +633,6 @@
38FA21DF14231BCC00444D67 /* Composers */ = {
isa = PBXGroup;
children = (
38FA21D814230E1000444D67 /* GureumComposer.h */,
38162D7A140F64B70077AA2D /* HangulComposer.h */,
38162D7B140F64B70077AA2D /* HangulComposer.m */,
38D3E42A21213E9700751191 /* HangulComposer.swift */,
Expand Down
26 changes: 13 additions & 13 deletions GureumTests/GureumTests.m
Expand Up @@ -9,10 +9,11 @@
#import <objc/runtime.h>
#import <XCTest/XCTest.h>
#import "CIMCommon.h"
#import "GureumComposer.h"
#import "CIMInputController.h"
#import "GureumMockObjects.h"

#import "Gureum-Swift.h"


@interface GureumTests : XCTestCase

Expand Down Expand Up @@ -47,7 +48,7 @@ - (void)tearDown {
- (void)test2 {
for (VirtualApp *app in self.apps) {
app.client.string = @"";
[app.controller setValue:kGureumInputSourceIdentifierHan2 forTag:kTextServiceInputModePropertyTag client:app.client];
[app.controller setValue:[GureumInputSourceIdentifier han2] forTag:kTextServiceInputModePropertyTag client:app.client];
[app inputText:@"g" key:5 modifiers:0];
[app inputText:@"k" key:40 modifiers:0];
[app inputText:@"s" key:1 modifiers:0];
Expand Down Expand Up @@ -88,7 +89,7 @@ - (void)test2 {
- (void)test3final {
for (VirtualApp *app in self.apps) {
app.client.string = @"";
[app.controller setValue:kGureumInputSourceIdentifierHan3Final forTag:kTextServiceInputModePropertyTag client:app.client];
[app.controller setValue:[GureumInputSourceIdentifier han3Final] forTag:kTextServiceInputModePropertyTag client:app.client];
[app inputText:@"m" key:46 modifiers:0];
[app inputText:@"f" key:3 modifiers:0];
[app inputText:@"s" key:1 modifiers:0];
Expand Down Expand Up @@ -129,7 +130,7 @@ - (void)test3final {
- (void)testCapslockRoman {
for (VirtualApp *app in self.apps) {
app.client.string = @"";
[app.controller setValue:kGureumInputSourceIdentifierQwerty forTag:kTextServiceInputModePropertyTag client:app.client];
[app.controller setValue:[GureumInputSourceIdentifier qwerty] forTag:kTextServiceInputModePropertyTag client:app.client];

[app inputText:@"m" key:46 modifiers:0];
[app inputText:@"r" key:15 modifiers:0];
Expand All @@ -147,7 +148,7 @@ - (void)testCapslockRoman {
- (void)testCapslockHangul {
for (VirtualApp *app in self.apps) {
app.client.string = @"";
[app.controller setValue:kGureumInputSourceIdentifierHan3Final forTag:kTextServiceInputModePropertyTag client:app.client];
[app.controller setValue:[GureumInputSourceIdentifier han3Final] forTag:kTextServiceInputModePropertyTag client:app.client];

[app inputText:@"m" key:46 modifiers:0];
[app inputText:@"r" key:15 modifiers:0];
Expand All @@ -169,7 +170,7 @@ - (void)testCapslockHangul {
- (void)testBlock {
for (VirtualApp *app in self.apps) {
app.client.string = @"";
[app.controller setValue:kGureumInputSourceIdentifierQwerty forTag:kTextServiceInputModePropertyTag client:app.client];
[app.controller setValue:[GureumInputSourceIdentifier qwerty] forTag:kTextServiceInputModePropertyTag client:app.client];
[app inputText:@"m" key:46 modifiers:0];
[app inputText:@"f" key:3 modifiers:0];
[app inputText:@"s" key:1 modifiers:0];
Expand All @@ -193,7 +194,7 @@ - (void)testBlock {
- (void)testLayoutChange {
for (VirtualApp *app in self.apps) {
app.client.string = @"";
[app.controller setValue:kGureumInputSourceIdentifierQwerty forTag:kTextServiceInputModePropertyTag client:app.client];
[app.controller setValue:[GureumInputSourceIdentifier qwerty] forTag:kTextServiceInputModePropertyTag client:app.client];
[app inputText:nil key:-1 modifiers:NSAlphaShiftKeyMask];

[app inputText:@" " key:kVK_Space modifiers:NSShiftKeyMask];
Expand All @@ -217,18 +218,17 @@ - (void)testIPMDServerClientWrapper {
- (void)test3Number {
for (VirtualApp *app in self.apps) {
app.client.string = @"";
[app.controller setValue:kGureumInputSourceIdentifierHan3Final forTag:kTextServiceInputModePropertyTag client:app.client];
[app.controller setValue:[GureumInputSourceIdentifier han3Final] forTag:kTextServiceInputModePropertyTag client:app.client];
[app inputText:@"K" key:40 modifiers:131072];
XCTAssertEqualObjects(@"2", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
XCTAssertEqualObjects(@"", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
}
}
/*

- (void)testHanjaSyllable {
for (VirtualApp *app in self.apps) {
app.client.string = @"";
[app.controller setValue:kGureumInputSourceIdentifierHan3Final forTag:kTextServiceInputModePropertyTag client:app.client];
[app.controller setValue:[GureumInputSourceIdentifier han3Final] forTag:kTextServiceInputModePropertyTag client:app.client];
[app inputText:@"m" key:46 modifiers:0];
[app inputText:@"f" key:3 modifiers:0];
[app inputText:@"s" key:1 modifiers:0];
Expand All @@ -252,7 +252,7 @@ - (void)testHanjaWord {
continue; // 터미널은 한자 모드 진입이 불가
}
app.client.string = @"";
[app.controller setValue:kGureumInputSourceIdentifierHan3Final forTag:kTextServiceInputModePropertyTag client:app.client];
[app.controller setValue:[GureumInputSourceIdentifier han3Final] forTag:kTextServiceInputModePropertyTag client:app.client];
// hanja search mode
[app inputText:@"\n" key:36 modifiers:524288];
[app inputText:@"i" key:34 modifiers:0];
Expand Down Expand Up @@ -309,7 +309,7 @@ - (void)testHanjaSelection {
continue; // 터미널은 한자 모드 진입이 불가
}
app.client.string = @"물 수";
[app.controller setValue:kGureumInputSourceIdentifierHan3Final forTag:kTextServiceInputModePropertyTag client:app.client];
[app.controller setValue:[GureumInputSourceIdentifier han3Final] forTag:kTextServiceInputModePropertyTag client:app.client];
// hanja search mode
[app.client setSelectedRange:NSMakeRange(0, 3)];
XCTAssertEqualObjects(@"물 수", app.client.selectedString, @"");
Expand All @@ -323,5 +323,5 @@ - (void)testHanjaSelection {
XCTAssertEqualObjects(@"", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
}
}
*/

@end
1 change: 0 additions & 1 deletion OSX/Bridge.h
Expand Up @@ -11,5 +11,4 @@
#import "CIMCommon.h"
#import "CIMInputController.h"
#import "CIMInputHandler.h"
#import "GureumComposer.h"
#import "HangulComposer.h"
32 changes: 0 additions & 32 deletions OSX/GureumComposer.h

This file was deleted.

88 changes: 45 additions & 43 deletions OSX/GureumComposer.swift
Expand Up @@ -13,48 +13,50 @@

import Foundation

let kGureumInputSourceIdentifierQwerty = "org.youknowone.inputmethod.Gureum.qwerty"
let kGureumInputSourceIdentifierDvorak = "org.youknowone.inputmethod.Gureum.dvorak"
let kGureumInputSourceIdentifierDvorakQwertyCommand = "org.youknowone.inputmethod.Gureum.dvorakq"
let kGureumInputSourceIdentifierColemak = "org.youknowone.inputmethod.Gureum.colemak"
let kGureumInputSourceIdentifierColemakQwertyCommand = "org.youknowone.inputmethod.Gureum.colemakq"
let kGureumInputSourceIdentifierHan2 = "org.youknowone.inputmethod.Gureum.han2"
let kGureumInputSourceIdentifierHan2Classic = "org.youknowone.inputmethod.Gureum.han2classic"
let kGureumInputSourceIdentifierHan3Final = "org.youknowone.inputmethod.Gureum.han3final"
let kGureumInputSourceIdentifierHan3FinalLoose = "org.youknowone.inputmethod.Gureum.han3finalloose"
let kGureumInputSourceIdentifierHan390 = "org.youknowone.inputmethod.Gureum.han390"
let kGureumInputSourceIdentifierHan390Loose = "org.youknowone.inputmethod.Gureum.han390loose"
let kGureumInputSourceIdentifierHan3NoShift = "org.youknowone.inputmethod.Gureum.han3noshift"
let kGureumInputSourceIdentifierHan3Classic = "org.youknowone.inputmethod.Gureum.han3classic"
let kGureumInputSourceIdentifierHan3Layout2 = "org.youknowone.inputmethod.Gureum.han3layout2"
let kGureumInputSourceIdentifierHanAhnmatae = "org.youknowone.inputmethod.Gureum.han3ahnmatae"
let kGureumInputSourceIdentifierHanRoman = "org.youknowone.inputmethod.Gureum.hanroman"
let kGureumInputSourceIdentifierHan3_2011 = "org.youknowone.inputmethod.Gureum.han3-2011"
let kGureumInputSourceIdentifierHan3_2011Loose = "org.youknowone.inputmethod.Gureum.han3-2011loose"
let kGureumInputSourceIdentifierHan3_2012 = "org.youknowone.inputmethod.Gureum.han3-2012"
let kGureumInputSourceIdentifierHan3_2012Loose = "org.youknowone.inputmethod.Gureum.han3-2012loose"
let kGureumInputSourceIdentifierHan3FinalNoShiftCompat = "org.youknowone.inputmethod.Gureum.han3finalnoshiftcompat"
let kGureumInputSourceIdentifierHan3FinalNoShiftSymbol = "org.youknowone.inputmethod.Gureum.han3finalnoshiftsymbol"
let kGureumInputSourceIdentifierHan3_2014 = "org.youknowone.inputmethod.Gureum.han3-2014"
let kGureumInputSourceIdentifierHan3_2015 = "org.youknowone.inputmethod.Gureum.han3-2015"
@objc class GureumInputSourceIdentifier: NSObject {
@objc static let qwerty = "org.youknowone.inputmethod.Gureum.qwerty"
@objc static let dvorak = "org.youknowone.inputmethod.Gureum.dvorak"
@objc static let dvorakQwertyCommand = "org.youknowone.inputmethod.Gureum.dvorakq"
@objc static let colemak = "org.youknowone.inputmethod.Gureum.colemak"
@objc static let colemakQwertyCommand = "org.youknowone.inputmethod.Gureum.colemakq"
@objc static let han2 = "org.youknowone.inputmethod.Gureum.han2"
@objc static let han2Classic = "org.youknowone.inputmethod.Gureum.han2classic"
@objc static let han3Final = "org.youknowone.inputmethod.Gureum.han3final"
@objc static let han3FinalLoose = "org.youknowone.inputmethod.Gureum.han3finalloose"
@objc static let han390 = "org.youknowone.inputmethod.Gureum.han390"
@objc static let han390Loose = "org.youknowone.inputmethod.Gureum.han390loose"
@objc static let han3NoShift = "org.youknowone.inputmethod.Gureum.han3noshift"
@objc static let han3Classic = "org.youknowone.inputmethod.Gureum.han3classic"
@objc static let han3Layout2 = "org.youknowone.inputmethod.Gureum.han3layout2"
@objc static let hanAhnmatae = "org.youknowone.inputmethod.Gureum.han3ahnmatae"
@objc static let hanRoman = "org.youknowone.inputmethod.Gureum.hanroman"
@objc static let han3_2011 = "org.youknowone.inputmethod.Gureum.han3-2011"
@objc static let han3_2011Loose = "org.youknowone.inputmethod.Gureum.han3-2011loose"
@objc static let han3_2012 = "org.youknowone.inputmethod.Gureum.han3-2012"
@objc static let han3_2012Loose = "org.youknowone.inputmethod.Gureum.han3-2012loose"
@objc static let han3FinalNoShiftCompat = "org.youknowone.inputmethod.Gureum.han3finalnoshiftcompat"
@objc static let han3FinalNoShiftSymbol = "org.youknowone.inputmethod.Gureum.han3finalnoshiftsymbol"
@objc static let han3_2014 = "org.youknowone.inputmethod.Gureum.han3-2014"
@objc static let han3_2015 = "org.youknowone.inputmethod.Gureum.han3-2015"
}

let GureumInputSourceToHangulKeyboardIdentifierTable: [String: String] = [
kGureumInputSourceIdentifierQwerty : "",
kGureumInputSourceIdentifierHan2 : "2",
kGureumInputSourceIdentifierHan2Classic : "2y",
kGureumInputSourceIdentifierHan3Final : "3f",
kGureumInputSourceIdentifierHan390 : "39",
kGureumInputSourceIdentifierHan3NoShift : "3s",
kGureumInputSourceIdentifierHan3Classic : "3y",
kGureumInputSourceIdentifierHan3Layout2 : "32",
kGureumInputSourceIdentifierHanRoman : "ro",
kGureumInputSourceIdentifierHanAhnmatae : "ahn",
kGureumInputSourceIdentifierHan3FinalNoShiftCompat: "3gc",
kGureumInputSourceIdentifierHan3FinalNoShiftSymbol : "3gs",
kGureumInputSourceIdentifierHan3_2011 : "3-2011",
kGureumInputSourceIdentifierHan3_2012 : "3-2012",
kGureumInputSourceIdentifierHan3_2014 : "3-2014",
kGureumInputSourceIdentifierHan3_2015 : "3-2015",
GureumInputSourceIdentifier.qwerty : "",
GureumInputSourceIdentifier.han2 : "2",
GureumInputSourceIdentifier.han2Classic : "2y",
GureumInputSourceIdentifier.han3Final : "3f",
GureumInputSourceIdentifier.han390 : "39",
GureumInputSourceIdentifier.han3NoShift : "3s",
GureumInputSourceIdentifier.han3Classic : "3y",
GureumInputSourceIdentifier.han3Layout2 : "32",
GureumInputSourceIdentifier.hanRoman : "ro",
GureumInputSourceIdentifier.hanAhnmatae : "ahn",
GureumInputSourceIdentifier.han3FinalNoShiftCompat: "3gc",
GureumInputSourceIdentifier.han3FinalNoShiftSymbol : "3gs",
GureumInputSourceIdentifier.han3_2011 : "3-2011",
GureumInputSourceIdentifier.han3_2012 : "3-2012",
GureumInputSourceIdentifier.han3_2014 : "3-2014",
GureumInputSourceIdentifier.han3_2015 : "3-2015",
]

@objcMembers class GureumComposer: CIMComposer {
Expand Down Expand Up @@ -181,11 +183,11 @@ let GureumInputSourceToHangulKeyboardIdentifierTable: [String: String] = [
if self.delegate === romanComposer {
var lastHangulInputMode = GureumConfiguration.shared().lastHangulInputMode
if lastHangulInputMode == nil {
lastHangulInputMode = kGureumInputSourceIdentifierHan2
lastHangulInputMode = GureumInputSourceIdentifier.han2
}
(sender as AnyObject).selectMode(lastHangulInputMode)
} else {
(sender as AnyObject).selectMode(kGureumInputSourceIdentifierQwerty)
(sender as AnyObject).selectMode(GureumInputSourceIdentifier.qwerty)
}
manager.needsFakeComposedString = true
return CIMInputTextProcessResult.processed
Expand All @@ -211,7 +213,7 @@ let GureumInputSourceToHangulKeyboardIdentifierTable: [String: String] = [
// Vi-mode: esc로 로마자 키보드로 전환
if GureumConfiguration.shared().romanModeByEscapeKey != 0 && (keyCode == kVK_Escape || false) {
self.delegate.cancelComposition()
(sender as AnyObject).selectMode(kGureumInputSourceIdentifierQwerty)
(sender as AnyObject).selectMode(GureumInputSourceIdentifier.qwerty)
return CIMInputTextProcessResult.notProcessedAndNeedsCommit
}
}
Expand Down

0 comments on commit 80acd74

Please sign in to comment.