Made mouse-wheel scrolling less drastic. - sam - An updated version of the sam text editor.
(HTM) git clone git://vernunftzentrum.de/sam.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 47f7f8ea74866f59c4a5a332f7a3aa3f6ac7654a
(DIR) parent 521228a11d99b58334f00796e284dff8c646add3
(HTM) Author: Rob King <jking@deadpixi.com>
Date: Fri, 19 Aug 2016 17:22:32 -0500
Made mouse-wheel scrolling less drastic.
Wheel-up is now equivalent to a button 1 click in the scroll bar, while
wheel-down is equivalent to a button 3 click.
Diffstat:
samterm/main.c | 8 ++++----
samterm/scroll.c | 14 +++++++-------
2 files changed, 11 insertions(+), 11 deletions(-)
---
(DIR) diff --git a/samterm/main.c b/samterm/main.c
@@ -135,10 +135,10 @@ main(int argc, char *argv[])
menu3hit();
}else if((mouse.buttons&16)){
flushtyping(0);
- center(which, which->origin+which->f.nchars+1);
+ scroll(which, 5, 5);
}else if((mouse.buttons&8)){
flushtyping(0);
- outTsll(Torigin, ((Text *)(which->user1))->tag, which->origin, which->f.maxlines+1);
+ scroll(which, 4, 4);
}
mouseunblock();
}
@@ -342,13 +342,13 @@ scrorigin(Flayer *l, int but, long p0)
Text *t=(Text *)l->user1;
switch(but){
- case 1:
+ case 1: case 4:
outTsll(Torigin, t->tag, l->origin, p0);
break;
case 2:
outTsll(Torigin, t->tag, p0, 1L);
break;
- case 3:
+ case 3: case 5:
horigin(t->tag,p0);
}
}
(DIR) diff --git a/samterm/scroll.c b/samterm/scroll.c
@@ -95,16 +95,16 @@ scroll(Flayer *l, int pbut, int but)
in = abs(x-mouse.xy.x)<=FLSCROLLWID/2;
if(oin != in)
scrflip(l, r);
- if(in){
+ if(in || but > 3){
oy = y;
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)))
+ if(!eqpt(mouse.xy, Pt(x, my)) && but <= 3)
cursorset(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;
@@ -112,7 +112,7 @@ scroll(Flayer *l, int pbut, 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;
@@ -124,18 +124,18 @@ scroll(Flayer *l, int pbut, int but)
}
}
}while(button(pbut));
- if(in){
+ if(in || but > 3){
h = s.max.y-s.min.y;
scrflip(l, r);
p0 = 0;
- if(but == 1)
+ if(but == 1 || but == 4)
p0 = (long)(my-s.min.y)/l->f.fheight+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;