summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-02-04 10:57:21 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-02-04 10:57:21 -0500
commit36673f1e78537de87ce58566f947a995e5897799 (patch)
treedb4a265e26b5bbbcd09e975feb352a2574b783d4
parent5a207b62cebb4673eb3422001e8d9435fca9f545 (diff)
highlight cursor line number
-rw-r--r--buffer.c5
-rw-r--r--colors.h2
-rw-r--r--ted.cfg1
3 files changed, 6 insertions, 2 deletions
diff --git a/buffer.c b/buffer.c
index 9df8b65..d42d53a 100644
--- a/buffer.c
+++ b/buffer.c
@@ -1927,11 +1927,12 @@ void buffer_render(TextBuffer *buffer, Rect r) {
float y = render_start_y;
text_chars_begin(font);
- gl_color_rgba(colors[COLOR_LINE_NUMBERS]);
- for (u32 line = start_line; line < buffer->nlines; ++line) {
+ u32 cursor_line = buffer->cursor_pos.line;
+ for (u32 line = start_line; line < nlines; ++line) {
char str[32] = {0};
strbuf_printf(str, U32_FMT, line + 1); // convert line number to string
float x = x1 + line_number_width - (float)strlen(str) * char_width; // right justify
+ gl_color_rgba(colors[line == cursor_line ? COLOR_CURSOR_LINE_NUMBER : COLOR_LINE_NUMBERS]);
text_render_with_state(font, &text_state, str, x, y);
y += char_height;
if (y > y2) break;
diff --git a/colors.h b/colors.h
index 374d652..c37240a 100644
--- a/colors.h
+++ b/colors.h
@@ -32,6 +32,7 @@ ENUM_U16 {
COLOR_CONSTANT,
COLOR_LINE_NUMBERS,
+ COLOR_CURSOR_LINE_NUMBER,
COLOR_LINE_NUMBERS_SEPARATOR,
COLOR_COUNT
@@ -72,6 +73,7 @@ static ColorName const color_names[COLOR_COUNT] = {
{COLOR_NO, "no"},
{COLOR_CANCEL, "cancel"},
{COLOR_LINE_NUMBERS, "line-numbers"},
+ {COLOR_CURSOR_LINE_NUMBER, "cursor-line-number"},
{COLOR_LINE_NUMBERS_SEPARATOR, "line-numbers-separator"},
};
diff --git a/ted.cfg b/ted.cfg
index 325c444..96f00e2 100644
--- a/ted.cfg
+++ b/ted.cfg
@@ -142,6 +142,7 @@ comment = #999
constant = #8ff
line-numbers = #779
+cursor-line-number = #ddf
line-numbers-separator = #fff3
[extensions]