Permalink
Browse files

fix capslock

  • Loading branch information...
1 parent dabb6d8 commit 1fd05187e4bd9f5d2692905e962cd1693706aca4 @youknowone youknowone committed Nov 11, 2014
@@ -504,6 +504,10 @@ - (CIMComposer *)composer {
return self->_receiver.composer;
}
+- (NSRange)selectionRange {
+ return [self->_receiver.inputClient selectedRange];
+}
+
@end
@@ -63,7 +63,7 @@ - (CIMInputTextProcessResult)inputController:(CIMInputController *)controller in
} else {
if (keyCode < 0x33) {
char key[2] = {0, 0};
- key[0] = (flags & NSAlphaShiftKeyMask || flags & NSShiftKeyMask) ? CIMKeyMapUpper[keyCode] : CIMKeyMapLower[keyCode];
+ key[0] = (flags & NSShiftKeyMask) ? CIMKeyMapUpper[keyCode] : CIMKeyMapLower[keyCode];
string = @(key);
}
}
@@ -85,6 +85,46 @@ - (void)testEvent {
}
}
+- (void)testCapslockRoman {
+ for (VirtualApp *app in self.apps) {
+ app.client.string = @"";
+ [app.controller setValue:kGureumInputSourceIdentifierQwerty forTag:kTextServiceInputModePropertyTag client:app.client];
+
+ [app inputText:@"m" key:46 modifiers:0];
+ [app inputText:@"r" key:15 modifiers:0];
+ [app inputText:@"2" key:19 modifiers:0];
+ XCTAssertEqualObjects(@"mr2", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
+
+ app.client.string = @"";
+ [app inputText:@"m" key:46 modifiers:0x10000];
+ [app inputText:@"r" key:15 modifiers:0x10000];
+ [app inputText:@"2" key:19 modifiers:0x10000];
+ XCTAssertEqualObjects(@"MR2", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
+ }
+}
+
+- (void)testCapslockHangul {
+ for (VirtualApp *app in self.apps) {
+ app.client.string = @"";
+ [app.controller setValue:kGureumInputSourceIdentifierHan3Final forTag:kTextServiceInputModePropertyTag client:app.client];
+
+ [app inputText:@"m" key:46 modifiers:0];
+ [app inputText:@"r" key:15 modifiers:0];
+ [app inputText:@"2" key:19 modifiers:0];
+ XCTAssertEqualObjects(@"", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
+ XCTAssertEqualObjects(@"", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
+
+ [app inputText:@" " key:49 modifiers:0];
+
+ app.client.string = @"";
+ [app inputText:@"m" key:46 modifiers:0x10000];
+ [app inputText:@"r" key:15 modifiers:0x10000];
+ [app inputText:@"2" key:19 modifiers:0x10000];
+ XCTAssertEqualObjects(@"", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
+ XCTAssertEqualObjects(@"", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
+ }
+}
+
- (void)testBlock {
for (VirtualApp *app in self.apps) {
app.client.string = @"";
@@ -154,8 +194,8 @@ - (void)testHanjaSyllable {
XCTAssertEqualObjects(@"", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
XCTAssertEqualObjects(@"", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
[app.controller candidateSelectionChanged:[[NSAttributedString alloc] initWithString:@"韓: 나라 이름 한"]];
- XCTAssertEqualObjects(@"", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
- XCTAssertEqualObjects(@"", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
+ XCTAssertEqualObjects(@"", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
+ XCTAssertEqualObjects(@"", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
[app.controller candidateSelected:[[NSAttributedString alloc] initWithString:@"韓: 나라 이름 한"]];
XCTAssertEqualObjects(@"", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
XCTAssertEqualObjects(@"", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
@@ -184,8 +224,8 @@ - (void)testHanjaWord {
XCTAssertEqualObjects(@"물 수", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
XCTAssertEqualObjects(@"물 수", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
[app.controller candidateSelectionChanged:[[NSAttributedString alloc] initWithString:@"水: 물 수, 고를 수"]];
- XCTAssertEqualObjects(@"", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
- XCTAssertEqualObjects(@"", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
+ XCTAssertEqualObjects(@"물 수", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
+ XCTAssertEqualObjects(@"물 수", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
[app.controller candidateSelected:[[NSAttributedString alloc] initWithString:@"水: 물 수, 고를 수"]];
XCTAssertEqualObjects(@"", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
XCTAssertEqualObjects(@"", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
@@ -211,8 +251,8 @@ - (void)testHanjaWord {
XCTAssertEqualObjects(@"水 물 수", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
XCTAssertEqualObjects(@"물 수", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
[app.controller candidateSelectionChanged:[[NSAttributedString alloc] initWithString:@"水: 물 수, 고를 수"]];
- XCTAssertEqualObjects(@"", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
- XCTAssertEqualObjects(@"", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
+ XCTAssertEqualObjects(@"물 수", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
+ XCTAssertEqualObjects(@"물 수", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
[app.controller candidateSelected:[[NSAttributedString alloc] initWithString:@"水: 물 수, 고를 수"]];
XCTAssertEqualObjects(@"水 水", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
XCTAssertEqualObjects(@"", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
@@ -232,8 +272,8 @@ - (void)testHanjaSelection {
[app inputText:@"\n" key:36 modifiers:524288];
[app.controller candidateSelectionChanged:[[NSAttributedString alloc] initWithString:@"水: 물 수, 고를 수"]];
- XCTAssertEqualObjects(@"", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
- XCTAssertEqualObjects(@"", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
+ XCTAssertEqualObjects(@"물 수", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
+ XCTAssertEqualObjects(@"물 수", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
[app.controller candidateSelected:[[NSAttributedString alloc] initWithString:@"水: 물 수, 고를 수"]];
XCTAssertEqualObjects(@"", app.client.string, @"buffer: %@ app: (%@)", app.client.string, app);
XCTAssertEqualObjects(@"", app.client.markedString, @"buffer: %@ app: (%@)", app.client.string, app);
View
@@ -49,6 +49,11 @@ - (NSArray *)candidates { return nil; }
- (CIMInputTextProcessResult)inputController:(CIMInputController *)controller inputText:(NSString *)string key:(NSInteger)keyCode modifiers:(NSUInteger)flags client:(id)sender {
if (string.length > 0 && keyCode < 0x33 && !(flags & NSAlternateKeyMask)) {
+ unichar chr = [string characterAtIndex:0];
+ if (flags & NSAlphaShiftKeyMask && 'a' <= chr && chr <= 'z') {
+ chr -= 0x20;
+ string = [NSString stringWithCharacters:&chr length:1];
+ }
self._commitString = string;
return CIMInputTextProcessResultProcessed;
} else {

0 comments on commit 1fd0518

Please sign in to comment.