BTextView::OffsetAt() wasn't working with TAB charachters. Fixes bug 249
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16597 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1778,9 +1778,8 @@ BTextView::OffsetAt(BPoint point) const
|
|||||||
point.x -= fTextRect.left;
|
point.x -= fTextRect.left;
|
||||||
point.x = max_c(point.x, 0.0);
|
point.x = max_c(point.x, 0.0);
|
||||||
|
|
||||||
// TODO: The following code chokes on TABs.
|
// TODO: The following isn't efficient like the part after the #else,
|
||||||
// we should do something like the part after the #else, but
|
// but it's multi-byte characters safe.
|
||||||
// multi-byte characters safe.
|
|
||||||
#if 1
|
#if 1
|
||||||
int32 offset = line->offset;
|
int32 offset = line->offset;
|
||||||
int32 limit = (line + 1)->offset;
|
int32 limit = (line + 1)->offset;
|
||||||
@@ -1789,7 +1788,11 @@ BTextView::OffsetAt(BPoint point) const
|
|||||||
do {
|
do {
|
||||||
saveOffset = offset;
|
saveOffset = offset;
|
||||||
int32 nextInitial = NextInitialByte(offset);
|
int32 nextInitial = NextInitialByte(offset);
|
||||||
float width = StyledWidth(saveOffset, nextInitial - saveOffset);
|
float width = 0;
|
||||||
|
if (ByteAt(offset) == B_TAB)
|
||||||
|
width = ActualTabWidth(offset);
|
||||||
|
else
|
||||||
|
width = StyledWidth(saveOffset, nextInitial - saveOffset);
|
||||||
if (x + width > point.x) {
|
if (x + width > point.x) {
|
||||||
if (fabs(x + width - point.x) < fabs(x - point.x))
|
if (fabs(x + width - point.x) < fabs(x - point.x))
|
||||||
offset = nextInitial;
|
offset = nextInitial;
|
||||||
|
|||||||
Reference in New Issue
Block a user