diff --git a/src/buffer.cc b/src/buffer.cc index 4713290e..b230c09d 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -27,7 +27,7 @@ Buffer::Buffer(const std::string& name, Type type, { BufferManager::instance().register_buffer(this); - HooksManager::instance().run_hook("BufCreate", name, Context(*this)); + GlobalHooksManager::instance().run_hook("BufCreate", name, Context(*this)); compute_lines(); } diff --git a/src/hooks_manager.hh b/src/hooks_manager.hh index 5a96aa83..3fdeece3 100644 --- a/src/hooks_manager.hh +++ b/src/hooks_manager.hh @@ -11,7 +11,7 @@ namespace Kakoune typedef std::function HookFunc; -class HooksManager : public Singleton +class HooksManager { public: void add_hook(const std::string& hook_name, HookFunc hook); @@ -22,6 +22,11 @@ private: std::unordered_map> m_hooks; }; +class GlobalHooksManager : public HooksManager, + public Singleton +{ +}; + } #endif // hooks_manager_hh_INCLUDED diff --git a/src/main.cc b/src/main.cc index 1c62cf7b..04e3b6bb 100644 --- a/src/main.cc +++ b/src/main.cc @@ -575,7 +575,7 @@ void add_hook(const CommandParameters& params, const Context& context) CommandParameters hook_params(params.begin()+2, params.end()); - HooksManager::instance().add_hook( + GlobalHooksManager::instance().add_hook( params[0], [=](const std::string& param, const Context& context) { if (boost::regex_match(param, boost::regex(params[1]))) @@ -955,7 +955,7 @@ int main(int argc, char* argv[]) RegisterManager register_manager; HighlighterRegistry highlighter_registry; FilterRegistry filter_registry; - HooksManager hooks_manager; + GlobalHooksManager hooks_manager; command_manager.register_command(std::vector{ "e", "edit" }, edit, CommandManager::None, diff --git a/src/window.cc b/src/window.cc index e220d0b3..ca4e7908 100644 --- a/src/window.cc +++ b/src/window.cc @@ -57,8 +57,8 @@ Window::Window(Buffer& buffer) HighlighterRegistry& registry = HighlighterRegistry::instance(); - HooksManager::instance().run_hook("WinCreate", buffer.name(), - Context(*this)); + GlobalHooksManager::instance().run_hook("WinCreate", buffer.name(), + Context(*this)); registry.add_highlighter_to_window(*this, "expand_tabs", HighlighterParameters()); registry.add_highlighter_to_window(*this, "highlight_selections", HighlighterParameters()); @@ -465,7 +465,7 @@ IncrementalInserter::~IncrementalInserter() m_window.push_selections(); try { - HooksManager::instance().run_hook("WinInsertEnd", "", Context(m_window)); + GlobalHooksManager::instance().run_hook("WinInsertEnd", "", Context(m_window)); } catch (runtime_error& e) {} m_window.pop_selections();