* 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();