vis

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

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

commit 3f575a3d2dcf6bc2c31a526c256a13ea147a25ac
parent 9782702cbd4333e6f623fd626c6fc526997e4b49
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sat,  4 Apr 2015 15:09:04 +0200

Fix drawing of selection

Diffstat:
Mui-curses.c | 17+++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/ui-curses.c b/ui-curses.c @@ -361,20 +361,17 @@ static void ui_window_cursor_to(UiWin *w, int x, int y) { static void ui_window_draw_text(UiWin *w, const Line *line) { UiCursesWin *win = (UiCursesWin*)w; wmove(win->win, 0, 0); - attr_t attr = 0; for (const Line *l = line; l; l = l->next) { /* add a single space in an otherwise empty line to make * the selection cohorent */ - if (l->width == 0) - waddch(win->win, ' '); - - for (int x = 0; x < l->width; x++) { - attr_t newattr = l->cells[x].attr; - if (newattr != attr) { - wattrset(win->win, newattr); - attr = newattr; + if (l->width == 1 && l->cells[0].data[0] == '\n') { + wattrset(win->win, l->cells[0].attr); + waddstr(win->win, " \n"); + } else { + for (int x = 0; x < l->width; x++) { + wattrset(win->win, l->cells[x].attr); + waddstr(win->win, l->cells[x].data); } - waddstr(win->win, l->cells[x].data); } wclrtoeol(win->win); }