vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 4d273847f8cbedd4bf7a653ba6afbdd6ceede548
parent b39dfc799f075a0b821c599e4baf8c9b64ba704d
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Tue,  7 Apr 2015 14:08:06 +0200

Show cursor in visual mode

Diffstat:
Mconfig.def.h | 2++
Mwindow.c | 9++++++---
2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -469,6 +469,8 @@ static void vis_mode_visual_line_leave(Mode *new) { if (!new->visual) { window_selection_clear(vis->win->win); vis_modes[VIS_MODE_OPERATOR].parent = &vis_modes[VIS_MODE_MOVE]; + } else { + window_cursor_to(vis->win->win, window_cursor_get(vis->win->win)); } } diff --git a/window.c b/window.c @@ -76,7 +76,6 @@ void window_selection_clear(Win *win) { win->sel = text_range_empty(); window_draw(win); window_cursor_update(win); - curs_set(1); } /* reset internal window data structures (cell matrix, line offsets etc.) */ @@ -120,8 +119,11 @@ Filerange window_selection_get(Win *win) { } void window_selection_set(Win *win, Filerange *sel) { + Cursor *cursor = &win->cursor; win->sel = *sel; window_draw(win); + if (win->ui) + win->ui->cursor_to(win->ui, cursor->col, cursor->row); } Filerange window_viewport_get(Win *win) { @@ -841,9 +843,10 @@ void window_scroll_to(Win *win, size_t pos) { void window_selection_start(Win *win) { if (win->sel.start != EPOS && win->sel.end != EPOS) return; - win->sel.start = win->sel.end = window_cursor_get(win); + size_t pos = window_cursor_get(win); + win->sel.start = win->sel.end = pos; window_draw(win); - curs_set(0); + window_cursor_to(win, pos); } void window_syntax_set(Win *win, Syntax *syntax) {