]> git.mdlowis.com Git - projs/tide.git/commitdiff
implemented first pass at scroll up and down. Still broken for wrapped lines
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 19 Apr 2018 16:57:01 +0000 (12:57 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 19 Apr 2018 16:57:01 +0000 (12:57 -0400)
lib/config.c
lib/view.c
lib/x11.c

index 4d21dec9a1a710088d0eb539a024d6a7388bd1c5..1681afa8730e06ab2f8474371651da44b978b679 100644 (file)
@@ -8,7 +8,7 @@
     #define FONT "Verdana:size=10"
     #define LNSPACE 0
 #else
-    #define FONT "Liberation Mono:size=11"
+    #define FONT "Verdana:size=11"
     #define LNSPACE 1
 #endif
 
@@ -22,7 +22,7 @@ int /* Integer config options */
     LineSpacing = LNSPACE,
     Timeout = 50,
     TabWidth = 4,
-    ScrollBy = 4,
+    ScrollBy = 1,
     ClickTime = 500,
     MaxScanDist = 0,
     Syntax = ON,
index c7b043e52a20f72e81dc05673605c16ce22d06cd..00d210efebc5e8f3a2a59ff9199375c54499ce0b 100644 (file)
@@ -285,6 +285,10 @@ char* view_getctx(View* view) {
 }
 
 static void scroll_up(View* view) {
+    if (view->index > 0)
+        view->index--;
+    else if (view->rows[0]->off > 0)
+        resize(view, view->width, view->nrows, (view->rows[0]->off - 1));
 }
 
 static void scroll_dn(View* view) {
@@ -295,6 +299,9 @@ static void scroll_dn(View* view) {
     } else {
         view->index++;
     }
+
+    printf("%ld <= %ld\n", view->nvisible, (view->nrows - view->index));
+    assert(view->nvisible <= (view->nrows - view->index));
 }
 
 void view_scroll(View* view, int move) {
index 535dcdfca215401450df6c96a1782094999a886a..6de77f589caf321a5bd39a3bf77cf0012753971f 100644 (file)
--- a/lib/x11.c
+++ b/lib/x11.c
@@ -246,8 +246,14 @@ static void mouse_click(int btn, bool pressed, int x, int y) {
         case MouseLeft:    mouse_left(Focused, pressed, row, col);    break;
         case MouseMiddle:  mouse_middle(Focused, pressed, row, col);  break;
         case MouseRight:   mouse_right(Focused, pressed, row, col);   break;
-        case MouseWheelUp: view_scroll(win_view(Focused), -ScrollBy); break;
-        case MouseWheelDn: view_scroll(win_view(Focused), +ScrollBy); break;
+        case MouseWheelUp:
+            if (!pressed) return;
+            view_scroll(win_view(Focused), -ScrollBy);
+            break;
+        case MouseWheelDn:
+            if (!pressed) return;
+            view_scroll(win_view(Focused), +ScrollBy);
+            break;
     }
 }