From cfa658b899b44a8a0f4c7f3dd9811ae0d44ddd3a Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 15 May 2023 21:10:02 +1000 Subject: Add to cancel current operation The current implementation only does this during regex operations, but should be extensible to other operations that might take a long time by regularly calling EventManager::handle_urgent_events(). --- src/client.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/client.cc') diff --git a/src/client.cc b/src/client.cc index f022c699..33285b95 100644 --- a/src/client.cc +++ b/src/client.cc @@ -53,6 +53,12 @@ Client::Client(std::unique_ptr&& ui, killpg(getpgrp(), SIGINT); set_signal_handler(SIGINT, prev_handler); } + else if (key == ctrl('g')) + { + m_pending_keys.clear(); + print_status({"operation cancelled", context().faces()["Error"]}); + throw cancel{}; + } else if (key.modifiers & Key::Modifiers::Resize) { m_window->set_dimensions(key.coord()); @@ -110,7 +116,7 @@ bool Client::process_pending_inputs() catch (Kakoune::runtime_error& error) { write_to_debug_buffer(format("Error: {}", error.what())); - context().print_status({error.what().str(), context().faces()["Error"] }); + context().print_status({error.what().str(), context().faces()["Error"]}); context().hooks().run_hook(Hook::RuntimeError, error.what(), context()); } } -- cgit v1.2.3