diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-10-17 22:41:18 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-11-08 13:37:23 +0100 |
| commit | 87c609e4c53202b4151c09bf479dc615eab4f84e (patch) | |
| tree | db882cca5dad2124edcda96925ae07a9aea07d5a /ui-curses.c | |
| parent | c339bb3ae6646c3dbef8e73f41c1e797ed5ec99b (diff) | |
| download | vis-87c609e4c53202b4151c09bf479dc615eab4f84e.tar.gz vis-87c609e4c53202b4151c09bf479dc615eab4f84e.tar.xz | |
vis: implement :set cursorline
Diffstat (limited to 'ui-curses.c')
| -rw-r--r-- | ui-curses.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/ui-curses.c b/ui-curses.c index d00dbf3..fd55705 100644 --- a/ui-curses.c +++ b/ui-curses.c @@ -17,6 +17,7 @@ #include "ui.h" #include "ui-curses.h" #include "util.h" +#include "text-util.h" #ifdef NCURSES_VERSION # ifndef NCURSES_EXT_COLORS @@ -649,9 +650,18 @@ static void ui_window_draw(UiWin *w) { wmove(win->win, 0, 0); int width = view_width_get(win->view); CellStyle *prev_style = NULL; + size_t cursor_lineno = -1; + if (win->options & UI_OPTION_CURSOR_LINE && win->ui->selwin == win) { + Cursor *cursor = view_cursors(win->view); + Filerange selection = view_cursors_selection_get(cursor); + if (!view_cursors_next(cursor) && !text_range_valid(&selection)) + cursor_lineno = view_cursor_getpos(win->view).line; + } short selection_bg = win->styles[UI_STYLE_SELECTION].bg; + short cursor_line_bg = win->styles[UI_STYLE_CURSOR_LINE].bg; attr_t attr; for (const Line *l = view_lines_get(win->view); l; l = l->next) { + bool cursor_line = l->lineno == cursor_lineno; for (int x = 0; x < width; x++) { CellStyle *style = &win->styles[l->cells[x].attr]; if (l->cells[x].cursor && (win->ui->selwin == win || win->ui->prompt_win == win)) { @@ -660,6 +670,9 @@ static void ui_window_draw(UiWin *w) { } else if (l->cells[x].selected) { attr = style->attr | COLOR_PAIR(color_pair_get(style->fg, selection_bg)); prev_style = NULL; + } else if (cursor_line) { + attr = style->attr | COLOR_PAIR(color_pair_get(style->fg, cursor_line_bg)); + prev_style = NULL; } else if (style != prev_style) { attr = style_to_attr(style); prev_style = style; |
