Commit | Line | Data |
---|---|---|
3e02121b | 1 | #ifndef lint |
2422abab | 2 | static char sccsid[] = "@(#)mloop.c 3.9 %G%"; |
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 | ||
13 | mloop() | |
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) { |
2422abab EW |
20 | if (!wwcurwin->ww_keepopen) |
21 | closewin(wwcurwin); | |
ffa20db4 | 22 | setcmd(1); |
b1189050 EW |
23 | if (wwpeekc() == escapec) |
24 | (void) wwgetc(); | |
25 | error("Process died."); | |
26 | } else { | |
3fdb475b | 27 | register struct ww *w = wwcurwin; |
b1189050 EW |
28 | register char *p; |
29 | register n; | |
30 | ||
8fa6d94c | 31 | wwiomux(); |
b1189050 EW |
32 | if (wwibp < wwibq) { |
33 | for (p = wwibp; p < wwibq && *p != escapec; | |
34 | p++) | |
35 | ; | |
36 | if ((n = p - wwibp) > 0) { | |
3fdb475b EW |
37 | if (!w->ww_ispty && w->ww_stopped) |
38 | startwin(w); | |
39 | (void) write(w->ww_pty, wwibp, n); | |
b1189050 EW |
40 | wwibp = p; |
41 | } | |
42 | if (wwpeekc() == escapec) { | |
b1189050 | 43 | (void) wwgetc(); |
ffa20db4 | 44 | setcmd(1); |
b1189050 | 45 | } |
3e02121b EW |
46 | } |
47 | } | |
48 | } | |
49 | } |