Restore previous status line after notifying wait for shell
Fixes prompt getting erased by the wait for shell message, and having to manually trigger a redraw to see it again.
This commit is contained in:
parent
0baf562c93
commit
ea66465144
|
@ -48,6 +48,7 @@ public:
|
||||||
void info_hide(bool even_modal = false);
|
void info_hide(bool even_modal = false);
|
||||||
|
|
||||||
void print_status(DisplayLine status_line);
|
void print_status(DisplayLine status_line);
|
||||||
|
const DisplayLine& current_status() { return m_status_line; }
|
||||||
|
|
||||||
DisplayCoord dimensions() const;
|
DisplayCoord dimensions() const;
|
||||||
|
|
||||||
|
|
|
@ -256,20 +256,22 @@ std::pair<String, int> ShellManager::eval(
|
||||||
|
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
static constexpr seconds wait_timeout{1};
|
static constexpr seconds wait_timeout{1};
|
||||||
bool wait_notified = false;
|
Optional<DisplayLine> previous_status;
|
||||||
Timer wait_timer{wait_time + wait_timeout, [&](Timer& timer)
|
Timer wait_timer{wait_time + wait_timeout, [&](Timer& timer)
|
||||||
{
|
{
|
||||||
auto wait_duration = Clock::now() - wait_time;
|
auto wait_duration = Clock::now() - wait_time;
|
||||||
if (context.has_client())
|
if (context.has_client())
|
||||||
{
|
{
|
||||||
auto& client = context.client();
|
auto& client = context.client();
|
||||||
|
if (not previous_status)
|
||||||
|
previous_status = client.current_status();
|
||||||
|
|
||||||
client.print_status({ format("waiting for shell command to finish ({}s)",
|
client.print_status({ format("waiting for shell command to finish ({}s)",
|
||||||
duration_cast<seconds>(wait_duration).count()),
|
duration_cast<seconds>(wait_duration).count()),
|
||||||
get_face("Information") });
|
get_face("Information") });
|
||||||
client.redraw_ifn();
|
client.redraw_ifn();
|
||||||
}
|
}
|
||||||
timer.set_next_date(Clock::now() + wait_timeout);
|
timer.set_next_date(Clock::now() + wait_timeout);
|
||||||
wait_notified = true;
|
|
||||||
}, EventMode::Urgent};
|
}, EventMode::Urgent};
|
||||||
|
|
||||||
while (not terminated or child_stdin.write_fd() != -1 or
|
while (not terminated or child_stdin.write_fd() != -1 or
|
||||||
|
@ -294,9 +296,9 @@ std::pair<String, int> ShellManager::eval(
|
||||||
(size_t)full.count(), (size_t)spawn.count(), (size_t)wait.count()));
|
(size_t)full.count(), (size_t)spawn.count(), (size_t)wait.count()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wait_notified and context.has_client()) // clear the status line
|
if (previous_status) // restore the status line
|
||||||
{
|
{
|
||||||
context.print_status({});
|
context.print_status(std::move(*previous_status));
|
||||||
context.client().redraw_ifn();
|
context.client().redraw_ifn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user