]> git.lizzy.rs Git - plan9front.git/commitdiff
acme: implement position-dependent scroll-wheel scrolling
authorkvik <kvik@a-b.xyz>
Thu, 11 Jun 2020 13:33:57 +0000 (15:33 +0200)
committerkvik <kvik@a-b.xyz>
Thu, 11 Jun 2020 13:33:57 +0000 (15:33 +0200)
This brings acme scrolling behaviour in line with that of 9front's rio
and sam, where the amount scrolled varies with a vertical position of
the pointer within the window, similar to how the scrollbar works.

At some point it would be good to implement a line-at-a-time scrolling
when the Shift key is pressed, as seen in rio.  For this to happen the
acme keyboard input needs to be rewritten in terms of /dev/kbd instead
of relying on keyboard(2) -- that is, the /dev/cons interface.

sys/src/cmd/acme/acme.c
sys/src/cmd/acme/scrl.c

index e874d35540846de5619d71a0112e1dc37c47f33a..96a7d6b0359daa4181fe45c05caf73e33a809bcc 100644 (file)
@@ -513,8 +513,13 @@ mousethread(void *)
                                but = 2;
                        else if(m.buttons == 4)
                                but = 3;
+                       else if(m.buttons == 8)
+                               but = 4;
+                       else if(m.buttons == 16)
+                               but = 5;
                        barttext = t;
-                       if(t->what==Body && ptinrect(m.xy, t->scrollr)){
+                       if(t->what==Body && w != nil
+                       && (ptinrect(m.xy, t->scrollr) || (m.buttons & (8|16)))){
                                if(but){
                                        winlock(w, 'M');
                                        t->eq0 = ~0;
@@ -523,18 +528,6 @@ mousethread(void *)
                                }
                                goto Continue;
                        }
-                       /* scroll buttons, wheels, etc. */
-                       if(t->what==Body && w != nil && (m.buttons & (8|16))){
-                               if(m.buttons & 8)
-                                       but = Kscrolloneup;
-                               else
-                                       but = Kscrollonedown;
-                               winlock(w, 'M');
-                               t->eq0 = ~0;
-                               texttype(t, but);
-                               winunlock(w);
-                               goto Continue;
-                       }
                        if(ptinrect(m.xy, t->scrollr)){
                                if(but){
                                        if(t->what == Columntag)
index 1310bc763fbc2e6888f879abae64a9a2c5ec8ea7..0d417396852ebe954172ceec598eb16037b9118d 100644 (file)
@@ -132,7 +132,7 @@ textscroll(Text *t, int but)
                        readmouse(mousectl);
                        continue;
                }
-               if(but == 1)
+               if(but == 1 || but == 4)
                        p0 = textbacknl(t, t->org, (my-s.min.y)/t->font->height);
                else
                        p0 = t->org+frcharofpt(t, Pt(s.max.x, my));
@@ -140,7 +140,7 @@ textscroll(Text *t, int but)
                        textsetorigin(t, p0, TRUE);
                oldp0 = p0;
                /* debounce */
-               if(first){
+               if(first && but < 4){
                        flushimage(display, 1);
                        sleep(200);
                        nbrecv(mousectl->c, &mousectl->Mouse);