git: 9front

Download patch

ref: 69ad74ec96187d96516f1c7e0f7e95063bdee47f
parent: 1d8901939abe578dfb1cda6cdbf53662d0447354
author: Aidan K. Wiggins <akw@oneiri.one>
date: Mon Nov 3 12:43:58 EST 2025

samterm: set last menu hit when receiving an Hcurrent msg

If you were current on file a, with file b already open in the menu,
and you proceeded to plumb an address in file b, it would not set b as
the current file in the menu after switching to that flayer.

--- a/sys/src/cmd/samterm/menu.c
+++ b/sys/src/cmd/samterm/menu.c
@@ -150,6 +150,12 @@
 }
 
 void
+setmenuhit(int m)
+{
+	menu3.lasthit = m + NMENU3;
+}
+
+void
 menu3hit(void)
 {
 	Rectangle r;
@@ -289,7 +295,7 @@
 	name[n][0] = m;
 	strcpy((char*)name[n]+1, (char*)s);
 	nname++;
-	menu3.lasthit = n+NMENU3;
+	setmenuhit(n);
 }
 
 void
--- a/sys/src/cmd/samterm/mesg.c
+++ b/sys/src/cmd/samterm/mesg.c
@@ -97,7 +97,7 @@
 inmesg(Hmesg type, int count)
 {
 	Text *t;
-	int i, m;
+	int i, m, menu;
 	long l;
 	Flayer *lp;
 
@@ -129,7 +129,7 @@
 		break;
 
 	case Hcurrent:
-		if(whichmenu(m)<0)
+		if((menu=whichmenu(m))<0)
 			break;
 		t = whichtext(m);
 		i = which && ((Text *)which->user1)==&cmd && m!=cmd.tag;
@@ -141,6 +141,7 @@
 		if(i){
 			flupfront(lp);
 			flborder(lp, 0);
+			setmenuhit(menu);
 			work = lp;
 		}else
 			current(lp);
--- a/sys/src/cmd/samterm/samterm.h
+++ b/sys/src/cmd/samterm/samterm.h
@@ -146,6 +146,7 @@
 Rune	*rload(Rasp*, ulong, ulong, ulong*);
 void	menuins(int, uchar*, Text*, int, int);
 void	menudel(int);
+void	setmenuhit(int);
 Text	*sweeptext(int, int);
 void	setpat(char*);
 void	menucmd(char*);
--