9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Scrolling for plan9port sam
@ 2009-07-01  4:31 J.R. Mauro
  2009-07-02  0:06 ` J.R. Mauro
  0 siblings, 1 reply; 2+ messages in thread
From: J.R. Mauro @ 2009-07-01  4:31 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

could someone help clean this crappy patch up a bit? i'm drunk and sam
not being able to understand my scrollwheel is really pissing me off.
at least this works despite it being ugly and steeped in cheap
whiskey...


--jorden


diff -r 5f1b36ecd9db src/cmd/samterm/main.c
--- a/src/cmd/samterm/main.c	Tue Jun 09 09:26:13 2009 -0700
+++ b/src/cmd/samterm/main.c	Wed Jul 01 00:29:48 2009 -0400
@@ -142,6 +142,10 @@
 					scroll(which, 3);
 				else
 					menu3hit();
+			} else if((mousep->buttons&8)) {
+				scroll(nwhich, 1);
+			} else if((mousep->buttons&16)) {
+				scroll(nwhich, 3);
 			}
 			mouseunblock();
 		}
diff -r 5f1b36ecd9db src/cmd/samterm/scroll.c
--- a/src/cmd/samterm/scroll.c	Tue Jun 09 09:26:13 2009 -0700
+++ b/src/cmd/samterm/scroll.c	Wed Jul 01 00:29:48 2009 -0400
@@ -100,7 +100,7 @@
 void
 scroll(Flayer *l, int but)
 {
-	int in = 0, oin;
+	int in = 0, oin, scw = 0;
 	long tot = scrtotal(l);
 	Rectangle scr, r, s, rt;
 	int x, y, my, oy, h;
@@ -116,9 +116,10 @@
 	do{
 		oin = in;
 		in = abs(x-mousep->xy.x)<=FLSCROLLWID/2;
+		scw = ((mousep->buttons&8) | (mousep->buttons&16));
 		if(oin && !in)
 			scrunmark(l, r);
-		if(in){
+		if(in || scw){
 			scrmark(l, r);
 			oy = y;
 			my = mousep->xy.y;



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Scrolling for plan9port sam
  2009-07-01  4:31 [9fans] Scrolling for plan9port sam J.R. Mauro
@ 2009-07-02  0:06 ` J.R. Mauro
  0 siblings, 0 replies; 2+ messages in thread
From: J.R. Mauro @ 2009-07-02  0:06 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs; +Cc: rsc

Here is a less drunk and better working version of the patch.
Scrolling seems to be working perfectly. I hope gmail doesn't eat this
patch.

=

Add scrollwheel support to sam

diff -r 5f1b36ecd9db src/cmd/samterm/main.c
--- a/src/cmd/samterm/main.c	Tue Jun 09 09:26:13 2009 -0700
+++ b/src/cmd/samterm/main.c	Wed Jul 01 20:01:37 2009 -0400
@@ -142,6 +142,10 @@
 					scroll(which, 3);
 				else
 					menu3hit();
+			} else if((mousep->buttons&8)) {
+				scroll(nwhich, 1);
+			} else if((mousep->buttons&16)) {
+				scroll(nwhich, 3);
 			}
 			mouseunblock();
 		}
diff -r 5f1b36ecd9db src/cmd/samterm/scroll.c
--- a/src/cmd/samterm/scroll.c	Tue Jun 09 09:26:13 2009 -0700
+++ b/src/cmd/samterm/scroll.c	Wed Jul 01 20:01:37 2009 -0400
@@ -100,7 +100,7 @@
 void
 scroll(Flayer *l, int but)
 {
-	int in = 0, oin;
+	int in = 0, oin, scw = 0;
 	long tot = scrtotal(l);
 	Rectangle scr, r, s, rt;
 	int x, y, my, oy, h;
@@ -116,18 +116,21 @@
 	do{
 		oin = in;
 		in = abs(x-mousep->xy.x)<=FLSCROLLWID/2;
+		scw = ((mousep->buttons&8) | (mousep->buttons&16));
 		if(oin && !in)
 			scrunmark(l, r);
-		if(in){
+		if(in || scw){
 			scrmark(l, r);
 			oy = y;
 			my = mousep->xy.y;
-			if(my < s.min.y)
-				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(!scw) {
+				if(my < s.min.y)
+					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){
 				p0 = l->origin-frcharofpt(&l->f, Pt(s.max.x, my));
 				rt = scrpos(l->scroll, p0, p0+l->f.nchars, tot);
@@ -148,7 +151,7 @@
 			}
 		}
 	}while(button(but));
-	if(in){
+	if(in || scw){
 		h = s.max.y-s.min.y;
 		scrunmark(l, r);
 		p0 = 0;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-07-02  0:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-01  4:31 [9fans] Scrolling for plan9port sam J.R. Mauro
2009-07-02  0:06 ` J.R. Mauro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).