Limit User Phrase Length to a hidden variable.
- Default: 10.
This commit is contained in:
parent
c6023966c5
commit
e038428475
|
@ -1372,7 +1372,7 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; }
|
|||
|
||||
size_t begin = min(_builder->markerCursorIndex(), _builder->cursorIndex());
|
||||
size_t end = max(_builder->markerCursorIndex(), _builder->cursorIndex());
|
||||
// A phrase should contian at least two characters.
|
||||
// A phrase should contain at least two characters.
|
||||
if (end - begin < 1) {
|
||||
return @"";
|
||||
}
|
||||
|
@ -1393,10 +1393,13 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; }
|
|||
|
||||
size_t begin = min(_builder->markerCursorIndex(), _builder->cursorIndex());
|
||||
size_t end = max(_builder->markerCursorIndex(), _builder->cursorIndex());
|
||||
// A phrase should contian at least two characters.
|
||||
// A phrase should contain at least two characters.
|
||||
if (end - begin < 2) {
|
||||
return @"";
|
||||
}
|
||||
if (end - begin > Preferences.maxCandidateLength) {
|
||||
return @"";
|
||||
}
|
||||
|
||||
NSRange range = NSMakeRange((NSInteger)begin, (NSInteger)(end - begin));
|
||||
NSString *selectedText = [_composingBuffer substringWithRange:range];
|
||||
|
@ -1416,6 +1419,7 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; }
|
|||
{
|
||||
NSString *currentMarkedPhrase = [self _currentMarkedTextAndReadings];
|
||||
if (![currentMarkedPhrase length]) {
|
||||
[self beep];
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
@ -1437,10 +1441,14 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; }
|
|||
NSString *message = [NSString stringWithFormat:NSLocalizedString(@"⚠︎ Phrase replacement mode enabled, interfering user phrase entry.", @""), text];
|
||||
[self _showTooltip:message client:client];
|
||||
}
|
||||
else if (length == 1) {
|
||||
else if (length < 2) {
|
||||
NSString *message = [NSString stringWithFormat:NSLocalizedString(@"\"%@\" length must ≥ 2 for a user phrase.", @""), text];
|
||||
[self _showTooltip:message client:client];
|
||||
}
|
||||
else if (length > Preferences.maxCandidateLength) {
|
||||
NSString *message = [NSString stringWithFormat:NSLocalizedString(@"\"%@\" length too long for a user phrase.", @""), text];
|
||||
[self _showTooltip:message client:client];
|
||||
}
|
||||
else {
|
||||
NSString *message = [NSString stringWithFormat:NSLocalizedString(@"\"%@\" selected. ENTER to add user phrase.", @""), text];
|
||||
[self _showTooltip:message client:client];
|
||||
|
|
|
@ -21,6 +21,7 @@ private let kChineseConversionEnabledKey = "ChineseConversionEnabled"
|
|||
private let kHalfWidthPunctuationEnabledKey = "HalfWidthPunctuationEnable"
|
||||
private let kEscToCleanInputBufferKey = "EscToCleanInputBuffer"
|
||||
private let kUseWinNT351BPMF = "UseWinNT351BPMF"
|
||||
private let kMaxCandidateLength = "MaxCandidateLength"
|
||||
private let kShouldNotFartInLieuOfBeep = "ShouldNotFartInLieuOfBeep"
|
||||
|
||||
private let kCandidateTextFontName = "CandidateTextFontName"
|
||||
|
@ -183,6 +184,7 @@ struct ComposingBufferSize {
|
|||
defaults.removeObject(forKey: kPhraseReplacementEnabledKey)
|
||||
defaults.removeObject(forKey: kChineseConversionEngineKey)
|
||||
defaults.removeObject(forKey: kUseWinNT351BPMF)
|
||||
defaults.removeObject(forKey: kMaxCandidateLength)
|
||||
defaults.removeObject(forKey: kShouldNotFartInLieuOfBeep)
|
||||
}
|
||||
|
||||
|
@ -226,6 +228,9 @@ struct ComposingBufferSize {
|
|||
return useWinNT351BPMF
|
||||
}
|
||||
|
||||
@UserDefault(key: kMaxCandidateLength, defaultValue: 10)
|
||||
@objc static var maxCandidateLength: Int
|
||||
|
||||
@UserDefault(key: kShouldNotFartInLieuOfBeep, defaultValue: true)
|
||||
@objc static var shouldNotFartInLieuOfBeep: Bool
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
"Edit Excluded Phrases" = "Edit Excluded Phrases";
|
||||
"Use Half-Width Punctuations" = "Use Half-Width Punctuations";
|
||||
"\"%@\" length must ≥ 2 for a user phrase." = "\"%@\" length must ≥ 2 for a user phrase.";
|
||||
"\"%@\" length too long for a user phrase." = "\"%@\" length too long for a user phrase.";
|
||||
"\"%@\" selected. ENTER to add user phrase." = "\"%@\" selected. ENTER to add user phrase.";
|
||||
"Edit Phrase Replacement Table" = "Edit Phrase Replacement Table";
|
||||
"Use Phrase Replacement" = "Use Phrase Replacement";
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
"Edit Excluded Phrases" = "辞書条目排除表を編集";
|
||||
"Use Half-Width Punctuations" = "半角句読機能を起用";
|
||||
"\"%@\" length must ≥ 2 for a user phrase." = "「%@」もう1つ文字のお選びを。";
|
||||
"\"%@\" length too long for a user phrase." = "「%@」文字数過剰で登録不可。";
|
||||
"\"%@\" selected. ENTER to add user phrase." = "「%@」を ENTER で辞書に登録。";
|
||||
"Edit Phrase Replacement Table" = "言葉置換表を編集";
|
||||
"Use Phrase Replacement" = "言葉置換機能";
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
"Edit Excluded Phrases" = "编辑要滤除的语汇";
|
||||
"Use Half-Width Punctuations" = "啟用半角標點輸出";
|
||||
"\"%@\" length must ≥ 2 for a user phrase." = "「%@」字数不足以自订语汇。";
|
||||
"\"%@\" length too long for a user phrase." = "「%@」字数太长、无法自订。";
|
||||
"\"%@\" selected. ENTER to add user phrase." = "「%@」敲 Enter 添入自订语汇。";
|
||||
"Edit Phrase Replacement Table" = "编辑语汇置换表";
|
||||
"Use Phrase Replacement" = "使用语汇置换";
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
"Edit Excluded Phrases" = "編輯要濾除的語彙";
|
||||
"Use Half-Width Punctuations" = "啟用半形標點輸出";
|
||||
"\"%@\" length must ≥ 2 for a user phrase." = "「%@」字數不足以自訂語彙。";
|
||||
"\"%@\" length too long for a user phrase." = "「%@」字數太長、無法自訂。";
|
||||
"\"%@\" selected. ENTER to add user phrase." = "「%@」敲 Enter 添入自訂語彙。";
|
||||
"Edit Phrase Replacement Table" = "編輯語彙置換表";
|
||||
"Use Phrase Replacement" = "使用語彙置換";
|
||||
|
|
Loading…
Reference in New Issue