diff --git a/src/client.cc b/src/client.cc index 1569b860..a519c60c 100644 --- a/src/client.cc +++ b/src/client.cc @@ -88,16 +88,21 @@ void Client::change_buffer(Buffer& buffer) void Client::redraw_ifn() { - if (context().window().timestamp() != context().buffer().timestamp()) + DisplayLine mode_line = generate_mode_line(); + const bool buffer_changed = context().window().timestamp() != context().buffer().timestamp(); + if (buffer_changed or mode_line.atoms() != m_mode_line.atoms()) { - CharCoord dimensions = context().ui().dimensions(); - if (dimensions == CharCoord{0,0}) - return; - context().window().set_dimensions(dimensions); - context().window().update_display_buffer(context()); - + if (buffer_changed) + { + CharCoord dimensions = context().ui().dimensions(); + if (dimensions == CharCoord{0,0}) + return; + context().window().set_dimensions(dimensions); + context().window().update_display_buffer(context()); + } + m_mode_line = std::move(mode_line); context().ui().draw(context().window().display_buffer(), - m_status_line, generate_mode_line()); + m_status_line, m_mode_line); } context().ui().refresh(); } diff --git a/src/client.hh b/src/client.hh index 56b8504b..00ebe46d 100644 --- a/src/client.hh +++ b/src/client.hh @@ -53,6 +53,7 @@ private: InputHandler m_input_handler; DisplayLine m_status_line; + DisplayLine m_mode_line; }; } diff --git a/src/display_buffer.hh b/src/display_buffer.hh index db70d840..c0d34dda 100644 --- a/src/display_buffer.hh +++ b/src/display_buffer.hh @@ -105,6 +105,13 @@ public: void trim_end(CharCount count); void check_invariant() const; + + bool operator==(const DisplayAtom& other) const + { + return colors == other.colors or attribute == other.attribute or + content() == other.content(); + } + public: ColorPair colors = {Colors::Default, Colors::Default}; Attribute attribute = Normal;