diff --git a/Terminal/Terminal.cpp b/Terminal/Terminal.cpp index 4d0c8aae6e..0fd39e7c25 100644 --- a/Terminal/Terminal.cpp +++ b/Terminal/Terminal.cpp @@ -75,10 +75,22 @@ Terminal::Line::~Line() void Terminal::Line::clear(Attribute attribute) { - dirty = true; - memset(characters, ' ', length); - for (word i = 0 ; i < length; ++i) + if (dirty) { + memset(characters, ' ', length); + for (word i = 0 ; i < length; ++i) + attributes[i] = attribute; + return; + } + for (unsigned i = 0 ; i < length; ++i) { + if (characters[i] != ' ') + dirty = true; + characters[i] = ' '; + } + for (unsigned i = 0 ; i < length; ++i) { + if (attributes[i] != attribute) + dirty = true; attributes[i] = attribute; + } } Terminal::~Terminal() diff --git a/Terminal/Terminal.h b/Terminal/Terminal.h index 5a81b410c9..e5e7d81f34 100644 --- a/Terminal/Terminal.h +++ b/Terminal/Terminal.h @@ -70,6 +70,10 @@ private: { return foreground_color == other.foreground_color && background_color == other.background_color; } + bool operator!=(const Attribute& other) const + { + return !(*this == other); + } }; struct Line {