Fix reference highlighter not forwarding compute_display_setup
This commit is contained in:
parent
475e8849a1
commit
e9c0c05548
|
@ -1509,27 +1509,46 @@ HighlighterAndId create_highlighter_group(HighlighterParameters params)
|
||||||
return HighlighterAndId(parser[0], make_unique<HighlighterGroup>(passes));
|
return HighlighterAndId(parser[0], make_unique<HighlighterGroup>(passes));
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlighterAndId create_reference_highlighter(HighlighterParameters params)
|
struct ReferenceHighlighter : Highlighter
|
||||||
{
|
{
|
||||||
|
ReferenceHighlighter(HighlightPass passes, String name)
|
||||||
|
: Highlighter{passes}, m_name{std::move(name)} {}
|
||||||
|
|
||||||
|
static HighlighterAndId create(HighlighterParameters params)
|
||||||
|
{
|
||||||
static const ParameterDesc param_desc{
|
static const ParameterDesc param_desc{
|
||||||
{ { "passes", { true, "" } } },
|
{ { "passes", { true, "" } } },
|
||||||
ParameterDesc::Flags::SwitchesOnlyAtStart, 1, 1
|
ParameterDesc::Flags::SwitchesOnlyAtStart, 1, 1
|
||||||
};
|
};
|
||||||
ParametersParser parser{params, param_desc};
|
ParametersParser parser{params, param_desc};
|
||||||
HighlightPass passes = parse_passes(parser.get_switch("passes").value_or("colorize"));
|
HighlightPass passes = parse_passes(parser.get_switch("passes").value_or("colorize"));
|
||||||
|
return {parser[0], make_unique<ReferenceHighlighter>(passes, parser[0])};
|
||||||
|
}
|
||||||
|
|
||||||
const String& name = parser[0];
|
private:
|
||||||
auto func = [=](const Context& context, HighlightPass pass, DisplayBuffer& display_buffer, BufferRange range)
|
void do_highlight(const Context& context, HighlightPass pass,
|
||||||
|
DisplayBuffer& display_buffer, BufferRange range) override
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DefinedHighlighters::instance().get_child(name).highlight(context, pass, display_buffer, range);
|
DefinedHighlighters::instance().get_child(m_name).highlight(context, pass, display_buffer, range);
|
||||||
}
|
}
|
||||||
catch (child_not_found&)
|
catch (child_not_found&)
|
||||||
{}
|
{}
|
||||||
};
|
}
|
||||||
return {name, make_highlighter(func, passes)};
|
|
||||||
}
|
void do_compute_display_setup(const Context& context, HighlightPass pass, DisplaySetup& setup) override
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DefinedHighlighters::instance().get_child(m_name).compute_display_setup(context, pass, setup);
|
||||||
|
}
|
||||||
|
catch (child_not_found&)
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
|
||||||
|
const String m_name;
|
||||||
|
};
|
||||||
|
|
||||||
struct RegexMatch
|
struct RegexMatch
|
||||||
{
|
{
|
||||||
|
@ -2012,7 +2031,7 @@ void register_highlighters()
|
||||||
"wrap at word boundaries instead of codepoint boundaries if -word is given" } });
|
"wrap at word boundaries instead of codepoint boundaries if -word is given" } });
|
||||||
registry.insert({
|
registry.insert({
|
||||||
"ref",
|
"ref",
|
||||||
{ create_reference_highlighter,
|
{ ReferenceHighlighter::create,
|
||||||
"Parameters: [-passes <passes>] <path>\n"
|
"Parameters: [-passes <passes>] <path>\n"
|
||||||
"Reference the highlighter at <path> in shared highlighters\n"
|
"Reference the highlighter at <path> in shared highlighters\n"
|
||||||
"<passes> is a flags(colorize|move|wrap) defaulting to colorize\n"
|
"<passes> is a flags(colorize|move|wrap) defaulting to colorize\n"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user