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.
This commit is contained in:
Siarzhuk Zharski 2013-03-16 11:19:20 +01:00
parent 13d0439623
commit 1dd3b537c3
6 changed files with 7 additions and 37 deletions

View File

@ -113,7 +113,6 @@ BasicTerminalBuffer::BasicTerminalBuffer()
fScreenOffset(0),
fHistory(NULL),
fAttributes(0),
fSavedAttributes(0),
fSoftWrappedCursor(false),
fOverwriteMode(false),
fAlternateScreenActive(false),

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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);

View File

@ -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;
}

View File

@ -69,6 +69,7 @@ private:
TerminalLine** fAlternateScreen;
HistoryBuffer* fAlternateHistory;
int32 fAlternateScreenOffset;
uint32 fAlternateAttributes;
rgb_color* fColorsPalette;
// listener/dirty region management