Permalink
Browse files

Added Aquamacs special case 2.2+ menu item. Commented out code trying…

… 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 b3a2a8610884c46143ece0612c09de5e4e461dc2
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -258,9 +258,9 @@ - (BOOL)_editFile:(NSString *)path isEditingString:(BOOL)editingStringFlag optio
[_filePathsBeingEdited setObject: dictionary forKey: path];
}
}
-
+
success = (status == noErr);
-
+
return success;
}
View
@@ -29,6 +29,7 @@
#pragma mark Actions
+- (IBAction)showHelp:(id)sender;
- (IBAction)showAbout:(id)sender;
- (IBAction)showPreferences:(id)sender;
- (IBAction)editInPopUpButtonClicked:(id)sender;
View
@@ -50,6 +50,11 @@ - (NSArray *)validatedEditorMenuItems:(SEL)action {
if (!bundleName) {
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];
[eachMenuItem setRepresentedObject:eachBundleID];
[eachMenuItem setIndentationLevel:1];
@@ -123,6 +128,9 @@ - (BOOL)validateMenuItem:(NSMenuItem *)anItem {
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
+ //NSMenu *m = [NSApp mainMenu];
+
+
quickCursorSessionQCUIElements = [[NSMutableSet alloc] init];
registeredHotKeys = [[NSMutableArray alloc] init];
@@ -157,14 +165,14 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSMenuItem *aboutMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"About", nil) action:@selector(showAbout:) keyEquivalent:@""] autorelease];
[aboutMenuItem setTarget:self];
[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];
[quickCursorMenu addItem:preferencesMenuItem];
[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];
[quickCursorMenu addItem:quitMenuItem];
@@ -303,11 +311,12 @@ - (IBAction)beginQuickCursorEdit:(id)sender {
}
QCUIElement *focusedElement = [QCUIElement focusedElement];
- NSString *editString = [focusedElement readString];
- NSString *processName = [focusedElement processName];
+ QCUIElement *sourceApplicationElement = [focusedElement application];
+ NSString *editString = [sourceApplicationElement readString];
+ NSString *processName = [sourceApplicationElement processName];
- if (editString) {
- NSDictionary *context = [NSDictionary dictionaryWithObjectsAndKeys:focusedElement, @"uiElement", editString, @"originalString", processName, @"processName", nil];
+ if (editString) {
+ NSDictionary *context = [NSDictionary dictionaryWithObjectsAndKeys:sourceApplicationElement, @"sourceApplicationElement", bundleID, @"editorBundleID", editString, @"originalString", processName, @"processName", nil];
NSString *windowTitle = focusedElement.window.title;
NSString *correctedWindowTitle = [windowTitle stringByReplacingOccurrencesOfString:@"/" withString:@":"];
NSString *editorCustomPath = [NSString stringWithFormat:@"%@ - %@", processName, correctedWindowTitle];
@@ -333,15 +342,27 @@ - (void)odbEditor:(ODBEditor *)editor didClosefile:(NSString *)path context:(NSD
}
- (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; {
- QCUIElement *uiElement = [context valueForKey:@"uiElement"];
+ QCUIElement *sourceApplicationElement = [context valueForKey:@"sourceApplicationElement"];
NSString *originalString = [context valueForKey:@"originalString"];
NSString *processName = [context valueForKey:@"processName"];
if (![originalString isEqualToString:newString]) {
- if (![uiElement writeString:newString]) {
+ if (![sourceApplicationElement writeString:newString]) {
NSBeep();
[NSApp activateIgnoringOtherApps:YES];
[[NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Could not paste text back into %@", nil), processName]
@@ -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];
}
} else {
- [uiElement activateProcess];
+ [sourceApplicationElement activateProcess];
}
}
View
@@ -345,9 +345,9 @@ - (NSString *)readString {
}
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
- NSString *savedContents = [pboard stringForType:NSPasteboardTypeString];
+ //NSString *savedContents = [pboard stringForType:NSPasteboardTypeString];
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;
}
Binary file not shown.
Binary file not shown.

0 comments on commit b3a2a86

Please sign in to comment.