diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-12-12 23:16:07 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-12-12 23:16:07 +0000 |
| commit | b6105fa10664bf3f37bb134b8214c296c93456fd (patch) | |
| tree | 1aba979db01baf166404f52294ab587877e52928 /src | |
| parent | 8d7e16a8e61a1748a1ee390f633d24a5b3c84615 (diff) | |
Use markup for line-flags instead of a single face
Diffstat (limited to 'src')
| -rw-r--r-- | src/highlighters.cc | 31 | ||||
| -rw-r--r-- | src/highlighters.hh | 2 | ||||
| -rw-r--r-- | src/option_types.hh | 3 |
3 files changed, 26 insertions, 10 deletions
diff --git a/src/highlighters.cc b/src/highlighters.cc index 28e36660..aba0079d 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -944,22 +944,37 @@ HighlighterAndId create_flag_lines_highlighter(HighlighterParameters params) } auto def_face = get_face(default_face); + Vector<DisplayLine> display_lines; + for (auto& line : lines) + { + display_lines.push_back(parse_display_line(std::get<1>(line))); + for (auto& atom : display_lines.back()) + atom.face = merge_faces(def_face, atom.face); + } CharCount width = 0; - for (auto& l : lines) - width = std::max(width, std::get<2>(l).char_length()); - const String empty{' ', width}; + for (auto& l : display_lines) + width = std::max(width, l.length()); + const DisplayAtom empty{String{' ', width}, def_face}; for (auto& line : display_buffer.lines()) { int line_num = (int)line.range().begin.line + 1; auto it = find_if(lines, [&](const LineAndFlag& l) { return std::get<0>(l) == line_num; }); - String content = it != lines.end() ? std::get<2>(*it) : empty; - content += String(' ', width - content.char_length()); - DisplayAtom atom{std::move(content)}; - atom.face = it != lines.end() ? merge_faces(get_face(std::get<1>(*it)), def_face) : def_face; - line.insert(line.begin(), std::move(atom)); + if (it == lines.end()) + line.insert(line.begin(), empty); + else + { + DisplayLine& display_line = display_lines[it - lines.begin()]; + DisplayAtom padding_atom{String(' ', width - display_line.length()), def_face}; + auto it = std::copy(std::make_move_iterator(display_line.begin()), + std::make_move_iterator(display_line.end()), + std::inserter(line, line.begin())); + + if (padding_atom.length() != 0) + *it++ = std::move(padding_atom); + } } }; diff --git a/src/highlighters.hh b/src/highlighters.hh index 8c6fd3c4..26b7a5d1 100644 --- a/src/highlighters.hh +++ b/src/highlighters.hh @@ -9,7 +9,7 @@ namespace Kakoune void register_highlighters(); -using LineAndFlag = std::tuple<LineCount, String, String>; +using LineAndFlag = std::tuple<LineCount, String>; } diff --git a/src/option_types.hh b/src/option_types.hh index 73a8bcfb..0330a7e9 100644 --- a/src/option_types.hh +++ b/src/option_types.hh @@ -253,7 +253,8 @@ inline void option_from_string(StringView str, TimestampedList<T>& opt) { auto it = find(str, ':'); opt.timestamp = str_to_int({str.begin(), it}); - option_from_string({it+1, str.end()}, opt.list); + if (it != str.end()) + option_from_string({it+1, str.end()}, opt.list); } template<typename T> |
