diff options
| author | Maxime Coste <mawww@kakoune.org> | 2018-10-23 08:15:53 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2018-10-23 08:15:53 +1100 |
| commit | dfc11d1c43b898394df8fda52a8079b34058de27 (patch) | |
| tree | 8d1923461be03b1d0eab5706740d22986a86997d /src/window.cc | |
| parent | e399bf7562475c92f4f9e983d2261c12903072d4 (diff) | |
Refactor Hook management to have a well defined list of hooks
Hooks are now an enum class instead of passing strings around.
Diffstat (limited to 'src/window.cc')
| -rw-r--r-- | src/window.cc | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/window.cc b/src/window.cc index de5a1b2a..1b814b8f 100644 --- a/src/window.cc +++ b/src/window.cc @@ -25,7 +25,7 @@ Window::Window(Buffer& buffer) m_buffer(&buffer), m_builtin_highlighters{highlighters()} { - run_hook_in_own_context("WinCreate", buffer.name()); + run_hook_in_own_context(Hook::WinCreate, buffer.name()); options().register_watcher(*this); @@ -40,7 +40,7 @@ Window::Window(Buffer& buffer) Window::~Window() { - run_hook_in_own_context("WinClose", buffer().name()); + run_hook_in_own_context(Hook::WinClose, buffer().name()); options().unregister_watcher(*this); } @@ -195,7 +195,7 @@ void Window::set_dimensions(DisplayCoord dimensions) if (m_dimensions != dimensions) { m_dimensions = dimensions; - run_hook_in_own_context("WinResize", format("{}.{}", dimensions.line, + run_hook_in_own_context(Hook::WinResize, format("{}.{}", dimensions.line, dimensions.column)); } } @@ -339,15 +339,14 @@ void Window::clear_display_buffer() void Window::on_option_changed(const Option& option) { - run_hook_in_own_context("WinSetOption", format("{}={}", option.name(), + run_hook_in_own_context(Hook::WinSetOption, format("{}={}", option.name(), option.get_as_string(Quoting::Kakoune))); // an highlighter might depend on the option, so we need to redraw force_redraw(); } -void Window::run_hook_in_own_context(StringView hook_name, StringView param, - String client_name) +void Window::run_hook_in_own_context(Hook hook, StringView param, String client_name) { if (m_buffer->flags() & Buffer::Flags::NoHooks) return; @@ -359,6 +358,6 @@ void Window::run_hook_in_own_context(StringView hook_name, StringView param, if (m_client) hook_handler.context().set_client(*m_client); - hooks().run_hook(hook_name, param, hook_handler.context()); + hooks().run_hook(hook, param, hook_handler.context()); } } |
