From b59ecd83de8fd84bdb42d64e891130d0c30f9c64 Mon Sep 17 00:00:00 2001 From: Philippe MECHAI Date: Thu, 11 Apr 2019 19:55:43 +0200 Subject: [PATCH] samterm: add mousewheel scrolling support --- src/cmd/samterm/main.c | 6 +++++- src/cmd/samterm/scroll.c | 16 +++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/cmd/samterm/main.c b/src/cmd/samterm/main.c index 5fc42908..6bc46faa 100644 --- a/src/cmd/samterm/main.c +++ b/src/cmd/samterm/main.c @@ -142,6 +142,10 @@ threadmain(int argc, char *argv[]) scroll(which, 3); else menu3hit(); + }else if((mousep->buttons&8)){ + scroll(which, 4); + }else if((mousep->buttons&16)){ + scroll(which, 5); } mouseunblock(); } @@ -464,7 +468,7 @@ flushtyping(int clearesc) ulong n; if(clearesc) - typeesc = -1; + typeesc = -1; if(typestart == typeend) { modified = 0; return; diff --git a/src/cmd/samterm/scroll.c b/src/cmd/samterm/scroll.c index 12614751..e96f52af 100644 --- a/src/cmd/samterm/scroll.c +++ b/src/cmd/samterm/scroll.c @@ -115,7 +115,7 @@ scroll(Flayer *l, int but) draw(scrback, Rect(0,0,Dx(l->scroll), Dy(l->scroll)), l->f.b, nil, l->scroll.min); do{ oin = in; - in = abs(x-mousep->xy.x)<=FLSCROLLWID(l)/2; + in = (but>3) || abs(x-mousep->xy.x)<=FLSCROLLWID(l)/2; if(oin && !in) scrunmark(l, r); if(in){ @@ -128,7 +128,7 @@ scroll(Flayer *l, int but) my = s.max.y; if(!eqpt(mousep->xy, Pt(x, my))) moveto(mousectl, Pt(x, my)); - if(but == 1){ + if(but == 1 || but == 4){ p0 = l->origin-frcharofpt(&l->f, Pt(s.max.x, my)); rt = scrpos(l->scroll, p0, p0+l->f.nchars, tot); y = rt.min.y; @@ -136,7 +136,7 @@ scroll(Flayer *l, int but) y = my; if(y > s.max.y-2) y = s.max.y-2; - }else if(but == 3){ + }else if(but == 3 || but == 5){ p0 = l->origin+frcharofpt(&l->f, Pt(s.max.x, my)); rt = scrpos(l->scroll, p0, p0+l->f.nchars, tot); y = rt.min.y; @@ -147,19 +147,21 @@ scroll(Flayer *l, int but) scrmark(l, r); } } - }while(button(but)); + }while(but<4 && button(but)); if(in){ h = s.max.y-s.min.y; scrunmark(l, r); p0 = 0; - if(but == 1) + if(but == 1 || but == 4){ + but = 1; p0 = (long)(my-s.min.y)/l->f.font->height+1; - else if(but == 2){ + }else if(but == 2){ if(tot > 1024L*1024L) p0 = ((tot>>10)*(y-s.min.y)/h)<<10; else p0 = tot*(y-s.min.y)/h; - }else if(but == 3){ + }else if(but == 3 || but == 5){ + but = 3; p0 = l->origin+frcharofpt(&l->f, Pt(s.max.x, my)); if(p0 > tot) p0 = tot;