shithub: purgatorio

Download patch

ref: 063c3f398e949895bb9795539e83a2e0be364376
parent: 38c0cf0737de03906729054ad7b7b011dd1ca475
author: henesy <devnull@localhost>
date: Sun Sep 27 18:39:08 EDT 2020

get wm/sam to build - still unsure how to use the tool

--- a/appl/wm/mkfile
+++ b/appl/wm/mkfile
@@ -3,7 +3,6 @@
 DIRS=\
 	brutus\
 	camera\
-#	diary\
 	drawmux\
 	ftree\
 	mailtool\
@@ -47,6 +46,9 @@
 	reversi.dis\
 	rmtdir.dis\
 	rt.dis\
+	sam.dis\
+	samstub.dis\
+	samtk.dis\
 	sendmail.dis\
 	sh.dis\
 	smenu.dis\
--- a/appl/wm/sam.b
+++ b/appl/wm/sam.b
@@ -29,7 +29,7 @@
 	draw = load Draw Draw->PATH;
 	stderr = sys->fildes(2);
 
-	logfd = sys->create("samterm.log", sys->OWRITE, 8r666);
+	logfd = sys->create("/fd/1", sys->OWRITE, 8r666);
 	if (logfd == nil) {
 		fprint(stderr, "Can't create samterm.log\n");
 		logfd = stderr;
--- a/appl/wm/samstub.b
+++ b/appl/wm/samstub.b
@@ -174,8 +174,9 @@
 	for (;;) {
 		if (samio.count == 0) {
 			n := sys->read(samio.data, samio.buffer, len samio.buffer);
+			#sys->fprint(stderr, "fd = %d ­ len = %d\n", samio.data.fd, len samio.buffer);
 			if (n <= 0) {
-				fprint(stderr, "Read error on sam's pipe\n");
+				fprint(stderr, "Read error on sam's pipe ⇒ %r\n");
 				return;
 			}
 			samio.index = 0;
--- a/appl/wm/samtk.b
+++ b/appl/wm/samtk.b
@@ -80,7 +80,7 @@
 		tk->cmd(ctxt.which.t,
 			".Wm_t.title configure -background blue; update");
 	}
-	(t, cmdc) := tkclient->toplevel(ctxt.ctxt.screen, "-borderwidth 1 -relief raised", "SamTerm", Tkclient->Appl);
+	(t, cmdc) := tkclient->toplevel(ctxt.ctxt, "-borderwidth 1 -relief raised", "SamTerm", Tkclient->Appl);
 	tk->cmd(t, ". configure -x "+string x+" -y "+string y+"; update");
 
 	if (x == 10 && y == 10) {
@@ -102,15 +102,15 @@
 	lines: int;
 	if (tp) {
 		lines = 8;
-		tkclient->tkcmds(t, tksam1);
+		tkcmds(t, tksam1);
 		mkmenu2c(t);
 	} else {
 		lines = 20;
-		tkclient->tkcmds(t, tkwork1);
+		tkcmds(t, tkwork1);
 		mkmenu2(t);
 	}
 	mkmenu3(t);
-	tkclient->tkcmds(t, tkcmdlist);
+	tkcmds(t, tkcmdlist);
 
 	f := ref Flayer(
 		tag,		# tag
@@ -152,7 +152,7 @@
 	for (i := 0; i < NMENU2; i++) {
 		menus[i+1] = addmenuitem(2, "menu2", menu2str[i]);
 	}
-	tkclient->tkcmds(t, menus);
+	tkcmds(t, menus);
 }
 
 mkmenu2(t: ref Tk->Toplevel)
@@ -164,7 +164,7 @@
 		menus[i+1] = addmenuitem(2, "menu2", menu2str[i]);
 	}
 	menus[NMENU2] = addmenuitem(2, "edit", "/");
-	tkclient->tkcmds(t, menus);
+	tkcmds(t, menus);
 }
 
 mkmenu3(t: ref Tk->Toplevel)
@@ -178,7 +178,7 @@
 	for (i = 0; i < len ctxt.menus; i++) {
 		menus[i+NMENU3+1] = addmenuitem(3, "menu3", ctxt.menus[i].name);
 	}
-	tkclient->tkcmds(t, menus);
+	tkcmds(t, menus);
 }
 
 addmenuitem(d: int, m, s: string): string
@@ -685,4 +685,16 @@
 	flayers[0:] = ctxt.flayers[0:n];
 	flayers[n:] = ctxt.flayers[n+1:];
 	ctxt.flayers = flayers;
+}
+
+tkcmd(t: ref Tk->Toplevel, s: string): string
+{
+	res := tk->cmd(t, s);
+	return res;
+}
+
+tkcmds(top: ref Tk->Toplevel, a: array of string)
+{
+	for(i := 0; i < len a; i++)
+		v := tkcmd(top, a[i]);
 }