cleaned up (removed space indentation). select/event bug fixed.
This commit is contained in:
parent
129bcd7586
commit
2f35cef54b
53
st.c
53
st.c
|
@ -31,7 +31,6 @@ xbell(void) { /* visual bell */
|
|||
XRectangle r = { 0, 0, xw.w, xw.h };
|
||||
XSetForeground(xw.dis, dc.gc, dc.col[BellCol]);
|
||||
XFillRectangles(xw.dis, xw.win, dc.gc, &r, 1);
|
||||
XFlush(xw.dis);
|
||||
usleep(30000);
|
||||
draw(SCredraw);
|
||||
}
|
||||
|
@ -501,6 +500,10 @@ eschandle(void) {
|
|||
DEFAULT(escseq.arg[0], 1);
|
||||
tinsertblankline(escseq.arg[0]);
|
||||
break;
|
||||
case 'l':
|
||||
if(escseq.priv && escseq.arg[0] == 25)
|
||||
term.c.hidden = 1;
|
||||
break;
|
||||
case 'M': /* Delete <n> lines */
|
||||
DEFAULT(escseq.arg[0], 1);
|
||||
tdeleteline(escseq.arg[0]);
|
||||
|
@ -514,6 +517,8 @@ eschandle(void) {
|
|||
tmoveto(term.c.x, escseq.arg[0]-1);
|
||||
break;
|
||||
case 'h': /* Set terminal mode */
|
||||
if(escseq.priv && escseq.arg[0] == 25)
|
||||
term.c.hidden = 0;
|
||||
break;
|
||||
case 'm': /* Terminal attribute (color) */
|
||||
tsetattr(escseq.arg, escseq.narg);
|
||||
|
@ -572,8 +577,9 @@ tputtab(void) {
|
|||
void
|
||||
tputc(char c) {
|
||||
static int inesc = 0;
|
||||
|
||||
//dump(c);
|
||||
#if 0
|
||||
dump(c);
|
||||
#endif
|
||||
/* start of escseq */
|
||||
if(c == '\033')
|
||||
escreset(), inesc = 1;
|
||||
|
@ -746,7 +752,6 @@ xinit(void) {
|
|||
XSetWMProperties(xw.dis, xw.win, NULL, NULL, &args[0], 0, &shint, &wmhint, &chint);
|
||||
XStoreName(xw.dis, xw.win, TNAME);
|
||||
XSync(xw.dis, 0);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -825,7 +830,7 @@ kpress(XKeyEvent *e) {
|
|||
int meta;
|
||||
int shift;
|
||||
|
||||
meta = e->state & Mod4Mask;
|
||||
meta = e->state & Mod1Mask;
|
||||
shift = e->state & ShiftMask;
|
||||
len = XLookupString(e, buf, sizeof(buf), &ksym, NULL);
|
||||
if(len > 0) {
|
||||
|
@ -836,11 +841,9 @@ kpress(XKeyEvent *e) {
|
|||
return;
|
||||
}
|
||||
switch(ksym) {
|
||||
#ifdef DEBUG1
|
||||
default:
|
||||
printf("errkey: %d\n", (int)ksym);
|
||||
fprintf(stderr, "errkey: %d\n", (int)ksym);
|
||||
break;
|
||||
#endif
|
||||
case XK_Up:
|
||||
case XK_Down:
|
||||
case XK_Left:
|
||||
|
@ -849,13 +852,14 @@ kpress(XKeyEvent *e) {
|
|||
ttywrite(buf, 3);
|
||||
break;
|
||||
case XK_Delete: ttywrite(KEYDELETE, sizeof(KEYDELETE)-1); break;
|
||||
case XK_Home: ttywrite( KEYHOME, sizeof( KEYHOME)-1); break;
|
||||
case XK_End: ttywrite( KEYEND, sizeof( KEYEND)-1); break;
|
||||
case XK_Prior: ttywrite( KEYPREV, sizeof( KEYPREV)-1); break;
|
||||
case XK_Next: ttywrite( KEYNEXT, sizeof( KEYNEXT)-1); break;
|
||||
case XK_Home: ttywrite(KEYHOME, sizeof(KEYHOME)-1); break;
|
||||
case XK_End: ttywrite(KEYEND, sizeof(KEYEND) -1); break;
|
||||
case XK_Prior: ttywrite(KEYPREV, sizeof(KEYPREV)-1); break;
|
||||
case XK_Next: ttywrite(KEYNEXT, sizeof(KEYNEXT)-1); break;
|
||||
case XK_Insert:
|
||||
/* XXX: paste X clipboard */
|
||||
if(shift);
|
||||
if(shift)
|
||||
;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -881,12 +885,25 @@ run(void) {
|
|||
int ret;
|
||||
XEvent ev;
|
||||
fd_set rfd;
|
||||
struct timeval tv = {0, 10000};
|
||||
int xfd = XConnectionNumber(xw.dis);
|
||||
|
||||
running = 1;
|
||||
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 */
|
||||
|
||||
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)) {
|
||||
XNextEvent(xw.dis, &ev);
|
||||
switch (ev.type) {
|
||||
|
@ -903,15 +920,7 @@ run(void) {
|
|||
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)) {
|
||||
ttyread();
|
||||
draw(SCupdate);
|
||||
|
|
Loading…
Reference in New Issue
Block a user