summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2012-06-14 13:19:38 +0000
committerMaxime Coste <frrrwww@gmail.com>2012-06-14 13:19:38 +0000
commitf7ee2801e9f74f4954c305a2dc75ee5d519c2ca0 (patch)
treea22d270ef960abf8d2943f03dd0fa4c3abb95898 /src
parenta943e08dc7b93c065d83639862fbcf1dd2fcb9c1 (diff)
Windows call the WinSetOption hook when an option changes
Diffstat (limited to 'src')
-rw-r--r--src/window.cc16
-rw-r--r--src/window.hh5
2 files changed, 20 insertions, 1 deletions
diff --git a/src/window.cc b/src/window.cc
index 2f32167f..e6fffa28 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 66264c89..a4b3abf5 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();