From 23e38a254f057558bcef57844a79c566719ad307 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 1 May 2017 21:26:50 +0100 Subject: [PATCH] Introduce a LineNumberWrapped face --- README.asciidoc | 2 ++ doc/manpages/faces.asciidoc | 3 +++ src/face_registry.cc | 1 + src/highlighters.cc | 6 +++++- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index 97c829371..5abcc032f 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -1032,6 +1032,8 @@ There are some builtins faces used by internal Kakoune functionalities: * `LineNumbers`: face used by the number_lines highlighter * `LineNumberCursor`: face used to highlight the line number of the main selection + * `LineNumberWrapped`: face used to highlight the line number of wrapped + lines * `MenuForeground`: face for the selected element in menus * `MenuBackground`: face for the not selected elements in menus * `Information`: face for the informations windows and information messages diff --git a/doc/manpages/faces.asciidoc b/doc/manpages/faces.asciidoc index 509b42a3a..324a98d5f 100644 --- a/doc/manpages/faces.asciidoc +++ b/doc/manpages/faces.asciidoc @@ -68,6 +68,9 @@ areas of the user interface: *LineNumberCursor*:: face used to highlight the line number of the main selection +*LineNumberWrapped*:: + face used to highlight the line number of wrapped lines + *MenuForeground*:: face for the selected element in menus diff --git a/src/face_registry.cc b/src/face_registry.cc index d0d15c104..a533d09e8 100644 --- a/src/face_registry.cc +++ b/src/face_registry.cc @@ -107,6 +107,7 @@ FaceRegistry::FaceRegistry() { "SecondaryCursor", Face{ Color::Black, Color::White } }, { "LineNumbers", Face{ Color::Default, Color::Default } }, { "LineNumberCursor", Face{ Color::Default, Color::Default, Attribute::Reverse } }, + { "LineNumbersWrapped", Face{ Color::Default, Color::Default, Attribute::Italic } }, { "MenuForeground", Face{ Color::White, Color::Blue } }, { "MenuBackground", Face{ Color::Blue, Color::White } }, { "MenuInfo", Face{ Color::Cyan, Color::Default } }, diff --git a/src/highlighters.cc b/src/highlighters.cc index 9a57d4619..db9b7fda1 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -924,12 +924,14 @@ struct LineNumbersHighlighter : Highlighter return; const Face face = get_face("LineNumbers"); + const Face face_wrapped = get_face("LineNumbersWrapped"); const Face face_absolute = get_face("LineNumberCursor"); int digit_count = compute_digit_count(context); char format[16]; format_to(format, "%{}d{}", digit_count, m_separator); const int main_line = (int)context.selections().main().cursor().line + 1; + int last_line = -1; for (auto& line : display_buffer.lines()) { const int current_line = (int)line.range().begin.line + 1; @@ -939,8 +941,10 @@ struct LineNumbersHighlighter : Highlighter char buffer[16]; snprintf(buffer, 16, format, std::abs(line_to_format)); DisplayAtom atom{buffer}; - atom.face = (m_hl_cursor_line and is_cursor_line) ? face_absolute : face; + atom.face = last_line == current_line ? face_wrapped : + ((m_hl_cursor_line and is_cursor_line) ? face_absolute : face); line.insert(line.begin(), std::move(atom)); + last_line = current_line; } }