From b0b7933ee7fb52833ec82118e00a6c085b4a4237 Mon Sep 17 00:00:00 2001 From: Siarzhuk Zharski Date: Thu, 7 Feb 2013 22:49:57 +0100 Subject: [PATCH] Use stack for storing saved cursor positions That fixes issue with latest versions of Midnight Commander - it "restores" on exit the latest postion was set, that is equal to 0.0. --- src/apps/terminal/BasicTerminalBuffer.cpp | 8 ++++++-- src/apps/terminal/BasicTerminalBuffer.h | 3 ++- src/apps/terminal/Jamfile | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) 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 ;