2011-11-29 23:37:20 +01:00
|
|
|
#ifndef highlighter_hh_INCLUDED
|
|
|
|
#define highlighter_hh_INCLUDED
|
|
|
|
|
|
|
|
#include <functional>
|
2012-11-23 13:40:20 +01:00
|
|
|
|
|
|
|
#include "string.hh"
|
|
|
|
#include "utils.hh"
|
2012-02-03 20:14:35 +01:00
|
|
|
#include "memoryview.hh"
|
2012-11-23 13:40:20 +01:00
|
|
|
#include "function_registry.hh"
|
2013-03-27 13:41:41 +01:00
|
|
|
#include "function_group.hh"
|
2011-11-29 23:37:20 +01:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
class DisplayBuffer;
|
2012-11-23 13:40:20 +01:00
|
|
|
class Window;
|
2011-11-29 23:37:20 +01:00
|
|
|
|
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)
|
|
|
|
|
2011-11-29 23:37:20 +01:00
|
|
|
typedef std::function<void (DisplayBuffer& display_buffer)> HighlighterFunc;
|
2012-04-14 03:17:09 +02:00
|
|
|
typedef std::pair<String, HighlighterFunc> HighlighterAndId;
|
|
|
|
typedef memoryview<String> HighlighterParameters;
|
2012-01-15 14:44:16 +01:00
|
|
|
|
2013-03-06 14:17:28 +01:00
|
|
|
using HighlighterFactory = std::function<HighlighterAndId (const HighlighterParameters& params,
|
|
|
|
const Window& window)>;
|
2012-11-23 13:40:20 +01:00
|
|
|
|
2013-03-27 13:41:41 +01:00
|
|
|
using HighlighterGroup = FunctionGroup<DisplayBuffer&>;
|
|
|
|
|
2012-11-23 13:40:20 +01:00
|
|
|
struct HighlighterRegistry : FunctionRegistry<HighlighterFactory>,
|
|
|
|
Singleton<HighlighterRegistry>
|
|
|
|
{};
|
2011-11-29 23:37:20 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // highlighter_hh_INCLUDED
|