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 | * |
fe2507a1 | 7 | * @(#)curses.h 5.21 (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. */ |
296fd6cc | 36 | #define baudrate() (cfgetospeed(&origtermio)) |
ddf60ab8 KB |
37 | #define crmode() cbreak() |
38 | #define erasechar() (origtermio.c_cc[VERASE]) | |
39 | #define killchar() (origtermio.c_cc[VKILL]) | |
40 | #define nocrmode() nocbreak() | |
296fd6cc | 41 | #define ospeed (cfgetospeed(&origtermio)) |
ddf60ab8 | 42 | #endif /* _CURSES_PRIVATE */ |
1b7ae9b8 | 43 | |
ddf60ab8 KB |
44 | extern int My_term; /* Use Def_term regardless. */ |
45 | extern char *Def_term; /* Default terminal type. */ | |
46 | ||
47 | /* END BACKWARD COMPATIBILITY ONLY. */ | |
48 | ||
49 | /* 7-bit ASCII characters. */ | |
50 | #define unctrl(c) __unctrl[(c) & 0x7f] | |
51 | #define unctrllen(ch) __unctrllen[(ch) & 0x7f] | |
52 | ||
0c5c5188 | 53 | /* |
1c04a491 EA |
54 | * A window an array of __LINE structures pointed to by the 'lines' pointer. |
55 | * A line is an array of __LDATA structures pointed to by the 'line' pointer. | |
56 | * | |
57 | * IMPORTANT: the __LDATA structure must NOT induce any padding, so if new | |
58 | * fields are added -- padding fields with *constant values* should ensure | |
59 | * that the compiler will not generate any padding when storing an array of | |
60 | * __LDATA structures. This is to enable consistent use of bcmp, and bcopy | |
61 | * for comparing and copying arrays. | |
0c5c5188 EA |
62 | */ |
63 | ||
1c04a491 EA |
64 | typedef struct { |
65 | char ch; /* the actual character */ | |
66 | ||
67 | #define __STANDOUT 0x01 /* Added characters are standout. */ | |
68 | char attr; /* attributes of character */ | |
69 | } __LDATA; | |
70 | ||
71 | #define __LDATASIZE (sizeof(__LDATA)) | |
72 | ||
73 | typedef struct { | |
0c5c5188 | 74 | #define __ISDIRTY 0x01 /* Line is dirty. */ |
091287a4 | 75 | #define __ISPASTEOL 0x02 /* Cursor is past end of line */ |
e3923e32 | 76 | #define __FORCEPAINT 0x04 /* Force a repaint of the line */ |
0c5c5188 EA |
77 | u_int flags; |
78 | u_int hash; /* Hash value for the line. */ | |
556a4108 | 79 | size_t *firstchp, *lastchp; /* First and last chngd columns ptrs */ |
0c5c5188 | 80 | size_t firstch, lastch; /* First and last changed columns. */ |
1c04a491 EA |
81 | __LDATA *line; /* Pointer to the line text. */ |
82 | } __LINE; | |
0c5c5188 EA |
83 | |
84 | typedef struct __window { /* Window structure. */ | |
85 | struct __window *nextp, *orig; /* Subwindows list and parent. */ | |
86 | size_t begy, begx; /* Window home. */ | |
87 | size_t cury, curx; /* Current x, y coordinates. */ | |
88 | size_t maxy, maxx; /* Maximum values for curx, cury. */ | |
89 | short ch_off; /* x offset for firstch/lastch. */ | |
1c04a491 EA |
90 | __LINE **lines; /* Array of pointers to the lines */ |
91 | __LINE *lspace; /* line space (for cleanup) */ | |
92 | __LDATA *wspace; /* window space (for cleanup) */ | |
0c5c5188 EA |
93 | |
94 | #define __ENDLINE 0x001 /* End of screen. */ | |
95 | #define __FLUSH 0x002 /* Fflush(stdout) after refresh. */ | |
96 | #define __FULLLINE 0x004 /* Line width = terminal width. */ | |
97 | #define __FULLWIN 0x008 /* Window is a screen. */ | |
98 | #define __IDLINE 0x010 /* Insert/delete sequences. */ | |
99 | #define __SCROLLWIN 0x020 /* Last char will scroll window. */ | |
100 | #define __SCROLLOK 0x040 /* Scrolling ok. */ | |
101 | #define __CLEAROK 0x080 /* Clear on next refresh. */ | |
102 | #define __WSTANDOUT 0x100 /* Standout window */ | |
103 | #define __LEAVEOK 0x200 /* If curser left */ | |
104 | u_int flags; | |
ddf60ab8 KB |
105 | } WINDOW; |
106 | ||
107 | /* Termcap capabilities. */ | |
108 | extern char AM, BS, CA, DA, EO, HC, HZ, IN, MI, MS, NC, NS, OS, | |
109 | PC, UL, XB, XN, XT, XS, XX; | |
f70d219c JB |
110 | extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, |
111 | *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6, | |
112 | *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL, | |
113 | *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF, | |
114 | *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS, | |
091287a4 | 115 | *VE, *al, *dl, *sf, *sr, |
ddf60ab8 KB |
116 | *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM, |
117 | *RIGHT_PARM; | |
1b7ae9b8 | 118 | |
ddf60ab8 KB |
119 | /* Curses external declarations. */ |
120 | extern WINDOW *curscr; /* Current screen. */ | |
121 | extern WINDOW *stdscr; /* Standard screen. */ | |
1b7ae9b8 | 122 | |
ddf60ab8 | 123 | extern struct termios origtermio; /* Original terminal modes. */ |
1b7ae9b8 | 124 | |
ddf60ab8 KB |
125 | extern int COLS; /* Columns on the screen. */ |
126 | extern int LINES; /* Lines on the screen. */ | |
1b7ae9b8 | 127 | |
ddf60ab8 KB |
128 | extern char GT; /* Gtty indicates tabs. */ |
129 | extern char NONL; /* Term can't hack LF doing a CR. */ | |
130 | extern char UPPERCASE; /* Terminal is uppercase only. */ | |
131 | extern char *ttytype; /* Full name of current terminal. */ | |
132 | extern char *__unctrl[0x80]; /* Control strings. */ | |
133 | extern char __unctrllen[0x80]; /* Control strings length. */ | |
1b7ae9b8 | 134 | |
ddf60ab8 KB |
135 | #define ERR (0) /* Error return. */ |
136 | #define OK (1) /* Success return. */ | |
1b7ae9b8 | 137 | |
ddf60ab8 KB |
138 | /* Standard screen pseudo functions. */ |
139 | #define addbytes(da, co) waddbytes(stdscr, da, co) | |
140 | #define addch(ch) waddch(stdscr, ch) | |
141 | #define addstr(str) waddbytes(stdscr, str, strlen(str)) | |
142 | #define clear() wclear(stdscr) | |
143 | #define clrtobot() wclrtobot(stdscr) | |
144 | #define clrtoeol() wclrtoeol(stdscr) | |
145 | #define delch() wdelch(stdscr) | |
146 | #define deleteln() wdeleteln(stdscr) | |
147 | #define erase() werase(stdscr) | |
148 | #define getch() wgetch(stdscr) | |
149 | #define getstr(str) wgetstr(stdscr, str) | |
150 | #define inch() winch(stdscr) | |
151 | #define insch(ch)) winsch(stdscr, ch) | |
152 | #define insertln() winsertln(stdscr) | |
153 | #define move(y, x) wmove(stdscr, y, x) | |
154 | #define refresh() wrefresh(stdscr) | |
155 | #define standend() wstandend(stdscr) | |
156 | #define standout() wstandout(stdscr) | |
1b7ae9b8 | 157 | |
ddf60ab8 KB |
158 | /* Standard screen plus movement pseudo functions. */ |
159 | #define mvaddbytes(y, x, da, co) \ | |
160 | mvwaddbytes(stdscr, y, x, da, co) | |
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 mvwaddbytes(win, y, x, da, co) \ | |
169 | (wmove(win, y, x) == ERR ? \ | |
170 | ERR : waddbytes(win, da, co)) | |
171 | #define mvwaddch(win, y, x, ch) (wmove(win, y, x) == ERR ? \ | |
172 | ERR : waddch(win, ch)) | |
173 | #define mvwaddstr(win, y, x, str) \ | |
174 | (wmove(win, y, x) == ERR ? \ | |
175 | ERR : waddbytes(win, str, strlen(str))) | |
176 | #define mvwdelch(win, y, x) (wmove(win, y, x) == ERR ? ERR : wdelch(win)) | |
177 | #define mvwgetch(win, y, x) (wmove(win, y, x) == ERR ? ERR : wgetch(win)) | |
178 | #define mvwgetstr(win, y, x, str) \ | |
179 | (wmove(win, y, x) == ERR ? \ | |
180 | ERR : wgetstr(win, str)) | |
181 | #define mvwinch(win, y, x) (wmove(win, y, x) == ERR ? ERR : winch(win)) | |
182 | #define mvwinsch(win, y, x, c) (wmove(win, y, x) == ERR ? ERR : winsch(win, c)) | |
1b7ae9b8 | 183 | |
ddf60ab8 | 184 | /* Random psuedo functions. */ |
0c5c5188 EA |
185 | #define clearok(win, bf) ((bf) ? (win->flags |= __CLEAROK) : \ |
186 | (win->flags &= ~__CLEAROK)) | |
187 | #define flushok(win, bf) ((bf) ? (win->flags |= __FLUSH) : \ | |
188 | (win->flags &= ~__FLUSH)) | |
189 | #define scrollok(win, bf) ((bf) ? (win->flags |= __SCROLLOK) : \ | |
190 | (win->flags &= ~__SCROLLOK)) | |
191 | #define leaveok(win, bf) ((bf) ? (win->flags |= __LEAVEOK) : \ | |
192 | (win->flags &= ~__LEAVEOK)) | |
193 | #define getyx(win, y, x) (y) = win->cury, (x) = win->curx | |
fe2507a1 | 194 | #define winch(win) (win->lines[win->cury]->line[win->curx].ch & 0177) |
1b7ae9b8 | 195 | |
ddf60ab8 KB |
196 | /* Public function prototypes. */ |
197 | void __cputchar __P((int)); | |
198 | int _sprintw __P((WINDOW *, const char *, _BSD_VA_LIST_)); | |
199 | int box __P((WINDOW *, int, int)); | |
200 | int cbreak __P((void)); | |
201 | int delwin __P((WINDOW *)); | |
202 | int echo __P((void)); | |
203 | int endwin __P((void)); | |
204 | char *fullname __P((char *, char *)); | |
205 | char *getcap __P((char *)); | |
206 | int gettmode __P((void)); | |
207 | void idlok __P((WINDOW *, int)); | |
208 | WINDOW *initscr __P((void)); | |
209 | char *longname __P((char *, char *)); | |
210 | int mvcur __P((int, int, int, int)); | |
211 | int mvprintw __P((int, int, const char *, ...)); | |
212 | int mvscanw __P((int, int, const char *, ...)); | |
213 | int mvwin __P((WINDOW *, int, int)); | |
214 | int mvwprintw __P((WINDOW *, int, int, const char *, ...)); | |
215 | int mvwscanw __P((WINDOW *, int, int, const char *, ...)); | |
216 | WINDOW *newwin __P((int, int, int, int)); | |
217 | int nl __P((void)); | |
218 | int nocbreak __P((void)); | |
219 | int noecho __P((void)); | |
220 | int nonl __P((void)); | |
221 | int noraw __P((void)); | |
222 | int overlay __P((WINDOW *, WINDOW *)); | |
223 | int overwrite __P((WINDOW *, WINDOW *)); | |
224 | int printw __P((const char *, ...)); | |
225 | int raw __P((void)); | |
226 | int resetty __P((void)); | |
227 | int savetty __P((void)); | |
228 | int scanw __P((const char *, ...)); | |
229 | int scroll __P((WINDOW *)); | |
230 | int setterm __P((char *)); | |
231 | int sscans __P((WINDOW *, const char *, _BSD_VA_LIST_)); | |
232 | WINDOW *subwin __P((WINDOW *, int, int, int, int)); | |
233 | int suspendwin __P((void)); | |
234 | int touchline __P((WINDOW *, int, int, int)); | |
235 | int touchoverlap __P((WINDOW *, WINDOW *)); | |
236 | int touchwin __P((WINDOW *)); | |
237 | void tstp __P((int)); | |
238 | int waddch __P((WINDOW *, int)); | |
239 | int waddstr __P((WINDOW *, char *)); | |
240 | int wclear __P((WINDOW *)); | |
241 | int wclrtobot __P((WINDOW *)); | |
242 | int wclrtoeol __P((WINDOW *)); | |
243 | int wdelch __P((WINDOW *)); | |
244 | int wdeleteln __P((WINDOW *)); | |
245 | int werase __P((WINDOW *)); | |
246 | int wgetch __P((WINDOW *)); | |
247 | int wgetstr __P((WINDOW *, char *)); | |
248 | int winsch __P((WINDOW *, int)); | |
249 | int winsertln __P((WINDOW *)); | |
250 | int wmove __P((WINDOW *, int, int)); | |
251 | int wprintw __P((WINDOW *, const char *, ...)); | |
252 | int wrefresh __P((WINDOW *)); | |
253 | int wscanw __P((WINDOW *, const char *, ...)); | |
254 | char *wstandend __P((WINDOW *)); | |
255 | char *wstandout __P((WINDOW *)); | |
1b7ae9b8 | 256 | |
ddf60ab8 KB |
257 | #ifdef _CURSES_PRIVATE |
258 | /* Private function prototypes. */ | |
e3923e32 | 259 | void __TRACE __P((const char *, ...)); |
ddf60ab8 KB |
260 | void __id_subwins __P((WINDOW *)); |
261 | void __set_subwin __P((WINDOW *, WINDOW *)); | |
262 | void __swflags __P((WINDOW *)); | |
e3923e32 EA |
263 | int __touchline __P((WINDOW *, int, int, int, int)); |
264 | int __touchwin __P((WINDOW *)); | |
091287a4 | 265 | char *tscroll __P((const char *, int)); |
e3923e32 | 266 | int waddbytes __P((WINDOW *, char *, int)); |
1b7ae9b8 | 267 | |
ddf60ab8 KB |
268 | /* Private #defines. */ |
269 | #define min(a,b) (a < b ? a : b) | |
270 | #define max(a,b) (a > b ? a : b) | |
1b7ae9b8 | 271 | |
ddf60ab8 KB |
272 | /* Private externs. */ |
273 | extern int __echoit; | |
274 | extern int __endwin; | |
275 | extern int __pfast; | |
276 | extern int __rawmode; | |
091287a4 | 277 | extern int __noqch; |
ddf60ab8 | 278 | #endif |
1b7ae9b8 | 279 | |
ddf60ab8 KB |
280 | /* Termcap functions. */ |
281 | int tgetent __P((char *, char *)); | |
282 | int tgetnum __P((char *)); | |
283 | int tgetflag __P((char *)); | |
284 | char *tgetstr __P((char *, char **)); | |
285 | char *tgoto __P((char *, int, int)); | |
286 | int tputs __P((char *, int, void (*)(int))); | |
7781fc01 | 287 | |
ddf60ab8 | 288 | #endif /* !_CURSES_H_ */ |