curses.h revision 1.6 1 /*
2 * Copyright (c) 1981 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * from: @(#)curses.h 5.12 (Berkeley) 9/1/92
34 * $Id: curses.h,v 1.6 1993/08/15 16:43:27 mycroft Exp $
35 */
36
37 #ifndef _CURSES_H_
38 #define _CURSES_H_
39
40 #include <stdio.h>
41
42 /*
43 * The following #defines and #includes are present for backward
44 * compatibility only. They should not be used in future code.
45 *
46 * START BACKWARD COMPATIBILITY ONLY.
47 */
48 #ifndef _CURSES_PRIVATE
49 #define bool char
50 #define reg register
51
52 #ifndef TRUE
53 #define TRUE (1)
54 #endif
55 #ifndef FALSE
56 #define FALSE (0)
57 #endif
58
59 #define _puts(s) tputs(s, 0, __cputchar)
60 #define _putchar(c) __cputchar(c)
61
62 /* Old-style terminal modes access. */
63 #define baudrate() (cfgetospeed(&origtermio))
64 #define crmode() cbreak()
65 #define erasechar() (origtermio.c_cc[VERASE])
66 #define killchar() (origtermio.c_cc[VKILL])
67 #define nocrmode() nocbreak()
68 #define ospeed (cfgetospeed(&origtermio))
69 #endif /* _CURSES_PRIVATE */
70
71 extern int My_term; /* Use Def_term regardless. */
72 extern char *Def_term; /* Default terminal type. */
73
74 /* END BACKWARD COMPATIBILITY ONLY. */
75
76 /* 7-bit ASCII characters. */
77 #define unctrl(c) __unctrl[(c) & 0x7f]
78 #define unctrllen(ch) __unctrllen[(ch) & 0x7f]
79
80 typedef struct _win_st { /* Window structure. */
81 short _cury, _curx; /* Current x, y coordinates. */
82 short _maxy, _maxx; /* Maximum values for curx, cury. */
83 short _begy, _begx; /* Window home. */
84
85 #define _ENDLINE 0x001 /* End of screen. */
86 #define _FLUSH 0x002 /* fflush(stdout) after refresh. */
87 #define _FULLLINE 0x004 /* Line width = terminal width. */
88 #define _FULLWIN 0x008 /* Window is a screen. */
89 #define _IDLINE 0x010 /* Insert/delete sequences. */
90 #define _SCROLLWIN 0x020 /* Last char will scroll window. */
91 /*
92 * XXX
93 * _STANDOUT is the 8th bit, characters themselves are encoded.
94 */
95 #define _STANDOUT 0x080 /* Added characters are standout. */
96 unsigned short _flags;
97
98 short _ch_off; /* x offset for firstch/lastch. */
99 char _clear; /* If clear on next refresh. */
100 char _leave; /* If cursor left. */
101 char _scroll; /* If scrolling permitted. */
102 char **_y; /* Line describing the window. */
103
104 #define _NOCHANGE -1 /* No change since last refresh. */
105 short *_firstch; /* First and last changed in line. */
106 short *_lastch;
107 struct _win_st *_nextp, *_orig;/* Subwindows list and parent. */
108 } WINDOW;
109
110 /* Termcap capabilities. */
111 extern char AM, BS, CA, DA, EO, HC, HZ, IN, MI, MS, NC, NS, OS,
112 PC, UL, XB, XN, XT, XS, XX;
113 extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
114 *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
115 *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
116 *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
117 *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
118 *VE,
119 *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM,
120 *RIGHT_PARM;
121
122 /* Curses external declarations. */
123 extern WINDOW *curscr; /* Current screen. */
124 extern WINDOW *stdscr; /* Standard screen. */
125
126 extern struct termios origtermio; /* Original terminal modes. */
127
128 extern int COLS; /* Columns on the screen. */
129 extern int LINES; /* Lines on the screen. */
130
131 extern char GT; /* Gtty indicates tabs. */
132 extern char NONL; /* Term can't hack LF doing a CR. */
133 extern char UPPERCASE; /* Terminal is uppercase only. */
134 extern char *ttytype; /* Full name of current terminal. */
135 extern char *__unctrl[0x80]; /* Control strings. */
136 extern char __unctrllen[0x80]; /* Control strings length. */
137
138 #define ERR (0) /* Error return. */
139 #define OK (1) /* Success return. */
140
141 /* Standard screen pseudo functions. */
142 #define addch(ch) waddch(stdscr, ch)
143 #define addstr(str) waddstr(stdscr, str)
144 #define clear() wclear(stdscr)
145 #define clrtobot() wclrtobot(stdscr)
146 #define clrtoeol() wclrtoeol(stdscr)
147 #define delch() wdelch(stdscr)
148 #define deleteln() wdeleteln(stdscr)
149 #define erase() werase(stdscr)
150 #define getch() wgetch(stdscr)
151 #define getstr(str) wgetstr(stdscr, str)
152 #define inch() winch(stdscr)
153 #define insch(ch) winsch(stdscr, ch)
154 #define insertln() winsertln(stdscr)
155 #define move(y, x) wmove(stdscr, y, x)
156 #define refresh() wrefresh(stdscr)
157 #define standend() wstandend(stdscr)
158 #define standout() wstandout(stdscr)
159
160 /* Standard screen plus movement pseudo functions. */
161 #define mvaddch(y, x, ch) mvwaddch(stdscr, y, x, ch)
162 #define mvaddstr(y, x, str) mvwaddstr(stdscr, y, x, str)
163 #define mvdelch(y, x) mvwdelch(stdscr, y, x)
164 #define mvgetch(y, x) mvwgetch(stdscr, y, x)
165 #define mvgetstr(y, x, str) mvwgetstr(stdscr, y, x, str)
166 #define mvinch(y, x) mvwinch(stdscr, y, x)
167 #define mvinsch(y, x, c) mvwinsch(stdscr, y, x, c)
168 #define mvwaddch(win, y, x, ch) (wmove(win, y, x) == ERR ? \
169 ERR : waddch(win, ch))
170 #define mvwaddstr(win, y, x, str) \
171 (wmove(win, y, x) == ERR ? \
172 ERR : waddstr(win, str))
173 #define mvwdelch(win, y, x) (wmove(win, y, x) == ERR ? ERR : wdelch(win))
174 #define mvwgetch(win, y, x) (wmove(win, y, x) == ERR ? ERR : wgetch(win))
175 #define mvwgetstr(win, y, x, str) \
176 (wmove(win, y, x) == ERR ? \
177 ERR : wgetstr(win, str))
178 #define mvwinch(win, y, x) (wmove(win, y, x) == ERR ? ERR : winch(win))
179 #define mvwinsch(win, y, x, c) (wmove(win, y, x) == ERR ? ERR : winsch(win, c))
180
181 /* Random psuedo functions. */
182 #define clearok(win, bf) (win->_clear = (bf))
183 #define flushok(win, bf) ((bf) ? (win->_flags |= _FLUSH) : \
184 (win->_flags &= ~_FLUSH))
185 #define getyx(win, y, x) (y) = win->_cury, (x) = win->_curx
186 #define leaveok(win, bf) (win->_leave = (bf))
187 #define scrollok(win, bf) (win->_scroll = (bf))
188 #define winch(win) (win->_y[win->_cury][win->_curx] & 0177)
189
190 /* Public function prototypes. */
191 void __cputchar __P((int));
192 int _sprintw __P((WINDOW *, const char *, _VA_LIST_));
193 int box __P((WINDOW *, int, int));
194 int cbreak __P((void));
195 int delwin __P((WINDOW *));
196 int echo __P((void));
197 int endwin __P((void));
198 char *fullname __P((char *, char *));
199 char *getcap __P((char *));
200 int gettmode __P((void));
201 void idlok __P((WINDOW *, int));
202 WINDOW *initscr __P((void));
203 char *longname __P((char *, char *));
204 int mvcur __P((int, int, int, int));
205 int mvprintw __P((int, int, const char *, ...));
206 int mvscanw __P((int, int, const char *, ...));
207 int mvwin __P((WINDOW *, int, int));
208 int mvwprintw __P((WINDOW *, int, int, const char *, ...));
209 int mvwscanw __P((WINDOW *, int, int, const char *, ...));
210 WINDOW *newwin __P((int, int, int, int));
211 int nl __P((void));
212 int nocbreak __P((void));
213 int noecho __P((void));
214 int nonl __P((void));
215 int noraw __P((void));
216 int overlay __P((WINDOW *, WINDOW *));
217 int overwrite __P((WINDOW *, WINDOW *));
218 int printw __P((const char *, ...));
219 int raw __P((void));
220 int resetty __P((void));
221 int savetty __P((void));
222 int scanw __P((const char *, ...));
223 int scroll __P((WINDOW *));
224 int setterm __P((char *));
225 int sscans __P((WINDOW *, const char *, _VA_LIST_));
226 WINDOW *subwin __P((WINDOW *, int, int, int, int));
227 int suspendwin __P((void));
228 int touchline __P((WINDOW *, int, int, int));
229 int touchoverlap __P((WINDOW *, WINDOW *));
230 int touchwin __P((WINDOW *));
231 void tstp __P((int));
232 int waddch __P((WINDOW *, int));
233 int waddstr __P((WINDOW *, const char *));
234 int wclear __P((WINDOW *));
235 int wclrtobot __P((WINDOW *));
236 int wclrtoeol __P((WINDOW *));
237 int wdelch __P((WINDOW *));
238 int wdeleteln __P((WINDOW *));
239 int werase __P((WINDOW *));
240 int wgetch __P((WINDOW *));
241 int wgetstr __P((WINDOW *, char *));
242 int winsch __P((WINDOW *, int));
243 int winsertln __P((WINDOW *));
244 int wmove __P((WINDOW *, int, int));
245 int wprintw __P((WINDOW *, const char *, ...));
246 int wrefresh __P((WINDOW *));
247 int wscanw __P((WINDOW *, const char *, ...));
248 char *wstandend __P((WINDOW *));
249 char *wstandout __P((WINDOW *));
250
251 #ifdef _CURSES_PRIVATE
252 /* Private aliases. */
253 #define addbytes(da, co) waddbytes(stdscr, da, co)
254 #define mvaddbytes(y, x, da, co) \
255 mvwaddbytes(stdscr, y, x, da, co)
256 #define mvwaddbytes(win, y, x, da, co) \
257 (wmove(win, y, x) == ERR ? \
258 ERR : waddbytes(win, da, co))
259
260 /* Private function prototypes. */
261 void __id_subwins __P((WINDOW *));
262 void __set_subwin __P((WINDOW *, WINDOW *));
263 void __swflags __P((WINDOW *));
264 void __TRACE __P((const char *, ...));
265 int waddbytes __P((WINDOW *, const char *, int));
266
267 /* Private #defines. */
268 #define min(a,b) (a < b ? a : b)
269 #define max(a,b) (a > b ? a : b)
270
271 /* Private externs. */
272 extern int __echoit;
273 extern int __endwin;
274 extern int __pfast;
275 extern int __rawmode;
276 #endif
277
278 /* Termcap functions. */
279 int tgetent __P((char *, char *));
280 int tgetnum __P((char *));
281 int tgetflag __P((char *));
282 char *tgetstr __P((char *, char **));
283 char *tgoto __P((char *, int, int));
284 int tputs __P((char *, int, void (*)(int)));
285
286 #endif /* !_CURSES_H_ */
287