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.17 (Berkeley) 06/06/90"; 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 && *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); 48 } 49 } 50 } 51 } 52