diff --git a/src/apps/terminal/BasicTerminalBuffer.cpp b/src/apps/terminal/BasicTerminalBuffer.cpp index fd765a5fca..7929b3c50d 100644 --- a/src/apps/terminal/BasicTerminalBuffer.cpp +++ b/src/apps/terminal/BasicTerminalBuffer.cpp @@ -628,10 +628,39 @@ BasicTerminalBuffer::InsertSpace(int32 num) } +void +BasicTerminalBuffer::EraseAbove() +{ + // Clear the preceding lines. + if (fCursor.y > 0) + _ClearLines(0, fCursor.y - 1); + + // Delete the chars on the cursor line before (and including) the cursor. + TerminalLine* line = _LineAt(fCursor.y); + if (fCursor.x < line->length) { + int32 to = fCursor.x; + if (IS_WIDTH(line->cells[fCursor.x].attributes)) + to++; + for (int32 i = 0; i <= to; i++) { + line->cells[i].attributes = 0; + line->cells[i].character = kSpaceChar; + } + } else + line->Clear(); + + _Invalidate(fCursor.y, fCursor.y); +} + + void BasicTerminalBuffer::EraseBelow() { - _Scroll(fCursor.y, fHeight - 1, fHeight); + // Clear the following lines. + if (fCursor.y < fHeight - 1) + _ClearLines(fCursor.y + 1, fHeight - 1); + + // Delete the chars on the cursor line after (and including) the cursor. + DeleteColumns(); } @@ -1146,6 +1175,14 @@ BasicTerminalBuffer::_Scroll(int32 top, int32 bottom, int32 numLines) // invalidate new empty lines _Invalidate(bottom + 1 - numLines, bottom); + + // In case only part of the screen was scrolled, we invalidate also + // the lines below the scroll region. Those remain unchanged, but + // we can't convey that they have not been scrolled via + // TerminalBufferDirtyInfo. So we need to force the view to sync + // them again. + if (bottom < fHeight - 1) + _Invalidate(bottom + 1, fHeight - 1); } else if (numLines >= bottom - top + 1) { // all lines are completely scrolled out of range -- just clear // them diff --git a/src/apps/terminal/BasicTerminalBuffer.h b/src/apps/terminal/BasicTerminalBuffer.h index 2bbcfc2814..8137b543c8 100644 --- a/src/apps/terminal/BasicTerminalBuffer.h +++ b/src/apps/terminal/BasicTerminalBuffer.h @@ -104,6 +104,7 @@ public: void InsertLines(int32 numLines); // delete chars/lines + void EraseAbove(); void EraseBelow(); void DeleteChars(int32 numChars); void DeleteColumns(); diff --git a/src/apps/terminal/TermParse.cpp b/src/apps/terminal/TermParse.cpp index 2ac2a7f4f6..738df89f32 100644 --- a/src/apps/terminal/TermParse.cpp +++ b/src/apps/terminal/TermParse.cpp @@ -630,11 +630,12 @@ TermParse::EscParse() break; case 1: + fBuffer->EraseAbove(); break; case 2: - fBuffer->SetCursor(0, 0); fBuffer->EraseBelow(); + fBuffer->EraseAbove(); break; } parsestate = groundtable;