diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-08-14 10:08:31 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-08-14 10:08:31 +0000 |
commit | 1fdf6898c1750fc0af72d9919cf370855f6a5bf2 (patch) | |
tree | 5df8cf5736a6311d712bbd29c844eec87a27b9f2 /Source/SPEditSheetTextView.m | |
parent | f0985197a759c5e6dcc1d60b71f2652f701da805 (diff) | |
download | sequelpro-1fdf6898c1750fc0af72d9919cf370855f6a5bf2.tar.gz sequelpro-1fdf6898c1750fc0af72d9919cf370855f6a5bf2.tar.bz2 sequelpro-1fdf6898c1750fc0af72d9919cf370855f6a5bf2.zip |
• added to the SPFieldEditorController's text editor view its own undoManager which runs in the same modal run loop
- RETURN or a ' ' forms a undo group
- undo groups will be formed after 5 run loops (to form longer block while writing quickly)
Note: Has to be tested and fine-tuned if necessary
Diffstat (limited to 'Source/SPEditSheetTextView.m')
-rw-r--r-- | Source/SPEditSheetTextView.m | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/Source/SPEditSheetTextView.m b/Source/SPEditSheetTextView.m index 83b691c9..bcde1167 100644 --- a/Source/SPEditSheetTextView.m +++ b/Source/SPEditSheetTextView.m @@ -28,7 +28,47 @@ @implementation SPEditSheetTextView -- (void) keyDown:(NSEvent *)theEvent +- (IBAction)undo:(id)sender +{ + textWasChanged = NO; + [[self undoManager] undo]; + // Due to the undoManager implementation it could happen that + // an action will be recoreded which actually didn't change the + // text buffer. That's why repeat undo. + if(!textWasChanged) [[self undoManager] undo]; +} + +- (IBAction)redo:(id)sender +{ + textWasChanged = NO; + [[self undoManager] redo]; + // Due to the undoManager implementation it could happen that + // an action will be recoreded which actually didn't change the + // text buffer. That's why repeat redo. + if(!textWasChanged) [[self undoManager] redo]; +} + +/* + * Validate undo and redo menu items + */ +- (BOOL)validateMenuItem:(NSMenuItem *)menuItem +{ + + if ([menuItem action] == @selector(undo:)) { + return ([[self undoManager] canUndo]); + } + if ([menuItem action] == @selector(redo:)) { + return ([[self undoManager] canRedo]); + } + return YES; +} + +- (void)textDidChange:(NSNotification *)aNotification +{ + textWasChanged = YES; +} + +- (void)keyDown:(NSEvent *)theEvent { long allFlags = (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask); @@ -62,9 +102,9 @@ return; } } - + [super keyDown: theEvent]; - + } /* |