Add support for changing candidate keys and candidate panel fonts.
This commit is contained in:
parent
c676d0d62c
commit
1693dc210e
|
@ -74,6 +74,11 @@ static NSString *const kComposingBufferSizePreferenceKey = @"ComposingBufferSize
|
||||||
static NSString *const kDisableUserCandidateSelectionLearning = @"DisableUserCandidateSelectionLearning";
|
static NSString *const kDisableUserCandidateSelectionLearning = @"DisableUserCandidateSelectionLearning";
|
||||||
static NSString *const kChooseCandidateUsingSpaceKey = @"ChooseCandidateUsingSpaceKey";
|
static NSString *const kChooseCandidateUsingSpaceKey = @"ChooseCandidateUsingSpaceKey";
|
||||||
|
|
||||||
|
// advanced (usually optional) settings
|
||||||
|
static NSString *const kCandidateTextFontName = @"kCandidateTextFontName";
|
||||||
|
static NSString *const kCandidateKeyLabelFontName = @"kCandidateTextFontName";
|
||||||
|
static NSString *const kCandidateKeys = @"CandidateKeys";
|
||||||
|
|
||||||
// a global object for saving the "learned" user candidate selections
|
// a global object for saving the "learned" user candidate selections
|
||||||
NSMutableDictionary *TLCandidateLearningDictionary = nil;
|
NSMutableDictionary *TLCandidateLearningDictionary = nil;
|
||||||
NSString *TLUserCandidatesDictionaryPath = nil;
|
NSString *TLUserCandidatesDictionaryPath = nil;
|
||||||
|
@ -212,6 +217,8 @@ public:
|
||||||
|
|
||||||
- (void)activateServer:(id)client
|
- (void)activateServer:(id)client
|
||||||
{
|
{
|
||||||
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||||
|
|
||||||
// reset the state
|
// reset the state
|
||||||
_currentDeferredClient = nil;
|
_currentDeferredClient = nil;
|
||||||
_currentCandidateClient = nil;
|
_currentCandidateClient = nil;
|
||||||
|
@ -588,7 +595,15 @@ public:
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
NSInteger index = [LTCurrentCandidateController.keyLabels indexOfObject:inputText];
|
NSInteger index = NSNotFound;
|
||||||
|
for (NSUInteger j = 0, c = [LTCurrentCandidateController.keyLabels count]; j < c; j++) {
|
||||||
|
if ([inputText compare:[LTCurrentCandidateController.keyLabels objectAtIndex:j] options:NSCaseInsensitiveSearch] == NSOrderedSame) {
|
||||||
|
index = j;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[LTCurrentCandidateController.keyLabels indexOfObject:inputText];
|
||||||
if (index != NSNotFound) {
|
if (index != NSNotFound) {
|
||||||
NSUInteger candidateIndex = [LTCurrentCandidateController candidateIndexAtKeyLabelIndex:index];
|
NSUInteger candidateIndex = [LTCurrentCandidateController candidateIndexAtKeyLabelIndex:index];
|
||||||
if (candidateIndex != NSUIntegerMax) {
|
if (candidateIndex != NSUIntegerMax) {
|
||||||
|
@ -1022,9 +1037,23 @@ public:
|
||||||
keyLabelSize = kMinKeyLabelSize;
|
keyLabelSize = kMinKeyLabelSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
LTCurrentCandidateController.keyLabelFont = [NSFont systemFontOfSize:keyLabelSize];
|
NSString *ctFontName = [[NSUserDefaults standardUserDefaults] stringForKey:kCandidateTextFontName];
|
||||||
LTCurrentCandidateController.candidateFont = [NSFont systemFontOfSize:textSize];
|
NSString *klFontName = [[NSUserDefaults standardUserDefaults] stringForKey:kCandidateKeyLabelFontName];
|
||||||
LTCurrentCandidateController.keyLabels = [NSArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", nil];
|
NSString *ckeys = [[NSUserDefaults standardUserDefaults] stringForKey:kCandidateKeys];
|
||||||
|
|
||||||
|
LTCurrentCandidateController.keyLabelFont = klFontName ? [NSFont fontWithName:klFontName size:keyLabelSize] : [NSFont systemFontOfSize:keyLabelSize];
|
||||||
|
LTCurrentCandidateController.candidateFont = ctFontName ? [NSFont fontWithName:ctFontName size:textSize] : [NSFont systemFontOfSize:textSize];
|
||||||
|
|
||||||
|
NSMutableArray *keyLabels = [NSMutableArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", nil];
|
||||||
|
|
||||||
|
if ([ckeys length] > 1) {
|
||||||
|
[keyLabels removeAllObjects];
|
||||||
|
for (NSUInteger i = 0, c = [ckeys length]; i < c; i++) {
|
||||||
|
[keyLabels addObject:[ckeys substringWithRange:NSMakeRange(i, 1)]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LTCurrentCandidateController.keyLabels = keyLabels;
|
||||||
[self collectCandidates];
|
[self collectCandidates];
|
||||||
|
|
||||||
LTCurrentCandidateController.delegate = self;
|
LTCurrentCandidateController.delegate = self;
|
||||||
|
|
Loading…
Reference in New Issue