diff --git a/src/window.cc b/src/window.cc index 2f32167f4..e6fffa283 100644 --- a/src/window.cc +++ b/src/window.cc @@ -21,9 +21,18 @@ Window::Window(Buffer& buffer) HighlighterRegistry& registry = HighlighterRegistry::instance(); m_hook_manager.run_hook("WinCreate", buffer.name(), Context(*this)); + m_option_manager.register_watcher(*this); registry.add_highlighter_to_group(*this, m_highlighters, "expand_tabs", HighlighterParameters()); registry.add_highlighter_to_group(*this, m_highlighters, "highlight_selections", HighlighterParameters()); + + for (auto& option : m_option_manager.flatten_options()) + on_option_changed(option.first, option.second); +} + +Window::~Window() +{ + m_option_manager.unregister_watcher(*this); } BufferIterator Window::iterator_at(const DisplayCoord& window_pos) const @@ -126,4 +135,11 @@ void Window::on_incremental_insertion_end() pop_selections(); } +void Window::on_option_changed(const String& name, const Option& option) +{ + String desc = name + "=" + option.as_string(); + m_hook_manager.run_hook("WinSetOption", desc, Context(*this)); +} + + } diff --git a/src/window.hh b/src/window.hh index 66264c892..a4b3abf59 100644 --- a/src/window.hh +++ b/src/window.hh @@ -21,9 +21,11 @@ class HighlighterGroup; // to the editing ones already provided by the Editor class. // Display can be customized through the use of highlighters handled by // the window's HighlighterGroup -class Window : public Editor +class Window : public Editor, public OptionManagerWatcher { public: + ~Window(); + const BufferCoord& position() const { return m_position; } BufferIterator iterator_at(const DisplayCoord& window_pos) const; @@ -49,6 +51,7 @@ private: Window(const Window&) = delete; void on_incremental_insertion_end(); + void on_option_changed(const String& name, const Option& option); void scroll_to_keep_cursor_visible_ifn();