If line breaks have changed, don't take the startOffset into account. Fixes bug #1430
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22095 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -3038,12 +3038,13 @@ BTextView::HandleAlphaKey(const char *bytes, int32 numBytes)
|
|||||||
undoBuffer->InputCharacter(numBytes);
|
undoBuffer->InputCharacter(numBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool refresh = fSelStart != fText->Length();
|
bool erase = fSelStart != fText->Length();
|
||||||
|
int32 saveStart = fSelStart;
|
||||||
|
|
||||||
if (fSelStart != fSelEnd) {
|
if (fSelStart != fSelEnd) {
|
||||||
Highlight(fSelStart, fSelEnd);
|
Highlight(fSelStart, fSelEnd);
|
||||||
DeleteText(fSelStart, fSelEnd);
|
DeleteText(fSelStart, fSelEnd);
|
||||||
refresh = true;
|
erase = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fAutoindent && numBytes == 1 && *bytes == B_ENTER) {
|
if (fAutoindent && numBytes == 1 && *bytes == B_ENTER) {
|
||||||
@@ -3063,11 +3064,10 @@ BTextView::HandleAlphaKey(const char *bytes, int32 numBytes)
|
|||||||
} else
|
} else
|
||||||
InsertText(bytes, numBytes, fSelStart, NULL);
|
InsertText(bytes, numBytes, fSelStart, NULL);
|
||||||
|
|
||||||
int32 saveStart = fSelStart;
|
|
||||||
fClickOffset = fSelEnd = fSelStart = fSelStart + numBytes;
|
fClickOffset = fSelEnd = fSelStart = fSelStart + numBytes;
|
||||||
|
|
||||||
if (Window())
|
if (Window())
|
||||||
Refresh(saveStart, fSelEnd, refresh, true);
|
Refresh(saveStart, fSelEnd, erase, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3082,6 +3082,8 @@ BTextView::HandleAlphaKey(const char *bytes, int32 numBytes)
|
|||||||
void
|
void
|
||||||
BTextView::Refresh(int32 fromOffset, int32 toOffset, bool erase, bool scroll)
|
BTextView::Refresh(int32 fromOffset, int32 toOffset, bool erase, bool scroll)
|
||||||
{
|
{
|
||||||
|
PRINT(("Refresh(fromOffset: %ld, toOffset: %ld, erase: %d, scroll: %d\n",
|
||||||
|
fromOffset, toOffset, erase, scroll));
|
||||||
// TODO: Cleanup
|
// TODO: Cleanup
|
||||||
float saveHeight = fTextRect.Height();
|
float saveHeight = fTextRect.Height();
|
||||||
int32 fromLine = LineAt(fromOffset);
|
int32 fromLine = LineAt(fromOffset);
|
||||||
@@ -3101,8 +3103,10 @@ BTextView::Refresh(int32 fromOffset, int32 toOffset, bool erase, bool scroll)
|
|||||||
|
|
||||||
// if the line breaks have changed, force an erase
|
// if the line breaks have changed, force an erase
|
||||||
if (fromLine != saveFromLine || toLine != saveToLine
|
if (fromLine != saveFromLine || toLine != saveToLine
|
||||||
|| newHeight != saveHeight )
|
|| newHeight != saveHeight ) {
|
||||||
erase = true;
|
erase = true;
|
||||||
|
fromOffset = -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (newHeight != saveHeight) {
|
if (newHeight != saveHeight) {
|
||||||
// the text area has changed
|
// the text area has changed
|
||||||
@@ -3177,7 +3181,7 @@ BTextView::RecalculateLineBreaks(int32 *startLine, int32 *endLine)
|
|||||||
|
|
||||||
lineIndex++;
|
lineIndex++;
|
||||||
STELine saveLine = *nextLine;
|
STELine saveLine = *nextLine;
|
||||||
if ( lineIndex > fLines->NumLines() ||
|
if (lineIndex > fLines->NumLines() ||
|
||||||
toOffset < nextLine->offset ) {
|
toOffset < nextLine->offset ) {
|
||||||
// the new line comes before the old line start, add a line
|
// the new line comes before the old line start, add a line
|
||||||
STELine newLine;
|
STELine newLine;
|
||||||
@@ -3526,7 +3530,9 @@ BTextView::_DrawLine(BView *view, const int32 &lineNum, const int32 &startOffset
|
|||||||
startLeft /= 2;
|
startLeft /= 2;
|
||||||
startLeft += fTextRect.left;
|
startLeft += fTextRect.left;
|
||||||
}
|
}
|
||||||
|
|
||||||
view->MovePenTo(startLeft, line->origin + line->ascent + fTextRect.top + 1);
|
view->MovePenTo(startLeft, line->origin + line->ascent + fTextRect.top + 1);
|
||||||
|
|
||||||
if (erase) {
|
if (erase) {
|
||||||
eraseRect.top = line->origin + fTextRect.top;
|
eraseRect.top = line->origin + fTextRect.top;
|
||||||
eraseRect.bottom = (line + 1)->origin + fTextRect.top;
|
eraseRect.bottom = (line + 1)->origin + fTextRect.top;
|
||||||
@@ -3616,6 +3622,9 @@ BTextView::DrawLines(int32 startLine, int32 endLine, int32 startOffset, bool era
|
|||||||
if (!Window())
|
if (!Window())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
PRINT(("DrawLines(startLine: %ld, endLine: %ld, startOffset: %ld, erase: %d\n",
|
||||||
|
startLine, endLine, startOffset, erase));
|
||||||
|
|
||||||
// clip the text
|
// clip the text
|
||||||
BRect clipRect = Bounds() & fTextRect;
|
BRect clipRect = Bounds() & fTextRect;
|
||||||
clipRect.InsetBy(-1, -1);
|
clipRect.InsetBy(-1, -1);
|
||||||
@@ -3655,10 +3664,11 @@ BTextView::DrawLines(int32 startLine, int32 endLine, int32 startOffset, bool era
|
|||||||
BRect eraseRect = clipRect;
|
BRect eraseRect = clipRect;
|
||||||
int32 startEraseLine = startLine;
|
int32 startEraseLine = startLine;
|
||||||
STELine* line = (*fLines)[startLine];
|
STELine* line = (*fLines)[startLine];
|
||||||
|
|
||||||
if (erase && startOffset != -1 && fAlignment == B_ALIGN_LEFT) {
|
if (erase && startOffset != -1 && fAlignment == B_ALIGN_LEFT) {
|
||||||
// erase only to the right of startOffset
|
// erase only to the right of startOffset
|
||||||
startEraseLine++;
|
startEraseLine++;
|
||||||
long startErase = startOffset;
|
int32 startErase = startOffset;
|
||||||
|
|
||||||
BPoint erasePoint = PointAt(startErase);
|
BPoint erasePoint = PointAt(startErase);
|
||||||
eraseRect.left = erasePoint.x;
|
eraseRect.left = erasePoint.x;
|
||||||
|
|||||||
Reference in New Issue
Block a user