shithub: cflood

ref: b503317e6c71100ce331e24715d8cc538781840b
dir: /kbd/rio-kbd-file-option.patch/

View raw version
diff -r 9e12b43399af sys/man/1/rio
--- a/sys/man/1/rio	Fri Dec 14 17:16:50 2012 +0100
+++ b/sys/man/1/rio	Sun Dec 16 22:38:55 2012 +0100
@@ -10,6 +10,9 @@
 .BI "-k '"kbdcmd '
 ]
 [
+.BI "-K '"kbdfile '
+]
+[
 .B -s
 ]
 [
@@ -89,6 +92,14 @@
 program described in
 .IR bitsyload (1)
 is the usual choice.
+The
+.B -K
+option instructs
+.I rio
+to read keyboard input from
+.I kbdfile
+instead of a default
+.BR /dev/kbd .
 .PP
 The
 .B -s
diff -r 9e12b43399af sys/man/4/rio
--- a/sys/man/4/rio	Fri Dec 14 17:16:50 2012 +0100
+++ b/sys/man/4/rio	Sun Dec 16 22:38:55 2012 +0100
@@ -12,6 +12,10 @@
 .BI ' kbdcmd '
 ]
 [
+.B -K
+.BI ' kbdfile '
+]
+[
 .B -s
 ]
 [
diff -r 9e12b43399af sys/src/cmd/rio/rio.c
--- a/sys/src/cmd/rio/rio.c	Fri Dec 14 17:16:50 2012 +0100
+++ b/sys/src/cmd/rio/rio.c	Sun Dec 16 22:38:55 2012 +0100
@@ -45,6 +45,7 @@
 Channel* initkbd(void);
 
 char		*fontname;
+char		*kbdname;
 
 enum
 {
@@ -112,7 +113,7 @@
 void
 usage(void)
 {
-	fprint(2, "usage: rio [-b] [-f font] [-i initcmd] [-k kbdcmd] [-s]\n");
+	fprint(2, "usage: rio [-b] [-f font] [-i initcmd] [-k kbdcmd] [-K kbdfile] [-s]\n");
 	exits("usage");
 }
 
@@ -153,6 +154,11 @@
 		if(kbdin == nil)
 			usage();
 		break;
+	case 'K':
+		kbdname = ARGF();
+		if(kbdname == nil)
+			usage();
+		break;
 	case 's':
 		scrolling = TRUE;
 		break;
@@ -164,6 +170,8 @@
 		startdir = estrdup(buf);
 	if(fontname == nil)
 		fontname = getenv("font");
+	if(kbdname == nil)
+		kbdname = "/dev/kbd";
 	s = getenv("tabstop");
 	if(s != nil)
 		maxtab = strtol(s, nil, 0);
@@ -1302,7 +1310,7 @@
 	if(sendp(c, nil) <= 0)
 		return;
 
-	if((kfd = open("/dev/kbd", OREAD)) >= 0){
+	if((kfd = open(kbdname, OREAD)) >= 0){
 		close(fd);
 
 		/* read kbd state */