Commit | Line | Data |
---|---|---|
87c6fcf8 | 1 | /* |
2f14f200 KB |
2 | * Copyright (c) 1981 Regents of the University of California. |
3 | * All rights reserved. | |
87c6fcf8 | 4 | * |
c07973a2 | 5 | * %sccs.include.redist.c% |
2f14f200 | 6 | * |
e00fdff3 | 7 | * @(#)curses.h 5.32 (Berkeley) %G% |
87c6fcf8 DF |
8 | */ |
9 | ||
ddf60ab8 KB |
10 | #ifndef _CURSES_H_ |
11 | #define _CURSES_H_ | |
1b7ae9b8 | 12 | |
ddf60ab8 | 13 | #include <stdio.h> |
1b7ae9b8 | 14 | |
ddf60ab8 KB |
15 | /* |
16 | * The following #defines and #includes are present for backward | |
17 | * compatibility only. They should not be used in future code. | |
18 | * | |
19 | * START BACKWARD COMPATIBILITY ONLY. | |
20 | */ | |
21 | #ifndef _CURSES_PRIVATE | |
512c20d0 MK |
22 | #define bool char |
23 | #define reg register | |
1b7ae9b8 | 24 | |
ddf60ab8 | 25 | #ifndef TRUE |
512c20d0 | 26 | #define TRUE (1) |
ddf60ab8 KB |
27 | #endif |
28 | #ifndef FALSE | |
512c20d0 | 29 | #define FALSE (0) |
ddf60ab8 | 30 | #endif |
1b7ae9b8 | 31 | |
296fd6cc | 32 | #define _puts(s) tputs(s, 0, __cputchar) |
ddf60ab8 | 33 | #define _putchar(c) __cputchar(c) |
1b7ae9b8 | 34 | |
ddf60ab8 | 35 | /* Old-style terminal modes access. */ |
5313de4c | 36 | #define baudrate() (cfgetospeed(&__orig_termios)) |
ddf60ab8 | 37 | #define crmode() cbreak() |
5313de4c KB |
38 | #define erasechar() (__orig_termios.c_cc[VERASE]) |
39 | #define killchar() (__orig_termios.c_cc[VKILL]) | |
ddf60ab8 | 40 | #define nocrmode() nocbreak() |
5313de4c | 41 | #define ospeed (cfgetospeed(&__orig_termios)) |
ddf60ab8 | 42 | #endif /* _CURSES_PRIVATE */ |
1b7ae9b8 | 43 | |
e91c7874 KB |
44 | extern char GT; /* Gtty indicates tabs. */ |
45 | extern char NONL; /* Term can't hack LF doing a CR. */ | |
46 | extern char UPPERCASE; /* Terminal is uppercase only. */ | |
47 | ||
ddf60ab8 KB |
48 | extern int My_term; /* Use Def_term regardless. */ |
49 | extern char *Def_term; /* Default terminal type. */ | |
50 | ||
e91c7874 KB |
51 | /* Termcap capabilities. */ |
52 | extern char AM, BS, CA, DA, EO, HC, HZ, IN, MI, MS, NC, NS, OS, | |
53 | PC, UL, XB, XN, XT, XS, XX; | |
54 | extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, | |
55 | *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6, | |
56 | *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL, | |
57 | *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF, | |
58 | *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS, | |
59 | *VE, *al, *dl, *sf, *sr, | |
60 | *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM, | |
61 | *RIGHT_PARM; | |
62 | ||
ddf60ab8 KB |
63 | /* END BACKWARD COMPATIBILITY ONLY. */ |
64 | ||
0495c810 EA |
65 | /* 8-bit ASCII characters. */ |
66 | #define unctrl(c) __unctrl[(c) & 0xff] | |
67 | #define unctrllen(ch) __unctrllen[(ch) & 0xff] | |
ddf60ab8 | 68 | |
6d9437b4 EA |
69 | extern char *__unctrl[256]; /* Control strings. */ |
70 | extern char __unctrllen[256]; /* Control strings length. */ | |
e91c7874 | 71 | |
0c5c5188 | 72 | /* |
1c04a491 EA |
73 | * A window an array of __LINE structures pointed to by the 'lines' pointer. |
74 | * A line is an array of __LDATA structures pointed to by the 'line' pointer. | |
75 | * | |
76 | * IMPORTANT: the __LDATA structure must NOT induce any padding, so if new | |
77 | * fields are added -- padding fields with *constant values* should ensure | |
78 | * that the compiler will not generate any padding when storing an array of | |
1cbb36c0 | 79 | * __LDATA structures. This is to enable consistent use of memcmp, and memcpy |
1c04a491 | 80 | * for comparing and copying arrays. |
0c5c5188 | 81 | */ |
1c04a491 EA |
82 | typedef struct { |
83 | char ch; /* the actual character */ | |
84 | ||
85 | #define __STANDOUT 0x01 /* Added characters are standout. */ | |
86 | char attr; /* attributes of character */ | |
87 | } __LDATA; | |
88 | ||
89 | #define __LDATASIZE (sizeof(__LDATA)) | |
90 | ||
91 | typedef struct { | |
0c5c5188 | 92 | #define __ISDIRTY 0x01 /* Line is dirty. */ |
091287a4 | 93 | #define __ISPASTEOL 0x02 /* Cursor is past end of line */ |
e3923e32 | 94 | #define __FORCEPAINT 0x04 /* Force a repaint of the line */ |
0c5c5188 EA |
95 | u_int flags; |
96 | u_int hash; /* Hash value for the line. */ | |
556a4108 | 97 | size_t *firstchp, *lastchp; /* First and last chngd columns ptrs */ |
0c5c5188 | 98 | size_t firstch, lastch; /* First and last changed columns. */ |
1c04a491 EA |
99 | __LDATA *line; /* Pointer to the line text. */ |
100 | } __LINE; | |
0c5c5188 EA |
101 | |
102 | typedef struct __window { /* Window structure. */ | |
103 | struct __window *nextp, *orig; /* Subwindows list and parent. */ | |
104 | size_t begy, begx; /* Window home. */ | |
105 | size_t cury, curx; /* Current x, y coordinates. */ | |
106 | size_t maxy, maxx; /* Maximum values for curx, cury. */ | |
107 | short ch_off; /* x offset for firstch/lastch. */ | |
1c04a491 EA |
108 | __LINE **lines; /* Array of pointers to the lines */ |
109 | __LINE *lspace; /* line space (for cleanup) */ | |
110 | __LDATA *wspace; /* window space (for cleanup) */ | |
0c5c5188 EA |
111 | |
112 | #define __ENDLINE 0x001 /* End of screen. */ | |
113 | #define __FLUSH 0x002 /* Fflush(stdout) after refresh. */ | |
114 | #define __FULLLINE 0x004 /* Line width = terminal width. */ | |
115 | #define __FULLWIN 0x008 /* Window is a screen. */ | |
116 | #define __IDLINE 0x010 /* Insert/delete sequences. */ | |
117 | #define __SCROLLWIN 0x020 /* Last char will scroll window. */ | |
118 | #define __SCROLLOK 0x040 /* Scrolling ok. */ | |
119 | #define __CLEAROK 0x080 /* Clear on next refresh. */ | |
120 | #define __WSTANDOUT 0x100 /* Standout window */ | |
121 | #define __LEAVEOK 0x200 /* If curser left */ | |
122 | u_int flags; | |
ddf60ab8 KB |
123 | } WINDOW; |
124 | ||
ddf60ab8 KB |
125 | /* Curses external declarations. */ |
126 | extern WINDOW *curscr; /* Current screen. */ | |
127 | extern WINDOW *stdscr; /* Standard screen. */ | |
1b7ae9b8 | 128 | |
5313de4c | 129 | extern struct termios __orig_termios; /* Original terminal modes. */ |
1b7ae9b8 | 130 | |
ddf60ab8 KB |
131 | extern int COLS; /* Columns on the screen. */ |
132 | extern int LINES; /* Lines on the screen. */ | |
1b7ae9b8 | 133 | |
ddf60ab8 | 134 | extern char *ttytype; /* Full name of current terminal. */ |
1b7ae9b8 | 135 | |
ddf60ab8 KB |
136 | #define ERR (0) /* Error return. */ |
137 | #define OK (1) /* Success return. */ | |
1b7ae9b8 | 138 | |
ddf60ab8 | 139 | /* Standard screen pseudo functions. */ |
6cdb6e3d | 140 | #define addbytes(s, n) __waddbytes(stdscr, s, n, 0) |
e91c7874 | 141 | #define addch(ch) waddch(stdscr, ch) |
6cdb6e3d KB |
142 | #define addnstr(s, n) waddnstr(stdscr, s, n) |
143 | #define addstr(s) __waddbytes(stdscr, s, strlen(s), 0) | |
e91c7874 KB |
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) | |
6cdb6e3d | 151 | #define getstr(s) wgetstr(stdscr, s) |
e91c7874 | 152 | #define inch() winch(stdscr) |
b7d3b7fd | 153 | #define insch(ch) winsch(stdscr, ch) |
e91c7874 KB |
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) | |
6cdb6e3d KB |
159 | #define waddbytes(w, s, n) __waddbytes(w, s, n, 0) |
160 | #define waddstr(w, s) __waddbytes(w, s, strlen(s), 0) | |
1b7ae9b8 | 161 | |
ddf60ab8 | 162 | /* Standard screen plus movement pseudo functions. */ |
6cdb6e3d | 163 | #define mvaddbytes(y, x, s, n) mvwaddbytes(stdscr, y, x, s, n) |
e91c7874 | 164 | #define mvaddch(y, x, ch) mvwaddch(stdscr, y, x, ch) |
6cdb6e3d KB |
165 | #define mvaddnstr(y, x, s, n) mvwaddnstr(stdscr, y, x, s, n) |
166 | #define mvaddstr(y, x, s) mvwaddstr(stdscr, y, x, s) | |
e91c7874 KB |
167 | #define mvdelch(y, x) mvwdelch(stdscr, y, x) |
168 | #define mvgetch(y, x) mvwgetch(stdscr, y, x) | |
6cdb6e3d | 169 | #define mvgetstr(y, x, s) mvwgetstr(stdscr, y, x, s) |
e91c7874 KB |
170 | #define mvinch(y, x) mvwinch(stdscr, y, x) |
171 | #define mvinsch(y, x, c) mvwinsch(stdscr, y, x, c) | |
6cdb6e3d KB |
172 | #define mvwaddbytes(w, y, x, s, n) \ |
173 | (wmove(w, y, x) == ERR ? ERR : __waddbytes(w, s, n, 0)) | |
174 | #define mvwaddch(w, y, x, ch) \ | |
175 | (wmove(w, y, x) == ERR ? ERR : waddch(w, ch)) | |
176 | #define mvwaddnstr(w, y, x, s, n) \ | |
177 | (wmove(w, y, x) == ERR ? ERR : waddnstr(w, s, n)) | |
178 | #define mvwaddstr(w, y, x, s) \ | |
179 | (wmove(w, y, x) == ERR ? ERR : __waddbytes(w, s, strlen(s), 0)) | |
180 | #define mvwdelch(w, y, x) \ | |
181 | (wmove(w, y, x) == ERR ? ERR : wdelch(w)) | |
182 | #define mvwgetch(w, y, x) \ | |
183 | (wmove(w, y, x) == ERR ? ERR : wgetch(w)) | |
184 | #define mvwgetstr(w, y, x, s) \ | |
185 | (wmove(w, y, x) == ERR ? ERR : wgetstr(w, s)) | |
186 | #define mvwinch(w, y, x) \ | |
187 | (wmove(w, y, x) == ERR ? ERR : winch(w)) | |
188 | #define mvwinsch(w, y, x, c) \ | |
189 | (wmove(w, y, x) == ERR ? ERR : winsch(w, c)) | |
e91c7874 KB |
190 | |
191 | /* Psuedo functions. */ | |
6cdb6e3d KB |
192 | #define clearok(w, bf) \ |
193 | ((bf) ? ((w)->flags |= __CLEAROK) : ((w)->flags &= ~__CLEAROK)) | |
194 | #define flushok(w, bf) \ | |
195 | ((bf) ? ((w)->flags |= __FLUSH) : ((w)->flags &= ~__FLUSH)) | |
196 | #define getyx(w, y, x) \ | |
197 | (y) = (w)->cury, (x) = (w)->curx | |
198 | #define leaveok(w, bf) \ | |
199 | ((bf) ? ((w)->flags |= __LEAVEOK) : ((w)->flags &= ~__LEAVEOK)) | |
200 | #define scrollok(w, bf) \ | |
201 | ((bf) ? ((w)->flags |= __SCROLLOK) : ((w)->flags &= ~__SCROLLOK)) | |
202 | #define winch(w) \ | |
203 | ((w)->lines[(w)->cury]->line[(w)->curx].ch & 0177) | |
1b7ae9b8 | 204 | |
ddf60ab8 | 205 | /* Public function prototypes. */ |
ddf60ab8 KB |
206 | int box __P((WINDOW *, int, int)); |
207 | int cbreak __P((void)); | |
208 | int delwin __P((WINDOW *)); | |
209 | int echo __P((void)); | |
210 | int endwin __P((void)); | |
211 | char *fullname __P((char *, char *)); | |
212 | char *getcap __P((char *)); | |
213 | int gettmode __P((void)); | |
214 | void idlok __P((WINDOW *, int)); | |
215 | WINDOW *initscr __P((void)); | |
216 | char *longname __P((char *, char *)); | |
217 | int mvcur __P((int, int, int, int)); | |
218 | int mvprintw __P((int, int, const char *, ...)); | |
219 | int mvscanw __P((int, int, const char *, ...)); | |
220 | int mvwin __P((WINDOW *, int, int)); | |
221 | int mvwprintw __P((WINDOW *, int, int, const char *, ...)); | |
222 | int mvwscanw __P((WINDOW *, int, int, const char *, ...)); | |
223 | WINDOW *newwin __P((int, int, int, int)); | |
224 | int nl __P((void)); | |
225 | int nocbreak __P((void)); | |
226 | int noecho __P((void)); | |
227 | int nonl __P((void)); | |
228 | int noraw __P((void)); | |
229 | int overlay __P((WINDOW *, WINDOW *)); | |
230 | int overwrite __P((WINDOW *, WINDOW *)); | |
231 | int printw __P((const char *, ...)); | |
232 | int raw __P((void)); | |
233 | int resetty __P((void)); | |
234 | int savetty __P((void)); | |
235 | int scanw __P((const char *, ...)); | |
236 | int scroll __P((WINDOW *)); | |
237 | int setterm __P((char *)); | |
b67f22a0 | 238 | int sscans __P((WINDOW *, const char *, ...)); |
ddf60ab8 KB |
239 | WINDOW *subwin __P((WINDOW *, int, int, int, int)); |
240 | int suspendwin __P((void)); | |
241 | int touchline __P((WINDOW *, int, int, int)); | |
242 | int touchoverlap __P((WINDOW *, WINDOW *)); | |
243 | int touchwin __P((WINDOW *)); | |
b67f22a0 EA |
244 | int vwprintw __P((WINDOW *, const char *, _BSD_VA_LIST_)); |
245 | int vwscanw __P((WINDOW *, const char *, _BSD_VA_LIST_)); | |
ddf60ab8 | 246 | int waddch __P((WINDOW *, int)); |
6cdb6e3d | 247 | int waddnstr __P((WINDOW *, const char *, int)); |
ddf60ab8 KB |
248 | int wclear __P((WINDOW *)); |
249 | int wclrtobot __P((WINDOW *)); | |
250 | int wclrtoeol __P((WINDOW *)); | |
251 | int wdelch __P((WINDOW *)); | |
252 | int wdeleteln __P((WINDOW *)); | |
253 | int werase __P((WINDOW *)); | |
254 | int wgetch __P((WINDOW *)); | |
255 | int wgetstr __P((WINDOW *, char *)); | |
256 | int winsch __P((WINDOW *, int)); | |
257 | int winsertln __P((WINDOW *)); | |
258 | int wmove __P((WINDOW *, int, int)); | |
259 | int wprintw __P((WINDOW *, const char *, ...)); | |
260 | int wrefresh __P((WINDOW *)); | |
261 | int wscanw __P((WINDOW *, const char *, ...)); | |
262 | char *wstandend __P((WINDOW *)); | |
263 | char *wstandout __P((WINDOW *)); | |
e91c7874 | 264 | int vwprintw __P((WINDOW *, const char *, _BSD_VA_LIST_)); |
1b7ae9b8 | 265 | |
e00fdff3 KB |
266 | void __cputchar __P((int)); /* Public: backward compatibility */ |
267 | ||
ddf60ab8 KB |
268 | #ifdef _CURSES_PRIVATE |
269 | /* Private function prototypes. */ | |
e3923e32 | 270 | void __TRACE __P((const char *, ...)); |
2fcfd3e1 | 271 | u_int __hash __P((char *, int)); |
ddf60ab8 KB |
272 | void __id_subwins __P((WINDOW *)); |
273 | void __set_subwin __P((WINDOW *, WINDOW *)); | |
5313de4c KB |
274 | void __startwin __P((void)); |
275 | void __stop_signal_handler __P((int)); | |
ddf60ab8 | 276 | void __swflags __P((WINDOW *)); |
e3923e32 EA |
277 | int __touchline __P((WINDOW *, int, int, int, int)); |
278 | int __touchwin __P((WINDOW *)); | |
e91c7874 | 279 | char *__tscroll __P((const char *, int)); |
f86a3ebe | 280 | int __waddbytes __P((WINDOW *, const char *, int, int)); |
2fcfd3e1 | 281 | int __waddch __P((WINDOW *, __LDATA *)); |
1b7ae9b8 | 282 | |
ddf60ab8 KB |
283 | /* Private #defines. */ |
284 | #define min(a,b) (a < b ? a : b) | |
285 | #define max(a,b) (a > b ? a : b) | |
1b7ae9b8 | 286 | |
ddf60ab8 KB |
287 | /* Private externs. */ |
288 | extern int __echoit; | |
289 | extern int __endwin; | |
290 | extern int __pfast; | |
291 | extern int __rawmode; | |
091287a4 | 292 | extern int __noqch; |
ddf60ab8 | 293 | #endif |
1b7ae9b8 | 294 | |
ddf60ab8 KB |
295 | /* Termcap functions. */ |
296 | int tgetent __P((char *, char *)); | |
297 | int tgetnum __P((char *)); | |
298 | int tgetflag __P((char *)); | |
299 | char *tgetstr __P((char *, char **)); | |
300 | char *tgoto __P((char *, int, int)); | |
301 | int tputs __P((char *, int, void (*)(int))); | |
7781fc01 | 302 | |
ddf60ab8 | 303 | #endif /* !_CURSES_H_ */ |