rip out SHELL_ESCAPE define
[unix-history] / usr / src / usr.bin / window / wwmove.c
CommitLineData
60de5df9 1/*
46e9ea25
KB
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
5e8b0e60
KB
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.
60de5df9
EW
16 */
17
46e9ea25 18#ifndef lint
5e8b0e60 19static char sccsid[] = "@(#)wwmove.c 3.9 (Berkeley) %G%";
46e9ea25
KB
20#endif /* not lint */
21
0d032a5f
EW
22#include "ww.h"
23
24/*
25 * Move a window. Should be unattached.
26 */
27wwmove(w, row, col)
28register struct ww *w;
29{
f2a77fe1
EW
30 register dr, dc;
31 register i;
32
f2a77fe1
EW
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;
0d032a5f
EW
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;
f2a77fe1
EW
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;
f2a77fe1
EW
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;
c1e16556
EW
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];
84ad208b 68 register char *smap = &wwsmap[i][j];
c1e16556
EW
69 int nvis = 0;
70
84ad208b
EW
71 for (; j < w->ww_i.r; j++, win++, smap++)
72 if (*win == 0 && *smap == w->ww_index)
c1e16556
EW
73 nvis++;
74 w->ww_nvis[i] = nvis;
75 }
f2a77fe1
EW
76 w->ww_buf -= dr;
77 for (i = w->ww_b.t; i < w->ww_b.b; i++)
78 w->ww_buf[i] -= dc;
0d032a5f 79}