diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-06-18 20:50:39 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-06-18 20:50:39 +0100 |
| commit | e202b7af50e81cfb72c8b03a73f8ed6d52bd4e9c (patch) | |
| tree | f378f7a520e4326e04fab7e9934ae49e58d7c59e /src | |
| parent | 6f2569ff30aecad1320b405249baed4bb1c1b6df (diff) | |
Add a line_option highlighter that highlight the line stored in an int option
Use it to highlight the current error in the *make* buffer
Diffstat (limited to 'src')
| -rw-r--r-- | src/highlighters.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/highlighters.cc b/src/highlighters.cc index b1213b6c..c7fcb748 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -391,6 +391,28 @@ HighlighterAndId highlight_regex_option_factory(HighlighterParameters params) return {"hloption_" + option_name, make_dynamic_regex_highlighter(get_regex, get_color)}; } +HighlighterAndId highlight_line_option_factory(HighlighterParameters params) +{ + if (params.size() != 2) + throw runtime_error("wrong parameter count"); + + const ColorPair& color = get_color(params[1]); + + String option_name = params[0]; + // verify option type now + GlobalOptions::instance()[option_name].get<int>(); + + auto highlighter = [=](const Context& context, HighlightFlags flags, + DisplayBuffer& display_buffer) + { + int line = context.options()[option_name].get<int>(); + highlight_range(display_buffer, {line-1, 0}, {line, 0}, false, + apply_colors(color)); + }; + + return {"hlline_" + option_name, std::move(highlighter)}; +} + void expand_tabulations(const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer) { const int tabstop = context.options()["tabstop"].get<int>(); @@ -1177,6 +1199,7 @@ void register_highlighters() registry.register_func("search", highlight_search_factory); registry.register_func("group", highlighter_group_factory); registry.register_func("flag_lines", flag_lines_factory); + registry.register_func("line_option", highlight_line_option_factory); registry.register_func("ref", reference_factory); registry.register_func("region", RegionHighlight::region_factory); registry.register_func("multi_region", RegionHighlight::multi_region_factory); |
