9front - general discussion about 9front
 help / color / mirror / Atom feed
From: ori@eigenstate.org
To: 9front@9front.org
Subject: [9front] vt: fix scrolling over ssh, add mouse scrolling
Date: Thu, 24 Jun 2021 00:00:57 -0400	[thread overview]
Message-ID: <16E08562D70F59B59716B917E13062F4@eigenstate.org> (raw)

Testing requested.

We were setting 'resize_flag = 1' in backup(), which was
causing resized() to get called, which was causing us to
call exportsize(), which was eventually singalling sshd,
which forwarded the signal over to the process on the
other end of the ssh pipe.

This was causing a SIGINT to get sent, which was screwing
up the scrolling.

I'm not sure why we were setting resize_flag=1 in the code:
we were always doing something like it since the code first
got into 9front -- eresized(0) initially, moving to setting
the flag when moving to libevent.

Things seem to work without it, so removing it doesn't seem
to have broken anything.

--- a/sys/src/cmd/vt/cons.h
+++ b/sys/src/cmd/vt/cons.h
@@ -54,7 +54,7 @@
 extern int	number(Rune *, int *);
 extern void	shift(int,int,int,int);
 extern void	scroll(int,int,int,int);
-extern int	backup(int);
+extern void	backup(int);
 extern void	sendnchars(int, char *);
 extern Point	pt(int, int);
 extern Point	pos(Point);
--- a/sys/src/cmd/vt/main.c
+++ b/sys/src/cmd/vt/main.c
@@ -133,9 +133,7 @@
 
 Rune	kbdchar;
 
-#define	button1()	((mc->buttons & 07)==1)
-#define	button2()	((mc->buttons & 07)==2)
-#define	button3()	((mc->buttons & 07)==4)
+#define	button(num)	(mc->buttons == (1<<((num)-1)))
 
 Mousectl	*mc;
 Keyboardctl	*kc;
@@ -210,6 +208,7 @@
 {
 	if(hostpid > 0)
 		postnote(PNGROUP, hostpid, "interrupt");
+
 }
 
 void
@@ -834,10 +833,14 @@
 		flushimage(display, 1);
 	switch(alt(a)){
 	case AMOUSE:
-		if(button1() || chording)
+		if(button(1) || chording)
 			selecting();
-		else if(button2() || button3())
+		else if(button(2) || button(3))
 			readmenu();
+		else if(button(4))
+			backup(backc+1);
+		else if(button(5))
+			backup(backc-1);
 		else if(resize_flag == 0)
 			goto Next;
 		break;
@@ -1128,7 +1131,7 @@
 			select(p, q, mode);
 			drawscreen();
 			readmouse(mc);
-		} while(button1());
+		} while(button(1));
 	}
 	if(mc->buttons != chording){
 		switch(mc->buttons & 0x7){
@@ -1167,7 +1170,7 @@
 	Point p;
 
 	p = pos(mc->xy);
-	if(button3()) {
+	if(button(3)) {
 		menu3.item[1] = ttystate[cs->raw].crnl ? "cr" : "crnl";
 		menu3.item[2] = ttystate[cs->raw].nlcr ? "nl" : "nlcr";
 		menu3.item[3] = cs->raw ? "cooked" : "raw";
@@ -1201,13 +1204,11 @@
 
 	switch(menuhit(2, mc, &menu2, nil)) {
 	case Mbackup:		/* back up */
-		if(backup(backc+1))
-			backc++;
+		backup(backc+1);
 		return;
 
 	case Mforward:		/* move forward */
-		if(backc > 0)
-			backup(--backc);
+		backup(backc-1);
 		return;
 
 	case Mreset:		/* reset */
@@ -1237,7 +1238,7 @@
 	}
 }
 
-int
+void
 backup(int count)
 {
 	Rune *cp;
@@ -1244,8 +1245,8 @@
 	int left, n;
 
 	unselect();
-
-	resize_flag = 1;
+	if(count < 0)
+		return;
 	if(count == 0 && !pagemode) {
 		n = ymax;
 		nbacklines = HISTSIZ;	/* make sure we scroll to the very end */
@@ -1270,7 +1271,8 @@
 	if(cp >= &hist[HISTSIZ])
 		cp = hist;
 	backp = cp;
-	return left;
+	if(left)
+		backc = count;
 }
 
 Point


             reply	other threads:[~2021-06-24  4:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-24  4:00 ori [this message]
2021-06-24  7:28 ` igor
2021-06-24 13:34   ` ori
2021-06-24 14:22     ` igor
2021-06-26  6:04 ` unobe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16E08562D70F59B59716B917E13062F4@eigenstate.org \
    --to=ori@eigenstate.org \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).