diff --git a/src/apps/terminal/BasicTerminalBuffer.cpp b/src/apps/terminal/BasicTerminalBuffer.cpp index e70c2098c5..4f403df766 100644 --- a/src/apps/terminal/BasicTerminalBuffer.cpp +++ b/src/apps/terminal/BasicTerminalBuffer.cpp @@ -176,6 +176,8 @@ BasicTerminalBuffer::Init(int32 width, int32 height, int32 historySize) fDirtyInfo.Reset(); + fSavedCursors.push(TermPos(0, 0)); + return B_OK; } @@ -923,14 +925,16 @@ BasicTerminalBuffer::DeleteLines(int32 numLines) void BasicTerminalBuffer::SaveCursor() { - fSavedCursor = fCursor; + fSavedCursors.push(fCursor); } void BasicTerminalBuffer::RestoreCursor() { - _SetCursor(fSavedCursor.x, fSavedCursor.y, true); + _SetCursor(fSavedCursors.top().x, fSavedCursors.top().y, true); + if (fSavedCursors.size() > 1) + fSavedCursors.pop(); } diff --git a/src/apps/terminal/BasicTerminalBuffer.h b/src/apps/terminal/BasicTerminalBuffer.h index e84847afa4..c5300d5aee 100644 --- a/src/apps/terminal/BasicTerminalBuffer.h +++ b/src/apps/terminal/BasicTerminalBuffer.h @@ -6,6 +6,7 @@ #define BASIC_TERMINAL_BUFFER_H #include +#include #include "HistoryBuffer.h" #include "TermPos.h" @@ -223,7 +224,7 @@ protected: // cursor position (origin: (0, 0)) TermPos fCursor; - TermPos fSavedCursor; + std::stack fSavedCursors; bool fSoftWrappedCursor; bool fOverwriteMode; // false for insert diff --git a/src/apps/terminal/Jamfile b/src/apps/terminal/Jamfile index 31b0b4b4b8..c8a114e927 100644 --- a/src/apps/terminal/Jamfile +++ b/src/apps/terminal/Jamfile @@ -37,7 +37,8 @@ Application Terminal : TitlePlaceholderMapper.cpp VTKeyTbl.c VTPrsTbl.c - : be $(HAIKU_LOCALE_LIBS) tracker textencoding $(TARGET_LIBSUPC++) + : be $(HAIKU_LOCALE_LIBS) tracker textencoding + $(TARGET_LIBSUPC++) $(TARGET_LIBSTDC++) : Terminal.rdef XColors.rdef ;