summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-05-05 20:21:17 +0100
committerMaxime Coste <frrrwww@gmail.com>2015-05-05 20:21:17 +0100
commit0ee95d02c45dfa768229dc6bfa3a18e910ca649b (patch)
tree5582276a4d404aa69049130345b73020891744c2
parent1a1db1cb3aa2afad849ac9619e524086ec306df8 (diff)
line highlighter highlights up to window's end
-rw-r--r--src/highlighters.cc28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/highlighters.cc b/src/highlighters.cc
index 839ab4b6..93cb0e4d 100644
--- a/src/highlighters.cc
+++ b/src/highlighters.cc
@@ -13,6 +13,7 @@
#include "parameters_parser.hh"
#include "register_manager.hh"
#include "string.hh"
+#include "window.hh"
#include "utf8.hh"
#include "utf8_iterator.hh"
@@ -505,9 +506,30 @@ HighlighterAndId create_line_highlighter(HighlighterParameters params)
auto func = [=](const Context& context, HighlightFlags flags,
DisplayBuffer& display_buffer, BufferRange)
{
- if (auto line = str_to_int_ifp(expand(option_name, context, {}, EnvVarMap{})))
- highlight_range(display_buffer, {*line-1, 0}, {*line, 0}, false,
- apply_face(get_face(facespec)));
+ const LineCount line = str_to_int_ifp(expand(option_name, context, {}, EnvVarMap{})).value_or(0) - 1;
+ if (line < 0)
+ return;
+
+ auto it = find_if(display_buffer.lines(),
+ [line](const DisplayLine& l)
+ { return l.range().begin.line == line; });
+ if (it == display_buffer.lines().end())
+ return;
+
+ auto face = get_face(facespec);
+ CharCount column = 0;
+ for (auto atom_it = it->begin(); atom_it != it->end(); ++atom_it)
+ {
+ column += atom_it->length();
+ if (!atom_it->has_buffer_range())
+ continue;
+
+ kak_assert(atom_it->begin().line == line);
+ apply_face(face)(*atom_it);
+ }
+ const CharCount remaining = context.window().dimensions().column - column;
+ if (remaining > 0)
+ it->push_back({ String{' ', remaining}, face });
};
return {"hlline_" + params[0], make_simple_highlighter(std::move(func))};