Introduce a LineNumberWrapped face

This commit is contained in:
Maxime Coste 2017-05-01 21:26:50 +01:00
parent 39826afde5
commit 23e38a254f
4 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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 } },

View File

@ -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;
}
}