Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
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
ttscoff committed May 20, 2011
1 parent 8db9db8 commit 60664fa
Show file tree
Hide file tree
Showing 36 changed files with 3,117 additions and 1,314 deletions.
1 change: 1 addition & 0 deletions AppController.h
Expand Up @@ -136,6 +136,7 @@ void outletObjectAwoke(id sender);
- (IBAction)copyNoteLink:(id)sender; - (IBAction)copyNoteLink:(id)sender;
- (IBAction)exportNote:(id)sender; - (IBAction)exportNote:(id)sender;
- (IBAction)revealNote:(id)sender; - (IBAction)revealNote:(id)sender;
- (IBAction)editNoteExternally:(id)sender;
- (IBAction)printNote:(id)sender; - (IBAction)printNote:(id)sender;
- (IBAction)tagNote:(id)sender; - (IBAction)tagNote:(id)sender;
- (IBAction)importNotes:(id)sender; - (IBAction)importNotes:(id)sender;
Expand Down
176 changes: 91 additions & 85 deletions AppController.m
Expand Up @@ -28,6 +28,7 @@
#import "NSFileManager_NV.h" #import "NSFileManager_NV.h"
#import "EncodingsManager.h" #import "EncodingsManager.h"
#import "ExporterManager.h" #import "ExporterManager.h"
#import "ExternalEditorListController.h"
#import "NSData_transformations.h" #import "NSData_transformations.h"
#import "BufferUtils.h" #import "BufferUtils.h"
#import "LinkingEditor.h" #import "LinkingEditor.h"
Expand Down Expand Up @@ -342,16 +343,11 @@ - (void)runDelayedUIActionsAfterLaunch {
} }
} }
// add elasticthreads' menuitems // add elasticthreads' menuitems
NSMenuItem *theMenuItem = [[[NSMenuItem alloc] initWithTitle:@"Open Note in TextEdit" NSMenuItem *theMenuItem = [[[NSMenuItem alloc] init] autorelease];
action:@selector(openFileInEditor:) keyEquivalent:@"O"] autorelease];
if ([prefsController textEditor]) {
[theMenuItem setTitle:[@"Open Note in " stringByAppendingString:[prefsController textEditor]]];
}
[theMenuItem setTarget:self]; [theMenuItem setTarget:self];
NSMenu *notesMenu = [[[NSApp mainMenu] itemWithTag:NOTES_MENU_ID] submenu]; NSMenu *notesMenu = [[[NSApp mainMenu] itemWithTag:NOTES_MENU_ID] submenu];
[notesMenu insertItem:theMenuItem atIndex:9];
theMenuItem = [theMenuItem copy]; theMenuItem = [theMenuItem copy];
[statBarMenu insertItem:theMenuItem atIndex:4]; // [statBarMenu insertItem:theMenuItem atIndex:4];
[theMenuItem release]; [theMenuItem release];
//theMenuItem = [[viewMenu itemWithTag:801] copy]; //theMenuItem = [[viewMenu itemWithTag:801] copy];
//[statBarMenu insertItem:theMenuItem atIndex:11]; //[statBarMenu insertItem:theMenuItem atIndex:11];
Expand Down Expand Up @@ -637,19 +633,12 @@ - (BOOL)validateMenuItem:(NSMenuItem*)menuItem {
} else if (selector == @selector(fixFileEncoding:)) { } else if (selector == @selector(fixFileEncoding:)) {


return (currentNote != nil && storageFormatOfNote(currentNote) == PlainTextFormat && ![currentNote contentsWere7Bit]); 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; return YES;
} }


/*
- (void)menuNeedsUpdate:(NSMenu *)menu {
NSLog(@"mama needs update: %@", [menu title]);
NSArray *selectedNotes = [notationController notesAtIndexes:[notesTableView selectedRowIndexes]];
[selectedNotes setURLsInNotesForMenu:menu];
}*/

- (void)updateNoteMenus { - (void)updateNoteMenus {
NSMenu *notesMenu = [[[NSApp mainMenu] itemWithTag:NOTES_MENU_ID] submenu]; NSMenu *notesMenu = [[[NSApp mainMenu] itemWithTag:NOTES_MENU_ID] submenu];


Expand All @@ -661,6 +650,7 @@ - (void)updateNoteMenus {
NSLocalizedString(@"Delete", nil), trailingQualifier]]; NSLocalizedString(@"Delete", nil), trailingQualifier]];
} }


[notesMenu setSubmenu:[[ExternalEditorListController sharedInstance] addEditNotesMenu] forItem:[notesMenu itemWithTag:88]];
NSMenu *viewMenu = [[[NSApp mainMenu] itemWithTag:VIEW_MENU_ID] submenu]; NSMenu *viewMenu = [[[NSApp mainMenu] itemWithTag:VIEW_MENU_ID] submenu];


menuIndex = [viewMenu indexOfItemWithTarget:notesTableView andAction:@selector(toggleNoteBodyPreviews:)]; menuIndex = [viewMenu indexOfItemWithTarget:notesTableView andAction:@selector(toggleNoteBodyPreviews:)];
Expand Down Expand Up @@ -861,6 +851,22 @@ - (IBAction)revealNote:(id)sender {
[[NSWorkspace sharedWorkspace] selectFile:path inFileViewerRootedAtPath:@""]; [[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 { - (IBAction)printNote:(id)sender {
NSIndexSet *indexes = [notesTableView selectedRowIndexes]; NSIndexSet *indexes = [notesTableView selectedRowIndexes];


Expand Down Expand Up @@ -2955,75 +2961,75 @@ - (IBAction)toggleWordCount:(id)sender{
} }


- (void)flagsChanged:(NSEvent *)theEvent{ - (void)flagsChanged:(NSEvent *)theEvent{
if (ModFlagger>=0) { // if (ModFlagger>=0) {
if (([theEvent keyCode]==58)||([theEvent keyCode]==61)) { // if (([theEvent keyCode]==58)||([theEvent keyCode]==61)) {
if (([theEvent modifierFlags]==524576)||([theEvent modifierFlags]==524608)) { //option down // if (([theEvent modifierFlags]==524576)||([theEvent modifierFlags]==524608)) { //option down
modifierTimer = [[NSTimer scheduledTimerWithTimeInterval:0.65 // modifierTimer = [[NSTimer scheduledTimerWithTimeInterval:0.65
target:self // target:self
selector:@selector(updateModifier:) // selector:@selector(updateModifier:)
userInfo:@"option" // userInfo:@"option"
repeats:NO] retain]; // repeats:NO] retain];
}else if ([theEvent modifierFlags]==256) { //option up // }else if ([theEvent modifierFlags]==256) { //option up

//
if (modifierTimer) { // if (modifierTimer) {
if ([modifierTimer isValid]) { // if ([modifierTimer isValid]) {
[modifierTimer invalidate]; // [modifierTimer invalidate];
}else { // }else {
[self performSelector:@selector(popWordCount:) withObject:NO afterDelay:0.35]; // [self performSelector:@selector(popWordCount:) withObject:NO afterDelay:0.35];
} // }
modifierTimer = nil; // modifierTimer = nil;
[modifierTimer release]; // [modifierTimer release];
} // }
ModFlagger = 0; // ModFlagger = 0;

//
} // }
}else if (([theEvent keyCode]==59)||([theEvent keyCode]==62)) { // }else if (([theEvent keyCode]==59)||([theEvent keyCode]==62)) {
if (([theEvent modifierFlags]==262401)||([theEvent modifierFlags]==270592)) { //control down // if (([theEvent modifierFlags]==262401)||([theEvent modifierFlags]==270592)) { //control down
modifierTimer = [[NSTimer scheduledTimerWithTimeInterval:0.70 // modifierTimer = [[NSTimer scheduledTimerWithTimeInterval:0.70
target:self // target:self
selector:@selector(updateModifier:) // selector:@selector(updateModifier:)
userInfo:@"control" // userInfo:@"control"
repeats:NO] retain]; // repeats:NO] retain];

//
}else if ([theEvent modifierFlags]==256) { //control up // }else if ([theEvent modifierFlags]==256) { //control up

//
if (modifierTimer) { // if (modifierTimer) {
if ([modifierTimer isValid]) { // if ([modifierTimer isValid]) {
[modifierTimer invalidate]; // [modifierTimer invalidate];
}else { // }else {
[self performSelector:@selector(popPreview:) withObject:NO afterDelay:0.46]; // [self performSelector:@selector(popPreview:) withObject:NO afterDelay:0.46];
} // }
modifierTimer = nil; // modifierTimer = nil;
[modifierTimer release]; // [modifierTimer release];
} // }
ModFlagger = 0; // ModFlagger = 0;
} // }
}else if ([theEvent modifierFlags]==256) { // }else if ([theEvent modifierFlags]==256) {
ModFlagger = 0; // ModFlagger = 0;
if (modifierTimer) { // if (modifierTimer) {
if ([modifierTimer isValid]) { // if ([modifierTimer isValid]) {
[modifierTimer invalidate]; // [modifierTimer invalidate];
} // }
modifierTimer = nil; // modifierTimer = nil;
[modifierTimer release]; // [modifierTimer release];
} // }

//
}else { // }else {
ModFlagger = -1; // ModFlagger = -1;
if (modifierTimer) { // if (modifierTimer) {
if ([modifierTimer isValid]) { // if ([modifierTimer isValid]) {
[modifierTimer invalidate]; // [modifierTimer invalidate];
} // }
modifierTimer = nil; // modifierTimer = nil;
[modifierTimer release]; // [modifierTimer release];
} // }
NSTimer *disTimer = [NSTimer scheduledTimerWithTimeInterval:0.2f // NSTimer *disTimer = [NSTimer scheduledTimerWithTimeInterval:0.2f
target:self // target:self
selector:@selector(disableKeyMasks:) // selector:@selector(disableKeyMasks:)
userInfo:@"commandorshift" // userInfo:@"commandorshift"
repeats:NO]; // repeats:NO];
} // }
} // }
} }


- (void)updateModifier:(NSTimer*)theTimer{ - (void)updateModifier:(NSTimer*)theTimer{
Expand Down

0 comments on commit 60664fa

Please sign in to comment.