]> git.mdlowis.com Git - projs/tide.git/commitdiff
added logic for drawing selection
authorMichael D. Lowis <mike@mdlowis.com>
Sun, 22 Apr 2018 02:36:30 +0000 (22:36 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sun, 22 Apr 2018 02:36:30 +0000 (22:36 -0400)
lib/view.c
lib/x11.c

index b3463f152dfbb6f3925ddc7626cd1da9f343a87d..dfbc5e8918c7d803cb6de3985f8308111cb32bb5 100644 (file)
@@ -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) {
index 6106b882c3a4c5b565df651a2b891d95eab11fc6..1b8aa47fa417e28397d4b078843c690d0a7bbe06 100644 (file)
--- 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;