shithub: riscv

Download patch

ref: 87325403b0b32e5c3f7f36dae92b9aaac0355175
parent: ea0f58090923bd7e435c4f48eb751854a4292b9a
author: cinap_lenrek <[email protected]>
date: Sun Jan 27 07:57:51 EST 2013

sam: make scroll wheel work outside scrollbar

--- a/sys/src/cmd/samterm/main.c
+++ b/sys/src/cmd/samterm/main.c
@@ -100,7 +100,7 @@
 					if(nwhich!=which)
 						current(nwhich);
 					else if(scr)
-						scroll(which, 1);
+						scroll(which, (mousep->buttons&8) ? 4 : 1);
 					else{
 						t=(Text *)which->user1;
 						if(flselect(which)){
@@ -119,7 +119,7 @@
 					menu2hit();
 			}else if(mousep->buttons&(4|16)){
 				if(scr)
-					scroll(which, 3);
+					scroll(which, (mousep->buttons&16) ? 5 : 3);
 				else
 					menu3hit();
 			}
--- a/sys/src/cmd/samterm/scroll.c
+++ b/sys/src/cmd/samterm/scroll.c
@@ -123,7 +123,7 @@
 		in = abs(x-mousep->xy.x)<=FLSCROLLWID/2;
 		if(oin && !in)
 			scrunmark(l, r);
-		if(in){
+		if(but > 3 || in){
 			scrmark(l, r);
 			oy = y;
 			my = mousep->xy.y;
@@ -131,9 +131,9 @@
 				my = s.min.y;
 			if(my >= s.max.y)
 				my = s.max.y;
-			if(!eqpt(mousep->xy, Pt(x, my)))
+			if(in && !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;
@@ -141,7 +141,7 @@
 				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;
@@ -152,19 +152,21 @@
 				scrmark(l, r);
 			}
 		}
-	}while(button(but));
-	if(in){
+	}while(but <= 3 && button(but));
+	if(but > 3 || 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;