diff options
-rw-r--r-- | Source/SPEditSheetTextView.m | 12 | ||||
-rw-r--r-- | Source/SPFieldEditorController.h | 3 | ||||
-rw-r--r-- | Source/SPFieldEditorController.m | 53 | ||||
-rw-r--r-- | Source/SPTooltip.m | 11 |
4 files changed, 55 insertions, 24 deletions
diff --git a/Source/SPEditSheetTextView.m b/Source/SPEditSheetTextView.m index bcde1167..0ca61dcd 100644 --- a/Source/SPEditSheetTextView.m +++ b/Source/SPEditSheetTextView.m @@ -48,6 +48,18 @@ if(!textWasChanged) [[self undoManager] redo]; } +- (IBAction)paste:(id)sender +{ + [[self delegate] setWasCutPaste]; + [super paste:sender]; +} + +- (IBAction)cut:(id)sender +{ + [[self delegate] setWasCutPaste]; + [super cut:sender]; +} + /* * Validate undo and redo menu items */ diff --git a/Source/SPFieldEditorController.h b/Source/SPFieldEditorController.h index e5fbb0e3..31ec6f44 100644 --- a/Source/SPFieldEditorController.h +++ b/Source/SPFieldEditorController.h @@ -52,6 +52,7 @@ unsigned long long maxTextLength; BOOL editTextViewWasChanged; BOOL allowUndo; + BOOL wasCutPaste; NSUserDefaults *prefs; @@ -83,4 +84,6 @@ - (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)aSelector; - (void)textViewDidChangeSelection:(NSNotification *)notification; +- (void)setWasCutPaste; + @end diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m index b2193b32..2c9359b7 100644 --- a/Source/SPFieldEditorController.m +++ b/Source/SPFieldEditorController.m @@ -213,24 +213,37 @@ int cycleCounter = 0; for (;;) { - cycleCounter++; + // cycleCounter++; // Allow undo grouping if user typed a ' ' (for word level undo) // or a RETURN - if([[NSApp currentEvent] type] == NSKeyDown - && ( - [[[NSApp currentEvent] charactersIgnoringModifiers] isEqualToString:@" "] - || [[NSApp currentEvent] keyCode] == 36 - ) - ) - cycleCounter=100; + // if([[NSApp currentEvent] type] == NSKeyDown + // && ( + // [[[NSApp currentEvent] charactersIgnoringModifiers] isEqualToString:@" "] + // || [[NSApp currentEvent] keyCode] == 36 + // // || [[NSApp currentEvent] modifierFlags] & (NSCommandKeyMask|NSControlKeyMask|NSAlternateKeyMask) + // ) + // ) + // cycleCounter=100; // After 5 run loops (fast writing forms longer blocks) // or the user typed a ' ' or RETURN and the textView was changed (allowUndo) // form an undo group - if(cycleCounter>5 && allowUndo && ![esUndoManager isUndoing] && ![esUndoManager isRedoing]) { - cycleCounter=0; + + // Break the run loop if editSheet was closed + if ([NSApp runModalSession:session] != NSRunContinuesResponse + || ![editSheet isVisible]) + break; + + // Execute code on DefaultRunLoop (like displaying a tooltip) + [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode + beforeDate:[NSDate distantFuture]]; + + if( (wasCutPaste || allowUndo) && ![esUndoManager isUndoing] && ![esUndoManager isRedoing] ) { + + cycleCounter = 0; allowUndo = NO; + wasCutPaste = NO; while([esUndoManager groupingLevel] > 0) { [esUndoManager endUndoGrouping]; cycleCounter++; @@ -239,16 +252,8 @@ [esUndoManager beginUndoGrouping]; cycleCounter = 0; - } - // Break the run loop if editSheet was closed - if ([NSApp runModalSession:session] != NSRunContinuesResponse - || ![editSheet isVisible]) - break; - - // Execute code on DefaultRunLoop (like displaying a tooltip) - [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode - beforeDate:[NSDate distantFuture]]; + } } [NSApp endModalSession:session]; @@ -272,6 +277,11 @@ return esUndoManager; } +- (void)setWasCutPaste +{ + wasCutPaste = YES; +} + - (IBAction)closeEditSheet:(id)sender { @@ -775,7 +785,8 @@ } -// TextView delegate methods +#pragma - +#pragma TextView delegate methods /** * Traps enter and return key and closes editSheet instead of inserting a linebreak when user hits return. @@ -789,8 +800,6 @@ [self closeEditSheet:editSheetOkButton]; return YES; } - else - return NO; } return NO; } diff --git a/Source/SPTooltip.m b/Source/SPTooltip.m index 9503262c..aa3e906f 100644 --- a/Source/SPTooltip.m +++ b/Source/SPTooltip.m @@ -58,6 +58,8 @@ #import "SPTooltip.h" #import "SPTextViewAdditions.h" +static int spTooltipCounter = 0; + static float slow_in_out (float t) { if(t < 1.0f) @@ -113,6 +115,8 @@ static float slow_in_out (float t) + (void)showWithObject:(id)content atLocation:(NSPoint)point ofType:(NSString *)type displayOptions:(NSDictionary *)displayOptions { + spTooltipCounter++; + SPTooltip* tip = [SPTooltip new]; [tip initMeWithOptions:displayOptions]; [tip setFrameTopLeftPoint:point]; @@ -367,8 +371,9 @@ static float slow_in_out (float t) - (void)animationTick:(id)sender { - float alpha = 0.97f * (1.0f - slow_in_out(-2.8 * [animationStart timeIntervalSinceNow])); - if(alpha > 0.0f) + float alpha = 0.97f * (1.0f - 40*slow_in_out(-2.2 * [animationStart timeIntervalSinceNow])); + + if(alpha > 0.0f && spTooltipCounter==1) { [self setAlphaValue:alpha]; } @@ -377,6 +382,8 @@ static float slow_in_out (float t) [super orderOut:self]; [self stopAnimation:self]; [self close]; + spTooltipCounter--; + if(spTooltipCounter < 0) spTooltipCounter = 0; } } |