Skip to content

Commit

Permalink
Merge pull request #307 from youknowone/hangul-combination
Browse files Browse the repository at this point in the history
Hangul combination
  • Loading branch information
youknowone committed Sep 13, 2018
2 parents e250e2f + db4c746 commit 44585ba
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 105 deletions.
8 changes: 0 additions & 8 deletions OSX/Bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,3 @@
#import "CIMInputHandler.h"
#import "GureumComposer.h"
#import "HangulComposer.h"

@interface HangulComposerCombination: NSObject

+ (NSString * _Nonnull)commitStringByCombinationModeWithUCSString:(const HGUCSChar *)UCSString;
+ (NSString * _Nonnull)composedStringByCombinationModeWithUCSString:(const HGUCSChar *)UCSString;

@end

20 changes: 0 additions & 20 deletions OSX/GureumConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ var CIMInputModeEnglishKeyCode = "CIMInputModeEnglishKeyCode"
var CIMInputModeKoreanKeyModifier = "CIMInputModeKoreanKeyModifier"
var CIMInputModeKoreanKeyCode = "CIMInputModeKoreanKeyCode"
var CIMOptionKeyBehavior = "CIMOptionKeyBehavior"
var CIMHangulCombinationModeComposing = "CIMHangulCombinationModeComposing"
var CIMHangulCombinationModeCommiting = "CIMHangulCombinationModeCommiting"

var CIMSharedInputManager = "CIMSharedInputManager"
var CIMAutosaveDefaultInputMode = "CIMAutosaveDefaultInputMode"
Expand Down Expand Up @@ -75,24 +73,6 @@ var CIMShowsInputForHanjaCandidates = "CIMShowsInputForHanjaCandidates"
}
}

@objc public var hangulCombinationModeCommiting: Int {
get {
return self.integer(forKey: CIMHangulCombinationModeCommiting)
}
set {
return self.set(newValue, forKey: CIMHangulCombinationModeCommiting)
}
}

@objc public var hangulCombinationModeComposing: Int {
get {
return self.integer(forKey: CIMHangulCombinationModeComposing)
}
set {
return self.set(newValue, forKey: CIMHangulCombinationModeComposing)
}
}

public var inputModeExchangeKey: (Int, Int) {
get {
return (self.inputModeExchangeKeyModifier, self.inputModeExchangeKeyCode)
Expand Down
3 changes: 0 additions & 3 deletions OSX/GureumPreferencesWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@

/* Hangul Preferences */
IBOutlet NSButton *showsInputForHanjaCandidatesCheckbox;

IBOutlet NSComboBox *hangulCombinationModeComposingComboBox;
IBOutlet NSComboBox *hangulCombinationModeCommitingComboBox;
}

- (IBAction)saveToConfiguration:(id)sender;
Expand Down
3 changes: 0 additions & 3 deletions OSX/GureumPreferencesWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,6 @@ - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)inde
if (aComboBox == defaultHangulInputModeComboBox) {
return GureumPreferencesHangulLayoutLocalizedNames[index];
}
if (aComboBox == hangulCombinationModeComposingComboBox || aComboBox == hangulCombinationModeCommitingComboBox) {
return GureumPreferencesHangulSyllablePresentations[index];
}
assert(NO);
return nil;
}
Expand Down
14 changes: 0 additions & 14 deletions OSX/HangulComposer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,6 @@
#import <Hangul/HGHanja.h>
#import "CIMComposer.h"

typedef NS_ENUM(unsigned int, HangulCharacterCombinationMode) {
// 채움 문자는 모두 지우고 결합해 표현한다.
HangulCharacterCombinationWithoutFiller = 0,
// 없는 자소가 있더라도 모두 채움 문자와 결합해 표현한다.
HangulCharacterCombinationWithFiller = 1,
// 중성이 빠졌을 경우만 채움 문자를 이용한다.
HangulCharacterCombinationWithOnlyJungseongFiller = 2,
// 채움 문자 뒤는 숨긴다.
HangulCharacterCombinationHiddenOnFiller = 3,
// 중성 채움 문자 뒤는 숨긴다.
HangulCharacterCombinationHiddenOnJungseongFiller = 4,
};
#define HangulCharacterCombinationModeCount 5

@class GureumConfiguration;

@interface HanjaComposer : CIMComposer {
Expand Down
24 changes: 0 additions & 24 deletions OSX/HangulComposer.m
Original file line number Diff line number Diff line change
Expand Up @@ -287,27 +287,3 @@ - (CIMInputTextProcessResult)inputController:(CIMInputController *)controller in
}

@end

@implementation HangulComposerCombination

/*!
@brief 설정에 따라 조합 완료할 문자 최종처리
*/
+ (NSString *)commitStringByCombinationModeWithUCSString:(const HGUCSChar *)UCSString {
NSInteger index = [GureumConfiguration shared].hangulCombinationModeCommiting;
dassert(0 <= index);
dassert(index < HangulCharacterCombinationModeCount);
return [NSString stringByRemovingFillerWithUCSString:UCSString];
}

/*!
@brief 설정에 따라 조합중으로 보여줄 문자 최종처리
*/
+ (NSString *)composedStringByCombinationModeWithUCSString:(const HGUCSChar *)UCSString {
NSInteger index = [GureumConfiguration shared].hangulCombinationModeComposing;
dassert(0 <= index);
dassert(index < HangulCharacterCombinationModeCount);
return [NSString stringByRemovingFillerWithUCSString:UCSString];
}

@end
30 changes: 23 additions & 7 deletions OSX/HangulComposer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@

import Foundation

class HangulComposerCombination {
/*!
@brief 설정에 따라 조합 완료할 문자 최종처리
*/
public class func commitString(ucsString: UnsafePointer<HGUCSChar>) -> String {
return NSString.stringByRemovingFillerWithUCSString(ucsString) as String
}

/*!
@brief 설정에 따라 조합중으로 보여줄 문자 최종처리
*/
public class func composedString(ucsString: UnsafePointer<HGUCSChar>) -> String {
return NSString.stringByRemovingFillerWithUCSString(ucsString) as String
}
}

/*!
@brief libhangul을 사용하는 합성기
Expand Down Expand Up @@ -69,9 +85,9 @@ import Foundation
}
}
let handled = self._inputContext.process(string.first!.unicodeScalars.first!.value)
let UCSString = self._inputContext.commitUCSString;
let UCSString = self._inputContext.commitUCSString!
// dassert(UCSString);
let recentCommitString = HangulComposerCombination.commitStringByCombinationMode(withUCSString: UCSString)
let recentCommitString = HangulComposerCombination.commitString(ucsString: UCSString)
self._commitString += recentCommitString
// dlog(DEBUG_HANGULCOMPOSER, @"HangulComposer -inputText: string %@ (%@ added)", self->_commitString, recentCommitString);
return handled ? .processed : .notProcessedAndNeedsCancel;
Expand All @@ -84,15 +100,15 @@ import Foundation

public var composedString: String! {
get {
let preedit = self._inputContext.preeditUCSString
return HangulComposerCombination.composedStringByCombinationMode(withUCSString: preedit)
let preedit = self._inputContext.preeditUCSString!
return HangulComposerCombination.composedString(ucsString: preedit)
}
}

public var originalString: String! {
get {
let preedit = self._inputContext.preeditUCSString
return HangulComposerCombination.commitStringByCombinationMode(withUCSString: preedit)
let preedit = self._inputContext.preeditUCSString!
return HangulComposerCombination.commitString(ucsString: preedit)
}
}

Expand All @@ -103,7 +119,7 @@ import Foundation
}

public func cancelComposition() {
let flushedString: String! = HangulComposerCombination.commitStringByCombinationMode(withUCSString: self._inputContext.flushUCSString())
let flushedString: String! = HangulComposerCombination.commitString(ucsString: self._inputContext.flushUCSString())
self._commitString += flushedString
}

Expand Down
26 changes: 0 additions & 26 deletions iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
384ADED819C1B33A0007A993 /* ThemeShopViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3852354A19B07B41001B8E3E /* ThemeShopViewController.swift */; };
386308FC199143800039369C /* libhangeul.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 38904F851944F71400858B09 /* libhangeul.a */; };
386308FD1991438B0039369C /* libhangeul.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 38904F851944F71400858B09 /* libhangeul.a */; };
386308FE199143A80039369C /* capi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 38303668199059D500C1EE0C /* capi.cpp */; };
386308FF199143A90039369C /* capi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 38303668199059D500C1EE0C /* capi.cpp */; };
3882BA01193F9E6600076C26 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3882B9FF193F9E6600076C26 /* Main.storyboard */; };
3882BA03193F9E6600076C26 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3882BA02193F9E6600076C26 /* Images.xcassets */; };
3882BA0F193F9E6600076C26 /* GureumTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3882BA0E193F9E6600076C26 /* GureumTests.swift */; };
Expand Down Expand Up @@ -163,14 +161,11 @@
380136B6199CB4A700355D69 /* PreviewViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreviewViewController.swift; sourceTree = "<group>"; };
38303652198A15DB00C1EE0C /* LayoutEditorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LayoutEditorViewController.swift; sourceTree = "<group>"; };
38303656198D9FA000C1EE0C /* icon_512x512@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "icon_512x512@2x.png"; path = "OSX/Icons/Gureum.iconset/icon_512x512@2x.png"; sourceTree = SOURCE_ROOT; };
38303668199059D500C1EE0C /* capi.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = capi.cpp; path = ../hangeul/hangeul/capi.cpp; sourceTree = "<group>"; };
3830366B199059DE00C1EE0C /* capi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = capi.h; path = ../hangeul/hangeul/capi.h; sourceTree = "<group>"; };
383B07F019E71482004046F5 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
3844B239198930BF007A2287 /* Gureum.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Gureum.entitlements; sourceTree = SOURCE_ROOT; };
3844B23A19893144007A2287 /* org.youknowone.Gureum.inputmethod.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = org.youknowone.Gureum.inputmethod.entitlements; sourceTree = "<group>"; };
3852354619B06009001B8E3E /* Store.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Store.swift; sourceTree = "<group>"; };
3852354A19B07B41001B8E3E /* ThemeShopViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThemeShopViewController.swift; sourceTree = "<group>"; };
3863089A199132210039369C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3882B9F6193F9E6600076C26 /* Gureum.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Gureum.app; sourceTree = BUILT_PRODUCTS_DIR; };
3882B9FA193F9E6600076C26 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3882B9FB193F9E6600076C26 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -259,24 +254,6 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
38630898199132210039369C /* iOSCore */ = {
isa = PBXGroup;
children = (
3830366B199059DE00C1EE0C /* capi.h */,
38303668199059D500C1EE0C /* capi.cpp */,
38630899199132210039369C /* Supporting Files */,
);
path = iOSCore;
sourceTree = "<group>";
};
38630899199132210039369C /* Supporting Files */ = {
isa = PBXGroup;
children = (
3863089A199132210039369C /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
3882B9ED193F9E6600076C26 = {
isa = PBXGroup;
children = (
Expand All @@ -285,7 +262,6 @@
3882BA0B193F9E6600076C26 /* Tests */,
38BB7010193FA11000605583 /* iOS */,
388802B0214500190050DEE8 /* iOSShared */,
38630898199132210039369C /* iOSCore */,
38D9A398199B7F8E0087A965 /* iOSTheme */,
3882B9F7193F9E6600076C26 /* Products */,
F98215E1D3C4FAFA74650D13 /* Pods */,
Expand Down Expand Up @@ -701,7 +677,6 @@
384ADED219C1B3130007A993 /* LayoutEditorViewController.swift in Sources */,
384ADED719C1B32E0007A993 /* Store.swift in Sources */,
388802D121450B8D0050DEE8 /* TenkeyKeyboardLayout.swift in Sources */,
386308FF199143A90039369C /* capi.cpp in Sources */,
388802F52145309C0050DEE8 /* QuickHelperViewController2.swift in Sources */,
384ADED019C1B3090007A993 /* PreviewViewController.swift in Sources */,
);
Expand Down Expand Up @@ -731,7 +706,6 @@
388802D221450B8E0050DEE8 /* TenkeyKeyboardLayout.swift in Sources */,
388802D021450AE60050DEE8 /* InputMethodView.swift in Sources */,
388802D421450BB00050DEE8 /* EmoticonKeyboardLayout.swift in Sources */,
386308FE199143A80039369C /* capi.cpp in Sources */,
388802E221452BDE0050DEE8 /* Theme.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down

0 comments on commit 44585ba

Please sign in to comment.