diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-10-28 11:00:51 +0800 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-10-28 13:43:04 +0800 |
| commit | d49555fc7568cff0db385d019a68cfdb0f28f8b0 (patch) | |
| tree | 54c852fe6bba4236baf632111341312547ed77f8 /src/highlighter_group.hh | |
| parent | 9a449a33446f1c52bb02b4bea13bbc86d5742f2d (diff) | |
Move highlighters into Scopes
That means we can now have highlighters active at global, buffer, and
window scope. The add-highlighter and remove-highlighter syntax changed
to take the parent path (scope/group/...) as a mandatory argument,
superseeding the previous -group switch.
Diffstat (limited to 'src/highlighter_group.hh')
| -rw-r--r-- | src/highlighter_group.hh | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/highlighter_group.hh b/src/highlighter_group.hh index 12fc07d3..95a88a6b 100644 --- a/src/highlighter_group.hh +++ b/src/highlighter_group.hh @@ -5,6 +5,7 @@ #include "hash_map.hh" #include "highlighter.hh" #include "utils.hh" +#include "safe_ptr.hh" namespace Kakoune { @@ -27,7 +28,7 @@ public: Completions complete_child(StringView path, ByteCount cursor_pos, bool group) const override; -private: +protected: void do_highlight(const Context& context, HighlightPass pass, DisplayBuffer& display_buffer, BufferRange range) override; void do_compute_display_setup(const Context& context, HighlightPass pass, DisplaySetup& setup) override; @@ -35,6 +36,21 @@ private: HighlighterMap m_highlighters; }; +class Highlighters : public HighlighterGroup, public SafeCountable +{ +public: + Highlighters(Highlighters& parent) : HighlighterGroup{HighlightPass::All}, SafeCountable{}, m_parent(&parent) {} + +private: + void do_highlight(const Context& context, HighlightPass pass, DisplayBuffer& display_buffer, BufferRange range) override; + void do_compute_display_setup(const Context& context, HighlightPass pass, DisplaySetup& setup) override; + + friend class Scope; + Highlighters() : HighlighterGroup{HighlightPass::All} {} + + SafePtr<Highlighters> m_parent; +}; + struct DefinedHighlighters : public HighlighterGroup, public Singleton<DefinedHighlighters> { |
