From ff6f3ceb3c8fbe408ac6d94ec2ed7acced0d094f Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Sat, 11 Dec 2004 08:27:49 +0000 Subject: [PATCH] Line wrapping was done a character off. Added 1 to the line origins calculation.Lines have now the same height of the be's version. Note that this last change made some visual glitches appear again when selecting. Need to research that. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10386 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/BTextView/TextView.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/kits/interface/BTextView/TextView.cpp b/src/kits/interface/BTextView/TextView.cpp index 8d42e639ab..1f6900de10 100644 --- a/src/kits/interface/BTextView/TextView.cpp +++ b/src/kits/interface/BTextView/TextView.cpp @@ -3331,13 +3331,13 @@ BTextView::RecalculateLineBreaks(int32 *startLine, int32 *endLine) // the new line comes before the old line start, add a line STELine newLine; newLine.offset = toOffset; - newLine.origin = ceil(curLine->origin + ascent + descent); + newLine.origin = ceil(curLine->origin + ascent + descent) + 1; newLine.ascent = 0; fLines->InsertLine(&newLine, lineIndex); } else { // update the exising line nextLine->offset = toOffset; - nextLine->origin = ceil(curLine->origin + ascent + descent); + nextLine->origin = ceil(curLine->origin + ascent + descent) + 1; // remove any lines that start before the current line while ( lineIndex < fLines->NumLines() && @@ -3537,11 +3537,13 @@ BTextView::FindLineBreak(int32 fromOffset, float *outAscent, strWidth = 0.0; int32 current = fromOffset; - for (offset = fromOffset; offset < limit; current = offset, offset = NextInitialByte(offset)) { + for (offset = fromOffset; offset <= limit; current = offset, offset = NextInitialByte(offset)) { strWidth += StyledWidth(current, offset - current, &ascent, &descent); - if (strWidth >= *ioWidth) + if (strWidth >= *ioWidth) { + offset = PreviousInitialByte(offset); break; + } *outAscent = max_c(ascent, *outAscent); *outDescent = max_c(descent, *outDescent);