]> git.mdlowis.com Git - projs/tide.git/commitdiff
tweaked line selection behavior to highlight entire line instead of just the text
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 4 Jul 2017 02:34:52 +0000 (22:34 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 4 Jul 2017 02:34:52 +0000 (22:34 -0400)
TODO.md
inc/x11.h
lib/view.c
lib/win.c
lib/x11.c
pick.c

diff --git a/TODO.md b/TODO.md
index 05882683f035b03eabfbc699e3b588d35cae6699..da354ce7eb88bedd97077d598b77058a01b71f38 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -88,17 +88,10 @@ Region  GROUP start=REGEX skip=REGEX end=REGEX
 https://www.slant.co/topics/358/~best-color-themes-for-text-editors
 
 * Wily
-* Gruvbox
 * badwolf
 * jelly beans
-* monokai/molokai
-* tomorrow
-* spacegray
-* base16
-* dracula
 * one dark
 * zenburn
-* ayu
 * railscast
 * material
 * spacemacs
@@ -106,13 +99,9 @@ https://www.slant.co/topics/358/~best-color-themes-for-text-editors
 * soda light
 * predawn
 * lucario
-* vim desert
-* two firewatch
 * obsidian
 * leuven
 * afterglow
-* apathy
-* vim guru
 * nord
 * plastic code wrap
 * wombat
index bb3c7460d05094244c08018f97c7f9ef3c1c7169..a78e0006b27c31738a6c52372a93bdb6598930ff 100644 (file)
--- a/inc/x11.h
+++ b/inc/x11.h
@@ -142,7 +142,7 @@ size_t x11_font_getglyphs(XGlyphSpec* specs, const XGlyph* glyphs, int len, XFon
 
 void x11_draw_rect(int color, int x, int y, int width, int height);
 void x11_draw_utf8(XFont font, int fg, int bg, int x, int y, char* str);
-void x11_draw_glyphs(int fg, int bg, XGlyphSpec* glyphs, size_t nglyphs);
+void x11_draw_glyphs(int fg, int bg, XGlyphSpec* specs, size_t nspecs, bool eol);
 void x11_draw_utf8(XFont font, int fg, int bg, int x, int y, char* str);
 
 bool x11_sel_get(int selid, void(*cbfn)(char*));
index d7104a212fd9837e3b71f637a5a4c70aa45aecf4..36a7b1b3021a7fc4fcad51e95ca3480943759835 100644 (file)
@@ -548,7 +548,9 @@ static size_t setcell(View* view, size_t row, size_t col, uint32_t attr, Rune r)
     int ncols = runewidth(col, r);
     /* write the rune to the screen buf */
     scrrow->cols[col].attr = attr;
-    if (r == '\t' || r == '\n' || r == RUNE_CRLF)
+    if (r == RUNE_CRLF)
+        scrrow->cols[col].rune = '\n';
+    else if (r == '\t')
         scrrow->cols[col].rune = ' ';
     else
         scrrow->cols[col].rune = r;
index f08d310e0e30b19b1e71f63b447ce76c55155a5d..3f68dc6c512ee5746b02cef6efa5e4b5413d407a 100644 (file)
--- a/lib/win.c
+++ b/lib/win.c
@@ -416,10 +416,13 @@ static void draw_line_num(bool current, size_t x, size_t y, size_t gcols, size_t
 static void draw_glyphs(size_t x, size_t y, UGlyph* glyphs, size_t rlen, size_t ncols) {
     XGlyphSpec specs[rlen];
     size_t i = 0;
+    bool eol = false;
     while (rlen && i < ncols) {
         int numspecs = 0;
         uint32_t attr = glyphs[i].attr;
         while (i < ncols && glyphs[i].attr == attr) {
+            if (glyphs[i].rune == '\n')
+                glyphs[i].rune = ' ', eol = true;
             x11_font_getglyph(Font, &(specs[numspecs]), glyphs[i].rune);
             specs[numspecs].x = x;
             specs[numspecs].y = y - x11_font_descent(Font);
@@ -433,8 +436,8 @@ static void draw_glyphs(size_t x, size_t y, UGlyph* glyphs, size_t rlen, size_t
         /* Draw the glyphs with the proper colors */
         uint8_t bg = attr >> 8;
         uint8_t fg = attr & 0xFF;
-        x11_draw_glyphs(fg, bg, specs, numspecs);
-        rlen -= numspecs;
+        x11_draw_glyphs(fg, bg, specs, numspecs, eol);
+        eol = false, rlen -= numspecs;
     }
 }
 
index 17530cde0469960e98277a68f79507fea545f4e5..5e9e2cd43f468065ba64cc2d33148d26205a54b7 100644 (file)
--- a/lib/x11.c
+++ b/lib/x11.c
@@ -436,7 +436,7 @@ void x11_font_getglyph(XFont fnt, XGlyphSpec* spec, uint32_t rune) {
     /* Otherwise check the cache */
     for (int f = 0; f < font->ncached; f++) {
         glyphidx = XftCharIndex(X.display, font->cache[f].font, rune);
-        /* Fond a suitable font or found a default font */
+        /* Found a suitable font or found a default font */
         if (glyphidx || (!glyphidx && font->cache[f].unicodep == rune)) {
             spec->font  = font->cache[f].font;
             spec->glyph = glyphidx;
@@ -488,10 +488,11 @@ size_t x11_font_getglyphs(XGlyphSpec* specs, const XGlyph* glyphs, int len, XFon
     return numspecs;
 }
 
-void x11_draw_glyphs(int fg, int bg, XGlyphSpec* specs, size_t nspecs) {
+void x11_draw_glyphs(int fg, int bg, XGlyphSpec* specs, size_t nspecs, bool eol) {
     if (!nspecs) return;
     XftFont* font = specs[0].font;
     XftColor fgc, bgc;
+
     if (bg > 0) {
         XGlyphInfo extent;
         XftTextExtentsUtf8(X.display, font, (const FcChar8*)"0", 1, &extent);
@@ -499,6 +500,7 @@ void x11_draw_glyphs(int fg, int bg, XGlyphSpec* specs, size_t nspecs) {
         int h = (font->height - font->descent) + config_get_int(LineSpacing);
         xftcolor(&bgc, bg);
         size_t width = specs[nspecs-1].x - specs[0].x + w;
+        if (eol) width = X.width - specs[0].x;
         x11_draw_rect(bg, specs[0].x, specs[0].y - h, width, font->height + config_get_int(LineSpacing));
         XftColorFree(X.display, X.visual, X.colormap, &bgc);
     }
@@ -519,7 +521,7 @@ void x11_draw_utf8(XFont fnt, int fg, int bg, int x, int y, char* str) {
         nspecs++;
         str++;
     }
-    x11_draw_glyphs(fg, bg, (XGlyphSpec*)specs, nspecs);
+    x11_draw_glyphs(fg, bg, (XGlyphSpec*)specs, nspecs, false);
 }
 
 /* Selection Handling
diff --git a/pick.c b/pick.c
index ee5e183ea976087f59b0fe768f3c94e474186fed..801b9a310b36788f0cc61cba700169018536aaba 100644 (file)
--- a/pick.c
+++ b/pick.c
@@ -146,7 +146,7 @@ void onupdate(void) {
             view_insert(view, false, *str);
         view_insert(view, false, '\n');
         if (ChoiceIdx == i+off) {
-            selection.beg = view->selection.end-1;
+            selection.beg = view->selection.end;
             selection.end = beg;
         }
     }