Add an auxiliary method to NSUndoManager to support coalescing undo

operations in NSTextView.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29163 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
wlux 2009-12-22 23:43:38 +00:00
parent e66625cfdf
commit 2aee2c5236
2 changed files with 42 additions and 0 deletions

View file

@ -1067,3 +1067,39 @@
@end
/*
* Category with auxiliary method to support coalescing undo actions
* for typing events in NSTextView. However, the implementation is
* not restricted to that purpose.
*/
@interface NSUndoManager(UndoCoalescing)
- (BOOL) _canCoalesceUndoWithTarget: (id)target
selector: (SEL)aSelector
object: (id)anObject;
@end
@implementation NSUndoManager(UndoCoalescing)
- (BOOL) _canCoalesceUndoWithTarget: (id)target
selector: (SEL)aSelector
object: (id)anObject
{
if (_isUndoing == NO && _isRedoing == NO && [_undoStack count] > 0)
{
int i;
NSArray *a = [[_undoStack lastObject] actions];
for (i = 0; i < [a count]; i++)
{
NSInvocation *inv = [a objectAtIndex: i];
if ([inv target] == target && [inv selector] == aSelector)
{
id object;
[inv getArgument: &object atIndex: 2];
if (object == anObject)
return YES;
}
}
}
return NO;
}
@end