Usability improvements: When setting the cursor to the beginning of a

line, set the typing attributes to the attributes of the first character
of that line rather than the preceding newline. When deleting text, set
the typing attributes to those of the first deleted character rather
than those of the character preceding the deleted range.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@30055 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
wlux 2010-03-27 21:41:29 +00:00
parent 21b251d643
commit d0a7bfda42
3 changed files with 25 additions and 1 deletions

View file

@ -1,5 +1,14 @@
2010-03-27 Wolfgang Lux <wolfgang.lux@gmail.com> 2010-03-27 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSTextView.m (-setSelectedRange:affinity:stillSelecting:):
* Source/NSTextView_actions.m (-deleteForward:, -deleteBackward:,
-deleteToEndOfLine:): Usability improvements: When setting the
cursor to the beginning of a line, set the typing attributes to
the attributes of the first character of that line rather than the
preceding newline. When deleting text, set the typing attributes
to those of the first deleted character rather than those of the
character preceding the deleted range.
* Source/NSTextView.m (-mouseDown:): Allow shift-clicking to * Source/NSTextView.m (-mouseDown:): Allow shift-clicking to
shrink the current selection. Comes handy when you accidentally shrink the current selection. Comes handy when you accidentally
select a few characters too much. select a few characters too much.

View file

@ -3597,7 +3597,9 @@ afterString in order over charRange.
{ {
NSDictionary *dict; NSDictionary *dict;
if (charRange.location > 0) if (charRange.location > 0 &&
[[_textStorage string] characterAtIndex:
(charRange.location - 1)] != '\n')
{ {
/* If the insertion point is after a bold word, for /* If the insertion point is after a bold word, for
example, we need to use bold for further example, we need to use bold for further

View file

@ -569,6 +569,7 @@ static NSNumber *float_plus_one(NSNumber *cur)
- (void) deleteForward: (id)sender - (void) deleteForward: (id)sender
{ {
NSRange range = [self rangeForUserTextChange]; NSRange range = [self rangeForUserTextChange];
NSDictionary *attributes;
if (range.location == NSNotFound) if (range.location == NSNotFound)
{ {
@ -603,15 +604,20 @@ static NSNumber *float_plus_one(NSNumber *cur)
return; return;
} }
attributes = RETAIN([_textStorage attributesAtIndex: range.location
effectiveRange: NULL]);
[_textStorage beginEditing]; [_textStorage beginEditing];
[_textStorage deleteCharactersInRange: range]; [_textStorage deleteCharactersInRange: range];
[_textStorage endEditing]; [_textStorage endEditing];
[self setTypingAttributes: attributes];
RELEASE(attributes);
[self didChangeText]; [self didChangeText];
} }
- (void) deleteBackward: (id)sender - (void) deleteBackward: (id)sender
{ {
NSRange range = [self rangeForUserTextChange]; NSRange range = [self rangeForUserTextChange];
NSDictionary *attributes;
if (range.location == NSNotFound) if (range.location == NSNotFound)
{ {
@ -647,6 +653,8 @@ static NSNumber *float_plus_one(NSNumber *cur)
return; return;
} }
attributes = RETAIN([_textStorage attributesAtIndex: range.location
effectiveRange: NULL]);
[_textStorage beginEditing]; [_textStorage beginEditing];
[_textStorage deleteCharactersInRange: range]; [_textStorage deleteCharactersInRange: range];
[_textStorage endEditing]; [_textStorage endEditing];
@ -659,6 +667,7 @@ static NSNumber *float_plus_one(NSNumber *cur)
NSRange linerange; NSRange linerange;
unsigned maxRange; unsigned maxRange;
unsigned endCorrection = 0; unsigned endCorrection = 0;
NSDictionary *attributes;
if (range.location == NSNotFound) if (range.location == NSNotFound)
{ {
@ -704,9 +713,13 @@ static NSNumber *float_plus_one(NSNumber *cur)
} }
ASSIGN(killBuffer, [[_textStorage string] substringWithRange: range]); ASSIGN(killBuffer, [[_textStorage string] substringWithRange: range]);
attributes = RETAIN([_textStorage attributesAtIndex: range.location
effectiveRange: NULL]);
[_textStorage beginEditing]; [_textStorage beginEditing];
[_textStorage deleteCharactersInRange: range]; [_textStorage deleteCharactersInRange: range];
[_textStorage endEditing]; [_textStorage endEditing];
[self setTypingAttributes: attributes];
RELEASE(attributes);
[self didChangeText]; [self didChangeText];
} }