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.
This commit is contained in:
Siarzhuk Zharski
2013-03-14 07:44:45 +00:00
parent 73d0eee58c
commit b0b7933ee7
3 changed files with 10 additions and 4 deletions
+6 -2
View File
@@ -176,6 +176,8 @@ BasicTerminalBuffer::Init(int32 width, int32 height, int32 historySize)
fDirtyInfo.Reset(); fDirtyInfo.Reset();
fSavedCursors.push(TermPos(0, 0));
return B_OK; return B_OK;
} }
@@ -923,14 +925,16 @@ BasicTerminalBuffer::DeleteLines(int32 numLines)
void void
BasicTerminalBuffer::SaveCursor() BasicTerminalBuffer::SaveCursor()
{ {
fSavedCursor = fCursor; fSavedCursors.push(fCursor);
} }
void void
BasicTerminalBuffer::RestoreCursor() BasicTerminalBuffer::RestoreCursor()
{ {
_SetCursor(fSavedCursor.x, fSavedCursor.y, true); _SetCursor(fSavedCursors.top().x, fSavedCursors.top().y, true);
if (fSavedCursors.size() > 1)
fSavedCursors.pop();
} }
+2 -1
View File
@@ -6,6 +6,7 @@
#define BASIC_TERMINAL_BUFFER_H #define BASIC_TERMINAL_BUFFER_H
#include <limits.h> #include <limits.h>
#include <stack>
#include "HistoryBuffer.h" #include "HistoryBuffer.h"
#include "TermPos.h" #include "TermPos.h"
@@ -223,7 +224,7 @@ protected:
// cursor position (origin: (0, 0)) // cursor position (origin: (0, 0))
TermPos fCursor; TermPos fCursor;
TermPos fSavedCursor; std::stack<TermPos> fSavedCursors;
bool fSoftWrappedCursor; bool fSoftWrappedCursor;
bool fOverwriteMode; // false for insert bool fOverwriteMode; // false for insert
+2 -1
View File
@@ -37,7 +37,8 @@ Application Terminal :
TitlePlaceholderMapper.cpp TitlePlaceholderMapper.cpp
VTKeyTbl.c VTKeyTbl.c
VTPrsTbl.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 : Terminal.rdef XColors.rdef
; ;