Commit | Line | Data |
---|---|---|
60de5df9 | 1 | /* |
46e9ea25 KB |
2 | * Copyright (c) 1983 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
3dd3a9e5 KB |
5 | * This code is derived from software contributed to Berkeley by |
6 | * Edward Wang at The University of California, Berkeley. | |
7 | * | |
87f529ec | 8 | * %sccs.include.redist.c% |
60de5df9 EW |
9 | */ |
10 | ||
46e9ea25 | 11 | #ifndef lint |
3dd3a9e5 | 12 | static char sccsid[] = "@(#)mloop.c 3.17 (Berkeley) %G%"; |
46e9ea25 KB |
13 | #endif /* not lint */ |
14 | ||
3e02121b EW |
15 | #include "defs.h" |
16 | ||
17 | mloop() | |
18 | { | |
3e02121b | 19 | while (!quit) { |
ffa20db4 | 20 | if (incmd) { |
3e02121b | 21 | docmd(); |
b1189050 | 22 | } else if (wwcurwin->ww_state != WWS_HASPROC) { |
2422abab EW |
23 | if (!wwcurwin->ww_keepopen) |
24 | closewin(wwcurwin); | |
ffa20db4 | 25 | setcmd(1); |
b1189050 EW |
26 | if (wwpeekc() == escapec) |
27 | (void) wwgetc(); | |
28 | error("Process died."); | |
29 | } else { | |
3fdb475b | 30 | register struct ww *w = wwcurwin; |
b1189050 EW |
31 | register char *p; |
32 | register n; | |
33 | ||
2c279448 EW |
34 | if (wwibp >= wwibq) |
35 | wwiomux(); | |
36 | for (p = wwibp; p < wwibq && *p != escapec; | |
37 | p++) | |
38 | ; | |
39 | if ((n = p - wwibp) > 0) { | |
40 | if (!w->ww_ispty && w->ww_stopped) | |
41 | startwin(w); | |
42 | (void) write(w->ww_pty, wwibp, n); | |
43 | wwibp = p; | |
44 | } | |
45 | if (wwpeekc() == escapec) { | |
46 | (void) wwgetc(); | |
47 | setcmd(1); | |
3e02121b EW |
48 | } |
49 | } | |
50 | } | |
51 | } |