less -> more
[unix-history] / usr / src / usr.bin / window / wwcursor.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[] = "@(#)wwcursor.c 3.10 (Berkeley) %G%";
46e9ea25
KB
20#endif /* not lint */
21
120c3815
EW
22#include "ww.h"
23
24wwcursor(w, on)
25register struct ww *w;
26{
27 register char *win;
120c3815
EW
28
29 if (on) {
30 if (w->ww_hascursor)
31 return;
32 w->ww_hascursor = 1;
33 } else {
34 if (!w->ww_hascursor)
35 return;
36 w->ww_hascursor = 0;
37 }
38 if (wwcursormodes != 0) {
39 win = &w->ww_win[w->ww_cur.r][w->ww_cur.c];
120c3815 40 *win ^= wwcursormodes;
f2a77fe1
EW
41 if (w->ww_cur.r < w->ww_i.t || w->ww_cur.r >= w->ww_i.b
42 || w->ww_cur.c < w->ww_i.l || w->ww_cur.c >= w->ww_i.r)
19f9784c 43 return;
f2a77fe1 44 if (wwsmap[w->ww_cur.r][w->ww_cur.c] == w->ww_index) {
84ad208b
EW
45 if (*win == 0)
46 w->ww_nvis[w->ww_cur.r]++;
47 else if (*win == wwcursormodes)
48 w->ww_nvis[w->ww_cur.r]--;
f2a77fe1 49 wwns[w->ww_cur.r][w->ww_cur.c].c_m ^= wwcursormodes;
04d70db4 50 wwtouched[w->ww_cur.r] |= WWU_TOUCHED;
19f9784c 51 }
120c3815
EW
52 }
53}
35ffbdff
EW
54
55wwsetcursormodes(new)
56register new;
57{
58 register i;
59 register struct ww *w;
60 register old = wwcursormodes;
61
62 new &= wwavailmodes;
63 if (new == wwcursormodes)
64 return;
65 for (i = 0; i < NWW; i++)
66 if (wwindex[i] != 0 && (w = wwindex[i])->ww_hascursor) {
67 wwcursor(w, 0);
68 wwcursormodes = new;
69 wwcursor(w, 1);
70 wwcursormodes = old;
71 }
72 wwcursormodes = new;
73}