cleaned up (removed space indentation). select/event bug fixed.

master
Aurélien Aptel 16 years ago
parent 129bcd7586
commit 2f35cef54b

53
st.c

@ -31,7 +31,6 @@ xbell(void) { /* visual bell */
XRectangle r = { 0, 0, xw.w, xw.h }; XRectangle r = { 0, 0, xw.w, xw.h };
XSetForeground(xw.dis, dc.gc, dc.col[BellCol]); XSetForeground(xw.dis, dc.gc, dc.col[BellCol]);
XFillRectangles(xw.dis, xw.win, dc.gc, &r, 1); XFillRectangles(xw.dis, xw.win, dc.gc, &r, 1);
XFlush(xw.dis);
usleep(30000); usleep(30000);
draw(SCredraw); draw(SCredraw);
} }
@ -501,6 +500,10 @@ eschandle(void) {
DEFAULT(escseq.arg[0], 1); DEFAULT(escseq.arg[0], 1);
tinsertblankline(escseq.arg[0]); tinsertblankline(escseq.arg[0]);
break; break;
case 'l':
if(escseq.priv && escseq.arg[0] == 25)
term.c.hidden = 1;
break;
case 'M': /* Delete <n> lines */ case 'M': /* Delete <n> lines */
DEFAULT(escseq.arg[0], 1); DEFAULT(escseq.arg[0], 1);
tdeleteline(escseq.arg[0]); tdeleteline(escseq.arg[0]);
@ -514,6 +517,8 @@ eschandle(void) {
tmoveto(term.c.x, escseq.arg[0]-1); tmoveto(term.c.x, escseq.arg[0]-1);
break; break;
case 'h': /* Set terminal mode */ case 'h': /* Set terminal mode */
if(escseq.priv && escseq.arg[0] == 25)
term.c.hidden = 0;
break; break;
case 'm': /* Terminal attribute (color) */ case 'm': /* Terminal attribute (color) */
tsetattr(escseq.arg, escseq.narg); tsetattr(escseq.arg, escseq.narg);
@ -572,8 +577,9 @@ tputtab(void) {
void void
tputc(char c) { tputc(char c) {
static int inesc = 0; static int inesc = 0;
#if 0
//dump(c); dump(c);
#endif
/* start of escseq */ /* start of escseq */
if(c == '\033') if(c == '\033')
escreset(), inesc = 1; escreset(), inesc = 1;
@ -746,7 +752,6 @@ xinit(void) {
XSetWMProperties(xw.dis, xw.win, NULL, NULL, &args[0], 0, &shint, &wmhint, &chint); XSetWMProperties(xw.dis, xw.win, NULL, NULL, &args[0], 0, &shint, &wmhint, &chint);
XStoreName(xw.dis, xw.win, TNAME); XStoreName(xw.dis, xw.win, TNAME);
XSync(xw.dis, 0); XSync(xw.dis, 0);
} }
void void
@ -825,7 +830,7 @@ kpress(XKeyEvent *e) {
int meta; int meta;
int shift; int shift;
meta = e->state & Mod4Mask; meta = e->state & Mod1Mask;
shift = e->state & ShiftMask; shift = e->state & ShiftMask;
len = XLookupString(e, buf, sizeof(buf), &ksym, NULL); len = XLookupString(e, buf, sizeof(buf), &ksym, NULL);
if(len > 0) { if(len > 0) {
@ -836,11 +841,9 @@ kpress(XKeyEvent *e) {
return; return;
} }
switch(ksym) { switch(ksym) {
#ifdef DEBUG1
default: default:
printf("errkey: %d\n", (int)ksym); fprintf(stderr, "errkey: %d\n", (int)ksym);
break; break;
#endif
case XK_Up: case XK_Up:
case XK_Down: case XK_Down:
case XK_Left: case XK_Left:
@ -849,13 +852,14 @@ kpress(XKeyEvent *e) {
ttywrite(buf, 3); ttywrite(buf, 3);
break; break;
case XK_Delete: ttywrite(KEYDELETE, sizeof(KEYDELETE)-1); break; case XK_Delete: ttywrite(KEYDELETE, sizeof(KEYDELETE)-1); break;
case XK_Home: ttywrite( KEYHOME, sizeof( KEYHOME)-1); break; case XK_Home: ttywrite(KEYHOME, sizeof(KEYHOME)-1); break;
case XK_End: ttywrite( KEYEND, sizeof( KEYEND)-1); break; case XK_End: ttywrite(KEYEND, sizeof(KEYEND) -1); break;
case XK_Prior: ttywrite( KEYPREV, sizeof( KEYPREV)-1); break; case XK_Prior: ttywrite(KEYPREV, sizeof(KEYPREV)-1); break;
case XK_Next: ttywrite( KEYNEXT, sizeof( KEYNEXT)-1); break; case XK_Next: ttywrite(KEYNEXT, sizeof(KEYNEXT)-1); break;
case XK_Insert: case XK_Insert:
/* XXX: paste X clipboard */ /* XXX: paste X clipboard */
if(shift); if(shift)
;
break; break;
} }
} }
@ -881,12 +885,25 @@ run(void) {
int ret; int ret;
XEvent ev; XEvent ev;
fd_set rfd; fd_set rfd;
struct timeval tv = {0, 10000}; int xfd = XConnectionNumber(xw.dis);
running = 1; running = 1;
XSelectInput(xw.dis, xw.win, ExposureMask | KeyPressMask | StructureNotifyMask); XSelectInput(xw.dis, xw.win, ExposureMask | KeyPressMask | StructureNotifyMask);
XResizeWindow(xw.dis, xw.win, xw.w , xw.h); /* seems to fix the resize bug in wmii */ XResizeWindow(xw.dis, xw.win, xw.w , xw.h); /* seems to fix the resize bug in wmii */
while(running) { while(running) {
FD_ZERO(&rfd);
FD_SET(cmdfd, &rfd);
FD_SET(xfd, &rfd);
XFlush(xw.dis);
ret = select(MAX(xfd, cmdfd)+1, &rfd, NULL, NULL, NULL);
if(ret < 0) {
fprintf(stderr, "select: %m\n");
running = 0;
}
if(FD_ISSET(xfd, &rfd)) {
while(XPending(xw.dis)) { while(XPending(xw.dis)) {
XNextEvent(xw.dis, &ev); XNextEvent(xw.dis, &ev);
switch (ev.type) { switch (ev.type) {
@ -903,15 +920,7 @@ run(void) {
break; break;
} }
} }
FD_ZERO(&rfd);
FD_SET(cmdfd, &rfd);
ret = select(cmdfd+1, &rfd, NULL, NULL, &tv);
if(ret < 0) {
fprintf(stderr, "select: %m\n");
running = 0;
} }
if(!ret)
continue;
if(FD_ISSET(cmdfd, &rfd)) { if(FD_ISSET(cmdfd, &rfd)) {
ttyread(); ttyread();
draw(SCupdate); draw(SCupdate);

Loading…
Cancel
Save