Implement the NSText kill buffer. Ctrl-k and Ctrl-y in a text view now

work as under Emacs and OS X.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29585 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Wolfgang Lux 2010-02-12 15:54:29 +00:00
parent c076dbd009
commit 9eb497b703
3 changed files with 22 additions and 1 deletions

View file

@ -115,6 +115,12 @@ send -shouldChangeTextInRange:replacementString: or -didChangeText.
*/
/* global kill buffer shared between all text views */
/* Note: I'm not using an attributed string here because Apple apparently is
using a plain string either. Maybe this is because NeXT was using the X11
cut buffer for the kill buffer, which can hold only plain strings? */
static NSString *killBuffer = @"";
/** First some helpers **/
@interface NSTextView (UserActionHelpers)
@ -697,12 +703,18 @@ static NSNumber *float_plus_one(NSNumber *cur)
return;
}
ASSIGN(killBuffer, [[_textStorage string] substringWithRange: range]);
[_textStorage beginEditing];
[_textStorage deleteCharactersInRange: range];
[_textStorage endEditing];
[self didChangeText];
}
- (void) yank: (id)sender
{
[self insertText: killBuffer];
}
/*
TODO: find out what affinity is supposed to mean