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[] = "@(#)wwflush.c 8.1 (Berkeley) 06/06/93"; 13 #endif /* not lint */ 14 15 #include "ww.h" 16 #include "tt.h" 17 #include <sys/signal.h> 18 19 wwflush() 20 { 21 register row, col; 22 23 if ((row = wwcursorrow) < 0) 24 row = 0; 25 else if (row >= wwnrow) 26 row = wwnrow - 1; 27 if ((col = wwcursorcol) < 0) 28 col = 0; 29 else if (col >= wwncol) 30 col = wwncol - 1; 31 xxmove(row, col); 32 if (wwdocheckpoint) { 33 xxflush(0); 34 wwcheckpoint(); 35 } else 36 xxflush(1); 37 } 38 39 wwcheckpoint() 40 { 41 int s = sigblock(sigmask(SIGALRM) | sigmask(SIGIO)); 42 43 tt.tt_ack = 0; 44 do { 45 (*tt.tt_checkpoint)(); 46 #ifndef OLD_TTY 47 (void) tcdrain(1); 48 #endif 49 (void) alarm(3); 50 for (wwdocheckpoint = 0; !wwdocheckpoint && tt.tt_ack == 0;) 51 (void) sigpause(s); 52 } while (tt.tt_ack == 0); 53 (void) alarm(0); 54 wwdocheckpoint = 0; 55 if (tt.tt_ack < 0) { 56 wwcopyscreen(wwcs, wwos); 57 (void) alarm(1); 58 wwreset(); 59 wwupdate(); 60 wwflush(); 61 } else { 62 wwcopyscreen(wwos, wwcs); 63 (void) alarm(3); 64 } 65 (void) sigsetmask(s); 66 } 67 68 wwcopyscreen(s1, s2) 69 register union ww_char **s1, **s2; 70 { 71 register i; 72 register s = wwncol * sizeof **s1; 73 74 for (i = wwnrow; --i >= 0;) 75 bcopy((char *) *s1++, (char *) *s2++, s); 76 } 77 78 void 79 wwalarm() 80 { 81 wwdocheckpoint = 1; 82 } 83