- wwsetcurwin(selwin);
- while (!quit) {
- if (curwin == cmdwin) {
- docmd();
- continue;
- }
- /*
- * Loop until we get some keyboard input.
- */
- while (ibufc == 0) {
- wwsetcursor(WCurRow(curwin->ww_win),
- WCurCol(curwin->ww_win));
- wwflush();
- imask = 1 << 0;
- while (wwforce(&imask) < 0)
- ;
- if ((imask & 1 << 0) == 0)
- continue;
- /* NOTE: ibufc == 0 */
- ibufp = ibuf;
- if ((ibufc = read(0, ibuf, sizeof ibuf)) < 0)
- ibufc = 0;
- }
- /*
- * Weird loop. Copy the buffer to the pty stopping
- * on the escape character in a hopefully efficient
- * way.
- * Probably a good thing to make ibufc == 1 a special
- * case.
- */
- for (p = ibufp, n = ibufc;;) {
- if (--n < 0) {
- write(curwin->ww_pty, ibufp, ibufc);
- ibufp = ibuf;
- ibufc = 0;
- break;
- } else if (*p++ == ESCAPE) {
- if ((n = p - ibufp) > 1)
- write(curwin->ww_pty, ibufp, n - 1);
- ibufp = p;
- ibufc -= n;
- wwsetcurwin(cmdwin);
- break;
- }
- }
- }