touchwin.c revision 1.9.6.2 1 /* $NetBSD: touchwin.c,v 1.9.6.2 2000/01/16 18:58:23 jdc Exp $ */
2
3 /*
4 * Copyright (c) 1981, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36 #include <sys/cdefs.h>
37 #ifndef lint
38 #if 0
39 static char sccsid[] = "@(#)touchwin.c 8.2 (Berkeley) 5/4/94";
40 #else
41 __RCSID("$NetBSD: touchwin.c,v 1.9.6.2 2000/01/16 18:58:23 jdc Exp $");
42 #endif
43 #endif /* not lint */
44
45 #include "curses.h"
46
47 /*
48 * Touch count lines starting at start. This is the SUS v2 compliant
49 * version.
50 */
51
52 int
53 touchline(win, start, count)
54 WINDOW *win;
55 int start, count;
56 {
57 int y;
58
59 for (y = start; y < start + count; y++) {
60 __touchline(win, y, 0, (int) win->maxx - 1, 1);
61 }
62
63 return OK;
64 }
65
66 /*
67 * touchwin --
68 * Make it look like the whole window has been changed.
69 */
70 int
71 touchwin(win)
72 WINDOW *win;
73 {
74 int y, maxy;
75
76 #ifdef DEBUG
77 __CTRACE("touchwin: (%0.2o)\n", win);
78 #endif
79 maxy = win->maxy;
80 for (y = 0; y < maxy; y++)
81 __touchline(win, y, 0, (int) win->maxx - 1, 1);
82 return (OK);
83 }
84
85
86 int
87 __touchwin(win)
88 WINDOW *win;
89 {
90 int y, maxy;
91
92 #ifdef DEBUG
93 __CTRACE("touchwin: (%0.2o)\n", win);
94 #endif
95 maxy = win->maxy;
96 for (y = 0; y < maxy; y++)
97 __touchline(win, y, 0, (int) win->maxx - 1, 0);
98 return (OK);
99 }
100
101 int
102 __touchline(win, y, sx, ex, force)
103 WINDOW *win;
104 int y, sx, ex;
105 int force;
106 {
107 #ifdef DEBUG
108 __CTRACE("touchline: (%0.2o, %d, %d, %d, %d)\n", win, y, sx, ex, force);
109 __CTRACE("touchline: first = %d, last = %d\n",
110 *win->lines[y]->firstchp, *win->lines[y]->lastchp);
111 #endif
112 if (force)
113 win->lines[y]->flags |= __FORCEPAINT;
114 sx += win->ch_off;
115 ex += win->ch_off;
116 if (!(win->lines[y]->flags & __ISDIRTY)) {
117 win->lines[y]->flags |= __ISDIRTY;
118 *win->lines[y]->firstchp = sx;
119 *win->lines[y]->lastchp = ex;
120 } else {
121 if (*win->lines[y]->firstchp > sx)
122 *win->lines[y]->firstchp = sx;
123 if (*win->lines[y]->lastchp < ex)
124 *win->lines[y]->lastchp = ex;
125 }
126 #ifdef DEBUG
127 __CTRACE("touchline: first = %d, last = %d\n",
128 *win->lines[y]->firstchp, *win->lines[y]->lastchp);
129 #endif
130 return (OK);
131 }
132