shithub: riow

Download patch

ref: dffed8b81f0d0f5144f081bd2d1f6d88bb6ca40c
parent: 83fdac4149ade5c81f76370bc2cadf95fcf2042f
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Aug 28 16:44:25 EDT 2022

add -s to append to the "sticky" list

--- a/riow.c
+++ b/riow.c
@@ -33,8 +33,15 @@
 static int wsn;
 static int vd2wcur[10] = {-1};
 
-static char *sticky[] = {
-	"bar", "cat clock", "clock", "faces", "kbmap", "stats", "winwatch",
+static char *sticky[32] = {
+	"bar",
+	"cat clock",
+	"clock",
+	"faces",
+	"kbmap",
+	"stats",
+	"winwatch",
+	nil,
 };
 
 static int
@@ -111,7 +118,7 @@
 				close(f);
 				if(n > 0){
 					s[n] = 0;
-					for(k = 0; k < nelem(sticky); k++){
+					for(k = 0; k < nelem(sticky) && sticky[k] != nil; k++){
 						if(strcmp(sticky[k], s) == 0){
 							w->flags |= Fsticky;
 							break;
@@ -314,7 +321,7 @@
 static void
 usage(void)
 {
-	fprint(2, "usage: %s\n", argv0);
+	fprint(2, "usage: %s [-s label]\n", argv0);
 	exits("usage");
 }
 
@@ -324,7 +331,15 @@
 	char b[128];
 	int i, j, n;
 
+	for(n = 0; sticky[n] != nil; n++)
+		;
+
 	ARGBEGIN{
+	case 's':
+		if(n >= nelem(sticky))
+			sysfatal("ewwww");
+		sticky[n++] = EARGF(usage());
+		break;
 	default:
 		usage();
 	}ARGEND