diff --git a/src/apps/terminal/HistoryBuffer.cpp b/src/apps/terminal/HistoryBuffer.cpp index 2a85e4823c..c947f8ab61 100644 --- a/src/apps/terminal/HistoryBuffer.cpp +++ b/src/apps/terminal/HistoryBuffer.cpp @@ -146,8 +146,10 @@ HistoryBuffer::AddLine(const TerminalLine* line) for (int32 i = 0; i < line->length; i++) { const TerminalCell& cell = line->cells[i]; byteLength += cell.character.ByteCount(); - if ((cell.attributes.state & CHAR_ATTRIBUTES) != attributes.state) { + if (cell != attributes) { attributes.state = cell.attributes.state & CHAR_ATTRIBUTES; + attributes.foreground = cell.attributes.foreground; + attributes.background = cell.attributes.background; if (attributes.state != 0) attributesRuns++; } @@ -173,7 +175,7 @@ HistoryBuffer::AddLine(const TerminalLine* line) chars += charLength; // deal with attributes - if ((cell.attributes.state & CHAR_ATTRIBUTES) != attributes.state) { + if (cell != attributes) { // terminate the previous attributes run if (attributes.state != 0) { attributesRun->length = i - attributesRun->offset; @@ -181,6 +183,8 @@ HistoryBuffer::AddLine(const TerminalLine* line) } attributes.state = cell.attributes.state & CHAR_ATTRIBUTES; + attributes.foreground = cell.attributes.foreground; + attributes.background = cell.attributes.background; // init the new one if (attributes.state != 0) { diff --git a/src/apps/terminal/TerminalLine.h b/src/apps/terminal/TerminalLine.h index abdc25a276..0f5e5cfa49 100644 --- a/src/apps/terminal/TerminalLine.h +++ b/src/apps/terminal/TerminalLine.h @@ -134,6 +134,15 @@ struct Attributes { struct TerminalCell { UTF8Char character; Attributes attributes; + + inline bool + operator!=(const Attributes& other) const + { + return (attributes.state & CHAR_ATTRIBUTES) + != (other.state & CHAR_ATTRIBUTES) + || attributes.foreground != other.foreground + || attributes.background != other.background; + } };