diff --git a/src/client.cc b/src/client.cc index 09a9cff3..a77ac917 100644 --- a/src/client.cc +++ b/src/client.cc @@ -146,25 +146,29 @@ void Client::change_buffer(Buffer& buffer) void Client::redraw_ifn() { - DisplayLine mode_line = generate_mode_line(); - const bool buffer_changed = context().window().timestamp() != context().buffer().timestamp(); - const bool mode_line_changed = mode_line.atoms() != m_mode_line.atoms(); - const bool status_line_changed = m_status_line.atoms() != m_pending_status_line.atoms(); - if (buffer_changed or status_line_changed or mode_line_changed) + Face default_face = get_face("Default"); + + if (context().window().timestamp() != context().buffer().timestamp()) + { + CharCoord dimensions = context().ui().dimensions(); + if (dimensions == CharCoord{0,0}) + return; + context().window().set_dimensions(dimensions); + context().window().update_display_buffer(context()); + + context().ui().draw(context().window().display_buffer(), default_face); + } + + DisplayLine mode_line = generate_mode_line(); + if (m_status_line.atoms() != m_pending_status_line.atoms() or + mode_line.atoms() != m_mode_line.atoms()) { - 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); m_status_line = m_pending_status_line; - context().ui().draw(context().window().display_buffer(), - m_status_line, m_mode_line); + + context().ui().draw_status(m_status_line, m_mode_line, default_face); } + context().ui().refresh(); } diff --git a/src/display_buffer.hh b/src/display_buffer.hh index 9d264279..35381058 100644 --- a/src/display_buffer.hh +++ b/src/display_buffer.hh @@ -149,13 +149,9 @@ public: void optimize(); void compute_range(); - void set_default_face(const Face& face) { m_default_face = face; } - const Face& default_face() const { return m_default_face; } - private: LineList m_lines; BufferRange m_range; - Face m_default_face; }; } diff --git a/src/main.cc b/src/main.cc index f2b5a310..2f36ce91 100644 --- a/src/main.cc +++ b/src/main.cc @@ -338,7 +338,8 @@ public: void info_show(StringView, StringView, CharCoord, Face, InfoStyle) override {} void info_hide() override {} - void draw(const DisplayBuffer&, const DisplayLine&, const DisplayLine&) override {} + void draw(const DisplayBuffer&, const Face&) override {} + void draw_status(const DisplayLine&, const DisplayLine&, const Face&) override {} CharCoord dimensions() override { return {24,80}; } bool is_key_available() override { return false; } Key get_key() override { return Key::Invalid; } diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index 7ea51ef2..7f7dbcba 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -368,10 +368,8 @@ void NCursesUI::draw_line(const DisplayLine& line, CharCount col_index, } void NCursesUI::draw(const DisplayBuffer& display_buffer, - const DisplayLine& status_line, - const DisplayLine& mode_line) + const Face& default_face) { - const Face& default_face = display_buffer.default_face(); wbkgdset(m_window, COLOR_PAIR(get_color_pair(default_face))); check_resize(); @@ -393,6 +391,13 @@ void NCursesUI::draw(const DisplayBuffer& display_buffer, waddch(m_window, '~'); } + m_dirty = true; +} + +void NCursesUI::draw_status(const DisplayLine& status_line, + const DisplayLine& mode_line, + const Face& default_face) +{ int status_line_pos = m_status_on_top ? 0 : (int)m_dimensions.line; wmove(m_window, status_line_pos, 0); wclrtoeol(m_window); diff --git a/src/ncurses_ui.hh b/src/ncurses_ui.hh index 5227c4be..a98550c6 100644 --- a/src/ncurses_ui.hh +++ b/src/ncurses_ui.hh @@ -22,11 +22,14 @@ public: NCursesUI& operator=(const NCursesUI&) = delete; void draw(const DisplayBuffer& display_buffer, - const DisplayLine& status_line, - const DisplayLine& mode_line) override; + const Face& default_face) override; - bool is_key_available() override; - Key get_key() override; + void draw_status(const DisplayLine& status_line, + const DisplayLine& mode_line, + const Face& default_face) override; + + bool is_key_available() override; + Key get_key() override; void menu_show(ConstArrayView items, CharCoord anchor, Face fg, Face bg, diff --git a/src/remote.cc b/src/remote.cc index 61434c38..af5c850f 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -26,6 +26,7 @@ enum class RemoteUIMsg InfoShow, InfoHide, Draw, + DrawStatus, Refresh, SetOptions }; @@ -123,7 +124,6 @@ public: void write(const DisplayBuffer& display_buffer) { - write(display_buffer.default_face()); write(display_buffer.lines()); } @@ -226,7 +226,6 @@ template<> DisplayBuffer read(int socket) { DisplayBuffer db; - db.set_default_face(read(socket)); db.lines() = read_vector(socket); return db; } @@ -263,8 +262,11 @@ public: void info_hide() override; void draw(const DisplayBuffer& display_buffer, - const DisplayLine& status_line, - const DisplayLine& mode_line) override; + const Face& default_face) override; + + void draw_status(const DisplayLine& status_line, + const DisplayLine& mode_line, + const Face& default_face) override; void refresh() override; @@ -344,14 +346,23 @@ void RemoteUI::info_hide() } void RemoteUI::draw(const DisplayBuffer& display_buffer, - const DisplayLine& status_line, - const DisplayLine& mode_line) + const Face& default_face) { Message msg(m_socket_watcher.fd()); msg.write(RemoteUIMsg::Draw); msg.write(display_buffer); + msg.write(default_face); +} + +void RemoteUI::draw_status(const DisplayLine& status_line, + const DisplayLine& mode_line, + const Face& default_face) +{ + Message msg(m_socket_watcher.fd()); + msg.write(RemoteUIMsg::DrawStatus); msg.write(status_line); msg.write(mode_line); + msg.write(default_face); } void RemoteUI::refresh() @@ -510,9 +521,16 @@ void RemoteClient::process_next_message() case RemoteUIMsg::Draw: { auto display_buffer = read(socket); + auto default_face = read(socket); + m_ui->draw(display_buffer, default_face); + break; + } + case RemoteUIMsg::DrawStatus: + { auto status_line = read(socket); auto mode_line = read(socket); - m_ui->draw(display_buffer, status_line, mode_line); + auto default_face = read(socket); + m_ui->draw_status(status_line, mode_line, default_face); break; } case RemoteUIMsg::Refresh: diff --git a/src/user_interface.hh b/src/user_interface.hh index 92aae13e..5f87d58b 100644 --- a/src/user_interface.hh +++ b/src/user_interface.hh @@ -53,8 +53,12 @@ public: virtual void info_hide() = 0; virtual void draw(const DisplayBuffer& display_buffer, - const DisplayLine& status_line, - const DisplayLine& mode_line) = 0; + const Face& default_face) = 0; + + virtual void draw_status(const DisplayLine& status_line, + const DisplayLine& mode_line, + const Face& default_face) = 0; + virtual CharCoord dimensions() = 0; virtual bool is_key_available() = 0; virtual Key get_key() = 0; diff --git a/src/window.cc b/src/window.cc index 0cacdad2..18ca03cc 100644 --- a/src/window.cc +++ b/src/window.cc @@ -2,7 +2,6 @@ #include "assert.hh" #include "context.hh" -#include "face_registry.hh" #include "highlighter.hh" #include "hook_manager.hh" #include "client.hh" @@ -66,7 +65,6 @@ void Window::update_display_buffer(const Context& context) kak_assert(&buffer() == &context.buffer()); scroll_to_keep_selection_visible_ifn(context); - m_display_buffer.set_default_face(get_face("Default")); DisplayBuffer::LineList& lines = m_display_buffer.lines(); lines.clear();