summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@centraldogma>2011-05-11 09:23:01 +0000
committercinap_lenrek <cinap_lenrek@centraldogma>2011-05-11 09:23:01 +0000
commitd831a028dc82c4b20c4748b764bbfda3d9addc04 (patch)
treed2b755df0698936ce62c863484c29d44a5d2be23
parent294e4f10971ccb746a6e15d5dd29b3caa685231c (diff)
downloadplan9front-d831a028dc82c4b20c4748b764bbfda3d9addc04.tar.xz
ignore \0 bytes, disable navigation keys when /dev/kbd is open
-rw-r--r--sys/src/cmd/aux/kbdfs.c3
-rw-r--r--sys/src/cmd/rio/rio.c29
-rw-r--r--sys/src/cmd/rio/wind.c44
3 files changed, 32 insertions, 44 deletions
diff --git a/sys/src/cmd/aux/kbdfs.c b/sys/src/cmd/aux/kbdfs.c
index 46939f925..a346cee8e 100644
--- a/sys/src/cmd/aux/kbdfs.c
+++ b/sys/src/cmd/aux/kbdfs.c
@@ -400,7 +400,8 @@ consproc(void *)
x = buf + n;
while(p < x && fullrune(p, x - p)){
p += chartorune(&r, p);
- send(rawchan, &r);
+ if(r)
+ send(rawchan, &r);
}
n = x - p;
if(n > 0){
diff --git a/sys/src/cmd/rio/rio.c b/sys/src/cmd/rio/rio.c
index 91cbe6086..6912bbb0a 100644
--- a/sys/src/cmd/rio/rio.c
+++ b/sys/src/cmd/rio/rio.c
@@ -337,6 +337,7 @@ keyboardthread(void*)
char *s;
threadsetname("keyboardthread");
+
while(s = recvp(kbdchan)){
if(input == nil || sendp(input->ck, s) <= 0)
free(s);
@@ -360,8 +361,10 @@ keyboardsend(char *s, int cnt)
r = runemalloc(cnt);
cvttorunes(s, cnt, r, &nb, &nr, nil);
for(i=0; i<nr; i++){
- chanprint(kbdchan, "%C", r[i]);
- chanprint(kbdchan, "");
+ if(r[i]){
+ chanprint(kbdchan, "%C", r[i]);
+ chanprint(kbdchan, "");
+ }
}
free(r);
}
@@ -1191,13 +1194,13 @@ new(Image *i, int hideit, int scrollit, int pid, char *dir, char *cmd, char **ar
}
static void
-kbdioproc(void *arg)
+kbdproc(void *arg)
{
Channel *c = arg;
char buf[128], *p, *e;
int fd, cfd, kfd, n;
- threadsetname("kbdioproc");
+ threadsetname("kbdproc");
if((fd = open("/dev/cons", OREAD)) < 0){
chanprint(c, "%r");
@@ -1234,8 +1237,10 @@ kbdioproc(void *arg)
e = p + n;
while(p < e && fullrune(p, e - p)){
p += chartorune(&r, p);
- chanprint(c, "%C", r);
- chanprint(c, "");
+ if(r){
+ chanprint(c, "%C", r);
+ chanprint(c, "");
+ }
}
n = e - p;
if(n > 0){
@@ -1252,15 +1257,15 @@ Channel*
initkbd(void)
{
Channel *c;
- char *err;
+ char *e;
c = chancreate(sizeof(char*), 16);
- proccreate(kbdioproc, c, STACK);
- if(err = recvp(c)){
+ proccreate(kbdproc, c, STACK);
+ if(e = recvp(c)){
chanfree(c);
- werrstr(err);
- free(err);
- return nil;
+ c = nil;
+ werrstr(e);
+ free(e);
}
return c;
}
diff --git a/sys/src/cmd/rio/wind.c b/sys/src/cmd/rio/wind.c
index 2690fa998..aec2c19ac 100644
--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -23,7 +23,6 @@ enum
static int topped;
static int id;
-static int reverse;
static Image *cols[NCOL];
static Image *grey;
@@ -31,7 +30,6 @@ static Image *darkgrey;
static Cursor *lastcursor;
static Image *titlecol;
static Image *lighttitlecol;
-static Image *dholdcol;
static Image *holdcol;
static Image *lightholdcol;
static Image *paleholdcol;
@@ -43,36 +41,19 @@ wmk(Image *i, Mousectl *mc, Channel *ck, Channel *cctl, int scrolling)
Rectangle r;
if(cols[0] == nil){
- /* there are no pastel paints in the dungeons and dragons world
- * - rob pike
- */
- reverse = 0;
- if(getenv("reverse") != nil)
- reverse = ~0xFF;
-
/* greys are multiples of 0x11111100+0xFF, 14* being palest */
- grey = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xEEEEEEFF^reverse);
- darkgrey = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x666666FF^reverse);
- cols[BACK] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xFFFFFFFF^reverse);
- cols[HIGH] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xCCCCCCFF^reverse);
+ grey = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xEEEEEEFF);
+ darkgrey = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x666666FF);
+ cols[BACK] = display->white;
+ cols[HIGH] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xCCCCCCFF);
cols[BORD] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x999999FF);
- cols[TEXT] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x000000FF^reverse);
- cols[HTEXT] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x000000FF^reverse);
- if(reverse == 0) {
- titlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DGreygreen);
- lighttitlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPalegreygreen);
- } else {
- titlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPurpleblue);
- lighttitlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x666666FF^reverse);
- }
- dholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DMedblue);
+ cols[TEXT] = display->black;
+ cols[HTEXT] = display->black;
+ titlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DGreygreen);
+ lighttitlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPalegreygreen);
+ holdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DMedblue);
lightholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DGreyblue);
paleholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPalegreyblue);
-
- if(reverse == 0)
- holdcol = dholdcol;
- else
- holdcol = paleholdcol;
}
w = emalloc(sizeof(Window));
w->screenr = i->r;
@@ -623,8 +604,8 @@ wkeyctl(Window *w, Rune r)
if(w->deleted)
return;
- /* navigation keys work only when mouse is not open */
- if(!w->mouseopen)
+ /* navigation keys work only when mouse and kbd is not open */
+ if(!w->mouseopen && !w->kbdopen)
switch(r){
case Kdown:
n = w->maxlines/3;
@@ -759,7 +740,7 @@ wsetcols(Window *w)
w->cols[TEXT] = w->cols[HTEXT] = lightholdcol;
else
if(w == input)
- w->cols[TEXT] = w->cols[HTEXT] = cols[TEXT];
+ w->cols[TEXT] = w->cols[HTEXT] = display->black;
else
w->cols[TEXT] = w->cols[HTEXT] = darkgrey;
}
@@ -1360,6 +1341,7 @@ wclosewin(Window *w)
if(hidden[i] == w){
--nhidden;
memmove(hidden+i, hidden+i+1, (nhidden-i)*sizeof(hidden[0]));
+ hidden[nhidden] = nil;
break;
}
for(i=0; i<nwindow; i++)