From 5d2d3a845c58cd135301bae1307faaddea7f4521 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Tue, 17 Jun 2008 01:44:10 +0000 Subject: [PATCH] * Fixed \ESC[0J (erase screen below). It shall not erase any character on the line before the cursor. * Implemented \ESC[1J (erase screen above. * Fixed \ESC[2J (erase all). It shall not move the cursor. * When scrolling only the top part of the screen, we do now also invalidate the line below the scroll region. Otherwise the view wouldn't know that they have not been scrolled. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25986 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/terminal/BasicTerminalBuffer.cpp | 39 ++++++++++++++++++++++- src/apps/terminal/BasicTerminalBuffer.h | 1 + src/apps/terminal/TermParse.cpp | 3 +- 3 files changed, 41 insertions(+), 2 deletions(-) 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;