mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 22:10:47 +00:00
Implemented [moveToBeginningOfParagraph:] and [moveToEndOfParagraph:].
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@12858 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e8ae30faea
commit
b4e4e22052
1 changed files with 48 additions and 0 deletions
|
@ -2664,6 +2664,14 @@ afterString in order over charRange. */
|
||||||
[self setSelectedRange: NSMakeRange (0, 0)];
|
[self setSelectedRange: NSMakeRange (0, 0)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) moveToBeginningOfParagraph: (id)sender
|
||||||
|
{
|
||||||
|
NSRange aRange;
|
||||||
|
|
||||||
|
aRange = [[_textStorage string] lineRangeForRange: _selected_range];
|
||||||
|
[self setSelectedRange: NSMakeRange (aRange.location, 0)];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) moveToBeginningOfLine: (id)sender
|
- (void) moveToBeginningOfLine: (id)sender
|
||||||
{
|
{
|
||||||
NSRange aRange;
|
NSRange aRange;
|
||||||
|
@ -2696,6 +2704,46 @@ afterString in order over charRange. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) moveToEndOfParagraph: (id)sender
|
||||||
|
{
|
||||||
|
NSRange aRange;
|
||||||
|
unsigned newLocation;
|
||||||
|
unsigned maxRange;
|
||||||
|
|
||||||
|
aRange = [[_textStorage string] lineRangeForRange: _selected_range];
|
||||||
|
maxRange = NSMaxRange (aRange);
|
||||||
|
|
||||||
|
if (maxRange == [_textStorage length])
|
||||||
|
{
|
||||||
|
/* End of text is special - we want the insertion point to
|
||||||
|
appear *after* the last character, which means as if before
|
||||||
|
the next (virtual) character after the end of text. */
|
||||||
|
//FIXME This is only true if the last character is not newline!
|
||||||
|
newLocation = maxRange;
|
||||||
|
}
|
||||||
|
else if (maxRange == 0)
|
||||||
|
{
|
||||||
|
/* Beginning of text is special only for technical reasons -
|
||||||
|
since maxRange is an unsigned, we can't safely subtract 1
|
||||||
|
from it if it is 0. */
|
||||||
|
newLocation = maxRange;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Else, we want the insertion point to appear before the last
|
||||||
|
character in the paragraph range. Normally the last character in
|
||||||
|
the paragraph range is a newline. */
|
||||||
|
newLocation = maxRange - 1;
|
||||||
|
|
||||||
|
if (newLocation < aRange.location)
|
||||||
|
{
|
||||||
|
newLocation = aRange.location;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[self setSelectedRange: NSMakeRange (newLocation, 0) ];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) moveToEndOfLine: (id)sender
|
- (void) moveToEndOfLine: (id)sender
|
||||||
{
|
{
|
||||||
NSRect ignored;
|
NSRect ignored;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue