From 1dd3b537c3d9e3545d78c50cc26775174eec2051 Mon Sep 17 00:00:00 2001 From: Siarzhuk Zharski Date: Sat, 16 Mar 2013 11:19:20 +0100 Subject: [PATCH] Fix Alternate/Normal screen's current attributes handling Handle the current attributes of the TextBuffer consistently with other Alt/Normal buffer sensitive variables. That fixes, for example, issues with wrong background coloring of new lines in normal text buffer after maximizing the terminal window running applications (like MC) performing output onto alternate screen. --- src/apps/terminal/BasicTerminalBuffer.cpp | 1 - src/apps/terminal/BasicTerminalBuffer.h | 12 ----------- src/apps/terminal/TermParse.cpp | 26 ++++------------------- src/apps/terminal/TermParse.h | 2 -- src/apps/terminal/TerminalBuffer.cpp | 2 ++ src/apps/terminal/TerminalBuffer.h | 1 + 6 files changed, 7 insertions(+), 37 deletions(-) diff --git a/src/apps/terminal/BasicTerminalBuffer.cpp b/src/apps/terminal/BasicTerminalBuffer.cpp index 895fef0785..28b5b40947 100644 --- a/src/apps/terminal/BasicTerminalBuffer.cpp +++ b/src/apps/terminal/BasicTerminalBuffer.cpp @@ -113,7 +113,6 @@ BasicTerminalBuffer::BasicTerminalBuffer() fScreenOffset(0), fHistory(NULL), fAttributes(0), - fSavedAttributes(0), fSoftWrappedCursor(false), fOverwriteMode(false), fAlternateScreenActive(false), diff --git a/src/apps/terminal/BasicTerminalBuffer.h b/src/apps/terminal/BasicTerminalBuffer.h index 4275c9041f..e581c97675 100644 --- a/src/apps/terminal/BasicTerminalBuffer.h +++ b/src/apps/terminal/BasicTerminalBuffer.h @@ -114,7 +114,6 @@ public: inline uint32 GetAttributes(); inline void SetAttributes(uint32 attributes); - inline void PreserveAttributes(bool store); // snapshots and data capture for debugging void MakeLinesSnapshots(time_t timeStamp, @@ -225,7 +224,6 @@ protected: HistoryBuffer* fHistory; uint32 fAttributes; - uint32 fSavedAttributes; // cursor position (origin: (0, 0)) TermPos fCursor; @@ -274,16 +272,6 @@ BasicTerminalBuffer::SetAttributes(uint32 attributes) } -void -BasicTerminalBuffer::PreserveAttributes(bool store) -{ - if (store) - fSavedAttributes = fAttributes; - else - fAttributes = fSavedAttributes; -} - - void BasicTerminalBuffer::InsertChar(UTF8Char c) { diff --git a/src/apps/terminal/TermParse.cpp b/src/apps/terminal/TermParse.cpp index 7197ab2435..f7fc346157 100644 --- a/src/apps/terminal/TermParse.cpp +++ b/src/apps/terminal/TermParse.cpp @@ -1106,13 +1106,13 @@ TermParse::EscParse() case CASE_DECSC: /* DECSC */ - _DecSaveCursor(); + fBuffer->SaveCursor(); parsestate = groundtable; break; case CASE_DECRC: /* DECRC */ - _DecRestoreCursor(); + fBuffer->RestoreCursor(); parsestate = groundtable; break; @@ -1466,7 +1466,7 @@ TermParse::_DecPrivateModeSet(int value) case 1049: // Save cursor as in DECSC and use Alternate Screen Buffer, clearing // it first. - _DecSaveCursor(); + fBuffer->SaveCursor(); fBuffer->UseAlternateScreenBuffer(true); break; } @@ -1541,30 +1541,12 @@ TermParse::_DecPrivateModeReset(int value) case 1049: // Use Normal Screen Buffer and restore cursor as in DECRC. fBuffer->UseNormalScreenBuffer(); - _DecRestoreCursor(); + fBuffer->RestoreCursor(); break; } } -void -TermParse::_DecSaveCursor() -{ - fBuffer->SaveCursor(); - fBuffer->SaveOriginMode(); - fBuffer->PreserveAttributes(true); -} - - -void -TermParse::_DecRestoreCursor() -{ - fBuffer->RestoreCursor(); - fBuffer->RestoreOriginMode(); - fBuffer->PreserveAttributes(false); -} - - void TermParse::_ProcessOperatingSystemControls(uchar* params) { diff --git a/src/apps/terminal/TermParse.h b/src/apps/terminal/TermParse.h index 35790d36ca..a9aeb8dacd 100644 --- a/src/apps/terminal/TermParse.h +++ b/src/apps/terminal/TermParse.h @@ -61,8 +61,6 @@ private: void _DecReqTermParms(int value); void _DecPrivateModeSet(int value); void _DecPrivateModeReset(int value); - void _DecSaveCursor(); - void _DecRestoreCursor(); int* _GuessGroundTable(int encoding); void _ProcessOperatingSystemControls(uchar* params); diff --git a/src/apps/terminal/TerminalBuffer.cpp b/src/apps/terminal/TerminalBuffer.cpp index 6910f28c51..14362d1b11 100644 --- a/src/apps/terminal/TerminalBuffer.cpp +++ b/src/apps/terminal/TerminalBuffer.cpp @@ -29,6 +29,7 @@ TerminalBuffer::TerminalBuffer() fAlternateScreen(NULL), fAlternateHistory(NULL), fAlternateScreenOffset(0), + fAlternateAttributes(0), fColorsPalette(NULL), fListenerValid(false) { @@ -378,5 +379,6 @@ TerminalBuffer::_SwitchScreenBuffer() std::swap(fScreen, fAlternateScreen); std::swap(fHistory, fAlternateHistory); std::swap(fScreenOffset, fAlternateScreenOffset); + std::swap(fAttributes, fAlternateAttributes); fAlternateScreenActive = !fAlternateScreenActive; } diff --git a/src/apps/terminal/TerminalBuffer.h b/src/apps/terminal/TerminalBuffer.h index f1c7c3c06a..aa856beb6d 100644 --- a/src/apps/terminal/TerminalBuffer.h +++ b/src/apps/terminal/TerminalBuffer.h @@ -69,6 +69,7 @@ private: TerminalLine** fAlternateScreen; HistoryBuffer* fAlternateHistory; int32 fAlternateScreenOffset; + uint32 fAlternateAttributes; rgb_color* fColorsPalette; // listener/dirty region management