diff --git a/src/window.cc b/src/window.cc index 2af9564c..966ffdb6 100644 --- a/src/window.cc +++ b/src/window.cc @@ -2,6 +2,7 @@ #include "assert.hh" #include "highlighter_registry.hh" +#include "highlighters.hh" #include "hooks_manager.hh" #include @@ -402,6 +403,21 @@ void Window::remove_highlighter(const std::string& id) m_highlighters.remove(id); } +HighlighterGroup& Window::get_highlighter_group(const std::string& id) +{ + auto group_it = m_highlighters.find(id); + + if (group_it == m_highlighters.end()) + throw runtime_error("no such group id " + id); + + HighlighterGroup* group = group_it->second.target(); + + if (not group) + throw runtime_error("not a group " + id); + + return *group; +} + CandidateList Window::complete_highlighterid(const std::string& prefix, size_t cursor_pos) { diff --git a/src/window.hh b/src/window.hh index fa367c53..da49c0d1 100644 --- a/src/window.hh +++ b/src/window.hh @@ -47,6 +47,7 @@ private: typedef std::vector SelectionList; class IncrementalInserter; +class HighlighterGroup; // A Window is an editing view onto a Buffer // @@ -103,6 +104,7 @@ public: void add_highlighter(HighlighterAndId&& highlighter); void remove_highlighter(const std::string& id); + HighlighterGroup& get_highlighter_group(const std::string& id); CandidateList complete_highlighterid(const std::string& prefix, size_t cursor_pos = std::string::npos);