From 0ac0b4d4a67b92b0896e6de831502d4aeed5de20 Mon Sep 17 00:00:00 2001 From: Siarzhuk Zharski Date: Sat, 16 Mar 2013 07:21:40 +0100 Subject: [PATCH] Fix Terminal cursor Save/Restore behaviour Yet another fix for the terminal cursor save/restore functionality. Fixes wrong cursor positions observed in modern versions of the Midnight Commander during switching between Alternate and Normal buffers. --- src/apps/terminal/BasicTerminalBuffer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/apps/terminal/BasicTerminalBuffer.cpp b/src/apps/terminal/BasicTerminalBuffer.cpp index 182551ef21..895fef0785 100644 --- a/src/apps/terminal/BasicTerminalBuffer.cpp +++ b/src/apps/terminal/BasicTerminalBuffer.cpp @@ -181,8 +181,6 @@ BasicTerminalBuffer::Init(int32 width, int32 height, int32 historySize) fDirtyInfo.Reset(); - fSavedCursors.push(TermPos(0, 0)); - return B_OK; } @@ -926,9 +924,11 @@ BasicTerminalBuffer::SaveCursor() void BasicTerminalBuffer::RestoreCursor() { + if (fSavedCursors.size() == 0) + return; + _SetCursor(fSavedCursors.top().x, fSavedCursors.top().y, true); - if (fSavedCursors.size() > 1) - fSavedCursors.pop(); + fSavedCursors.pop(); }