1 /* $NetBSD: display.c,v 1.7 2003/08/07 11:16:04 agc Exp $ */
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/cdefs.h>
35 static char sccsid
[] = "@(#)display.c 8.1 (Berkeley) 6/6/93";
37 __RCSID("$NetBSD: display.c,v 1.7 2003/08/07 11:16:04 agc Exp $");
41 * The window 'manager', initializes curses and handles the actual
51 int curses_initialized
= 0;
54 * max HAS to be a function, it is called with
55 * a argument of the form --foo at least once.
62 return (a
> b
? a
: b
);
66 * Display some text on somebody's window, processing some control
67 * characters while we are at it.
70 display(win
, text
, size
)
78 for (i
= 0; i
< size
; i
++) {
85 if (*text
== win
->cerase
) {
86 wmove(win
->x_win
, win
->x_line
, max(--win
->x_col
, 0));
87 getyx(win
->x_win
, win
->x_line
, win
->x_col
);
88 waddch(win
->x_win
, ' ');
89 wmove(win
->x_win
, win
->x_line
, win
->x_col
);
90 getyx(win
->x_win
, win
->x_line
, win
->x_col
);
95 * On word erase search backwards until we find
96 * the beginning of a word or the beginning of
99 if (*text
== win
->werase
) {
100 int endcol
, xcol
, j
, c
;
105 c
= readwin(win
->x_win
, win
->x_line
, xcol
);
111 c
= readwin(win
->x_win
, win
->x_line
, xcol
);
116 wmove(win
->x_win
, win
->x_line
, xcol
+ 1);
117 for (j
= xcol
+ 1; j
< endcol
; j
++)
118 waddch(win
->x_win
, ' ');
119 wmove(win
->x_win
, win
->x_line
, xcol
+ 1);
120 getyx(win
->x_win
, win
->x_line
, win
->x_col
);
125 if (*text
== win
->kill
) {
126 wmove(win
->x_win
, win
->x_line
, 0);
127 wclrtoeol(win
->x_win
);
128 getyx(win
->x_win
, win
->x_line
, win
->x_col
);
138 if (*text
== '\07') {
143 if (win
->x_col
== COLS
-1) {
144 /* check for wraparound */
147 if ( !isprint((u_char
)*text
) && *text
!= '\t') {
148 waddch(win
->x_win
, '^');
149 getyx(win
->x_win
, win
->x_line
, win
->x_col
);
150 if (win
->x_col
== COLS
-1) /* check for wraparound */
152 cch
= (*text
& 63) + 64;
153 waddch(win
->x_win
, cch
);
155 waddch(win
->x_win
, *text
);
156 getyx(win
->x_win
, win
->x_line
, win
->x_col
);
159 wrefresh(win
->x_win
);
163 * Read the character at the indicated position in win
166 readwin(win
, line
, col
)
173 getyx(win
, oldline
, oldcol
);
174 wmove(win
, line
, col
);
176 wmove(win
, oldline
, oldcol
);
181 * Scroll a window, blanking out the line following the current line
182 * so that the current position is obvious
191 wmove(win
->x_win
, 0, 0);
196 win
->x_line
= (win
->x_line
+ 1) % win
->x_nlines
;
198 wmove(win
->x_win
, win
->x_line
, win
->x_col
);
199 wclrtoeol(win
->x_win
);
200 wmove(win
->x_win
, (win
->x_line
+ 1) % win
->x_nlines
, win
->x_col
);
201 wclrtoeol(win
->x_win
);
202 wmove(win
->x_win
, win
->x_line
, win
->x_col
);