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