mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
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:
parent
6797a06652
commit
37b81067e9
2 changed files with 42 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue