2014-06-10 20:58:02 +02:00
|
|
|
#ifndef highlighter_group_hh_INCLUDED
|
|
|
|
#define highlighter_group_hh_INCLUDED
|
|
|
|
|
|
|
|
#include "exception.hh"
|
2017-03-07 02:12:37 +01:00
|
|
|
#include "hash_map.hh"
|
2014-06-10 20:58:02 +02:00
|
|
|
#include "highlighter.hh"
|
|
|
|
#include "utils.hh"
|
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2014-10-22 01:20:09 +02:00
|
|
|
struct child_not_found : public runtime_error
|
2014-06-10 20:58:02 +02:00
|
|
|
{
|
|
|
|
using runtime_error::runtime_error;
|
|
|
|
};
|
|
|
|
|
2014-10-22 01:20:09 +02:00
|
|
|
class HighlighterGroup : public Highlighter
|
2014-06-10 20:58:02 +02:00
|
|
|
{
|
|
|
|
public:
|
2017-05-03 20:41:37 +02:00
|
|
|
HighlighterGroup(HighlightPass passes) : Highlighter{passes} {}
|
2014-06-10 20:58:02 +02:00
|
|
|
|
2015-05-25 14:54:18 +02:00
|
|
|
bool has_children() const override { return true; }
|
2014-10-22 01:20:09 +02:00
|
|
|
void add_child(HighlighterAndId&& hl) override;
|
|
|
|
void remove_child(StringView id) override;
|
2014-06-10 20:58:02 +02:00
|
|
|
|
2014-10-22 01:20:09 +02:00
|
|
|
Highlighter& get_child(StringView path) override;
|
2014-06-10 20:58:02 +02:00
|
|
|
|
2014-10-22 01:20:09 +02:00
|
|
|
Completions complete_child(StringView path, ByteCount cursor_pos, bool group) const override;
|
2014-06-10 20:58:02 +02:00
|
|
|
|
|
|
|
private:
|
2017-05-03 20:41:37 +02:00
|
|
|
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;
|
|
|
|
|
2017-03-07 02:12:37 +01:00
|
|
|
using HighlighterMap = HashMap<String, std::unique_ptr<Highlighter>, MemoryDomain::Highlight>;
|
2014-10-22 01:20:09 +02:00
|
|
|
HighlighterMap m_highlighters;
|
2014-06-10 22:35:03 +02:00
|
|
|
};
|
|
|
|
|
2014-06-10 20:58:02 +02:00
|
|
|
struct DefinedHighlighters : public HighlighterGroup,
|
|
|
|
public Singleton<DefinedHighlighters>
|
|
|
|
{
|
2017-05-03 20:41:37 +02:00
|
|
|
DefinedHighlighters() : HighlighterGroup{HighlightPass::All} {}
|
2014-06-10 20:58:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // highlighter_group_hh_INCLUDED
|