From 0baf562c93670d90369ef99828bccc94a9d92520 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 30 Mar 2018 09:58:18 +1100 Subject: [PATCH] Support full redraws during shell execution and handle resize there Fixes #1973 --- src/client.cc | 22 +++++++--------------- src/client.hh | 2 +- src/context.cc | 4 ++-- src/context.hh | 2 +- src/shell_manager.cc | 19 ++++++++++++++----- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/client.cc b/src/client.cc index 225a10b2..6520dc9c 100644 --- a/src/client.cc +++ b/src/client.cc @@ -47,6 +47,11 @@ Client::Client(std::unique_ptr&& ui, m_ui->set_on_key([this](Key key) { if (key == ctrl('c')) killpg(getpgrp(), SIGINT); + else if (key.modifiers == Key::Modifiers::Resize) + { + m_window->set_dimensions(m_ui->dimensions()); + force_redraw(); + } else m_pending_keys.push_back(key); }); @@ -83,11 +88,6 @@ bool Client::process_pending_inputs() context().hooks().run_hook("FocusIn", context().name(), context()); else if (key == Key::FocusOut) context().hooks().run_hook("FocusOut", context().name(), context()); - else if (key.modifiers == Key::Modifiers::Resize) - { - m_window->set_dimensions(m_ui->dimensions()); - force_redraw(); - } else m_input_handler.handle_key(key); @@ -103,18 +103,10 @@ bool Client::process_pending_inputs() return not keys.empty(); } -void Client::print_status(DisplayLine status_line, bool immediate) +void Client::print_status(DisplayLine status_line) { m_status_line = std::move(status_line); - if (immediate) - { - m_ui->draw_status(m_status_line, m_mode_line, get_face("StatusLine")); - m_ui->refresh(true); - } - else - { - m_ui_pending |= StatusLine; - } + m_ui_pending |= StatusLine; } diff --git a/src/client.hh b/src/client.hh index d7db0391..3d90a247 100644 --- a/src/client.hh +++ b/src/client.hh @@ -47,7 +47,7 @@ public: void info_show(String title, String content, BufferCoord anchor, InfoStyle style); void info_hide(bool even_modal = false); - void print_status(DisplayLine status_line, bool immediate = false); + void print_status(DisplayLine status_line); DisplayCoord dimensions() const; diff --git a/src/context.cc b/src/context.cc index da23aac1..ece4a2f4 100644 --- a/src/context.cc +++ b/src/context.cc @@ -70,10 +70,10 @@ void Context::set_window(Window& window) m_window.reset(&window); } -void Context::print_status(DisplayLine status, bool immediate) const +void Context::print_status(DisplayLine status) const { if (has_client()) - client().print_status(std::move(status), immediate); + client().print_status(std::move(status)); } void JumpList::push(SelectionList jump) diff --git a/src/context.hh b/src/context.hh index 754dfd77..cad77d4c 100644 --- a/src/context.hh +++ b/src/context.hh @@ -96,7 +96,7 @@ public: KeymapManager& keymaps() const { return scope().keymaps(); } AliasRegistry& aliases() const { return scope().aliases(); } - void print_status(DisplayLine status, bool immediate = false) const; + void print_status(DisplayLine status) const; StringView main_sel_register_value(StringView reg) const; diff --git a/src/shell_manager.cc b/src/shell_manager.cc index 11d2b0cc..47bfd101 100644 --- a/src/shell_manager.cc +++ b/src/shell_manager.cc @@ -1,6 +1,7 @@ #include "shell_manager.hh" #include "buffer_utils.hh" +#include "client.hh" #include "clock.hh" #include "context.hh" #include "display_buffer.hh" @@ -259,9 +260,14 @@ std::pair ShellManager::eval( Timer wait_timer{wait_time + wait_timeout, [&](Timer& timer) { auto wait_duration = Clock::now() - wait_time; - context.print_status({ format("waiting for shell command to finish ({}s)", - duration_cast(wait_duration).count()), - get_face("Information") }, true); + if (context.has_client()) + { + auto& client = context.client(); + client.print_status({ format("waiting for shell command to finish ({}s)", + duration_cast(wait_duration).count()), + get_face("Information") }); + client.redraw_ifn(); + } timer.set_next_date(Clock::now() + wait_timeout); wait_notified = true; }, EventMode::Urgent}; @@ -288,8 +294,11 @@ std::pair ShellManager::eval( (size_t)full.count(), (size_t)spawn.count(), (size_t)wait.count())); } - if (wait_notified) // clear the status line - context.print_status({}, true); + if (wait_notified and context.has_client()) // clear the status line + { + context.print_status({}); + context.client().redraw_ifn(); + } return { std::move(stdout_contents), WIFEXITED(status) ? WEXITSTATUS(status) : -1 }; }