Zonble: Input Experience // Half-Size Punctuation Support
This commit is contained in:
parent
650d08f5e2
commit
4bbccca283
|
@ -83,5 +83,8 @@
|
||||||
|
|
||||||
// if Chinese conversion is enabled
|
// if Chinese conversion is enabled
|
||||||
BOOL _chineseConversionEnabled;
|
BOOL _chineseConversionEnabled;
|
||||||
|
|
||||||
|
// if half-width punctuation is enabled
|
||||||
|
BOOL _halfWidthPunctuationEnabled;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -81,6 +81,7 @@ static NSString *const kUseHorizontalCandidateListPreferenceKey = @"UseHorizonta
|
||||||
static NSString *const kComposingBufferSizePreferenceKey = @"ComposingBufferSize";
|
static NSString *const kComposingBufferSizePreferenceKey = @"ComposingBufferSize";
|
||||||
static NSString *const kChooseCandidateUsingSpaceKey = @"ChooseCandidateUsingSpaceKey";
|
static NSString *const kChooseCandidateUsingSpaceKey = @"ChooseCandidateUsingSpaceKey";
|
||||||
static NSString *const kChineseConversionEnabledKey = @"ChineseConversionEnabledKey";
|
static NSString *const kChineseConversionEnabledKey = @"ChineseConversionEnabledKey";
|
||||||
|
static NSString *const kHalfWidthPunctuationEnabledKey = @"HalfWidthPunctuationEnabledKey";
|
||||||
static NSString *const kEscToCleanInputBufferKey = @"EscToCleanInputBufferKey";
|
static NSString *const kEscToCleanInputBufferKey = @"EscToCleanInputBufferKey";
|
||||||
|
|
||||||
// advanced (usually optional) settings
|
// advanced (usually optional) settings
|
||||||
|
@ -192,6 +193,7 @@ static double FindHighestScore(const vector<NodeAnchor>& nodes, double epsilon)
|
||||||
|
|
||||||
_inputMode = kBopomofoModeIdentifier;
|
_inputMode = kBopomofoModeIdentifier;
|
||||||
_chineseConversionEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:kChineseConversionEnabledKey];
|
_chineseConversionEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:kChineseConversionEnabledKey];
|
||||||
|
_halfWidthPunctuationEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:kHalfWidthPunctuationEnabledKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -209,8 +211,11 @@ static double FindHighestScore(const vector<NodeAnchor>& nodes, double epsilon)
|
||||||
chineseConversionMenuItem.state = _chineseConversionEnabled ? NSControlStateValueOn : NSControlStateValueOff;
|
chineseConversionMenuItem.state = _chineseConversionEnabled ? NSControlStateValueOn : NSControlStateValueOff;
|
||||||
[menu addItem:chineseConversionMenuItem];
|
[menu addItem:chineseConversionMenuItem];
|
||||||
|
|
||||||
[menu addItem:[NSMenuItem separatorItem]];
|
NSMenuItem *halfWidthPunctuationMenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Use Half-Width Punctuations", @"") action:@selector(toggleHalfWidthPunctuation:) keyEquivalent:@""];
|
||||||
[menu addItemWithTitle:NSLocalizedString(@"User Phrases", @"") action:NULL keyEquivalent:@""];
|
halfWidthPunctuationMenuItem.state = _halfWidthPunctuationEnabled ? NSControlStateValueOn : NSControlStateValueOff;
|
||||||
|
[menu addItem:halfWidthPunctuationMenuItem];
|
||||||
|
|
||||||
|
[menu addItem:[NSMenuItem separatorItem]]; // ------------------------------
|
||||||
|
|
||||||
if (_inputMode == kSimpBopomofoModeIdentifier) {
|
if (_inputMode == kSimpBopomofoModeIdentifier) {
|
||||||
NSMenuItem *editExcludedPhrasesItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Edit Excluded Phrases", @"") action:@selector(openExcludedPhrasesSimpBopomofo:) keyEquivalent:@""];
|
NSMenuItem *editExcludedPhrasesItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Edit Excluded Phrases", @"") action:@selector(openExcludedPhrasesSimpBopomofo:) keyEquivalent:@""];
|
||||||
|
@ -226,7 +231,8 @@ static double FindHighestScore(const vector<NodeAnchor>& nodes, double epsilon)
|
||||||
|
|
||||||
NSMenuItem *reloadUserPhrasesItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Reload User Phrases", @"") action:@selector(reloadUserPhrases:) keyEquivalent:@""];
|
NSMenuItem *reloadUserPhrasesItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Reload User Phrases", @"") action:@selector(reloadUserPhrases:) keyEquivalent:@""];
|
||||||
[menu addItem:reloadUserPhrasesItem];
|
[menu addItem:reloadUserPhrasesItem];
|
||||||
[menu addItem:[NSMenuItem separatorItem]];
|
|
||||||
|
[menu addItem:[NSMenuItem separatorItem]]; // ------------------------------
|
||||||
|
|
||||||
NSMenuItem *updateCheckItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Check for Updates…", @"") action:@selector(checkForUpdate:) keyEquivalent:@""];
|
NSMenuItem *updateCheckItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Check for Updates…", @"") action:@selector(checkForUpdate:) keyEquivalent:@""];
|
||||||
[menu addItem:updateCheckItem];
|
[menu addItem:updateCheckItem];
|
||||||
|
@ -385,7 +391,8 @@ static double FindHighestScore(const vector<NodeAnchor>& nodes, double epsilon)
|
||||||
|
|
||||||
// Chinese conversion.
|
// Chinese conversion.
|
||||||
NSString *buffer = _composingBuffer;
|
NSString *buffer = _composingBuffer;
|
||||||
if (_chineseConversionEnabled) {
|
BOOL chineseConversionEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:kChineseConversionEnabledKey];
|
||||||
|
if (chineseConversionEnabled) {
|
||||||
buffer = [OpenCCBridge convert:_composingBuffer];
|
buffer = [OpenCCBridge convert:_composingBuffer];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,7 +552,8 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; }
|
||||||
NodeAnchor &anchor = _walkedNodes[0];
|
NodeAnchor &anchor = _walkedNodes[0];
|
||||||
NSString *popedText = [NSString stringWithUTF8String:anchor.node->currentKeyValue().value.c_str()];
|
NSString *popedText = [NSString stringWithUTF8String:anchor.node->currentKeyValue().value.c_str()];
|
||||||
// Chinese conversion.
|
// Chinese conversion.
|
||||||
if (_chineseConversionEnabled) {
|
BOOL chineseConversionEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:kChineseConversionEnabledKey];
|
||||||
|
if (chineseConversionEnabled) {
|
||||||
popedText = [OpenCCBridge convert:popedText];
|
popedText = [OpenCCBridge convert:popedText];
|
||||||
}
|
}
|
||||||
[client insertText:popedText replacementRange:NSMakeRange(NSNotFound, NSNotFound)];
|
[client insertText:popedText replacementRange:NSMakeRange(NSNotFound, NSNotFound)];
|
||||||
|
@ -1065,13 +1073,14 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; }
|
||||||
|
|
||||||
// if nothing is matched, see if it's a punctuation key for current layout.
|
// if nothing is matched, see if it's a punctuation key for current layout.
|
||||||
string layout = [self currentLayout];
|
string layout = [self currentLayout];
|
||||||
string customPunctuation = string("_punctuation_") + layout + string(1, (char)charCode);
|
string punctuationNamePrefix = (_halfWidthPunctuationEnabled ? string("_half_punctuation_"): string("_punctuation_"));
|
||||||
|
string customPunctuation = punctuationNamePrefix + layout + string(1, (char)charCode);
|
||||||
if ([self handlePunctuation:customPunctuation usingVerticalMode:useVerticalMode client:client]) {
|
if ([self handlePunctuation:customPunctuation usingVerticalMode:useVerticalMode client:client]) {
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if nothing is matched, see if it's a punctuation key.
|
// if nothing is matched, see if it's a punctuation key.
|
||||||
string punctuation = string("_punctuation_") + string(1, (char)charCode);
|
string punctuation = punctuationNamePrefix + string(1, (char)charCode);
|
||||||
if ([self handlePunctuation:punctuation usingVerticalMode:useVerticalMode client:client]) {
|
if ([self handlePunctuation:punctuation usingVerticalMode:useVerticalMode client:client]) {
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -1552,6 +1561,12 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; }
|
||||||
[[NSUserDefaults standardUserDefaults] setBool:_chineseConversionEnabled forKey:kChineseConversionEnabledKey];
|
[[NSUserDefaults standardUserDefaults] setBool:_chineseConversionEnabled forKey:kChineseConversionEnabledKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)toggleHalfWidthPunctuation:(id)sender
|
||||||
|
{
|
||||||
|
_halfWidthPunctuationEnabled = !_halfWidthPunctuationEnabled;
|
||||||
|
[[NSUserDefaults standardUserDefaults] setBool:_halfWidthPunctuationEnabled forKey:kHalfWidthPunctuationEnabledKey];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
|
@ -24,3 +24,4 @@
|
||||||
"Unable to create the user phrase file." = "Unable to create the user phrase file.";
|
"Unable to create the user phrase file." = "Unable to create the user phrase file.";
|
||||||
"Please check the permission of at \"%@\"." = "Please check the permission of at \"%@\".";
|
"Please check the permission of at \"%@\"." = "Please check the permission of at \"%@\".";
|
||||||
"Edit Excluded Phrases" = "Edit Excluded Phrases";
|
"Edit Excluded Phrases" = "Edit Excluded Phrases";
|
||||||
|
"Use Half-Width Punctuations" = "Use Half-Width Punctuations";
|
||||||
|
|
|
@ -24,3 +24,4 @@
|
||||||
"Unable to create the user phrase file." = "无法创建自订语汇档案。";
|
"Unable to create the user phrase file." = "无法创建自订语汇档案。";
|
||||||
"Please check the permission of at \"%@\"." = "请检查此处的存取权限:\"%@\".";
|
"Please check the permission of at \"%@\"." = "请检查此处的存取权限:\"%@\".";
|
||||||
"Edit Excluded Phrases" = "编辑要滤除的语汇";
|
"Edit Excluded Phrases" = "编辑要滤除的语汇";
|
||||||
|
"Use Half-Width Punctuations" = "啟用半角標點輸出";
|
||||||
|
|
|
@ -24,3 +24,4 @@
|
||||||
"Unable to create the user phrase file." = "無法創建自訂語彙檔案。";
|
"Unable to create the user phrase file." = "無法創建自訂語彙檔案。";
|
||||||
"Please check the permission of at \"%@\"." = "請檢查此處的存取權限:\"%@\".";
|
"Please check the permission of at \"%@\"." = "請檢查此處的存取權限:\"%@\".";
|
||||||
"Edit Excluded Phrases" = "編輯要濾除的語彙";
|
"Edit Excluded Phrases" = "編輯要濾除的語彙";
|
||||||
|
"Use Half-Width Punctuations" = "啟用半形標點輸出";
|
||||||
|
|
Loading…
Reference in New Issue