Permalink
Browse files

Squashed commit of the following:

commit 772c503
Author: Brett Terpstra <me@brettterpstra.com>
Date:   Fri May 20 00:20:44 2011 -0500

    Random license update.

commit 3c82201
Author: Brett Terpstra <me@brettterpstra.com>
Date:   Thu May 19 23:30:09 2011 -0500

    Cleaning up some loose ends; removing some now-unnecessary functions.

    Signed-off-by: Brett Terpstra <me@brettterpstra.com>

commit ba60478
Author: Brett Terpstra <me@brettterpstra.com>
Date:   Thu May 19 22:48:33 2011 -0500

    Pretty close to implementing the ODBEditor method for external editing.

Signed-off-by: Brett Terpstra <me@brettterpstra.com>
  • Loading branch information...
1 parent 8db9db8 commit 60664fa7cb35a7c6806e7883c8b3e759e7a0c5a1 @ttscoff committed May 20, 2011
View
@@ -136,6 +136,7 @@ void outletObjectAwoke(id sender);
- (IBAction)copyNoteLink:(id)sender;
- (IBAction)exportNote:(id)sender;
- (IBAction)revealNote:(id)sender;
+- (IBAction)editNoteExternally:(id)sender;
- (IBAction)printNote:(id)sender;
- (IBAction)tagNote:(id)sender;
- (IBAction)importNotes:(id)sender;
View
@@ -28,6 +28,7 @@
#import "NSFileManager_NV.h"
#import "EncodingsManager.h"
#import "ExporterManager.h"
+#import "ExternalEditorListController.h"
#import "NSData_transformations.h"
#import "BufferUtils.h"
#import "LinkingEditor.h"
@@ -342,16 +343,11 @@ - (void)runDelayedUIActionsAfterLaunch {
}
}
// add elasticthreads' menuitems
- NSMenuItem *theMenuItem = [[[NSMenuItem alloc] initWithTitle:@"Open Note in TextEdit"
- action:@selector(openFileInEditor:) keyEquivalent:@"O"] autorelease];
- if ([prefsController textEditor]) {
- [theMenuItem setTitle:[@"Open Note in " stringByAppendingString:[prefsController textEditor]]];
- }
+ NSMenuItem *theMenuItem = [[[NSMenuItem alloc] init] autorelease];
[theMenuItem setTarget:self];
NSMenu *notesMenu = [[[NSApp mainMenu] itemWithTag:NOTES_MENU_ID] submenu];
- [notesMenu insertItem:theMenuItem atIndex:9];
theMenuItem = [theMenuItem copy];
- [statBarMenu insertItem:theMenuItem atIndex:4];
+// [statBarMenu insertItem:theMenuItem atIndex:4];
[theMenuItem release];
//theMenuItem = [[viewMenu itemWithTag:801] copy];
//[statBarMenu insertItem:theMenuItem atIndex:11];
@@ -637,19 +633,12 @@ - (BOOL)validateMenuItem:(NSMenuItem*)menuItem {
} else if (selector == @selector(fixFileEncoding:)) {
return (currentNote != nil && storageFormatOfNote(currentNote) == PlainTextFormat && ![currentNote contentsWere7Bit]);
+ } else if (selector == @selector(editNoteExternally:)) {
+ return (numberSelected > 0) && [[menuItem representedObject] canEditAllNotes:[notationController notesAtIndexes:[notesTableView selectedRowIndexes]]];
}
-
return YES;
}
-/*
- - (void)menuNeedsUpdate:(NSMenu *)menu {
- NSLog(@"mama needs update: %@", [menu title]);
-
- NSArray *selectedNotes = [notationController notesAtIndexes:[notesTableView selectedRowIndexes]];
- [selectedNotes setURLsInNotesForMenu:menu];
- }*/
-
- (void)updateNoteMenus {
NSMenu *notesMenu = [[[NSApp mainMenu] itemWithTag:NOTES_MENU_ID] submenu];
@@ -661,6 +650,7 @@ - (void)updateNoteMenus {
NSLocalizedString(@"Delete", nil), trailingQualifier]];
}
+ [notesMenu setSubmenu:[[ExternalEditorListController sharedInstance] addEditNotesMenu] forItem:[notesMenu itemWithTag:88]];
NSMenu *viewMenu = [[[NSApp mainMenu] itemWithTag:VIEW_MENU_ID] submenu];
menuIndex = [viewMenu indexOfItemWithTarget:notesTableView andAction:@selector(toggleNoteBodyPreviews:)];
@@ -861,6 +851,22 @@ - (IBAction)revealNote:(id)sender {
[[NSWorkspace sharedWorkspace] selectFile:path inFileViewerRootedAtPath:@""];
}
+- (IBAction)editNoteExternally:(id)sender {
+ ExternalEditor *ed = [sender representedObject];
+ if ([ed isKindOfClass:[ExternalEditor class]]) {
+ NSIndexSet *indexes = [notesTableView selectedRowIndexes];
+ if (kCGEventFlagMaskAlternate == (CGEventSourceFlagsState(kCGEventSourceStateCombinedSessionState) & NSDeviceIndependentModifierFlagsMask)) {
+ //allow changing the default editor directly from Notes menu
+ [[ExternalEditorListController sharedInstance] setDefaultEditor:ed];
+ }
+ //force-write any queued changes to disk in case notes are being stored as separate files which might be opened directly by the method below
+ [notationController synchronizeNoteChanges:nil];
+ [[notationController notesAtIndexes:indexes] makeObjectsPerformSelector:@selector(editExternallyUsingEditor:) withObject:ed];
+ } else {
+ NSBeep();
+ }
+}
+
- (IBAction)printNote:(id)sender {
NSIndexSet *indexes = [notesTableView selectedRowIndexes];
@@ -2955,75 +2961,75 @@ - (IBAction)toggleWordCount:(id)sender{
}
- (void)flagsChanged:(NSEvent *)theEvent{
- if (ModFlagger>=0) {
- if (([theEvent keyCode]==58)||([theEvent keyCode]==61)) {
- if (([theEvent modifierFlags]==524576)||([theEvent modifierFlags]==524608)) { //option down
- modifierTimer = [[NSTimer scheduledTimerWithTimeInterval:0.65
- target:self
- selector:@selector(updateModifier:)
- userInfo:@"option"
- repeats:NO] retain];
- }else if ([theEvent modifierFlags]==256) { //option up
-
- if (modifierTimer) {
- if ([modifierTimer isValid]) {
- [modifierTimer invalidate];
- }else {
- [self performSelector:@selector(popWordCount:) withObject:NO afterDelay:0.35];
- }
- modifierTimer = nil;
- [modifierTimer release];
- }
- ModFlagger = 0;
-
- }
- }else if (([theEvent keyCode]==59)||([theEvent keyCode]==62)) {
- if (([theEvent modifierFlags]==262401)||([theEvent modifierFlags]==270592)) { //control down
- modifierTimer = [[NSTimer scheduledTimerWithTimeInterval:0.70
- target:self
- selector:@selector(updateModifier:)
- userInfo:@"control"
- repeats:NO] retain];
-
- }else if ([theEvent modifierFlags]==256) { //control up
-
- if (modifierTimer) {
- if ([modifierTimer isValid]) {
- [modifierTimer invalidate];
- }else {
- [self performSelector:@selector(popPreview:) withObject:NO afterDelay:0.46];
- }
- modifierTimer = nil;
- [modifierTimer release];
- }
- ModFlagger = 0;
- }
- }else if ([theEvent modifierFlags]==256) {
- ModFlagger = 0;
- if (modifierTimer) {
- if ([modifierTimer isValid]) {
- [modifierTimer invalidate];
- }
- modifierTimer = nil;
- [modifierTimer release];
- }
-
- }else {
- ModFlagger = -1;
- if (modifierTimer) {
- if ([modifierTimer isValid]) {
- [modifierTimer invalidate];
- }
- modifierTimer = nil;
- [modifierTimer release];
- }
- NSTimer *disTimer = [NSTimer scheduledTimerWithTimeInterval:0.2f
- target:self
- selector:@selector(disableKeyMasks:)
- userInfo:@"commandorshift"
- repeats:NO];
- }
- }
+// if (ModFlagger>=0) {
+// if (([theEvent keyCode]==58)||([theEvent keyCode]==61)) {
+// if (([theEvent modifierFlags]==524576)||([theEvent modifierFlags]==524608)) { //option down
+// modifierTimer = [[NSTimer scheduledTimerWithTimeInterval:0.65
+// target:self
+// selector:@selector(updateModifier:)
+// userInfo:@"option"
+// repeats:NO] retain];
+// }else if ([theEvent modifierFlags]==256) { //option up
+//
+// if (modifierTimer) {
+// if ([modifierTimer isValid]) {
+// [modifierTimer invalidate];
+// }else {
+// [self performSelector:@selector(popWordCount:) withObject:NO afterDelay:0.35];
+// }
+// modifierTimer = nil;
+// [modifierTimer release];
+// }
+// ModFlagger = 0;
+//
+// }
+// }else if (([theEvent keyCode]==59)||([theEvent keyCode]==62)) {
+// if (([theEvent modifierFlags]==262401)||([theEvent modifierFlags]==270592)) { //control down
+// modifierTimer = [[NSTimer scheduledTimerWithTimeInterval:0.70
+// target:self
+// selector:@selector(updateModifier:)
+// userInfo:@"control"
+// repeats:NO] retain];
+//
+// }else if ([theEvent modifierFlags]==256) { //control up
+//
+// if (modifierTimer) {
+// if ([modifierTimer isValid]) {
+// [modifierTimer invalidate];
+// }else {
+// [self performSelector:@selector(popPreview:) withObject:NO afterDelay:0.46];
+// }
+// modifierTimer = nil;
+// [modifierTimer release];
+// }
+// ModFlagger = 0;
+// }
+// }else if ([theEvent modifierFlags]==256) {
+// ModFlagger = 0;
+// if (modifierTimer) {
+// if ([modifierTimer isValid]) {
+// [modifierTimer invalidate];
+// }
+// modifierTimer = nil;
+// [modifierTimer release];
+// }
+//
+// }else {
+// ModFlagger = -1;
+// if (modifierTimer) {
+// if ([modifierTimer isValid]) {
+// [modifierTimer invalidate];
+// }
+// modifierTimer = nil;
+// [modifierTimer release];
+// }
+// NSTimer *disTimer = [NSTimer scheduledTimerWithTimeInterval:0.2f
+// target:self
+// selector:@selector(disableKeyMasks:)
+// userInfo:@"commandorshift"
+// repeats:NO];
+// }
+// }
}
- (void)updateModifier:(NSTimer*)theTimer{
Oops, something went wrong.

0 comments on commit 60664fa

Please sign in to comment.