From: Michael D. Lowis Date: Sun, 22 Apr 2018 02:36:30 +0000 (-0400) Subject: added logic for drawing selection X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=cca4a1671a93cb4fc4cacd9acd42ce337df8dd0e;p=projs%2Ftide.git added logic for drawing selection --- diff --git a/lib/view.c b/lib/view.c index b3463f1..dfbc5e8 100644 --- a/lib/view.c +++ b/lib/view.c @@ -168,7 +168,10 @@ void view_setcursor(View* view, size_t row, size_t col, bool extsel) { y += selrow->cols[i].width; if (col < y) break; } + /* Set cursor/selection */ getsel(view)->end = selrow->cols[i].off; + if (!extsel) + getsel(view)->beg = getsel(view)->end; } void view_selword(View* view, size_t row, size_t col) { diff --git a/lib/x11.c b/lib/x11.c index 6106b88..1b8aa47 100644 --- a/lib/x11.c +++ b/lib/x11.c @@ -302,7 +302,9 @@ static void draw_view(int i, size_t nrows, drawcsr* csr, int bg, int fg, int sel int rune = row->cols[i].rune; if (rune == '\r' || rune == '\n' || rune == '\t') rune = ' '; - if (row->cols[i].off == view->buffer.selection.end) + if (buf_insel(&(view->buffer), row->cols[i].off)) + draw_rect(sel, x, y, row->cols[i].width, fheight); + if (!view_selsize(view) && row->cols[i].off == view->buffer.selection.end) draw_rect((i == TAGS ? TagsCsr : EditCsr), x, y, 1, fheight); specs[i].glyph = XftCharIndex(X.display, X.font, rune); specs[i].x = x;