Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/themes/base-16.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ lexers.STYLE_IDENTIFIER = ''
lexers.STYLE_LINENUMBER = ''
lexers.STYLE_LINENUMBER_CURSOR = lexers.STYLE_LINENUMBER
lexers.STYLE_CURSOR = 'back:white,keep_attribute'
lexers.STYLE_CURSOR_PRIMARY = lexers.STYLE_CURSOR
lexers.STYLE_CURSOR_MATCHING = lexers.STYLE_CURSOR
lexers.STYLE_CURSOR_LINE = 'underlined,keep_attribute'
lexers.STYLE_COLOR_COLUMN = 'back:red'
lexers.STYLE_SELECTION = 'back:white,fore:black,keep_attribute'
Expand Down
2 changes: 1 addition & 1 deletion lua/themes/solarized.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ lexers.STYLE_IDENTIFIER = fg
lexers.STYLE_LINENUMBER = 'fore:'..colors.base00..',back:'..colors.base02
lexers.STYLE_LINENUMBER_CURSOR = 'back:'..colors.base00..',fore:'..colors.base02
lexers.STYLE_CURSOR = 'fore:'..colors.base03..',back:'..colors.base0..',keep_attribute'
lexers.STYLE_CURSOR_PRIMARY = lexers.STYLE_CURSOR..',back:yellow'
lexers.STYLE_CURSOR_MATCHING = lexers.STYLE_CURSOR..',back:yellow'
lexers.STYLE_CURSOR_LINE = 'back:'..colors.base02..',keep_attribute'
lexers.STYLE_COLOR_COLUMN = 'back:'..colors.base02
-- lexers.STYLE_SELECTION = 'back:'..colors.base02
Expand Down
2 changes: 1 addition & 1 deletion lua/themes/zenburn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ lexers.STYLE_IDENTIFIER = ''
lexers.STYLE_LINENUMBER = 'fore:#585858'
lexers.STYLE_LINENUMBER_CURSOR = 'fore:#666666'
lexers.STYLE_CURSOR = 'back:#585858,keep_attribute'
lexers.STYLE_CURSOR_PRIMARY = 'fore:#1c1c1c,back:#87afaf,bold,keep_attribute'
lexers.STYLE_CURSOR_MATCHING = 'fore:#1c1c1c,back:#87afaf,bold,keep_attribute'
lexers.STYLE_CURSOR_LINE = 'back:#444444,keep_attribute'
lexers.STYLE_COLOR_COLUMN = 'back:#444444'
lexers.STYLE_SELECTION = 'back:#5f875f'
Expand Down
2 changes: 1 addition & 1 deletion lua/vis-std.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ vis:option_register("theme", "string", function(name)
local ui = vis.ui
ui:style_define(ui.style_ids.DEFAULT, lexers.STYLE_DEFAULT or '')
ui:style_define(ui.style_ids.CURSOR, lexers.STYLE_CURSOR or '')
ui:style_define(ui.style_ids.CURSOR_PRIMARY, lexers.STYLE_CURSOR_PRIMARY or '')
ui:style_define(ui.style_ids.CURSOR_MATCHING, lexers.STYLE_CURSOR_MATCHING or '')
ui:style_define(ui.style_ids.CURSOR_LINE, lexers.STYLE_CURSOR_LINE or '')
ui:style_define(ui.style_ids.SELECTION, lexers.STYLE_SELECTION or '')
ui:style_define(ui.style_ids.LINENUMBER, lexers.STYLE_LINENUMBER or '')
Expand Down
7 changes: 6 additions & 1 deletion ui-terminal-curses.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ static bool ui_term_backend_resize(Ui *tui, int width, int height) {
}

static void ui_term_backend_save(Ui *tui, bool fscr) {
curs_set(1);
if (fscr) {
def_prog_mode();
endwin();
Expand All @@ -242,6 +243,11 @@ static void ui_term_backend_save(Ui *tui, bool fscr) {
static void ui_term_backend_restore(Ui *tui) {
reset_prog_mode();
wclear(stdscr);
curs_set(0);
}

static void ui_term_backend_cursor(Ui *tui, bool visible) {
curs_set(visible ? 1 : 0);
}

int ui_terminal_colors(void) {
Expand Down Expand Up @@ -284,7 +290,6 @@ ui_term_backend_suspend(Ui *ui)
{
if (ui->curses.change_colors == 1)
undo_palette();
curs_set(1);
}

VIS_INTERNAL void
Expand Down
16 changes: 14 additions & 2 deletions ui-terminal-vt100.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,26 @@ ui_term_backend_blit(Ui *ui)
}

VIS_INTERNAL void ui_term_backend_clear(Ui *ui) {}
VIS_INTERNAL void ui_term_backend_save(Ui *ui, bool fscr) {}

VIS_INTERNAL void
ui_term_backend_save(Ui *ui, bool fscr)
{
vis_ui_vt100_cursor_visible(true);
}

VIS_INTERNAL void
ui_term_backend_restore(Ui *ui)
{
vis_ui_vt100_cursor_visible(false);
ui->vt100.flush_terminal = true;
}

VIS_INTERNAL void
ui_term_backend_cursor(Ui *ui, bool visible)
{
vis_ui_vt100_cursor_visible(visible);
}

VIS_INTERNAL bool
ui_term_backend_resize(Ui *ui, int width, int height)
{
Expand All @@ -262,8 +274,8 @@ VIS_INTERNAL void
ui_term_backend_suspend(Ui *tui)
{
termkey_stop(&tui->termkey);
vis_ui_vt100_cursor_visible(true);
vis_ui_vt100_altscreen(false);
vis_ui_vt100_cursor_visible(true);
}

VIS_INTERNAL void
Expand Down
11 changes: 7 additions & 4 deletions ui-terminal.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,15 +408,17 @@ VIS_INTERNAL void
ui_draw(Vis *vis)
{
Ui *tui = &vis->ui;
ui_arrange(vis, vis->ui.layout);
ui_arrange(vis, tui->layout);

for (Win *win = vis->windows; win; win = win->next)
ui_window_draw(win);

/* determine primary cursor's position */
bool show_cursor = false;
if (vis->win) {
Win *win = vis->win;
View *view = &win->view;
view_coord_get(view, view_cursor_get(view), 0, &tui->cur_row, &tui->cur_col);
show_cursor = view_coord_get(view, view_cursor_get(view), 0, &tui->cur_row, &tui->cur_col);
tui->cur_col += win->sidebar_width + win->x;
tui->cur_row += win->y;
}
Expand All @@ -425,8 +427,9 @@ ui_draw(Vis *vis)
case PROMPTSTATE_ONELINE:
break;
case PROMPTSTATE_COMMAND:
tui->cur_row = vis->ui.height;
show_cursor = false;
}
ui_term_backend_cursor(tui, show_cursor);
if (tui->info[0])
ui_draw_string(tui, 0, tui->height-1, tui->info, UI_STYLE_INFO);
vis_event_emit(vis, VIS_EVENT_UI_DRAW);
Expand Down Expand Up @@ -611,7 +614,7 @@ ui_init(Ui *tui)
tui->styles[it] = default_style;

tui->styles[UI_STYLE_CURSOR].attributes |= VisCellAttribute_Reverse;
tui->styles[UI_STYLE_CURSOR_PRIMARY].attributes |= VisCellAttribute_Reverse|VisCellAttribute_Blink;
tui->styles[UI_STYLE_CURSOR_MATCHING].attributes |= VisCellAttribute_Reverse|VisCellAttribute_Blink;
tui->styles[UI_STYLE_SELECTION].attributes |= VisCellAttribute_Reverse;
tui->styles[UI_STYLE_COLOR_COLUMN].attributes |= VisCellAttribute_Reverse;
tui->styles[UI_STYLE_STATUS].attributes |= VisCellAttribute_Reverse;
Expand Down
2 changes: 1 addition & 1 deletion ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ enum UiOption {
typedef enum {
UI_STYLE_DEFAULT,
UI_STYLE_CURSOR,
UI_STYLE_CURSOR_PRIMARY,
UI_STYLE_CURSOR_MATCHING,
UI_STYLE_CURSOR_LINE,
UI_STYLE_SELECTION,
UI_STYLE_LINENUMBER,
Expand Down
2 changes: 1 addition & 1 deletion vis-lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -3420,7 +3420,7 @@ static void vis_lua_init(Vis *vis)
{UI_STYLE_MAX, "MAX" },
{UI_STYLE_DEFAULT, "DEFAULT" },
{UI_STYLE_CURSOR, "CURSOR" },
{UI_STYLE_CURSOR_PRIMARY, "CURSOR_PRIMARY" },
{UI_STYLE_CURSOR_MATCHING, "CURSOR_MATCHING" },
{UI_STYLE_CURSOR_LINE, "CURSOR_LINE" },
{UI_STYLE_SELECTION, "SELECTION" },
{UI_STYLE_LINENUMBER, "LINENUMBER" },
Expand Down
1 change: 1 addition & 0 deletions vis-prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ vis_prompt_enter(Vis *vis, const char *keys, const Arg *arg)
} else {
vis->win = prompt;
vis->mode = vis_modes + VIS_MODE_INSERT;
vis->prompt_state = PROMPTSTATE_ONELINE;
}
free(cmd);
return keys;
Expand Down
13 changes: 9 additions & 4 deletions vis.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ static void window_draw_selection(Win *win, Selection *cur) {
Filerange sel = view_selections_get(cur);
if (!text_range_valid(sel))
return;
bool skip_cursor = win->vis->win == win && cur == view_selections_primary_get(view);
Line *start_line; int start_col;
Line *end_line; int end_col;
view_coord_get(view, sel.start, &start_line, NULL, &start_col);
Expand All @@ -234,8 +235,11 @@ static void window_draw_selection(Win *win, Selection *cur) {
for (Line *l = start_line; l != end_line->next; l = l->next) {
int col = (l == start_line) ? start_col : 0;
int end = (l == end_line) ? end_col : l->width;
while (col < end)
vis_ui_window_style_set(&win->vis->ui, l->cells + col++, UI_STYLE_SELECTION);
for (; col < end; col++) {
if (skip_cursor && l == cur->line && col == cur->col)
continue;
vis_ui_window_style_set(&win->vis->ui, l->cells + col, UI_STYLE_SELECTION);
}
}
}

Expand All @@ -250,7 +254,7 @@ static void window_draw_cursor_matching(Win *win, Selection *cur) {
return;
if (!view_coord_get(&win->view, pos_match, &line_match, NULL, &col_match))
return;
vis_ui_window_style_set(&win->vis->ui, line_match->cells + col_match, UI_STYLE_SELECTION);
vis_ui_window_style_set(&win->vis->ui, line_match->cells + col_match, UI_STYLE_CURSOR_MATCHING);
}

static void window_draw_cursor(Win *win, Selection *cur) {
Expand All @@ -260,7 +264,8 @@ static void window_draw_cursor(Win *win, Selection *cur) {
if (!line)
return;
Selection *primary = view_selections_primary_get(&win->view);
vis_ui_window_style_set(&win->vis->ui, line->cells + cur->col, primary == cur ? UI_STYLE_CURSOR_PRIMARY : UI_STYLE_CURSOR);
if (cur != primary)
vis_ui_window_style_set(&win->vis->ui, line->cells + cur->col, UI_STYLE_CURSOR);
window_draw_cursor_matching(win, cur);
return;
}
Expand Down
Loading