From cca4a1671a93cb4fc4cacd9acd42ce337df8dd0e Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Sat, 21 Apr 2018 22:36:30 -0400 Subject: [PATCH] added logic for drawing selection --- lib/view.c | 3 +++ lib/x11.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) 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; -- 2.49.0