mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
Implement NSTextView -deleteToEndOfParagraph:, which was introduced in
OS X 10.3. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33378 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
251ee4d491
commit
ed3c950428
2 changed files with 57 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
2011-06-26 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/NSTextView_actions.m (-deleteToEndOfParagraph:):
|
||||
Implement method, which was introduced in OS X 10.3.
|
||||
|
||||
2011-06-26 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/NSTextView_actions.m (-deleteToEndOfLine:): Fix
|
||||
|
|
|
@ -725,6 +725,58 @@ static NSNumber *float_plus_one(NSNumber *cur)
|
|||
[self didChangeText];
|
||||
}
|
||||
|
||||
- (void) deleteToEndOfParagraph: (id)sender
|
||||
{
|
||||
NSRange range = [self rangeForUserTextChange];
|
||||
NSDictionary *attributes;
|
||||
|
||||
if (range.location == NSNotFound)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* If the selection is not empty delete it, otherwise delete up to
|
||||
the next paragraph end from the insertion point or the delete the
|
||||
paragraph end itself when the insertion point is already at the
|
||||
end of the paragraph. */
|
||||
if (range.length == 0)
|
||||
{
|
||||
NSUInteger start, end, contentsEnd;
|
||||
|
||||
[[_textStorage string] getParagraphStart: &start
|
||||
end: &end
|
||||
contentsEnd: &contentsEnd
|
||||
forRange: range];
|
||||
if (range.location == contentsEnd)
|
||||
{
|
||||
range = NSMakeRange(contentsEnd, end - contentsEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
range.length = contentsEnd - range.location;
|
||||
}
|
||||
if (range.length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (![self shouldChangeTextInRange: range replacementString: @""])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
- (void) yank: (id)sender
|
||||
{
|
||||
[self insertText: killBuffer];
|
||||
|
|
Loading…
Reference in a new issue