From a4070d9037ba442b34688241a97a3cd5ba0db2d3 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 24 Mar 2014 19:31:40 +0000 Subject: [PATCH] Use an info box to prompt for reloading of modified files --- src/client.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/client.cc b/src/client.cc index 1fcd5e3e..e6527944 100644 --- a/src/client.cc +++ b/src/client.cc @@ -114,15 +114,19 @@ void Client::check_buffer_fs_timestamp() return; if (reload == Ask) { - print_status({"'" + buffer.display_name() + "' was modified externally, press r or y to reload, k or n to keep", get_color("Prompt")}); + DisplayCoord pos = context().window().dimensions(); + pos.column -= 1; + m_ui->info_show("reload '" + buffer.display_name() + "' ?", + "'" + buffer.display_name() + "' was modified externally\n" + "press r or y to reload, k or n to keep", + pos, get_color("Information"), MenuStyle::Prompt); + m_input_handler.on_next_key([this, ts, filename](Key key, Context& context) { Buffer* buf = BufferManager::instance().get_buffer_ifp(filename); + m_ui->info_hide(); // buffer got deleted while waiting for the key, do nothing if (not buf) - { - print_status({}); return; - } if (key == 'r' or key == 'y') reload_buffer(context, filename); if (key == 'k' or key == 'n') @@ -131,7 +135,10 @@ void Client::check_buffer_fs_timestamp() print_status({"'" + buf->display_name() + "' kept", get_color("Information") }); } else + { + print_status({"'" + key_to_str(key) + "' is not a valid choice", get_color("Error")}); check_buffer_fs_timestamp(); + } }); } else