aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-03-10 21:55:41 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-03-10 22:36:54 +0100
commit0e322d577bf834d8f7c9a7d3c53a58f8e7bb93c1 (patch)
treeeefe6bbc9eb8ce96d71cd8b857cace4caa662507
parent650ef03aa0529f7b69e4757697f161258b07ef1d (diff)
downloadvis-0e322d577bf834d8f7c9a7d3c53a58f8e7bb93c1.tar.gz
vis-0e322d577bf834d8f7c9a7d3c53a58f8e7bb93c1.tar.xz
ui: make primary cursor blink
-rw-r--r--lexers/themes/solarized.lua1
-rw-r--r--ui-curses.c6
-rw-r--r--ui.h1
-rw-r--r--view.c4
-rw-r--r--view.h1
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)
diff --git a/ui.h b/ui.h
index 76de366..2e471e9 100644
--- a/ui.h
+++ b/ui.h
@@ -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,
diff --git a/view.c b/view.c
index fb3a4a7..05fbaf3 100644
--- a/view.c
+++ b/view.c
@@ -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, "(){}[]\"'`");
diff --git a/view.h b/view.h
index f33f1a8..f2e30eb 100644
--- a/view.h
+++ b/view.h
@@ -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;