Skip to content

Commit

Permalink
Added Aquamacs special case 2.2+ menu item. Commented out code trying…
Browse files Browse the repository at this point in the history
… to restore clipboard. Made Close(command-w) keyboard shortcut (and others) work for QuickCursor windows
  • Loading branch information
jessegrosjean committed Jan 20, 2011
1 parent e930231 commit b3a2a86
Show file tree
Hide file tree
Showing 7 changed files with 652 additions and 30 deletions.
632 changes: 616 additions & 16 deletions English.lproj/MainMenu.xib

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ODBEditor.m
Expand Up @@ -258,9 +258,9 @@ - (BOOL)_editFile:(NSString *)path isEditingString:(BOOL)editingStringFlag optio
[_filePathsBeingEdited setObject: dictionary forKey: path]; [_filePathsBeingEdited setObject: dictionary forKey: path];
} }
} }

success = (status == noErr); success = (status == noErr);

return success; return success;
} }


Expand Down
1 change: 1 addition & 0 deletions QCAppDelegate.h
Expand Up @@ -29,6 +29,7 @@


#pragma mark Actions #pragma mark Actions


- (IBAction)showHelp:(id)sender;
- (IBAction)showAbout:(id)sender; - (IBAction)showAbout:(id)sender;
- (IBAction)showPreferences:(id)sender; - (IBAction)showPreferences:(id)sender;
- (IBAction)editInPopUpButtonClicked:(id)sender; - (IBAction)editInPopUpButtonClicked:(id)sender;
Expand Down
41 changes: 31 additions & 10 deletions QCAppDelegate.m
Expand Up @@ -50,6 +50,11 @@ - (NSArray *)validatedEditorMenuItems:(SEL)action {
if (!bundleName) { if (!bundleName) {
bundleName = [[bundlePath lastPathComponent] stringByDeletingPathExtension]; bundleName = [[bundlePath lastPathComponent] stringByDeletingPathExtension];
} }

if ([eachBundleID isEqualToString:@"org.gnu.Aquamacs"]) {
bundleName = [bundleName stringByAppendingString:@" 2.2+"];
}

NSMenuItem *eachMenuItem = [[[NSMenuItem alloc] initWithTitle:bundleName action:NULL keyEquivalent:@""] autorelease]; NSMenuItem *eachMenuItem = [[[NSMenuItem alloc] initWithTitle:bundleName action:NULL keyEquivalent:@""] autorelease];
[eachMenuItem setRepresentedObject:eachBundleID]; [eachMenuItem setRepresentedObject:eachBundleID];
[eachMenuItem setIndentationLevel:1]; [eachMenuItem setIndentationLevel:1];
Expand Down Expand Up @@ -123,6 +128,9 @@ - (BOOL)validateMenuItem:(NSMenuItem *)anItem {
} }


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
//NSMenu *m = [NSApp mainMenu];


quickCursorSessionQCUIElements = [[NSMutableSet alloc] init]; quickCursorSessionQCUIElements = [[NSMutableSet alloc] init];
registeredHotKeys = [[NSMutableArray alloc] init]; registeredHotKeys = [[NSMutableArray alloc] init];


Expand Down Expand Up @@ -157,14 +165,14 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSMenuItem *aboutMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"About", nil) action:@selector(showAbout:) keyEquivalent:@""] autorelease]; NSMenuItem *aboutMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"About", nil) action:@selector(showAbout:) keyEquivalent:@""] autorelease];
[aboutMenuItem setTarget:self]; [aboutMenuItem setTarget:self];
[quickCursorMenu addItem:aboutMenuItem]; [quickCursorMenu addItem:aboutMenuItem];

NSMenuItem *preferencesMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Preferences...", nil) action:@selector(showPreferences:) keyEquivalent:@""] autorelease]; NSMenuItem *preferencesMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Preferences...", nil) action:@selector(showPreferences:) keyEquivalent:@","] autorelease];
[preferencesMenuItem setTarget:self]; [preferencesMenuItem setTarget:self];
[quickCursorMenu addItem:preferencesMenuItem]; [quickCursorMenu addItem:preferencesMenuItem];


[quickCursorMenu addItem:[NSMenuItem separatorItem]]; [quickCursorMenu addItem:[NSMenuItem separatorItem]];


NSMenuItem *quitMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Quit", nil) action:@selector(terminate:) keyEquivalent:@""] autorelease]; NSMenuItem *quitMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Quit", nil) action:@selector(terminate:) keyEquivalent:@"q"] autorelease];
[quitMenuItem setTarget:NSApp]; [quitMenuItem setTarget:NSApp];
[quickCursorMenu addItem:quitMenuItem]; [quickCursorMenu addItem:quitMenuItem];


Expand Down Expand Up @@ -303,11 +311,12 @@ - (IBAction)beginQuickCursorEdit:(id)sender {
} }


QCUIElement *focusedElement = [QCUIElement focusedElement]; QCUIElement *focusedElement = [QCUIElement focusedElement];
NSString *editString = [focusedElement readString]; QCUIElement *sourceApplicationElement = [focusedElement application];
NSString *processName = [focusedElement processName]; NSString *editString = [sourceApplicationElement readString];
NSString *processName = [sourceApplicationElement processName];


if (editString) { if (editString) {
NSDictionary *context = [NSDictionary dictionaryWithObjectsAndKeys:focusedElement, @"uiElement", editString, @"originalString", processName, @"processName", nil]; NSDictionary *context = [NSDictionary dictionaryWithObjectsAndKeys:sourceApplicationElement, @"sourceApplicationElement", bundleID, @"editorBundleID", editString, @"originalString", processName, @"processName", nil];
NSString *windowTitle = focusedElement.window.title; NSString *windowTitle = focusedElement.window.title;
NSString *correctedWindowTitle = [windowTitle stringByReplacingOccurrencesOfString:@"/" withString:@":"]; NSString *correctedWindowTitle = [windowTitle stringByReplacingOccurrencesOfString:@"/" withString:@":"];
NSString *editorCustomPath = [NSString stringWithFormat:@"%@ - %@", processName, correctedWindowTitle]; NSString *editorCustomPath = [NSString stringWithFormat:@"%@ - %@", processName, correctedWindowTitle];
Expand All @@ -333,15 +342,27 @@ - (void)odbEditor:(ODBEditor *)editor didClosefile:(NSString *)path context:(NSD
} }


- (void)odbEditor:(ODBEditor *)editor didModifyFileForString:(NSString *)newString context:(NSDictionary *)context; { - (void)odbEditor:(ODBEditor *)editor didModifyFileForString:(NSString *)newString context:(NSDictionary *)context; {
// HACK TextMate doesn't sedn a didCloseFile event when a file is closed as the result of the application shutdown process.
// But it does send a didModifyFile event, so here I'm catching that event and if the application is no longer running then I paste
// text back into source app... This test still has issues (user saves in textmate, then quite app after save), so commenting out for now. Darn TextMate!
/*NSString *editorBundleID = [context valueForKey:@"editorBundleID"];
if ([editorBundleID isEqualToString:@"com.macromates.textmate"]) {
NSRunningApplication *runingEditorApplication = [[NSRunningApplication runningApplicationsWithBundleIdentifier:editorBundleID] lastObject];
if (runingEditorApplication) {
NSLog(@"%@ is still running", editorBundleID);
} else {
NSLog(@"%@ is not still running", editorBundleID);
}
}*/
} }


- (void)odbEditor:(ODBEditor *)editor didCloseFileForString:(NSString *)newString context:(NSDictionary *)context; { - (void)odbEditor:(ODBEditor *)editor didCloseFileForString:(NSString *)newString context:(NSDictionary *)context; {
QCUIElement *uiElement = [context valueForKey:@"uiElement"]; QCUIElement *sourceApplicationElement = [context valueForKey:@"sourceApplicationElement"];
NSString *originalString = [context valueForKey:@"originalString"]; NSString *originalString = [context valueForKey:@"originalString"];
NSString *processName = [context valueForKey:@"processName"]; NSString *processName = [context valueForKey:@"processName"];


if (![originalString isEqualToString:newString]) { if (![originalString isEqualToString:newString]) {
if (![uiElement writeString:newString]) { if (![sourceApplicationElement writeString:newString]) {
NSBeep(); NSBeep();
[NSApp activateIgnoringOtherApps:YES]; [NSApp activateIgnoringOtherApps:YES];
[[NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Could not paste text back into %@", nil), processName] [[NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Could not paste text back into %@", nil), processName]
Expand All @@ -351,7 +372,7 @@ - (void)odbEditor:(ODBEditor *)editor didCloseFileForString:(NSString *)newStrin
informativeTextWithFormat:NSLocalizedString(@"Your edited text has been saved to the clipboard and can be pasted into another application.", nil)] runModal]; informativeTextWithFormat:NSLocalizedString(@"Your edited text has been saved to the clipboard and can be pasted into another application.", nil)] runModal];
} }
} else { } else {
[uiElement activateProcess]; [sourceApplicationElement activateProcess];
} }
} }


Expand Down
4 changes: 2 additions & 2 deletions QCUIElement.m
Expand Up @@ -345,9 +345,9 @@ - (NSString *)readString {
} }


NSPasteboard *pboard = [NSPasteboard generalPasteboard]; NSPasteboard *pboard = [NSPasteboard generalPasteboard];
NSString *savedContents = [pboard stringForType:NSPasteboardTypeString]; //NSString *savedContents = [pboard stringForType:NSPasteboardTypeString];
NSString *copiedContents = [self performCopy:YES]; NSString *copiedContents = [self performCopy:YES];
[pboard setString:savedContents forType:NSPasteboardTypeString]; //[pboard setString:savedContents forType:NSPasteboardTypeString]; // trying to restore original clip board contents... doesn't seem to work, not sure if good idaea anyway.
return copiedContents; return copiedContents;
} }


Expand Down
Binary file modified QuickCursor User's Guide.pages
Binary file not shown.
Binary file modified QuickCursor User's Guide.pdf
Binary file not shown.

0 comments on commit b3a2a86

Please sign in to comment.