Fix issue where the insertion point was not placed in an empty last

line of a text view when clicking with the mouse.
Fix issue where the insertion point was not placed in an empty last
line when using the down arrow key (bug #15893).
Fix issue where the insertion point was placed incorrectly if the last
line of a text view ends in an invisible character (e.g., a tab).


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29584 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
wlux 2010-02-12 15:27:02 +00:00
parent 414b85653e
commit f61bf18e28
3 changed files with 43 additions and 2 deletions

View file

@ -802,7 +802,7 @@ has the same y origin and height as the line frag rect it is in.
if (extra_textcontainer)
{
for (tc = textcontainers, i = 0; i < num_textcontainers; i++, tc++)
if (tc == textcontainers)
if (tc->textContainer == extra_textcontainer)
break;
NSAssert(i < num_textcontainers, @"invalid extraTextContainer");
*textContainer = i;
@ -821,8 +821,9 @@ has the same y origin and height as the line frag rect it is in.
}
fraction_through = 1.0;
}
else
[self _doLayoutToGlyph: glyph_index];
[self _doLayoutToGlyph: glyph_index];
for (tc = textcontainers, i = 0; i < num_textcontainers; i++, tc++)
if (tc->pos + tc->length > glyph_index)
break;
@ -836,6 +837,20 @@ has the same y origin and height as the line frag rect it is in.
LINEFRAG_FOR_GLYPH(glyph_index);
/* Special case if we are asked for the insertion point rectangle at the
end of text, since the standard code yields an incorrect result if the
last line fragment ends with an invisible character (e.g., a tab).
Note that fraction_through is always less than 1 except when
-_glyphIndexForCharacterIndex:fractionThrough: is called for
cindex == [_textStorage length], in which case we set it to 1. */
if (fraction_through == 1.0)
{
r = lf->used_rect;
r.origin.x += r.size.width;
r.size.width = 1;
return r;
}
{
unsigned int i;
int j;
@ -1023,6 +1038,12 @@ has the same y origin and height as the line frag rect it is in.
if (i == tc->num_linefrags)
{
/* Special case for moving into the extra line at the end */
if (tc->textContainer == extra_textcontainer &&
NSMaxY(extra_rect) >= distance + NSMaxY(from_rect) &&
NSMinY(extra_rect) != NSMinY(from_rect))
return length;
/* We can't move as far as we want to. In fact, we might not
have been able to move at all.
TODO: figure out how to handle this