1 /* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. 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 8.1 (Berkeley) 06/06/93"; 13 #endif /* not lint */ 14 15 #include <sys/param.h> 16 #include "defs.h" 17 18 mloop() 19 { 20 while (!quit) { 21 if (incmd) { 22 docmd(); 23 } else if (wwcurwin->ww_state != WWS_HASPROC) { 24 if (!wwcurwin->ww_keepopen) 25 closewin(wwcurwin); 26 setcmd(1); 27 if (wwpeekc() == escapec) 28 (void) wwgetc(); 29 error("Process died."); 30 } else { 31 register struct ww *w = wwcurwin; 32 register char *p; 33 register n; 34 35 if (wwibp >= wwibq) 36 wwiomux(); 37 for (p = wwibp; p < wwibq && wwmaskc(*p) != escapec; 38 p++) 39 ; 40 if ((n = p - wwibp) > 0) { 41 if (!w->ww_ispty && w->ww_stopped) 42 startwin(w); 43 #if defined(sun) && !defined(BSD) 44 /* workaround for SunOS pty bug */ 45 while (--n >= 0) 46 (void) write(w->ww_pty, wwibp++, 1); 47 #else 48 (void) write(w->ww_pty, wwibp, n); 49 wwibp = p; 50 #endif 51 } 52 if (wwpeekc() == escapec) { 53 (void) wwgetc(); 54 setcmd(1); 55 } 56 } 57 } 58 } 59