aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/samterm
diff options
context:
space:
mode:
authorPetter Rodhelind <petter.rodhelind@gmail.com>2017-10-25 01:50:06 +0200
committerPetter Rodhelind <petter.rodhelind@gmail.com>2017-10-25 01:50:06 +0200
commit6db445613816bd773d34e16d0a23d8086fb09edb (patch)
tree6643a47c8576e381dd917cde1c8a3d6fb6f37c13 /src/cmd/samterm
parent970f3e9ed7debf60b290c22e73ed167232129a36 (diff)
downloadplan9port-6db445613816bd773d34e16d0a23d8086fb09edb.tar.gz
plan9port-6db445613816bd773d34e16d0a23d8086fb09edb.tar.bz2
plan9port-6db445613816bd773d34e16d0a23d8086fb09edb.zip
samterm: Add mouse scrolling.
This makes it possible to use the scroll wheel to simulate button 1 and button 3 clicks in the scroll bar. It scrolls in the same way with variable scroll sections. Further down, more lines per scroll etc...
Diffstat (limited to 'src/cmd/samterm')
-rw-r--r--src/cmd/samterm/main.c13
-rw-r--r--src/cmd/samterm/scroll.c22
2 files changed, 21 insertions, 14 deletions
diff --git a/src/cmd/samterm/main.c b/src/cmd/samterm/main.c
index c37fa08b..a97516c4 100644
--- a/src/cmd/samterm/main.c
+++ b/src/cmd/samterm/main.c
@@ -110,19 +110,21 @@ threadmain(int argc, char *argv[])
nwhich = flwhich(mousep->xy);
if(nwhich && nwhich!=which)
current(nwhich);
- scr = which && ptinrect(mousep->xy, which->scroll);
+ //scr = which && ptinrect(mousep->xy, which->scroll);
+ scr = which && (ptinrect(mousep->xy, which->scroll) || mousep->buttons&(8|16));
if(mousep->buttons)
flushtyping(1);
if(chording && chord==1 && !mousep->buttons)
chord = 0;
if(chording && chord)
chord |= mousep->buttons;
- else if(mousep->buttons&1){
+ else if(mousep->buttons&(1|8)){
if(nwhich){
if(nwhich!=which)
current(nwhich);
else if(scr)
- scroll(which, 1);
+ //scroll(which, 1);
+ scroll(which, (mousep->buttons&8) ? 4 : 1);
else{
t=(Text *)which->user1;
if(flselect(which)){
@@ -139,9 +141,10 @@ threadmain(int argc, char *argv[])
scroll(which, 2);
else
menu2hit();
- }else if((mousep->buttons&4)){
+ }else if((mousep->buttons&(4|16))){
if(scr)
- scroll(which, 3);
+ //scroll(which, 3);
+ scroll(which, (mousep->buttons&16) ? 5 : 3);
else
menu3hit();
}
diff --git a/src/cmd/samterm/scroll.c b/src/cmd/samterm/scroll.c
index 12614751..dd44bc3d 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) || (but == 2) || abs(x-mousep->xy.x)<=FLSCROLLWID(l)/2;
if(oin && !in)
scrunmark(l, r);
if(in){
@@ -126,9 +126,11 @@ scroll(Flayer *l, int but)
my = s.min.y;
if(my >= s.max.y)
my = s.max.y;
- if(!eqpt(mousep->xy, Pt(x, my)))
- moveto(mousectl, Pt(x, my));
- if(but == 1){
+ if(!eqpt(mousep->xy, Pt(x, my))) {
+ if (but <=3)
+ moveto(mousectl, Pt(x, my));
+ }
+ 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 +138,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,22 +149,24 @@ scroll(Flayer *l, int but)
scrmark(l, r);
}
}
- }while(button(but));
+ }while(but <=3 && button(but));
if(in){
h = s.max.y-s.min.y;
scrunmark(l, r);
p0 = 0;
- if(but == 1)
+ if(but == 1 || but == 4) {
p0 = (long)(my-s.min.y)/l->f.font->height+1;
- else if(but == 2){
+ but = 1;
+ }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){
p0 = l->origin+frcharofpt(&l->f, Pt(s.max.x, my));
if(p0 > tot)
p0 = tot;
+ but = 3;
}
scrorigin(l, but, p0);
}