From 98f937146a282d1cafb70eda544045ae37f49cbe Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 15 Jan 2012 13:46:45 +0000 Subject: [PATCH] HighlighterRegistry: add add_highlighter_to_group method --- src/highlighter_registry.cc | 13 +++++++++++++ src/highlighter_registry.hh | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/src/highlighter_registry.cc b/src/highlighter_registry.cc index ca5669ca..42de13cc 100644 --- a/src/highlighter_registry.cc +++ b/src/highlighter_registry.cc @@ -2,6 +2,7 @@ #include "exception.hh" #include "window.hh" +#include "highlighters.hh" namespace Kakoune { @@ -30,6 +31,18 @@ void HighlighterRegistry::add_highlighter_to_window(Window& window, window.add_highlighter(it->second(window, parameters)); } +void HighlighterRegistry::add_highlighter_to_group(Window& window, + HighlighterGroup& group, + const std::string& name, + const HighlighterParameters& parameters) +{ + auto it = m_factories.find(name); + if (it == m_factories.end()) + throw factory_not_found(name); + + group.add_highlighter(it->second(window, parameters)); +} + CandidateList HighlighterRegistry::complete_highlighter(const std::string& prefix, size_t cursor_pos) { diff --git a/src/highlighter_registry.hh b/src/highlighter_registry.hh index f888325a..cd77fdc9 100644 --- a/src/highlighter_registry.hh +++ b/src/highlighter_registry.hh @@ -13,6 +13,7 @@ namespace Kakoune { class Window; +class HighlighterGroup; typedef std::function HighlighterFactory; @@ -27,6 +28,11 @@ public: const std::string& factory_name, const HighlighterParameters& parameters); + void add_highlighter_to_group(Window& window, + HighlighterGroup& group, + const std::string& factory_name, + const HighlighterParameters& parameters); + CandidateList complete_highlighter(const std::string& prefix, size_t cursor_pos);