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 <draw.h>
#include <bio.h> #include <bio.h>
#include <event.h> #include <event.h>
#include <keyboard.h>
int newwin(char*); int newwin(char*);
@ -135,7 +136,7 @@ bar(Biobuf *b)
case 0: case 0:
sleep(1000); sleep(1000);
while(!die && (k = eread(Ekeyboard|Emouse, &e))) { 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; die = 1;
postnote(PNPROC, parent, "interrupt"); postnote(PNPROC, parent, "interrupt");
_exits("interrupt"); _exits("interrupt");

View file

@ -3,6 +3,7 @@
#include <draw.h> #include <draw.h>
#include <bio.h> #include <bio.h>
#include <event.h> #include <event.h>
#include <keyboard.h>
int newwin(char*); int newwin(char*);
@ -77,7 +78,7 @@ msg(Biobuf *b)
case 0: case 0:
sleep(1000); sleep(1000);
while(!die && (k = eread(Ekeyboard|Emouse, &e))) { 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; die = 1;
postnote(PNPROC, parent, "interrupt"); postnote(PNPROC, parent, "interrupt");
_exits("interrupt"); _exits("interrupt");

View file

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

View file

@ -3,6 +3,7 @@
#include <bio.h> #include <bio.h>
#include <draw.h> #include <draw.h>
#include <event.h> #include <event.h>
#include <keyboard.h>
#include "imagefile.h" #include "imagefile.h"
int cflag = 0; int cflag = 0;
@ -186,7 +187,7 @@ show(int fd, char *name)
} }
image = i; image = i;
eresized(0); eresized(0);
if((ch=ekbd())=='q' || ch==0x7F || ch==0x04) if((ch=ekbd())=='q' || ch==Kdel || ch==Keof)
exits(nil); exits(nil);
draw(screen, screen->clipr, display->white, nil, ZP); draw(screen, screen->clipr, display->white, nil, ZP);
image = nil; image = nil;

View file

@ -3,6 +3,7 @@
#include <bio.h> #include <bio.h>
#include <draw.h> #include <draw.h>
#include <event.h> #include <event.h>
#include <keyboard.h>
#include "imagefile.h" #include "imagefile.h"
int cflag = 0; int cflag = 0;
@ -382,7 +383,7 @@ show(int fd, char *name)
dt = 50; dt = 50;
while(n==1 || ecankbd()){ while(n==1 || ecankbd()){
/* an odd, democratic list */ /* an odd, democratic list */
if((ch=ekbd())=='q' || ch==0x7F || ch==0x04) if((ch=ekbd())=='q' || ch==Kdel || ch==Keof)
exits(nil); exits(nil);
if(ch == '\n') if(ch == '\n')
goto Out; goto Out;

View file

@ -3,6 +3,7 @@
#include <bio.h> #include <bio.h>
#include <draw.h> #include <draw.h>
#include <event.h> #include <event.h>
#include <keyboard.h>
#include "imagefile.h" #include "imagefile.h"
int cflag = 0; int cflag = 0;
@ -321,7 +322,7 @@ rpt: array = Breadjpg(&b, colorspace);
free(array); free(array);
goto rpt; goto rpt;
} }
if((ch=ekbd())=='q' || ch==0x7F || ch==0x04) if((ch=ekbd())=='q' || ch==Kdel || ch==Keof)
exits(nil); exits(nil);
draw(screen, screen->clipr, display->white, nil, ZP); draw(screen, screen->clipr, display->white, nil, ZP);
image = nil; image = nil;

View file

@ -3,6 +3,7 @@
#include <bio.h> #include <bio.h>
#include <draw.h> #include <draw.h>
#include <event.h> #include <event.h>
#include <keyboard.h>
#include "imagefile.h" #include "imagefile.h"
extern int debug; extern int debug;
@ -198,7 +199,7 @@ show(int fd, char *name, int outc)
draw(i2, i2->r, i, nil, i->r.min); draw(i2, i2->r, i, nil, i->r.min);
image = i2; image = i2;
eresized(0); eresized(0);
if((ch=ekbd())=='q' || ch==0x7F || ch==0x04) if((ch=ekbd())=='q' || ch==Kdel || ch==Keof)
exits(nil); exits(nil);
draw(screen, screen->clipr, display->white, nil, ZP); draw(screen, screen->clipr, display->white, nil, ZP);
image = nil; image = nil;

View file

@ -3,6 +3,7 @@
#include <bio.h> #include <bio.h>
#include <draw.h> #include <draw.h>
#include <event.h> #include <event.h>
#include <keyboard.h>
#include "imagefile.h" #include "imagefile.h"
int cflag = 0; int cflag = 0;
@ -183,7 +184,7 @@ show(int fd, char *name)
} }
image = i; image = i;
eresized(0); eresized(0);
if((ch=ekbd())=='q' || ch==0x7F || ch==0x04) if((ch=ekbd())=='q' || ch==Kdel || ch==Keof)
exits(nil); exits(nil);
draw(screen, screen->clipr, display->white, nil, ZP); draw(screen, screen->clipr, display->white, nil, ZP);
image = nil; image = nil;

View file

@ -3,6 +3,7 @@
#include <bio.h> #include <bio.h>
#include <draw.h> #include <draw.h>
#include <event.h> #include <event.h>
#include <keyboard.h>
#include "imagefile.h" #include "imagefile.h"
int cflag = 0; int cflag = 0;
@ -189,7 +190,7 @@ show(int fd, char *name)
} }
image = i; image = i;
eresized(0); eresized(0);
if((ch=ekbd())=='q' || ch==0x7F || ch==0x04) if((ch=ekbd())=='q' || ch==Kdel || ch==Keof)
exits(nil); exits(nil);
draw(screen, screen->clipr, display->white, nil, ZP); draw(screen, screen->clipr, display->white, nil, ZP);
image = nil; image = nil;

View file

@ -3,6 +3,7 @@
#include <bio.h> #include <bio.h>
#include <draw.h> #include <draw.h>
#include <event.h> #include <event.h>
#include <keyboard.h>
#include "imagefile.h" #include "imagefile.h"
int cflag = 0; int cflag = 0;
@ -220,7 +221,7 @@ show(int fd, char *name, int outchan)
image = i; image = i;
eresized(0); eresized(0);
ch = ekbd(); ch = ekbd();
if(ch == 'q' || ch == 0x7f || ch == 0x04) if(ch == 'q' || ch == Kdel || ch == Keof)
exits(nil); exits(nil);
draw(screen, screen->clipr, display->white, draw(screen, screen->clipr, display->white,
nil, ZP); nil, ZP);

View file

@ -3,6 +3,7 @@
#include <bio.h> #include <bio.h>
#include <draw.h> #include <draw.h>
#include <event.h> #include <event.h>
#include <keyboard.h>
#include "imagefile.h" #include "imagefile.h"
int cflag = 0; int cflag = 0;
@ -186,7 +187,7 @@ show(int fd, char *name)
} }
image = i; image = i;
eresized(0); eresized(0);
if((ch=ekbd())=='q' || ch==0x7F || ch==0x04) if((ch=ekbd())=='q' || ch==Kdel || ch==Keof)
exits(nil); exits(nil);
draw(screen, screen->clipr, display->white, nil, ZP); draw(screen, screen->clipr, display->white, nil, ZP);
image = nil; image = nil;

View file

@ -3,6 +3,7 @@
#include <bio.h> #include <bio.h>
#include <draw.h> #include <draw.h>
#include <event.h> #include <event.h>
#include <keyboard.h>
#include "imagefile.h" #include "imagefile.h"
int cflag = 0; int cflag = 0;
@ -186,7 +187,7 @@ show(int fd, char *name)
} }
image = i; image = i;
eresized(0); eresized(0);
if((ch=ekbd())=='q' || ch==0x7F || ch==0x04) if((ch=ekbd())=='q' || ch==Kdel || ch==Keof)
exits(nil); exits(nil);
draw(screen, screen->clipr, display->white, nil, ZP); draw(screen, screen->clipr, display->white, nil, ZP);
image = nil; image = nil;

View file

@ -2,6 +2,7 @@
#include <libc.h> #include <libc.h>
#include <draw.h> #include <draw.h>
#include <event.h> #include <event.h>
#include <keyboard.h>
typedef struct KbMap KbMap; typedef struct KbMap KbMap;
struct KbMap { struct KbMap {
@ -245,7 +246,7 @@ main(int argc, char **argv)
for(;;){ for(;;){
switch(eread(Emouse|Ekeyboard, &e)){ switch(eread(Emouse|Ekeyboard, &e)){
case Ekeyboard: case Ekeyboard:
if(e.kbdc==0x7F || e.kbdc=='q') if(e.kbdc==Kdel || e.kbdc=='q')
exits(0); exits(0);
break; break;
case Emouse: case Emouse:

View file

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

View file

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

View file

@ -195,7 +195,7 @@ cmdkey(Win *w, Rune r)
cmddel(w, w->toprune + w->fr.p0, w->toprune + w->fr.p1); cmddel(w, w->toprune + w->fr.p0, w->toprune + w->fr.p1);
switch(r){ switch(r){
case 0x00: case 0x00:
case 0x1b: case Kesc:
break; break;
case '\b': case '\b':
if(w->fr.p0 > 0 && w->toprune + w->fr.p0 != w->opoint) if(w->fr.p0 > 0 && w->toprune + w->fr.p0 != w->opoint)

View file

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

View file

@ -3,6 +3,7 @@
#include <draw.h> #include <draw.h>
#include <event.h> #include <event.h>
#include <regexp.h> #include <regexp.h>
#include <keyboard.h>
enum { enum {
VISIBLE = 1, VISIBLE = 1,
@ -318,7 +319,7 @@ main(int argc, char **argv)
for(;;){ for(;;){
switch(eread(Emouse|Ekeyboard|Etimer, &e)){ switch(eread(Emouse|Ekeyboard|Etimer, &e)){
case Ekeyboard: case Ekeyboard:
if(e.kbdc==0x7F || e.kbdc=='q') if(e.kbdc==Kdel || e.kbdc=='q')
exits(0); exits(0);
break; break;
case Emouse: case Emouse: