Windows call the WinSetOption hook when an option changes

This commit is contained in:
Maxime Coste 2012-06-14 13:19:38 +00:00
parent a943e08dc7
commit f7ee2801e9
2 changed files with 20 additions and 1 deletions

View File

@ -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));
}
}

View File

@ -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();