Remove Window::force_redraw()

This was mostly redundant with Client::force_redraw.
This commit is contained in:
Maxime Coste 2023-08-27 07:23:39 +10:00
parent 6f9f32b4bb
commit fe93a9df37
7 changed files with 20 additions and 20 deletions

View File

@ -62,7 +62,7 @@ Client::Client(std::unique_ptr<UserInterface>&& ui,
else if (key.modifiers & Key::Modifiers::Resize) else if (key.modifiers & Key::Modifiers::Resize)
{ {
m_window->set_dimensions(key.coord()); m_window->set_dimensions(key.coord());
force_redraw(); force_redraw(true);
} }
else else
m_pending_keys.push_back(key); m_pending_keys.push_back(key);
@ -210,7 +210,7 @@ void Client::change_buffer(Buffer& buffer, Optional<FunctionRef<void()>> set_sel
m_ui->set_ui_options(m_window->options()["ui_options"].get<UserInterface::Options>()); m_ui->set_ui_options(m_window->options()["ui_options"].get<UserInterface::Options>());
m_window->hooks().run_hook(Hook::WinDisplay, buffer.name(), context()); m_window->hooks().run_hook(Hook::WinDisplay, buffer.name(), context());
force_redraw(); force_redraw(true);
} }
static bool is_inline(InfoStyle style) static bool is_inline(InfoStyle style)
@ -289,11 +289,14 @@ void Client::redraw_ifn()
m_ui_pending = 0; m_ui_pending = 0;
} }
void Client::force_redraw() void Client::force_redraw(bool full)
{ {
m_ui_pending |= Refresh | Draw | StatusLine | if (full)
(m_menu.items.empty() ? MenuHide : MenuShow | MenuSelect) | m_ui_pending |= Refresh | Draw | StatusLine |
(m_info.content.empty() ? InfoHide : InfoShow); (m_menu.items.empty() ? MenuHide : MenuShow | MenuSelect) |
(m_info.content.empty() ? InfoHide : InfoShow);
else
m_ui_pending |= Draw;
} }
void Client::reload_buffer() void Client::reload_buffer()
@ -422,10 +425,8 @@ StringView Client::get_env_var(StringView name) const
void Client::on_option_changed(const Option& option) void Client::on_option_changed(const Option& option)
{ {
if (option.name() == "ui_options") if (option.name() == "ui_options")
{
m_ui->set_ui_options(option.get<UserInterface::Options>()); m_ui->set_ui_options(option.get<UserInterface::Options>());
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<DisplayLine> choices, BufferCoord anchor, MenuStyle style) void Client::menu_show(Vector<DisplayLine> choices, BufferCoord anchor, MenuStyle style)

View File

@ -54,7 +54,7 @@ public:
DisplayCoord dimensions() const; DisplayCoord dimensions() const;
void force_redraw(); void force_redraw(bool full = false);
void redraw_ifn(); void redraw_ifn();
void check_if_buffer_needs_reloading(); void check_if_buffer_needs_reloading();

View File

@ -152,7 +152,6 @@ WindowAndSelections ClientManager::get_free_window(Buffer& buffer)
if (it == m_free_windows.rend()) if (it == m_free_windows.rend())
return { std::make_unique<Window>(buffer), { buffer, Selection{} } }; return { std::make_unique<Window>(buffer), { buffer, Selection{} } };
it->window->force_redraw();
WindowAndSelections res = std::move(*it); WindowAndSelections res = std::move(*it);
m_free_windows.erase(it.base()-1); m_free_windows.erase(it.base()-1);
res.selections.update(); res.selections.update();

View File

@ -976,20 +976,23 @@ static void redraw_relevant_clients(Context& context, StringView highlighter_pat
{ {
StringView scope{highlighter_path.begin(), find(highlighter_path, '/')}; StringView scope{highlighter_path.begin(), find(highlighter_path, '/')};
if (scope == "window") if (scope == "window")
context.window().force_redraw(); {
if (context.has_client())
context.client().force_redraw();
}
else if (scope == "buffer" or prefix_match(scope, "buffer=")) else if (scope == "buffer" or prefix_match(scope, "buffer="))
{ {
auto& buffer = scope == "buffer" ? context.buffer() : BufferManager::instance().get_buffer(scope.substr(7_byte)); auto& buffer = scope == "buffer" ? context.buffer() : BufferManager::instance().get_buffer(scope.substr(7_byte));
for (auto&& client : ClientManager::instance()) for (auto&& client : ClientManager::instance())
{ {
if (&client->context().buffer() == &buffer) if (&client->context().buffer() == &buffer)
client->context().window().force_redraw(); client->force_redraw();
} }
} }
else else
{ {
for (auto&& client : ClientManager::instance()) for (auto&& client : ClientManager::instance())
client->context().window().force_redraw(); client->force_redraw();
} }
} }

View File

@ -1008,8 +1008,8 @@ void use_selection_as_search_pattern(Context& context, NormalParams params)
RegisterManager::instance()[reg].set(context, {pattern}); RegisterManager::instance()[reg].set(context, {pattern});
// Hack, as Window do not take register state into account // Hack, as Window do not take register state into account
if (context.has_window()) if (context.has_client())
context.window().force_redraw(); context.client().force_redraw();
} }
void select_regex(Context& context, NormalParams params) void select_regex(Context& context, NormalParams params)
@ -2208,7 +2208,7 @@ void force_redraw(Context& context, NormalParams)
{ {
if (context.has_client()) if (context.has_client())
{ {
context.client().force_redraw(); context.client().force_redraw(true);
context.client().redraw_ifn(); context.client().redraw_ifn();
} }
} }

View File

@ -324,8 +324,6 @@ void Window::clear_display_buffer()
void Window::on_option_changed(const Option& option) void Window::on_option_changed(const Option& option)
{ {
run_hook_in_own_context(Hook::WinSetOption, format("{}={}", option.name(), option.get_desc_string())); 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();
} }

View File

@ -43,7 +43,6 @@ public:
Buffer& buffer() const { return *m_buffer; } Buffer& buffer() const { return *m_buffer; }
bool needs_redraw(const Context& context) const; bool needs_redraw(const Context& context) const;
void force_redraw() { m_last_setup = Setup{}; }
void set_client(Client* client) { m_client = client; } void set_client(Client* client) { m_client = client; }