mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-25 20:41:49 +03:00
Introduce a LineNumberWrapped face
This commit is contained in:
parent
39826afde5
commit
23e38a254f
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 } },
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user