lint
[unix-history] / usr / src / usr.bin / window / mloop.c
CommitLineData
60de5df9 1/*
a96d7d6f
KB
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
46e9ea25 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
a96d7d6f 12static char sccsid[] = "@(#)mloop.c 8.1 (Berkeley) %G%";
46e9ea25
KB
13#endif /* not lint */
14
45723d81 15#include <sys/param.h>
3e02121b
EW
16#include "defs.h"
17
18mloop()
19{
3e02121b 20 while (!quit) {
ffa20db4 21 if (incmd) {
3e02121b 22 docmd();
b1189050 23 } else if (wwcurwin->ww_state != WWS_HASPROC) {
2422abab
EW
24 if (!wwcurwin->ww_keepopen)
25 closewin(wwcurwin);
ffa20db4 26 setcmd(1);
b1189050
EW
27 if (wwpeekc() == escapec)
28 (void) wwgetc();
29 error("Process died.");
30 } else {
3fdb475b 31 register struct ww *w = wwcurwin;
b1189050
EW
32 register char *p;
33 register n;
34
2c279448
EW
35 if (wwibp >= wwibq)
36 wwiomux();
21e9e78d 37 for (p = wwibp; p < wwibq && wwmaskc(*p) != escapec;
2c279448
EW
38 p++)
39 ;
40 if ((n = p - wwibp) > 0) {
41 if (!w->ww_ispty && w->ww_stopped)
42 startwin(w);
45723d81
CT
43#if defined(sun) && !defined(BSD)
44 /* workaround for SunOS pty bug */
0926efed
EW
45 while (--n >= 0)
46 (void) write(w->ww_pty, wwibp++, 1);
47#else
2c279448
EW
48 (void) write(w->ww_pty, wwibp, n);
49 wwibp = p;
0926efed 50#endif
2c279448
EW
51 }
52 if (wwpeekc() == escapec) {
53 (void) wwgetc();
54 setcmd(1);
3e02121b
EW
55 }
56 }
57 }
58}