mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 22:50:48 +00:00
Fix implementation of NSTextView's transpose action to really match
the implementation of Emacs' transpose command. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27366 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8279ffddbb
commit
ad13684362
2 changed files with 27 additions and 13 deletions
|
@ -8,6 +8,9 @@
|
||||||
* Source/NSTextView_actions.m (-centerSelectionInVisibleArea):
|
* Source/NSTextView_actions.m (-centerSelectionInVisibleArea):
|
||||||
Replace the provisional implementation by a correct one.
|
Replace the provisional implementation by a correct one.
|
||||||
|
|
||||||
|
* Source/NSTextView_actions.m (-transpose): Fix implementation to
|
||||||
|
really match the implementation of Emacs' transpose command.
|
||||||
|
|
||||||
2008-12-20 22:13-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
2008-12-20 22:13-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* Source/GSNibLoading.m: Read objects/accessibility and oids
|
* Source/GSNibLoading.m: Read objects/accessibility and oids
|
||||||
|
|
|
@ -1381,14 +1381,14 @@ and layout is left-to-right */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* The following method is bound to 'Control-t', and must work like
|
/* The following method is bound to 'Control-t', and works exactly like
|
||||||
* pressing 'Control-t' inside Emacs. For example, say that I type
|
* pressing 'Control-t' inside Emacs, i.e., in general it swaps the
|
||||||
* 'Nicoal' in a NSTextView. Then, I press 'Control-t'. This should
|
* character immediately before and after the insertion point and moves
|
||||||
* swap the last two characters which were inserted, thus swapping the
|
* the insertion point forward by one character. If, however, the
|
||||||
* 'a' and the 'l', and changing the text to read 'Nicola'. */
|
* insertion point is at the end of a line, it swaps the two characters
|
||||||
/*
|
* before the insertion point and does not move the insertion point.
|
||||||
TODO: description incorrect. should swap characters on either side of the
|
* Note that Mac OS X does not implement the special case at the end
|
||||||
insertion point. (see also: miswart)
|
* of a line, but I consider Emacs' behavior more useful.
|
||||||
*/
|
*/
|
||||||
- (void) transpose: (id)sender
|
- (void) transpose: (id)sender
|
||||||
{
|
{
|
||||||
|
@ -1397,16 +1397,26 @@ insertion point. (see also: miswart)
|
||||||
NSString *replacementString;
|
NSString *replacementString;
|
||||||
unichar chars[2];
|
unichar chars[2];
|
||||||
|
|
||||||
/* Do nothing if we are at beginning of text. */
|
/* Do nothing if the selection is not empty or if we are at the
|
||||||
if (range.location < 2)
|
* beginning of text. */
|
||||||
|
if (range.length > 0 || range.location < 1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
range = NSMakeRange(range.location - 2, 2);
|
range = NSMakeRange(range.location - 1, 2);
|
||||||
|
|
||||||
|
/* Eventually adjust the range if we are at the end of a line. */
|
||||||
|
string = [_textStorage string];
|
||||||
|
if (range.location + 1 == [string length]
|
||||||
|
|| [string characterAtIndex: range.location + 1] == '\n')
|
||||||
|
{
|
||||||
|
if (range.location == 0)
|
||||||
|
return;
|
||||||
|
range.location -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the two chars and swap them. */
|
/* Get the two chars and swap them. */
|
||||||
string = [_textStorage string];
|
|
||||||
chars[1] = [string characterAtIndex: range.location];
|
chars[1] = [string characterAtIndex: range.location];
|
||||||
chars[0] = [string characterAtIndex: (range.location + 1)];
|
chars[0] = [string characterAtIndex: (range.location + 1)];
|
||||||
|
|
||||||
|
@ -1418,6 +1428,7 @@ insertion point. (see also: miswart)
|
||||||
{
|
{
|
||||||
[self replaceCharactersInRange: range
|
[self replaceCharactersInRange: range
|
||||||
withString: replacementString];
|
withString: replacementString];
|
||||||
|
[self setSelectedRange: NSMakeRange(range.location + 2, 0)];
|
||||||
[self didChangeText];
|
[self didChangeText];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue