Select text restored by an undo in a NSTextView and set insertion

point to the end of the changed text after a redo.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@30498 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Wolfgang Lux 2010-05-30 21:17:50 +00:00
parent cec8360d99
commit 36c6a1a4bb
2 changed files with 14 additions and 8 deletions

View file

@ -1,3 +1,10 @@
2010-05-30 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSTextView.m (NSTextViewUndoObject, -performUndo:,
-shouldChangeTextInRange:replacementString:): Select text
restored by an undo operation and set insertion point to the end
of the changed text after a redo operation.
2010-05-30 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSTextView.m (-initWithFrame:, -initWithFrame:textContainer:):

View file

@ -113,11 +113,9 @@ a new internal method called from NSLayoutManager when text has changed.
{
NSRange range;
NSAttributedString *string;
NSRange selectedRange;
}
- (id) initWithRange: (NSRange)aRange
attributedString: (NSAttributedString *)aString
selectedRange: (NSRange)selected;
attributedString: (NSAttributedString *)aString;
- (NSRange) range;
- (void) setRange: (NSRange)aRange;
- (void) performUndo: (NSTextStorage *)aTextStorage;
@ -2617,8 +2615,7 @@ TextDidEndEditing notification _without_ asking the delegate
undoObject =
[[NSTextViewUndoObject alloc] initWithRange: undoRange
attributedString: undoString
selectedRange: [self selectedRange]];
attributedString: undoString];
[undo registerUndoWithTarget: _textStorage
selector: @selector(_undoTextChange:)
object: undoObject];
@ -5658,13 +5655,11 @@ or add guards
- (id) initWithRange: (NSRange)aRange
attributedString: (NSAttributedString *)aString
selectedRange: (NSRange)selected
{
if ((self = [super init]) != nil)
{
range = aRange;
string = RETAIN(aString);
selectedRange = selected;
}
return self;
}
@ -5695,7 +5690,11 @@ or add guards
{
[tv replaceCharactersInRange: range
withAttributedString: string];
[tv setSelectedRange: selectedRange];
range.length = [string length];
if ([[tv undoManager] isUndoing])
[tv setSelectedRange: range];
else
[tv setSelectedRange: NSMakeRange(NSMaxRange(range), 0)];
[tv didChangeText];
}
}