2011-11-29 23:37:20 +01:00
|
|
|
#ifndef highlighter_hh_INCLUDED
|
|
|
|
#define highlighter_hh_INCLUDED
|
|
|
|
|
2013-04-09 20:05:40 +02:00
|
|
|
#include "function_group.hh"
|
|
|
|
#include "function_registry.hh"
|
|
|
|
#include "memoryview.hh"
|
2012-11-23 13:40:20 +01:00
|
|
|
#include "string.hh"
|
|
|
|
#include "utils.hh"
|
2013-04-09 20:05:40 +02:00
|
|
|
|
|
|
|
#include <functional>
|
2011-11-29 23:37:20 +01:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
class DisplayBuffer;
|
2013-12-17 00:24:08 +01:00
|
|
|
class Context;
|
2011-11-29 23:37:20 +01:00
|
|
|
|
2014-01-18 02:56:51 +01:00
|
|
|
enum class HighlightFlags
|
|
|
|
{
|
|
|
|
Highlight,
|
|
|
|
MoveOnly
|
|
|
|
};
|
|
|
|
|
2012-01-11 15:21:58 +01:00
|
|
|
// An Highlighter is a function which mutates a DisplayBuffer in order to
|
|
|
|
// change the visual representation of a file. It could be changing text
|
|
|
|
// color, adding information text (line numbering for example) or replacing
|
|
|
|
// buffer content (folding for example)
|
|
|
|
|
2014-01-18 02:56:51 +01:00
|
|
|
using HighlighterFunc = std::function<void (const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer)>;
|
2014-01-09 20:50:01 +01:00
|
|
|
using HighlighterAndId = std::pair<String, HighlighterFunc>;
|
|
|
|
using HighlighterParameters = memoryview<String>;
|
2013-11-19 00:19:48 +01:00
|
|
|
using HighlighterFactory = std::function<HighlighterAndId (HighlighterParameters params)>;
|
2014-01-18 02:56:51 +01:00
|
|
|
using HighlighterGroup = FunctionGroup<const Context&, HighlightFlags, DisplayBuffer&>;
|
2013-03-27 13:41:41 +01:00
|
|
|
|
2012-11-23 13:40:20 +01:00
|
|
|
struct HighlighterRegistry : FunctionRegistry<HighlighterFactory>,
|
|
|
|
Singleton<HighlighterRegistry>
|
|
|
|
{};
|
2011-11-29 23:37:20 +01:00
|
|
|
|
2013-12-03 23:03:10 +01:00
|
|
|
struct DefinedHighlighters : public HighlighterGroup,
|
|
|
|
public Singleton<DefinedHighlighters>
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2011-11-29 23:37:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // highlighter_hh_INCLUDED
|