diff --git a/src/client.cc b/src/client.cc index 33285b95..6996ee13 100644 --- a/src/client.cc +++ b/src/client.cc @@ -62,7 +62,7 @@ Client::Client(std::unique_ptr&& ui, else if (key.modifiers & Key::Modifiers::Resize) { m_window->set_dimensions(key.coord()); - force_redraw(); + force_redraw(true); } else m_pending_keys.push_back(key); @@ -210,7 +210,7 @@ void Client::change_buffer(Buffer& buffer, Optional> set_sel m_ui->set_ui_options(m_window->options()["ui_options"].get()); m_window->hooks().run_hook(Hook::WinDisplay, buffer.name(), context()); - force_redraw(); + force_redraw(true); } static bool is_inline(InfoStyle style) @@ -289,11 +289,14 @@ void Client::redraw_ifn() m_ui_pending = 0; } -void Client::force_redraw() +void Client::force_redraw(bool full) { - m_ui_pending |= Refresh | Draw | StatusLine | - (m_menu.items.empty() ? MenuHide : MenuShow | MenuSelect) | - (m_info.content.empty() ? InfoHide : InfoShow); + if (full) + m_ui_pending |= Refresh | Draw | StatusLine | + (m_menu.items.empty() ? MenuHide : MenuShow | MenuSelect) | + (m_info.content.empty() ? InfoHide : InfoShow); + else + m_ui_pending |= Draw; } void Client::reload_buffer() @@ -422,10 +425,8 @@ StringView Client::get_env_var(StringView name) const void Client::on_option_changed(const Option& option) { if (option.name() == "ui_options") - { m_ui->set_ui_options(option.get()); - m_ui_pending |= Draw; - } + m_ui_pending |= Draw; // a highlighter might depend on the option, so we need to redraw } void Client::menu_show(Vector choices, BufferCoord anchor, MenuStyle style) diff --git a/src/client.hh b/src/client.hh index e379e1e7..75a2a02f 100644 --- a/src/client.hh +++ b/src/client.hh @@ -54,7 +54,7 @@ public: DisplayCoord dimensions() const; - void force_redraw(); + void force_redraw(bool full = false); void redraw_ifn(); void check_if_buffer_needs_reloading(); diff --git a/src/client_manager.cc b/src/client_manager.cc index 0f601fc1..53caeea0 100644 --- a/src/client_manager.cc +++ b/src/client_manager.cc @@ -152,7 +152,6 @@ WindowAndSelections ClientManager::get_free_window(Buffer& buffer) if (it == m_free_windows.rend()) return { std::make_unique(buffer), { buffer, Selection{} } }; - it->window->force_redraw(); WindowAndSelections res = std::move(*it); m_free_windows.erase(it.base()-1); res.selections.update(); diff --git a/src/commands.cc b/src/commands.cc index 16d04f2d..fe986c42 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -976,20 +976,23 @@ static void redraw_relevant_clients(Context& context, StringView highlighter_pat { StringView scope{highlighter_path.begin(), find(highlighter_path, '/')}; if (scope == "window") - context.window().force_redraw(); + { + if (context.has_client()) + context.client().force_redraw(); + } else if (scope == "buffer" or prefix_match(scope, "buffer=")) { auto& buffer = scope == "buffer" ? context.buffer() : BufferManager::instance().get_buffer(scope.substr(7_byte)); for (auto&& client : ClientManager::instance()) { if (&client->context().buffer() == &buffer) - client->context().window().force_redraw(); + client->force_redraw(); } } else { for (auto&& client : ClientManager::instance()) - client->context().window().force_redraw(); + client->force_redraw(); } } diff --git a/src/normal.cc b/src/normal.cc index b16b9c37..79a434ac 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -1008,8 +1008,8 @@ void use_selection_as_search_pattern(Context& context, NormalParams params) RegisterManager::instance()[reg].set(context, {pattern}); // Hack, as Window do not take register state into account - if (context.has_window()) - context.window().force_redraw(); + if (context.has_client()) + context.client().force_redraw(); } void select_regex(Context& context, NormalParams params) @@ -2208,7 +2208,7 @@ void force_redraw(Context& context, NormalParams) { if (context.has_client()) { - context.client().force_redraw(); + context.client().force_redraw(true); context.client().redraw_ifn(); } } diff --git a/src/window.cc b/src/window.cc index 093a96ed..757723d2 100644 --- a/src/window.cc +++ b/src/window.cc @@ -324,8 +324,6 @@ void Window::clear_display_buffer() void Window::on_option_changed(const Option& option) { run_hook_in_own_context(Hook::WinSetOption, format("{}={}", option.name(), option.get_desc_string())); - // a highlighter might depend on the option, so we need to redraw - force_redraw(); } diff --git a/src/window.hh b/src/window.hh index e6f27369..2b96cb70 100644 --- a/src/window.hh +++ b/src/window.hh @@ -43,7 +43,6 @@ public: Buffer& buffer() const { return *m_buffer; } bool needs_redraw(const Context& context) const; - void force_redraw() { m_last_setup = Setup{}; } void set_client(Client* client) { m_client = client; }