Skip to content

Commit

Permalink
修复对InsertMode下ESC的处理
Browse files Browse the repository at this point in the history
  • Loading branch information
milu committed Apr 13, 2015
1 parent 50b9bde commit 2c82653
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 27 deletions.
6 changes: 2 additions & 4 deletions PreviewAssistant.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/* Begin PBXBuildFile section */
2B698D6D1AD441D10012F1DB /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B698D5B1AD441D10012F1DB /* AppDelegate.m */; };
2B698D6E1AD441D10012F1DB /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2B698D5D1AD441D10012F1DB /* MainMenu.xib */; };
2B698D6F1AD441D10012F1DB /* globalkeypress.c in Sources */ = {isa = PBXBuildFile; fileRef = 2B698D5F1AD441D10012F1DB /* globalkeypress.c */; };
2B698D701AD441D10012F1DB /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2B698D601AD441D10012F1DB /* Images.xcassets */; };
2B698D711AD441D10012F1DB /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 2B698D611AD441D10012F1DB /* Info.plist */; };
2B698D721AD441D10012F1DB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B698D631AD441D10012F1DB /* main.m */; };
Expand All @@ -35,7 +34,6 @@
2B698D5B1AD441D10012F1DB /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
2B698D5C1AD441D10012F1DB /* Assistant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Assistant.h; sourceTree = "<group>"; };
2B698D5E1AD441D10012F1DB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
2B698D5F1AD441D10012F1DB /* globalkeypress.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = globalkeypress.c; sourceTree = "<group>"; };
2B698D601AD441D10012F1DB /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
2B698D611AD441D10012F1DB /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
2B698D621AD441D10012F1DB /* KeyCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyCode.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -80,7 +78,6 @@
2B698D5B1AD441D10012F1DB /* AppDelegate.m */,
2B698D5C1AD441D10012F1DB /* Assistant.h */,
2B698D5D1AD441D10012F1DB /* MainMenu.xib */,
2B698D5F1AD441D10012F1DB /* globalkeypress.c */,
2B698D601AD441D10012F1DB /* Images.xcassets */,
2B698D611AD441D10012F1DB /* Info.plist */,
2B698D621AD441D10012F1DB /* KeyCode.h */,
Expand Down Expand Up @@ -238,7 +235,6 @@
2B698D741AD441D10012F1DB /* MyWindow.m in Sources */,
2B698D731AD441D10012F1DB /* MyLabel.m in Sources */,
2B698D6D1AD441D10012F1DB /* AppDelegate.m in Sources */,
2B698D6F1AD441D10012F1DB /* globalkeypress.c in Sources */,
2B698D751AD441D10012F1DB /* UIElementInfo.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -356,6 +352,7 @@
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = PreviewAssistant/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
Expand All @@ -367,6 +364,7 @@
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = PreviewAssistant/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "PreviewAssistant/MyLabel.m"
timestampString = "450116958.889416"
timestampString = "450121672.46165"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "185"
endingLineNumber = "185"
startingLineNumber = "187"
endingLineNumber = "187"
landmarkName = "-performAction"
landmarkType = "5">
</BreakpointContent>
Expand Down Expand Up @@ -227,5 +227,37 @@
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "PreviewAssistant/WindowController.m"
timestampString = "450118726.927141"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "107"
endingLineNumber = "107"
landmarkName = "-generateWord"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "PreviewAssistant/Utility.h"
timestampString = "450123181.726489"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "612"
endingLineNumber = "612"
landmarkName = "enumWindowChildren(AXUIElementRef elem,NSMutableArray* arr)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
2 changes: 2 additions & 0 deletions PreviewAssistant/MyLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ - (void) updateLabel
- (void) updateColor
{

if(s == nil)
return;
NSString *str = s;

NSMutableAttributedString *attrstr = [[NSMutableAttributedString alloc] initWithString:str];
Expand Down
90 changes: 71 additions & 19 deletions PreviewAssistant/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,13 @@ NSPointerArray* getAppMainWindow()
for(int i = 0;i < CFArrayGetCount(windows);++i)
{
AXUIElementRef window = (AXUIElementRef) CFArrayGetValueAtIndex(windows, i);
CFBooleanRef main;
AXUIElementCopyAttributeValue(window,kAXMainAttribute,(CFTypeRef *)&main);
if(main == kCFBooleanTrue)
{
[arr addPointer:window];
}
[arr addPointer:window];
// CFBooleanRef main;
// AXUIElementCopyAttributeValue(window,kAXMainAttribute,(CFTypeRef *)&main);
// if(main == kCFBooleanTrue)
// {
// [arr addPointer:window];
// }


// AXUIElementCopyAttributeValue(window,kAXMainAttribute,(CFTypeRef *)&main);
Expand Down Expand Up @@ -566,16 +567,6 @@ void enumWindowChildren(AXUIElementRef elem,NSMutableArray* arr)
return;

// 2. return close btn
if([info.role isEqualToString:@"AXButton"])
{
NSArray* ignore = [[NSArray alloc] initWithObjects:@"AXCloseButton",@"AXZoomButton",@"AXMinimizeButton",@"AXFullScreenButton",nil];
if([ignore containsObject:info.subRole])
return;
info.type = buttonType;
[arr addObject:info];
return;
}

// 3. non-inputable AXSearchField
if(info.subRole != nil && [info.subRole isEqualToString:@"AXSearchField"])
{
Expand All @@ -598,10 +589,73 @@ void enumWindowChildren(AXUIElementRef elem,NSMutableArray* arr)
return;
}

if([info.role isEqualToString:@"AXTextArea"])
{
info.type = input;
[arr addObject:info];
return;
}
// 4. AXRow
if([info.role isEqualToString:@"AXRow"])
{
info.type = inputType;
error = AXUIElementCopyAttributeValue(elem, kAXChildrenAttribute, (CFTypeRef *)&cfchilds);
if(error != kAXErrorSuccess || cfchilds == nil)
{
info.type = input;
[arr addObject:info];
return;
}
AXUIElementRef btn_ = nil;
AXUIElementRef input_ = nil;
AXUIElementRef cell_ = nil;
UIElementInfo* info_ = nil;
for(int i = 0;i < CFArrayGetCount(cfchilds);++i)
{
AXUIElementRef child = (AXUIElementRef) CFArrayGetValueAtIndex( cfchilds, i);
info_ = getUIElementInfo(child);
if([info_.role isEqualToString:@"AXCell"])
{
cell_ = info_.ref;
break;
}
if([info_.role isEqualToString:@"AXButton"])
{
btn_ = info_.ref;
}
else if([info_.role isEqualToString:@"AXTextField"])
{
input_ = info_.ref;
break;
}
}

if(cell_ == nil && btn_ == nil && input_ == nil)
{
info.type = input;
[arr addObject:info];
return;
}
else if(cell_ == nil && input_ != nil)
{
info_.type = input;
[arr addObject:info_];
return;
}
else if(cell_ == nil && btn_ != nil)
{
info_.type = button;
[arr addObject:info_];
return;
}

}
// btn
if([info.role isEqualToString:@"AXButton"])
{
NSArray* ignore = [[NSArray alloc] initWithObjects:@"AXCloseButton",@"AXZoomButton",@"AXMinimizeButton",@"AXFullScreenButton",nil];
if([ignore containsObject:info.subRole])
return;
info.type = buttonType;
[arr addObject:info];
return;
}
Expand All @@ -618,13 +672,11 @@ void enumWindowChildren(AXUIElementRef elem,NSMutableArray* arr)
info.type = buttonType;
[arr addObject:info];
return;

}

if([info.role isEqualToString:@"AXTable"] || [info.role isEqualToString:@"AXOutline"])
{
error = AXUIElementCopyAttributeValue(elem, kAXVisibleRowsAttribute, (CFTypeRef *)&cfchilds);

}
else
{
Expand Down
2 changes: 1 addition & 1 deletion PreviewAssistant/WindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ - (bool) handleKeyPress_:(CGKeyCode) k
if(duration < 10000)
{
[self toReady];
return true;
return false;
}
}
}
Expand Down

0 comments on commit 2c82653

Please sign in to comment.