diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-03-10 21:55:41 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-03-10 22:36:54 +0100 |
| commit | 0e322d577bf834d8f7c9a7d3c53a58f8e7bb93c1 (patch) | |
| tree | eefe6bbc9eb8ce96d71cd8b857cace4caa662507 | |
| parent | 650ef03aa0529f7b69e4757697f161258b07ef1d (diff) | |
| download | vis-0e322d577bf834d8f7c9a7d3c53a58f8e7bb93c1.tar.gz vis-0e322d577bf834d8f7c9a7d3c53a58f8e7bb93c1.tar.xz | |
ui: make primary cursor blink
| -rw-r--r-- | lexers/themes/solarized.lua | 1 | ||||
| -rw-r--r-- | ui-curses.c | 6 | ||||
| -rw-r--r-- | ui.h | 1 | ||||
| -rw-r--r-- | view.c | 4 | ||||
| -rw-r--r-- | view.h | 1 |
5 files changed, 12 insertions, 1 deletions
diff --git a/lexers/themes/solarized.lua b/lexers/themes/solarized.lua index 9470536..b7b89a3 100644 --- a/lexers/themes/solarized.lua +++ b/lexers/themes/solarized.lua @@ -52,6 +52,7 @@ lexers.STYLE_IDENTIFIER = fg lexers.STYLE_LINENUMBER = fg lexers.STYLE_CURSOR = 'fore:'..colors.base03..',back:'..colors.base0 +lexers.STYLE_CURSOR_PRIMARY = lexers.STYLE_CURSOR..',blink' lexers.STYLE_CURSOR_LINE = 'back:'..colors.base02 lexers.STYLE_COLOR_COLUMN = 'back:'..colors.base02 -- lexers.STYLE_SELECTION = 'back:'..colors.base02 diff --git a/ui-curses.c b/ui-curses.c index e38eb7b..35d43c8 100644 --- a/ui-curses.c +++ b/ui-curses.c @@ -683,13 +683,17 @@ static void ui_window_draw(UiWin *w) { } short selection_bg = win->styles[UI_STYLE_SELECTION].bg; short cursor_line_bg = win->styles[UI_STYLE_CURSOR_LINE].bg; + bool multiple_cursors = view_cursors_next(view_cursors(win->view)); attr_t attr = A_NORMAL; 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) { - attr = style_to_attr(&win->styles[UI_STYLE_CURSOR]); + if (multiple_cursors && l->cells[x].cursor_primary) + attr = style_to_attr(&win->styles[UI_STYLE_CURSOR_PRIMARY]); + else + attr = style_to_attr(&win->styles[UI_STYLE_CURSOR]); prev_style = NULL; } else if (l->cells[x].selected) { if (style->fg == selection_bg) @@ -32,6 +32,7 @@ enum UiStyles { UI_STYLE_LEXER_MAX = 64, UI_STYLE_DEFAULT, UI_STYLE_CURSOR, + UI_STYLE_CURSOR_PRIMARY, UI_STYLE_CURSOR_LINE, UI_STYLE_SELECTION, UI_STYLE_LINENUMBER, @@ -235,6 +235,9 @@ bool view_syntax_set(View *view, const char *name) { lua_getfield(L, -1, "STYLE_CURSOR"); view->ui->syntax_style(view->ui, UI_STYLE_CURSOR, lua_tostring(L, -1)); lua_pop(L, 1); + lua_getfield(L, -1, "STYLE_CURSOR_PRIMARY"); + view->ui->syntax_style(view->ui, UI_STYLE_CURSOR_PRIMARY, lua_tostring(L, -1)); + lua_pop(L, 1); lua_getfield(L, -1, "STYLE_CURSOR_LINE"); view->ui->syntax_style(view->ui, UI_STYLE_CURSOR_LINE, lua_tostring(L, -1)); lua_pop(L, 1); @@ -610,6 +613,7 @@ void view_draw(View *view) { size_t pos = view_cursors_pos(c); if (view_coord_get(view, pos, &c->line, &c->row, &c->col)) { c->line->cells[c->col].cursor = true; + c->line->cells[c->col].cursor_primary = (c == view->cursor); if (view->ui && !c->sel) { Line *line_match; int col_match; size_t pos_match = text_bracket_match_symbol(view->text, pos, "(){}[]\"'`"); @@ -28,6 +28,7 @@ typedef struct { unsigned int attr; bool selected; /* whether this cell is part of a selected region */ bool cursor; /* whether a cursor is currently located on the cell */ + bool cursor_primary; } Cell; typedef struct Line Line; |
