X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/8fa6d94c226ba0c6e3df519508bca32fdf58fdb5..2422ababf73a0fd039388491e282e6f01d70b0ba:/usr/src/usr.bin/window/mloop.c diff --git a/usr/src/usr.bin/window/mloop.c b/usr/src/usr.bin/window/mloop.c index 8a7864d0d0..d0669c78a5 100644 --- a/usr/src/usr.bin/window/mloop.c +++ b/usr/src/usr.bin/window/mloop.c @@ -1,49 +1,48 @@ #ifndef lint -static char *sccsid = "@(#)mloop.c 3.2 84/01/16"; +static char sccsid[] = "@(#)mloop.c 3.9 %G%"; #endif +/* + * Copyright (c) 1983 Regents of the University of California, + * All rights reserved. Redistribution permitted subject to + * the terms of the Berkeley Software License Agreement. + */ + #include "defs.h" mloop() { - register n; - register char *p; - int imask; - + wwrint(); /* catch typeahead before we set ASYNC */ while (!quit) { - if (!incmd && selwin->ww_state != WWS_HASPROC) { - incmd = 1; - error("Process died."); - } if (incmd) { docmd(); - continue; - } - while (wwibc == 0) { - wwcurtowin(selwin); + } else if (wwcurwin->ww_state != WWS_HASPROC) { + if (!wwcurwin->ww_keepopen) + closewin(wwcurwin); + setcmd(1); + if (wwpeekc() == escapec) + (void) wwgetc(); + error("Process died."); + } else { + register struct ww *w = wwcurwin; + register char *p; + register n; + wwiomux(); - } - /* - * Weird loop. Copy the buffer to the pty - * and stopping on the escape character - * in a hopefully efficient way. - * Probably a good thing to make wwibc == 1 a special - * case. - */ - for (p = wwibp, n = wwibc;;) { - if (--n < 0) { - (void) write(selwin->ww_pty, wwibp, wwibc); - wwibc = 0; - break; - } - if (*p++ == escapec) { - if ((n = p - wwibp) > 1) - (void) write(selwin->ww_pty, - wwibp, n - 1); - wwibp = p; - wwibc -= n; - incmd = 1; - break; + if (wwibp < wwibq) { + for (p = wwibp; p < wwibq && *p != escapec; + p++) + ; + if ((n = p - wwibp) > 0) { + if (!w->ww_ispty && w->ww_stopped) + startwin(w); + (void) write(w->ww_pty, wwibp, n); + wwibp = p; + } + if (wwpeekc() == escapec) { + (void) wwgetc(); + setcmd(1); + } } } }