BSD 4_3 release
[unix-history] / usr / src / ucb / window / mloop.c
CommitLineData
3e02121b 1#ifndef lint
95f51977 2static char sccsid[] = "@(#)mloop.c 3.8 4/24/85";
3e02121b
EW
3#endif
4
60de5df9
EW
5/*
6 * Copyright (c) 1983 Regents of the University of California,
7 * All rights reserved. Redistribution permitted subject to
8 * the terms of the Berkeley Software License Agreement.
9 */
10
3e02121b
EW
11#include "defs.h"
12
13mloop()
14{
4cbd8755 15 wwrint(); /* catch typeahead before we set ASYNC */
3e02121b 16 while (!quit) {
ffa20db4 17 if (incmd) {
3e02121b 18 docmd();
b1189050 19 } else if (wwcurwin->ww_state != WWS_HASPROC) {
ffa20db4 20 setcmd(1);
b1189050
EW
21 if (wwpeekc() == escapec)
22 (void) wwgetc();
23 error("Process died.");
24 } else {
3fdb475b 25 register struct ww *w = wwcurwin;
b1189050
EW
26 register char *p;
27 register n;
28
8fa6d94c 29 wwiomux();
b1189050
EW
30 if (wwibp < wwibq) {
31 for (p = wwibp; p < wwibq && *p != escapec;
32 p++)
33 ;
34 if ((n = p - wwibp) > 0) {
3fdb475b
EW
35 if (!w->ww_ispty && w->ww_stopped)
36 startwin(w);
37 (void) write(w->ww_pty, wwibp, n);
b1189050
EW
38 wwibp = p;
39 }
40 if (wwpeekc() == escapec) {
b1189050 41 (void) wwgetc();
ffa20db4 42 setcmd(1);
b1189050 43 }
3e02121b
EW
44 }
45 }
46 }
47}