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"
|
2017-10-28 05:00:51 +02:00
|
|
|
#include "safe_ptr.hh"
|
2014-06-10 20:58:02 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
2017-10-28 05:00:51 +02:00
|
|
|
protected:
|
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
|
|
|
};
|
|
|
|
|
2017-10-31 06:53:08 +01:00
|
|
|
struct ScopeList;
|
|
|
|
|
|
|
|
class Highlighters : public SafeCountable
|
2017-10-28 05:00:51 +02:00
|
|
|
{
|
|
|
|
public:
|
2017-10-31 06:53:08 +01:00
|
|
|
Highlighters(Highlighters& parent) : SafeCountable{}, m_parent{&parent}, m_group{HighlightPass::All} {}
|
2017-10-28 05:00:51 +02:00
|
|
|
|
2017-10-31 06:53:08 +01:00
|
|
|
HighlighterGroup& group() { return m_group; }
|
|
|
|
const HighlighterGroup& group() const { return m_group; }
|
|
|
|
|
|
|
|
void highlight(const Context& context, HighlightPass pass, DisplayBuffer& display_buffer, BufferRange range);
|
|
|
|
void compute_display_setup(const Context& context, HighlightPass pass, DisplaySetup& setup);
|
2017-10-28 05:00:51 +02:00
|
|
|
|
2017-10-31 06:53:08 +01:00
|
|
|
private:
|
2017-10-28 05:00:51 +02:00
|
|
|
friend class Scope;
|
2017-10-31 06:53:08 +01:00
|
|
|
Highlighters() : m_group{HighlightPass::All} {}
|
2017-10-28 05:00:51 +02:00
|
|
|
|
|
|
|
SafePtr<Highlighters> m_parent;
|
2017-10-31 06:53:08 +01:00
|
|
|
HighlighterGroup m_group;
|
2017-10-28 05:00:51 +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
|