shithub: riscv

Download patch

ref: 96525edaae6e1fb076b4286fdd41032dafff651c
parent: feb7702c9eba0eeb420dd08cbcdb4d922c1ba49c
author: ftrvxmtrx <devnull@localhost>
date: Sat Dec 13 16:58:49 EST 2014

various cmds: replace magic numbers with Kdel/Keof, etc

--- a/sys/src/cmd/aux/statusbar.c
+++ b/sys/src/cmd/aux/statusbar.c
@@ -3,6 +3,7 @@
 #include <draw.h>
 #include <bio.h>
 #include <event.h>
+#include <keyboard.h>
 
 int newwin(char*);
 
@@ -135,7 +136,7 @@
 	case 0:
 		sleep(1000);
 		while(!die && (k = eread(Ekeyboard|Emouse, &e))) {
-			if(nokill==0 && k == Ekeyboard && (e.kbdc == 0x7F || e.kbdc == 0x03)) { /* del, ctl-c */
+			if(nokill==0 && k == Ekeyboard && (e.kbdc == Kdel || e.kbdc == Ketx)) {
 				die = 1;
 				postnote(PNPROC, parent, "interrupt");
 				_exits("interrupt");
--- a/sys/src/cmd/aux/statusmsg.c
+++ b/sys/src/cmd/aux/statusmsg.c
@@ -3,6 +3,7 @@
 #include <draw.h>
 #include <bio.h>
 #include <event.h>
+#include <keyboard.h>
 
 int newwin(char*);
 
@@ -77,7 +78,7 @@
 	case 0:
 		sleep(1000);
 		while(!die && (k = eread(Ekeyboard|Emouse, &e))) {
-			if(nokill==0 && k == Ekeyboard && (e.kbdc == 0x7F || e.kbdc == 0x03)) { /* del, ctl-c */
+			if(nokill==0 && k == Ekeyboard && (e.kbdc == Kdel || e.kbdc == Ketx)) {
 				die = 1;
 				postnote(PNPROC, parent, "interrupt");
 				_exits("interrupt");
--- a/sys/src/cmd/histogram.c
+++ b/sys/src/cmd/histogram.c
@@ -251,7 +251,7 @@
 				goto done;
 			break;
 		case 2:
-			if(km == 0x7F)
+			if(km == Kdel)
 				goto done;
 			break;
 		case 3:
--- a/sys/src/cmd/jpg/bmp.c
+++ b/sys/src/cmd/jpg/bmp.c
@@ -3,6 +3,7 @@
 #include <bio.h>
 #include <draw.h>
 #include <event.h>
+#include <keyboard.h>
 #include "imagefile.h"
 
 int		cflag = 0;
@@ -186,7 +187,7 @@
 		}
 		image = i;
 		eresized(0);
-		if((ch=ekbd())=='q' || ch==0x7F || ch==0x04)
+		if((ch=ekbd())=='q' || ch==Kdel || ch==Keof)
 			exits(nil);
 		draw(screen, screen->clipr, display->white, nil, ZP);
 		image = nil;
--- a/sys/src/cmd/jpg/gif.c
+++ b/sys/src/cmd/jpg/gif.c
@@ -3,6 +3,7 @@
 #include <bio.h>
 #include <draw.h>
 #include <event.h>
+#include <keyboard.h>
 #include "imagefile.h"
 
 int		cflag = 0;
@@ -382,7 +383,7 @@
 					dt = 50;
 				while(n==1 || ecankbd()){
 					/* an odd, democratic list */
-					if((ch=ekbd())=='q' || ch==0x7F || ch==0x04)
+					if((ch=ekbd())=='q' || ch==Kdel || ch==Keof)
 						exits(nil);
 					if(ch == '\n')
 						goto Out;
--- a/sys/src/cmd/jpg/jpg.c
+++ b/sys/src/cmd/jpg/jpg.c
@@ -3,6 +3,7 @@
 #include <bio.h>
 #include <draw.h>
 #include <event.h>
+#include <keyboard.h>
 #include "imagefile.h"
 
 int		cflag = 0;
@@ -321,7 +322,7 @@
 			free(array);
 			goto rpt;
 		}
-		if((ch=ekbd())=='q' || ch==0x7F || ch==0x04)
+		if((ch=ekbd())=='q' || ch==Kdel || ch==Keof)
 			exits(nil);
 		draw(screen, screen->clipr, display->white, nil, ZP);
 		image = nil;
--- a/sys/src/cmd/jpg/png.c
+++ b/sys/src/cmd/jpg/png.c
@@ -3,6 +3,7 @@
 #include <bio.h>
 #include <draw.h>
 #include <event.h>
+#include <keyboard.h>
 #include "imagefile.h"
 
 extern int	debug;
@@ -198,7 +199,7 @@
 		draw(i2, i2->r, i, nil, i->r.min);
 		image = i2;
 		eresized(0);
-		if((ch=ekbd())=='q' || ch==0x7F || ch==0x04)
+		if((ch=ekbd())=='q' || ch==Kdel || ch==Keof)
 			exits(nil);
 		draw(screen, screen->clipr, display->white, nil, ZP);
 		image = nil;
--- a/sys/src/cmd/jpg/ppm.c
+++ b/sys/src/cmd/jpg/ppm.c
@@ -3,6 +3,7 @@
 #include <bio.h>
 #include <draw.h>
 #include <event.h>
+#include <keyboard.h>
 #include "imagefile.h"
 
 int		cflag = 0;
@@ -183,7 +184,7 @@
 		}
 		image = i;
 		eresized(0);
-		if((ch=ekbd())=='q' || ch==0x7F || ch==0x04)
+		if((ch=ekbd())=='q' || ch==Kdel || ch==Keof)
 			exits(nil);
 		draw(screen, screen->clipr, display->white, nil, ZP);
 		image = nil;
--- a/sys/src/cmd/jpg/tga.c
+++ b/sys/src/cmd/jpg/tga.c
@@ -3,6 +3,7 @@
 #include <bio.h>
 #include <draw.h>
 #include <event.h>
+#include <keyboard.h>
 #include "imagefile.h"
 
 int		cflag = 0;
@@ -189,7 +190,7 @@
 		}
 		image = i;
 		eresized(0);
-		if((ch=ekbd())=='q' || ch==0x7F || ch==0x04)
+		if((ch=ekbd())=='q' || ch==Kdel || ch==Keof)
 			exits(nil);
 		draw(screen, screen->clipr, display->white, nil, ZP);
 		image = nil;
--- a/sys/src/cmd/jpg/tif.c
+++ b/sys/src/cmd/jpg/tif.c
@@ -3,6 +3,7 @@
 #include <bio.h>
 #include <draw.h>
 #include <event.h>
+#include <keyboard.h>
 #include "imagefile.h"
 
 int cflag = 0;
@@ -220,7 +221,7 @@
 		image = i;
 		eresized(0);
 		ch = ekbd();
-		if(ch == 'q' || ch == 0x7f || ch == 0x04)
+		if(ch == 'q' || ch == Kdel || ch == Keof)
 			exits(nil);
 		draw(screen, screen->clipr, display->white,
 			nil, ZP);
--- a/sys/src/cmd/jpg/v210.c
+++ b/sys/src/cmd/jpg/v210.c
@@ -3,6 +3,7 @@
 #include <bio.h>
 #include <draw.h>
 #include <event.h>
+#include <keyboard.h>
 #include "imagefile.h"
 
 int		cflag = 0;
@@ -186,7 +187,7 @@
 		}
 		image = i;
 		eresized(0);
-		if((ch=ekbd())=='q' || ch==0x7F || ch==0x04)
+		if((ch=ekbd())=='q' || ch==Kdel || ch==Keof)
 			exits(nil);
 		draw(screen, screen->clipr, display->white, nil, ZP);
 		image = nil;
--- a/sys/src/cmd/jpg/yuv.c
+++ b/sys/src/cmd/jpg/yuv.c
@@ -3,6 +3,7 @@
 #include <bio.h>
 #include <draw.h>
 #include <event.h>
+#include <keyboard.h>
 #include "imagefile.h"
 
 int		cflag = 0;
@@ -186,7 +187,7 @@
 		}
 		image = i;
 		eresized(0);
-		if((ch=ekbd())=='q' || ch==0x7F || ch==0x04)
+		if((ch=ekbd())=='q' || ch==Kdel || ch==Keof)
 			exits(nil);
 		draw(screen, screen->clipr, display->white, nil, ZP);
 		image = nil;
--- a/sys/src/cmd/kbmap.c
+++ b/sys/src/cmd/kbmap.c
@@ -2,6 +2,7 @@
 #include <libc.h>
 #include <draw.h>
 #include <event.h>
+#include <keyboard.h>
 
 typedef struct KbMap KbMap;
 struct KbMap {
@@ -245,7 +246,7 @@
 	for(;;){
 		switch(eread(Emouse|Ekeyboard, &e)){
 		case Ekeyboard:
-			if(e.kbdc==0x7F || e.kbdc=='q')
+			if(e.kbdc==Kdel || e.kbdc=='q')
 				exits(0);
 			break;
 		case Emouse:
--- a/sys/src/cmd/lens.c
+++ b/sys/src/cmd/lens.c
@@ -2,6 +2,7 @@
 #include <libc.h>
 #include <draw.h>
 #include <event.h>
+#include <keyboard.h>
 
 enum {
 	Edge = 5,
@@ -109,8 +110,8 @@
 		case Ekeyboard:
 			switch(e.kbdc){
 			case 'q':
-			case 0x7f:
-			case '\04':
+			case Kdel:
+			case Keof:
 			caseexit:
 				exits(nil);
 			case '=':
--- a/sys/src/cmd/plot/plot.c
+++ b/sys/src/cmd/plot/plot.c
@@ -210,8 +210,8 @@
 		case Akbd:
 			switch(r){
 			case 'q':
-			case 0x7f:
-			case 0x04:
+			case Kdel:
+			case Keof:
 				threadexitsall("");
 			}
 			break;
--- a/sys/src/cmd/spred/cmdw.c
+++ b/sys/src/cmd/spred/cmdw.c
@@ -195,7 +195,7 @@
 		cmddel(w, w->toprune + w->fr.p0, w->toprune + w->fr.p1);
 	switch(r){
 	case 0x00:
-	case 0x1b:
+	case Kesc:
 		break;
 	case '\b':
 		if(w->fr.p0 > 0 && w->toprune + w->fr.p0 != w->opoint)
--- a/sys/src/cmd/vnc/kbdv.c
+++ b/sys/src/cmd/vnc/kbdv.c
@@ -18,9 +18,9 @@
 	{'\n',		0xff0d},
 	/* {0x0b, 0xff0b}, */
 	{'\r',		0xff0d},
-	{0x1b,	0xff1b},	/* escape */
+	{Kesc,	0xff1b},
 	{Kins,	0xff63},
-	{0x7F,	0xffff},
+	{Kdel,	0xffff},
 	{Khome,	0xff50},
 	{Kend,	0xff57},
 	{Kpgup,	0xff55},
--- a/sys/src/cmd/winwatch.c
+++ b/sys/src/cmd/winwatch.c
@@ -3,6 +3,7 @@
 #include <draw.h>
 #include <event.h>
 #include <regexp.h>
+#include <keyboard.h>
 
 enum {
 	VISIBLE = 1,
@@ -318,7 +319,7 @@
 	for(;;){
 		switch(eread(Emouse|Ekeyboard|Etimer, &e)){
 		case Ekeyboard:
-			if(e.kbdc==0x7F || e.kbdc=='q')
+			if(e.kbdc==Kdel || e.kbdc=='q')
 				exits(0);
 			break;
 		case Emouse: