tbetter scrolling - plan9port - [fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port
Log
Files
Refs
README
LICENSE
---
commit f334d7563298445ff07b1317a98150ed393769c0
parent 4b12db117158b9dfd739d0bcbb1a2837663961c1
Author: rsc 
Date:   Fri, 18 Mar 2005 19:33:26 +0000

better scrolling

Diffstat:
  M src/cmd/acme/cols.c                 |       3 +++
  M src/cmd/acme/scrl.c                 |      71 ++++++++++++++-----------------

2 files changed, 35 insertions(+), 39 deletions(-)
---
diff --git a/src/cmd/acme/cols.c b/src/cmd/acme/cols.c
t@@ -541,6 +541,9 @@ colwhich(Column *c, Point p)
                                 return &w->tag;
                         return &w->body;
                 }
+                /* scrollr drops below w->r on low windows */
+                if(ptinrect(p, w->body.scrollr))
+                        return &w->body;
         }
         return nil;
 }
diff --git a/src/cmd/acme/scrl.c b/src/cmd/acme/scrl.c
t@@ -117,48 +117,41 @@ textscroll(Text *t, int but)
         first = TRUE;
         do{
                 flushimage(display, 1);
-                if(mouse->xy.xxy.x){
-                        readmouse(mousectl);
-                }else{
-                        my = mouse->xy.y;
-                        if(my < s.min.y)
-                                my = s.min.y;
-                        if(my >= s.max.y)
-                                my = s.max.y;
-                        if(!eqpt(mouse->xy, Pt(x, my))){
-                                moveto(mousectl, Pt(x, my));
-                                readmouse(mousectl);                /* absorb event generated by moveto() */
-                        }
-                        if(but == 2){
-                                y = my;
-                                if(y > s.max.y-2)
-                                        y = s.max.y-2;
-                                if(t->file->b.nc > 1024*1024)
-                                        p0 = ((t->file->b.nc>>10)*(y-s.min.y)/h)<<10;
-                                else
-                                        p0 = t->file->b.nc*(y-s.min.y)/h;
-                                if(oldp0 != p0)
-                                        textsetorigin(t, p0, FALSE);
-                                oldp0 = p0;
-                                readmouse(mousectl);
-                                continue;
-                        }
-                        if(but == 1)
-                                p0 = textbacknl(t, t->org, (my-s.min.y)/t->fr.font->height);
-                        else
-                                p0 = t->org+frcharofpt(&t->fr, Pt(s.max.x, my));
+                my = mouse->xy.y;
+                if(my < s.min.y)
+                        my = s.min.y;
+                if(my >= s.max.y)
+                        my = s.max.y;
+                if(!eqpt(mouse->xy, Pt(x, my))){
+                        moveto(mousectl, Pt(x, my));
+                        readmouse(mousectl);                /* absorb event generated by moveto() */
+                }
+                if(but == 2){
+                        y = my;
+                        p0 = (vlong)t->file->b.nc*(y-s.min.y)/h;
+                        if(p0 >= t->q1)
+                                p0 = textbacknl(t, p0, 2);
                         if(oldp0 != p0)
-                                textsetorigin(t, p0, TRUE);
+                                textsetorigin(t, p0, FALSE);
                         oldp0 = p0;
-                        /* debounce */
-                        if(first){
-                                flushimage(display, 1);
-                                sleep(200);
-                                nbrecv(mousectl->c, &mousectl->m);
-                                first = FALSE;
-                        }
-                        scrsleep(80);
+                        readmouse(mousectl);
+                        continue;
+                }
+                if(but == 1)
+                        p0 = textbacknl(t, t->org, (my-s.min.y)/t->fr.font->height);
+                else
+                        p0 = t->org+frcharofpt(&t->fr, Pt(s.max.x, my));
+                if(oldp0 != p0)
+                        textsetorigin(t, p0, TRUE);
+                oldp0 = p0;
+                /* debounce */
+                if(first){
+                        flushimage(display, 1);
+                        sleep(200);
+                        nbrecv(mousectl->c, &mousectl->m);
+                        first = FALSE;
                 }
+                scrsleep(80);
         }while(mouse->buttons & (1<<(but-1)));
         while(mouse->buttons)
                 readmouse(mousectl);