Plan 9 from Bell Labs’s /usr/web/sources/contrib/yk/dist/9legacy/applied/sam-wheel.diff

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


--- /n/sources/plan9/sys/src/cmd/samterm/scroll.c	Wed Jan 13 17:22:35 2010
+++ /sys/src/cmd/samterm/scroll.c	Sat Feb 13 21:38:30 2021
@@ -120,7 +120,7 @@
 	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/2;
+		in = (but>3) ||(but==2) || abs(x-mousep->xy.x)<=FLSCROLLWID/2;
 		if(oin && !in)
 			scrunmark(l, r);
 		if(in){
@@ -131,9 +131,7 @@
 				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(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 +139,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 +150,21 @@
 				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){
+			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;
--- /n/sources/plan9/sys/src/cmd/samterm/main.c	Mon Apr 29 22:39:33 2013
+++ /sys/src/cmd/samterm/main.c	Sat Feb 13 16:39:13 2021
@@ -104,6 +104,10 @@
 					scroll(which, 3);
 				else
 					menu3hit();
+			}else if((mousep->buttons&8)){
+				scroll(which, 4);
+			}else if((mousep->buttons&16)){
+				scroll(which, 5);
 			}
 			mouseunblock();
 		}
@@ -432,6 +436,7 @@
 #define	PAGEUP	Kpgup
 #define	RIGHTARROW	Kright
 #define	SCROLLKEY	Kdown
+#define Kstx		0x02
 
 int
 nontypingkey(int c)
@@ -447,6 +452,7 @@
 	case PAGEUP:
 	case RIGHTARROW:
 	case SCROLLKEY:
+	case Kstx:
 		return 1;
 	}
 	return 0;
@@ -604,6 +610,19 @@
 				}
 			}
 		}
+	}else if((mousep->buttons&8)){
+		scroll(which, 4);
+	}else if((mousep->buttons&16)){
+		scroll(which, 5);
+	}else if(c == Kstx){
+		t = &cmd;
+		for(l=t->l; l->textfn==0; l++)
+			;
+		current(l);
+		flushtyping(0);
+		a = t->rasp.nrunes;
+		flsetselect(l, a, a);
+		center(l, a);
 	}else{
 		if(c==ESC && typeesc>=0){
 			l->p0 = typeesc;

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].