shithub: purgatorio

Download patch

ref: 42dfac6916ebbdac65cbec8b3e1a80c3ee41423c
parent: ad5a80bfb081dc954be03836cc65090e0f6c7e4f
author: henesy <devnull@localhost>
date: Tue Mar 12 22:22:53 EDT 2019

fix usage in wm/sh ;; add -b flag to wm/sh ;; fix tk starting before usage check in wm/sh

--- a/appl/wm/sh.b
+++ b/appl/wm/sh.b
@@ -100,6 +100,7 @@
 partialread: array of byte;
 cwd := "";
 width, height, font: string;
+blackmode := 0;
 
 events: list of string;
 evrdreq: list of Rdreq;
@@ -130,6 +131,32 @@
 		badmod(Arg->PATH);
 	arg->init(argv);
 
+	arg->setusage("wm/sh [-bilxvn] [-w width] [-h height] [-f font] [-c command] [file [args...]");
+
+	shargs: list of string;
+	while ((opt := arg->opt()) != 0) {
+		case opt {
+		'w' =>
+			width = arg->earg();
+		'h' =>
+			height = arg->earg();
+		'b' =>
+			blackmode = 1;
+		'f' =>
+			font = arg->earg();
+		'c' =>
+			a := arg->earg();
+			shargs = a :: "-c" :: shargs;
+		'i' or 'l' or 'x' or 'v' or 'n' =>
+			shargs = sys->sprint("-%c", opt) :: shargs;
+		* =>
+			arg->usage();
+		}
+	}
+	argv = arg->argv();
+	for (; shargs != nil; shargs = tl shargs)
+		argv = hd shargs :: argv;
+
 	plumbmsg = load Plumbmsg Plumbmsg->PATH;
 
 	sys->pctl(Sys->FORKNS | Sys->NEWPGRP | Sys->FORKENV, nil);
@@ -148,30 +175,6 @@
 		cwd = workdir->init();
 	}
 
-	shargs: list of string;
-	while ((opt := arg->opt()) != 0) {
-		case opt {
-		'w' =>
-			width = arg->arg();
-		'h' =>
-			height = arg->arg();
-		'f' =>
-			font = arg->arg();
-		'c' =>
-			a := arg->arg();
-			if (a == nil) {
-				sys->print("usage: wm/sh [-ilxvn] [-w width] [-h height] [-f font] [-c command] [file [args...]\n");
-				raise "fail:usage";
-			}
-			shargs = a :: "-c" :: shargs;
-		'i' or 'l' or 'x' or 'v' or 'n' =>
-			shargs = sys->sprint("-%c", opt) :: shargs;
-		}
-	}
-	argv = arg->argv();
-	for (; shargs != nil; shargs = tl shargs)
-		argv = hd shargs :: argv;
-
 	winname = Name + " " + cwd;
 
 	spawn main(ctxt, argv);
@@ -250,6 +253,10 @@
 
 	rdrpc: Rdreq;
 
+	if(blackmode) {
+		cmd(t, ".ft.t configure -bg black -selectforeground white");
+	}
+
 	# outpoint is place in text to insert characters printed by programs
 	cmd(t, ".ft.t mark set outpoint 1.0; .ft.t mark gravity outpoint left");
 
@@ -505,17 +512,15 @@
 
 setcols(t: ref Tk->Toplevel)
 {
-	fgcol := "black";
+	if(blackmode)
+		fgcol := "white";
+	else
+		fgcol = "black";
 	if(holding){
 		if(haskbdfocus)
 			fgcol = "#000099FF";	# DMedblue
 		else
 			fgcol = "#005DBBFF";	# DGreyblue
-	}else{
-		if(haskbdfocus)
-			fgcol = "black";
-		else
-			fgcol = "#666666FF";	# dark grey
 	}
 	cmd(t, ".ft.t configure -foreground "+fgcol+" -selectforeground "+fgcol);
 	cmd(t, ".ft.t tag configure sel -foreground "+fgcol);
--- a/man/1/wm-sh
+++ b/man/1/wm-sh
@@ -4,6 +4,8 @@
 .SH SYNOPSIS
 .B wm/sh
 [
+.B -b
+] [
 .B -w
 .I width
 ] [
@@ -43,6 +45,10 @@
 accepts the following additional options, which are
 not passed through to
 .IR sh :
+.HP
+.B -b
+.br
+Inverts the default background and text color scheme.
 .HP
 .B -w
 .I width