mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
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:
parent
c076dbd009
commit
9eb497b703
3 changed files with 22 additions and 1 deletions
|
@ -1,3 +1,12 @@
|
|||
2010-02-12 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/NSTextView_actions.m (killBuffer, -deleteToEndOfLine:,
|
||||
-yank:): Implement the NSText kill buffer; -deleteToEndOfLine:
|
||||
saves the deleted text to the kill buffer, -yank: inserts the
|
||||
contents of the kill buffer.
|
||||
* KeyBindings/DefaultKeyBindings.dict: Enable the keybinding for
|
||||
the yank: command.
|
||||
|
||||
2010-02-12 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/NSTextView.m (-_characterIndexForPoint:respectFraction:):
|
||||
|
|
|
@ -69,5 +69,5 @@
|
|||
"Control-p" = "moveUp:";
|
||||
"Control-t" = "transpose:";
|
||||
"Control-v" = "pageDown:";
|
||||
/* "Control-y" = "yank:"; */
|
||||
"Control-y" = "yank:";
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue