touchwin.c revision 1.10 1 /* $NetBSD: touchwin.c,v 1.10 2000/04/11 13:57:10 blymn 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.10 2000/04/11 13:57:10 blymn Exp $");
42 #endif
43 #endif /* not lint */
44
45 #include "curses.h"
46 #include "curses_private.h"
47
48 /*
49 * Touch count lines starting at start. This is the SUS v2 compliant
50 * version.
51 */
52
53 int
54 touchline(win, start, count)
55 WINDOW *win;
56 int start, count;
57 {
58 int y;
59
60 for (y = start; y < start + count; y++) {
61 __touchline(win, y, 0, (int) win->maxx - 1, 1);
62 }
63
64 return OK;
65 }
66
67 /*
68 * touchwin --
69 * Make it look like the whole window has been changed.
70 */
71 int
72 touchwin(win)
73 WINDOW *win;
74 {
75 int y, maxy;
76
77 #ifdef DEBUG
78 __CTRACE("touchwin: (%0.2o)\n", win);
79 #endif
80 maxy = win->maxy;
81 for (y = 0; y < maxy; y++)
82 __touchline(win, y, 0, (int) win->maxx - 1, 1);
83 return (OK);
84 }
85
86
87 int
88 __touchwin(win)
89 WINDOW *win;
90 {
91 int y, maxy;
92
93 #ifdef DEBUG
94 __CTRACE("touchwin: (%0.2o)\n", win);
95 #endif
96 maxy = win->maxy;
97 for (y = 0; y < maxy; y++)
98 __touchline(win, y, 0, (int) win->maxx - 1, 0);
99 return (OK);
100 }
101
102 int
103 __touchline(win, y, sx, ex, force)
104 WINDOW *win;
105 int y, sx, ex;
106 int force;
107 {
108 #ifdef DEBUG
109 __CTRACE("touchline: (%0.2o, %d, %d, %d, %d)\n", win, y, sx, ex, force);
110 __CTRACE("touchline: first = %d, last = %d\n",
111 *win->lines[y]->firstchp, *win->lines[y]->lastchp);
112 #endif
113 if (force)
114 win->lines[y]->flags |= __FORCEPAINT;
115 sx += win->ch_off;
116 ex += win->ch_off;
117 if (!(win->lines[y]->flags & __ISDIRTY)) {
118 win->lines[y]->flags |= __ISDIRTY;
119 *win->lines[y]->firstchp = sx;
120 *win->lines[y]->lastchp = ex;
121 } else {
122 if (*win->lines[y]->firstchp > sx)
123 *win->lines[y]->firstchp = sx;
124 if (*win->lines[y]->lastchp < ex)
125 *win->lines[y]->lastchp = ex;
126 }
127 #ifdef DEBUG
128 __CTRACE("touchline: first = %d, last = %d\n",
129 *win->lines[y]->firstchp, *win->lines[y]->lastchp);
130 #endif
131 return (OK);
132 }
133