Skip to content

Commit fd45641

Browse files
author
Chen Xiaoliang
committed
automatically detect Dvorak
1 parent 542e153 commit fd45641

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

VVDocumenter-Xcode.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
893D8F8018262EF500E8A00C /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 893D8F7F18262EF500E8A00C /* Carbon.framework */; };
1011
D114BEE0179644D00043FA65 /* NSString+PDRegex.m in Sources */ = {isa = PBXBuildFile; fileRef = D114BEDE179644D00043FA65 /* NSString+PDRegex.m */; };
1112
D114BEE3179644FA0043FA65 /* NSTextView+VVTextGetter.m in Sources */ = {isa = PBXBuildFile; fileRef = D114BEE2179644FA0043FA65 /* NSTextView+VVTextGetter.m */; };
1213
D11C542D17999D9000D3DE38 /* VVArgument.m in Sources */ = {isa = PBXBuildFile; fileRef = D11C542B17999D9000D3DE38 /* VVArgument.m */; };
@@ -42,6 +43,7 @@
4243
/* End PBXBuildFile section */
4344

4445
/* Begin PBXFileReference section */
46+
893D8F7F18262EF500E8A00C /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; };
4547
D114BEDD179644D00043FA65 /* NSString+PDRegex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+PDRegex.h"; sourceTree = "<group>"; };
4648
D114BEDE179644D00043FA65 /* NSString+PDRegex.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+PDRegex.m"; sourceTree = "<group>"; };
4749
D114BEE1179644FA0043FA65 /* NSTextView+VVTextGetter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSTextView+VVTextGetter.h"; sourceTree = "<group>"; };
@@ -106,6 +108,7 @@
106108
isa = PBXFrameworksBuildPhase;
107109
buildActionMask = 2147483647;
108110
files = (
111+
893D8F8018262EF500E8A00C /* Carbon.framework in Frameworks */,
109112
D14380F7179551B900C829CE /* Cocoa.framework in Frameworks */,
110113
);
111114
runOnlyForDeploymentPostprocessing = 0;
@@ -172,6 +175,7 @@
172175
D14380F5179551B900C829CE /* Frameworks */ = {
173176
isa = PBXGroup;
174177
children = (
178+
893D8F7F18262EF500E8A00C /* Carbon.framework */,
175179
D14380F6179551B900C829CE /* Cocoa.framework */,
176180
D1C462DB17999C2000EB7B23 /* SenTestingKit.framework */,
177181
D14380F8179551B900C829CE /* Other Frameworks */,

VVDocumenter-Xcode/VVDocumenterManager.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ -(void) showSettingPanel:(NSNotification *)noti {
7171
[self.settingPanel showWindow:self.settingPanel];
7272
}
7373

74+
-(BOOL) isDvorakActive
75+
{
76+
TISInputSourceRef inputSource = TISCopyCurrentKeyboardLayoutInputSource();
77+
NSString *layoutID = (__bridge NSString *)TISGetInputSourceProperty(inputSource, kTISPropertyInputSourceID);
78+
if ([layoutID isEqualToString:@"com.apple.keylayout.Dvorak"]) {
79+
return YES;
80+
} else {
81+
return NO;
82+
}
83+
}
84+
7485
- (void) textStorageDidChange:(NSNotification *)noti {
7586

7687
if ([[noti object] isKindOfClass:[NSTextView class]]) {
@@ -150,7 +161,7 @@ - (void) textStorageDidChange:(NSNotification *)noti {
150161
[kes sendKeyCode:kVK_Delete withModifierCommand:YES alt:NO shift:NO control:NO];
151162
//if (shouldReplace) [textView setSelectedRange:resultToDocument.range];
152163
//Cmd+V, paste (If it is Dvorak layout, use '.', which is corresponding the key 'V' in a QWERTY layout)
153-
NSInteger kKeyVCode = [[VVDocumenterSetting defaultSetting] useDvorakLayout] ? kVK_ANSI_Period : kVK_ANSI_V;
164+
NSInteger kKeyVCode = [self isDvorakActive] ? kVK_ANSI_Period : kVK_ANSI_V;
154165
[kes sendKeyCode:kKeyVCode withModifierCommand:YES alt:NO shift:NO control:NO];
155166

156167
//The key down is just a defined finish signal by me. When we receive this key, we know operation above is finished.

0 commit comments

Comments
 (0)