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

This commit is contained in:
ftrvxmtrx 2014-12-13 21:58:49 +01:00
parent feb7702c9e
commit 96525edaae
18 changed files with 35 additions and 21 deletions

View file

@ -3,6 +3,7 @@
#include <draw.h>
#include <bio.h>
#include <event.h>
#include <keyboard.h>
int newwin(char*);
@ -135,7 +136,7 @@ bar(Biobuf *b)
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");

View file

@ -3,6 +3,7 @@
#include <draw.h>
#include <bio.h>
#include <event.h>
#include <keyboard.h>
int newwin(char*);
@ -77,7 +78,7 @@ msg(Biobuf *b)
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");

View file

@ -251,7 +251,7 @@ histogram(char *rect)
goto done;
break;
case 2:
if(km == 0x7F)
if(km == Kdel)
goto done;
break;
case 3:

View file

@ -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 @@ show(int fd, char *name)
}
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;

View file

@ -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 @@ show(int fd, char *name)
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;

View file

@ -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 @@ rpt: array = Breadjpg(&b, colorspace);
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;

View file

@ -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 @@ show(int fd, char *name, int outc)
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;

View file

@ -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 @@ show(int fd, char *name)
}
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;

View file

@ -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 @@ show(int fd, char *name)
}
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;

View file

@ -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 @@ show(int fd, char *name, int outchan)
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);

View file

@ -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 @@ show(int fd, char *name)
}
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;

View file

@ -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 @@ show(int fd, char *name)
}
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;

View file

@ -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 @@ main(int argc, char **argv)
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:

View file

@ -2,6 +2,7 @@
#include <libc.h>
#include <draw.h>
#include <event.h>
#include <keyboard.h>
enum {
Edge = 5,
@ -109,8 +110,8 @@ main(int argc, char *argv[])
case Ekeyboard:
switch(e.kbdc){
case 'q':
case 0x7f:
case '\04':
case Kdel:
case Keof:
caseexit:
exits(nil);
case '=':

View file

@ -210,8 +210,8 @@ mouseproc(void*)
case Akbd:
switch(r){
case 'q':
case 0x7f:
case 0x04:
case Kdel:
case Keof:
threadexitsall("");
}
break;

View file

@ -195,7 +195,7 @@ cmdkey(Win *w, Rune r)
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)

View file

@ -18,9 +18,9 @@ static struct {
{'\n', 0xff0d},
/* {0x0b, 0xff0b}, */
{'\r', 0xff0d},
{0x1b, 0xff1b}, /* escape */
{Kesc, 0xff1b},
{Kins, 0xff63},
{0x7F, 0xffff},
{Kdel, 0xffff},
{Khome, 0xff50},
{Kend, 0xff57},
{Kpgup, 0xff55},

View file

@ -3,6 +3,7 @@
#include <draw.h>
#include <event.h>
#include <regexp.h>
#include <keyboard.h>
enum {
VISIBLE = 1,
@ -318,7 +319,7 @@ main(int argc, char **argv)
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: