1 /* 2 * Copyright (c) 1983 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 18 #ifndef lint 19 static char sccsid[] = "@(#)wwmove.c 3.9 (Berkeley) 06/29/88"; 20 #endif /* not lint */ 21 22 #include "ww.h" 23 24 /* 25 * Move a window. Should be unattached. 26 */ 27 wwmove(w, row, col) 28 register struct ww *w; 29 { 30 register dr, dc; 31 register i; 32 33 dr = row - w->ww_w.t; 34 dc = col - w->ww_w.l; 35 36 w->ww_w.t += dr; 37 w->ww_w.b += dr; 38 w->ww_w.l += dc; 39 w->ww_w.r += dc; 40 41 w->ww_b.t += dr; 42 w->ww_b.b += dr; 43 w->ww_b.l += dc; 44 w->ww_b.r += dc; 45 46 w->ww_i.t = MAX(w->ww_w.t, 0); 47 w->ww_i.b = MIN(w->ww_w.b, wwnrow); 48 w->ww_i.nr = w->ww_i.b - w->ww_i.t; 49 w->ww_i.l = MAX(w->ww_w.l, 0); 50 w->ww_i.r = MIN(w->ww_w.r, wwncol); 51 w->ww_i.nc = w->ww_i.r - w->ww_i.l; 52 53 w->ww_cur.r += dr; 54 w->ww_cur.c += dc; 55 56 w->ww_win -= dr; 57 for (i = w->ww_w.t; i < w->ww_w.b; i++) 58 w->ww_win[i] -= dc; 59 if (w->ww_fmap != 0) { 60 w->ww_fmap -= dr; 61 for (i = w->ww_w.t; i < w->ww_w.b; i++) 62 w->ww_fmap[i] -= dc; 63 } 64 w->ww_nvis -= dr; 65 for (i = w->ww_i.t; i < w->ww_i.b; i++) { 66 register j = w->ww_i.l; 67 register char *win = &w->ww_win[i][j]; 68 register char *smap = &wwsmap[i][j]; 69 int nvis = 0; 70 71 for (; j < w->ww_i.r; j++, win++, smap++) 72 if (*win == 0 && *smap == w->ww_index) 73 nvis++; 74 w->ww_nvis[i] = nvis; 75 } 76 w->ww_buf -= dr; 77 for (i = w->ww_b.t; i < w->ww_b.b; i++) 78 w->ww_buf[i] -= dc; 79 } 80