diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-12-14 19:06:30 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-12-14 19:06:30 +0000 |
| commit | d2b0dba39dfc87fe7da7610b0ed68df65d89ded8 (patch) | |
| tree | 215edd19fb28d9f631b6445d5fcd872b56dae8d0 /src | |
| parent | 6873a44e3ea7eaaa435e3bf018d2c68fa214e858 (diff) | |
Support quitting while executing RuntimeError hooks
Fixes #529
Diffstat (limited to 'src')
| -rw-r--r-- | src/client.cc | 35 | ||||
| -rw-r--r-- | src/client_manager.cc | 17 |
2 files changed, 29 insertions, 23 deletions
diff --git a/src/client.cc b/src/client.cc index ec7f3ce8..3a4f44ed 100644 --- a/src/client.cc +++ b/src/client.cc @@ -67,24 +67,27 @@ void Client::handle_available_input(EventMode mode) try { - while (Optional<Key> key = get_next_key(mode)) + try { - if (*key == ctrl('c')) - killpg(getpgrp(), SIGINT); - else if (*key == Key::FocusIn) - 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) - force_redraw(); - else - m_input_handler.handle_key(*key); + while (Optional<Key> key = get_next_key(mode)) + { + if (*key == ctrl('c')) + killpg(getpgrp(), SIGINT); + else if (*key == Key::FocusIn) + 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) + force_redraw(); + else + m_input_handler.handle_key(*key); + } + } + catch (Kakoune::runtime_error& error) + { + context().print_status({ error.what().str(), get_face("Error") }); + context().hooks().run_hook("RuntimeError", error.what(), context()); } - } - catch (Kakoune::runtime_error& error) - { - context().print_status({ error.what().str(), get_face("Error") }); - context().hooks().run_hook("RuntimeError", error.what(), context()); } catch (Kakoune::client_removed& removed) { diff --git a/src/client_manager.cc b/src/client_manager.cc index 7e70d5c4..b71dfc75 100644 --- a/src/client_manager.cc +++ b/src/client_manager.cc @@ -42,13 +42,16 @@ Client* ClientManager::create_client(std::unique_ptr<UserInterface>&& ui, m_clients.emplace_back(client); try { - CommandManager::instance().execute(init_commands, client->context()); - } - catch (Kakoune::runtime_error& error) - { - client->context().print_status({ error.what().str(), get_face("Error") }); - client->context().hooks().run_hook("RuntimeError", error.what(), - client->context()); + try + { + CommandManager::instance().execute(init_commands, client->context()); + } + catch (Kakoune::runtime_error& error) + { + client->context().print_status({ error.what().str(), get_face("Error") }); + client->context().hooks().run_hook("RuntimeError", error.what(), + client->context()); + } } catch (Kakoune::client_removed& removed) { |
