summaryrefslogtreecommitdiff
path: root/src/highlighter_group.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2012-01-19 20:37:29 +0000
committerMaxime Coste <frrrwww@gmail.com>2012-01-19 20:37:29 +0000
commit2824bd9a464521999f7f68f4f08356ac9e69538e (patch)
tree4b45632921c945aa361297d4e573eab03fcaca4b /src/highlighter_group.hh
parent2fe07d2dadec5014bab0ca1ef3eaf4a6ca9d0896 (diff)
HighlighterGroup: move to it's own file, Window uses them directly
Diffstat (limited to 'src/highlighter_group.hh')
-rw-r--r--src/highlighter_group.hh43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/highlighter_group.hh b/src/highlighter_group.hh
new file mode 100644
index 00000000..07379a63
--- /dev/null
+++ b/src/highlighter_group.hh
@@ -0,0 +1,43 @@
+#ifndef highlighter_group_hh_INCLUDED
+#define highlighter_group_hh_INCLUDED
+
+#include "highlighter.hh"
+#include "idvaluemap.hh"
+
+namespace Kakoune
+{
+
+class DisplayBuffer;
+class Window;
+
+class HighlighterGroup
+{
+public:
+ void operator()(DisplayBuffer& display_buffer);
+
+ void append(HighlighterAndId&& highlighter);
+ void remove(const std::string& id);
+
+ HighlighterGroup& get_group(const std::string& id);
+
+ CandidateList complete_id(const std::string& prefix, size_t cursor_pos);
+
+ CandidateList complete_group_id(const std::string& prefix, size_t cursor_pos)
+ {
+ CandidateList all = complete_id(prefix, cursor_pos);
+ CandidateList res;
+ for (auto& id : all)
+ {
+ if (m_highlighters.find(id)->second.target<HighlighterGroup>())
+ res.push_back(id);
+ }
+ return res;
+ }
+
+private:
+ idvaluemap<std::string, HighlighterFunc> m_highlighters;
+};
+
+}
+
+#endif // highlighter_group_hh_INCLUDED