]> git.mdlowis.com Git - projs/tide.git/commitdiff
corrected some of the math for drawing the scroll bar
authorMichael D. Lowis <mike@mdlowis.com>
Sun, 26 Feb 2017 21:43:45 +0000 (16:43 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Sun, 26 Feb 2017 21:43:45 +0000 (16:43 -0500)
TODO.md
lib/win.c

diff --git a/TODO.md b/TODO.md
index c12b6e4534a54ea742bed129d4d6ec4e739f483d..ec64a818213293faef57338273e9748e2f819020 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -3,6 +3,7 @@
 Up Next:
 
 * implement 9term-like scrollbar
+* tab inserts dont coalesce like one would expect
 * check for file changes on save
 * check for file changes when window regains focus
 * Right click in tags region should search edit region
index 1452defd8e7888176fe9107986329d8147902143..2c82d2d06cee2541169ccb9d9b04722737d81993 100644 (file)
--- a/lib/win.c
+++ b/lib/win.c
@@ -172,13 +172,15 @@ static void onredraw(int width, int height) {
     size_t vbeg = view->rows[0]->off;
     size_t vend = view->rows[view->nrows-1]->off + view->rows[view->nrows-1]->rlen;
     size_t vtot = ((vend - vbeg) * 100) / bend;
+    if (vend > bend) vtot += 1;
     size_t voff = (vbeg * 100 / bend);
-    size_t thumboff = (Regions[SCROLL].y - 2) + (Regions[SCROLL].height * voff / 100);
-    size_t thumbsz  = Regions[SCROLL].height * vtot / 100;
+    size_t thumbreg = (Regions[SCROLL].height - Regions[SCROLL].y + 9);
+    size_t thumboff = (thumbreg * voff / 100) + (Regions[SCROLL].y - 2);
+    size_t thumbsz  = (thumbreg * vtot / 100);
     if (thumbsz < 5) thumbsz = 5;
-    x11_draw_rect(CLR_BASE01, Regions[SCROLL].width, Regions[SCROLL].y-2, 1, Regions[SCROLL].height);
-    x11_draw_rect(CLR_BASE00, 0, Regions[SCROLL].y - 2, Regions[SCROLL].width, Regions[SCROLL].height);
-    x11_draw_rect(CLR_BASE02, 0, thumboff, Regions[SCROLL].width, thumbsz);
+    x11_draw_rect(CLR_BASE01, Regions[SCROLL].width, Regions[SCROLL].y - 2, 1, Regions[SCROLL].height);
+    x11_draw_rect(CLR_BASE00, 0, Regions[SCROLL].y - 2, Regions[SCROLL].width, thumbreg);
+    x11_draw_rect(CLR_BASE03, 0, thumboff, Regions[SCROLL].width, thumbsz);
     
     /* place the cursor on screen */
     if (Regions[Focused].csrx != SIZE_MAX && Regions[Focused].csry != SIZE_MAX) {