X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=demo%2Fboxshell.c;h=43c007a2a90ab95281e4c9d48f2f76b6fee2c38a;hb=714e9fd2445997a69dec855e59a2a93cb991f3dd;hp=a1d1fa88abf49592b3490344e62f89b4d8ef3001;hpb=d0e48d929c19d39c4a13e57e0f8a8dd6194d6dde;p=apps%2Fmadtty.git diff --git a/demo/boxshell.c b/demo/boxshell.c index a1d1fa8..43c007a 100644 --- a/demo/boxshell.c +++ b/demo/boxshell.c @@ -89,13 +89,28 @@ int main(int argc, char *argv[]) * also, redraw the terminal to the window at each iteration */ ch = '\0'; while (!getout) { - usleep(10000); - rote_vt_draw(rt, term_win, 1, 1, NULL); - wrefresh(term_win); + fd_set rfds; + struct timeval tv = { 0 , 1000 }; + + FD_ZERO(&rfds); + FD_SET(rt->pty, &rfds); + + if (select(rt->pty + 1, &rfds, NULL, NULL, &tv) > 0) { + char buf[512]; + int nbread; + + nbread = rote_vt_read(rt, buf, sizeof(buf)); + if (nbread > 0) + rote_vt_inject(rt, buf, nbread); + } - ch = getch(); - if (ch != ERR) + + while ((ch = getch()) != ERR) { rote_vt_keypress(rt, ch); /* pass the keypress for handling */ + } + + rote_vt_draw(rt, term_win, 1, 1, NULL); + wrefresh(term_win); } endwin();