diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-06-21 22:06:02 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-06-21 22:06:02 +0100 |
| commit | b89b7c754fcbb2493d5e9a63dffec7ada82cfe9a (patch) | |
| tree | 70306f2439d162a78e7fd20791962f116f566758 /src/input_handler.cc | |
| parent | edd883ad18d8b56f0a57d4a20e1de6e5c0141797 (diff) | |
Add \ in normal mode to disable user hooks on next normal command
Fixes #112
Diffstat (limited to 'src/input_handler.cc')
| -rw-r--r-- | src/input_handler.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc index 2551669e..a440dc1a 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -82,16 +82,33 @@ public: void on_key(Key key) override { + bool do_restore_hooks = false; + auto restore_hooks = on_scope_end([&, this]{ + if (do_restore_hooks) + { + GlobalHooks::instance().enable_user_hooks(); + m_disable_hooks = false; + } + }); + if (key.modifiers == Key::Modifiers::None and isdigit(key.key)) m_count = m_count * 10 + key.key - '0'; else if (key == Key::Backspace) m_count /= 10; + else if (key == '\\') + m_disable_hooks = true; else { + if (m_disable_hooks) + { + GlobalHooks::instance().disable_user_hooks(); + do_restore_hooks = true; + } auto it = keymap.find(key); if (it != keymap.end()) it->second(context(), m_count); m_count = 0; + } context().hooks().run_hook("NormalKey", key_to_str(key), context()); m_idle_timer.set_next_date(Clock::now() + idle_timeout); @@ -107,6 +124,7 @@ public: private: int m_count = 0; + bool m_disable_hooks = false; Timer m_idle_timer; Timer m_fs_check_timer; }; |
