Permalink
Browse files

Port hangul combination mode

  • Loading branch information...
youknowone committed Sep 13, 2018
1 parent 92ccc9f commit db4c74632a200e8fe83ad4df0f7c30b3b1555135
View
@@ -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
@@ -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"
@@ -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)
@@ -39,9 +39,6 @@
/* Hangul Preferences */
IBOutlet NSButton *showsInputForHanjaCandidatesCheckbox;
IBOutlet NSComboBox *hangulCombinationModeComposingComboBox;
IBOutlet NSComboBox *hangulCombinationModeCommitingComboBox;
}
- (IBAction)saveToConfiguration:(id)sender;
@@ -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;
}
View
@@ -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 {
View
@@ -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
View
@@ -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을 사용하는 합성기
@@ -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;
@@ -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)
}
}
@@ -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
}

0 comments on commit db4c746

Please sign in to comment.