From d0a7bfda42b97476542ef48b1ae688723999ba0d Mon Sep 17 00:00:00 2001 From: wlux Date: Sat, 27 Mar 2010 21:41:29 +0000 Subject: [PATCH] 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 --- ChangeLog | 9 +++++++++ Source/NSTextView.m | 4 +++- Source/NSTextView_actions.m | 13 +++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7a5844903..383c75b79 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2010-03-27 Wolfgang Lux + * 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 shrink the current selection. Comes handy when you accidentally select a few characters too much. diff --git a/Source/NSTextView.m b/Source/NSTextView.m index eb25111b5..1393787f2 100644 --- a/Source/NSTextView.m +++ b/Source/NSTextView.m @@ -3597,7 +3597,9 @@ afterString in order over charRange. { 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 example, we need to use bold for further diff --git a/Source/NSTextView_actions.m b/Source/NSTextView_actions.m index 378e70114..5a0e05717 100644 --- a/Source/NSTextView_actions.m +++ b/Source/NSTextView_actions.m @@ -569,6 +569,7 @@ static NSNumber *float_plus_one(NSNumber *cur) - (void) deleteForward: (id)sender { NSRange range = [self rangeForUserTextChange]; + NSDictionary *attributes; if (range.location == NSNotFound) { @@ -603,15 +604,20 @@ static NSNumber *float_plus_one(NSNumber *cur) return; } + attributes = RETAIN([_textStorage attributesAtIndex: range.location + effectiveRange: NULL]); [_textStorage beginEditing]; [_textStorage deleteCharactersInRange: range]; [_textStorage endEditing]; + [self setTypingAttributes: attributes]; + RELEASE(attributes); [self didChangeText]; } - (void) deleteBackward: (id)sender { NSRange range = [self rangeForUserTextChange]; + NSDictionary *attributes; if (range.location == NSNotFound) { @@ -647,6 +653,8 @@ static NSNumber *float_plus_one(NSNumber *cur) return; } + attributes = RETAIN([_textStorage attributesAtIndex: range.location + effectiveRange: NULL]); [_textStorage beginEditing]; [_textStorage deleteCharactersInRange: range]; [_textStorage endEditing]; @@ -659,6 +667,7 @@ static NSNumber *float_plus_one(NSNumber *cur) NSRange linerange; unsigned maxRange; unsigned endCorrection = 0; + NSDictionary *attributes; if (range.location == NSNotFound) { @@ -704,9 +713,13 @@ static NSNumber *float_plus_one(NSNumber *cur) } ASSIGN(killBuffer, [[_textStorage string] substringWithRange: range]); + attributes = RETAIN([_textStorage attributesAtIndex: range.location + effectiveRange: NULL]); [_textStorage beginEditing]; [_textStorage deleteCharactersInRange: range]; [_textStorage endEditing]; + [self setTypingAttributes: attributes]; + RELEASE(attributes); [self didChangeText]; }