Support full redraws during shell execution and handle resize there

Fixes #1973
This commit is contained in:
Maxime Coste 2018-03-30 09:58:18 +11:00
parent 510be03910
commit 0baf562c93
5 changed files with 25 additions and 24 deletions

View File

@ -47,6 +47,11 @@ Client::Client(std::unique_ptr<UserInterface>&& 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;
}

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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<String, int> 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<seconds>(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<seconds>(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<String, int> 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 };
}