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 | * |
296fd6cc | 7 | * @(#)curses.h 5.11 (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 | ||
53 | typedef struct _win_st { /* Window structure. */ | |
54 | short _cury, _curx; /* Current x, y coordinates. */ | |
55 | short _maxy, _maxx; /* Maximum values for curx, cury. */ | |
56 | short _begy, _begx; /* Window home. */ | |
57 | ||
58 | #define _ENDLINE 0x001 /* End of screen. */ | |
59 | #define _FLUSH 0x002 /* fflush(stdout) after refresh. */ | |
60 | #define _FULLLINE 0x004 /* Line width = terminal width. */ | |
61 | #define _FULLWIN 0x008 /* Window is a screen. */ | |
62 | #define _IDLINE 0x010 /* Insert/delete sequences. */ | |
63 | #define _SCROLLWIN 0x020 /* Last char will scroll window. */ | |
64 | /* | |
65 | * XXX | |
66 | * _STANDOUT is the 8th bit, characters themselves are encoded. | |
1b7ae9b8 | 67 | */ |
ddf60ab8 KB |
68 | #define _STANDOUT 0x080 /* Added characters are standout. */ |
69 | unsigned short _flags; | |
1b7ae9b8 | 70 | |
ddf60ab8 KB |
71 | short scroll; /* Scrolling offset. */ |
72 | short _ch_off; /* x offset for firstch/lastch. */ | |
73 | char _clear; /* If clear on next refresh. */ | |
74 | char _leave; /* If cursor left. */ | |
75 | char _scroll; /* If scrolling permitted. */ | |
76 | char **_y; /* Line describing the window. */ | |
77 | ||
78 | #define _NOCHANGE -1 /* No change since last refresh. */ | |
79 | short *_firstch; /* First and last changed in line. */ | |
80 | short *_lastch; | |
81 | struct _win_st *_nextp, *_orig;/* Subwindows list and parent. */ | |
82 | } WINDOW; | |
83 | ||
84 | /* Termcap capabilities. */ | |
85 | extern char AM, BS, CA, DA, EO, HC, HZ, IN, MI, MS, NC, NS, OS, | |
86 | PC, UL, XB, XN, XT, XS, XX; | |
f70d219c JB |
87 | extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, |
88 | *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6, | |
89 | *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL, | |
90 | *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF, | |
91 | *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS, | |
ddf60ab8 KB |
92 | *VE, |
93 | *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM, | |
94 | *RIGHT_PARM; | |
1b7ae9b8 | 95 | |
ddf60ab8 KB |
96 | /* Curses external declarations. */ |
97 | extern WINDOW *curscr; /* Current screen. */ | |
98 | extern WINDOW *stdscr; /* Standard screen. */ | |
1b7ae9b8 | 99 | |
ddf60ab8 | 100 | extern struct termios origtermio; /* Original terminal modes. */ |
1b7ae9b8 | 101 | |
ddf60ab8 KB |
102 | extern int COLS; /* Columns on the screen. */ |
103 | extern int LINES; /* Lines on the screen. */ | |
1b7ae9b8 | 104 | |
ddf60ab8 KB |
105 | extern char GT; /* Gtty indicates tabs. */ |
106 | extern char NONL; /* Term can't hack LF doing a CR. */ | |
107 | extern char UPPERCASE; /* Terminal is uppercase only. */ | |
108 | extern char *ttytype; /* Full name of current terminal. */ | |
109 | extern char *__unctrl[0x80]; /* Control strings. */ | |
110 | extern char __unctrllen[0x80]; /* Control strings length. */ | |
1b7ae9b8 | 111 | |
ddf60ab8 KB |
112 | #define ERR (0) /* Error return. */ |
113 | #define OK (1) /* Success return. */ | |
1b7ae9b8 | 114 | |
ddf60ab8 KB |
115 | /* Standard screen pseudo functions. */ |
116 | #define addbytes(da, co) waddbytes(stdscr, da, co) | |
117 | #define addch(ch) waddch(stdscr, ch) | |
118 | #define addstr(str) waddbytes(stdscr, str, strlen(str)) | |
119 | #define clear() wclear(stdscr) | |
120 | #define clrtobot() wclrtobot(stdscr) | |
121 | #define clrtoeol() wclrtoeol(stdscr) | |
122 | #define delch() wdelch(stdscr) | |
123 | #define deleteln() wdeleteln(stdscr) | |
124 | #define erase() werase(stdscr) | |
125 | #define getch() wgetch(stdscr) | |
126 | #define getstr(str) wgetstr(stdscr, str) | |
127 | #define inch() winch(stdscr) | |
128 | #define insch(ch)) winsch(stdscr, ch) | |
129 | #define insertln() winsertln(stdscr) | |
130 | #define move(y, x) wmove(stdscr, y, x) | |
131 | #define refresh() wrefresh(stdscr) | |
132 | #define standend() wstandend(stdscr) | |
133 | #define standout() wstandout(stdscr) | |
1b7ae9b8 | 134 | |
ddf60ab8 KB |
135 | /* Standard screen plus movement pseudo functions. */ |
136 | #define mvaddbytes(y, x, da, co) \ | |
137 | mvwaddbytes(stdscr, y, x, da, co) | |
138 | #define mvaddch(y, x, ch) mvwaddch(stdscr, y, x, ch) | |
139 | #define mvaddstr(y, x, str) mvwaddstr(stdscr, y, x, str) | |
140 | #define mvdelch(y, x) mvwdelch(stdscr, y, x) | |
141 | #define mvgetch(y, x) mvwgetch(stdscr, y, x) | |
142 | #define mvgetstr(y, x, str) mvwgetstr(stdscr, y, x, str) | |
143 | #define mvinch(y, x) mvwinch(stdscr, y, x) | |
144 | #define mvinsch(y, x, c) mvwinsch(stdscr, y, x, c) | |
145 | #define mvwaddbytes(win, y, x, da, co) \ | |
146 | (wmove(win, y, x) == ERR ? \ | |
147 | ERR : waddbytes(win, da, co)) | |
148 | #define mvwaddch(win, y, x, ch) (wmove(win, y, x) == ERR ? \ | |
149 | ERR : waddch(win, ch)) | |
150 | #define mvwaddstr(win, y, x, str) \ | |
151 | (wmove(win, y, x) == ERR ? \ | |
152 | ERR : waddbytes(win, str, strlen(str))) | |
153 | #define mvwdelch(win, y, x) (wmove(win, y, x) == ERR ? ERR : wdelch(win)) | |
154 | #define mvwgetch(win, y, x) (wmove(win, y, x) == ERR ? ERR : wgetch(win)) | |
155 | #define mvwgetstr(win, y, x, str) \ | |
156 | (wmove(win, y, x) == ERR ? \ | |
157 | ERR : wgetstr(win, str)) | |
158 | #define mvwinch(win, y, x) (wmove(win, y, x) == ERR ? ERR : winch(win)) | |
159 | #define mvwinsch(win, y, x, c) (wmove(win, y, x) == ERR ? ERR : winsch(win, c)) | |
1b7ae9b8 | 160 | |
ddf60ab8 KB |
161 | /* Random psuedo functions. */ |
162 | #define clearok(win, bf) (win->_clear = (bf)) | |
163 | #define flushok(win, bf) ((bf) ? (win->_flags |= _FLUSH) : \ | |
164 | (win->_flags &= ~_FLUSH)) | |
165 | #define getyx(win, y, x) (y) = win->_cury, (x) = win->_curx | |
166 | #define leaveok(win, bf) (win->_leave = (bf)) | |
167 | #define scrollok(win, bf) (win->_scroll = (bf)) | |
168 | #define winch(win) (win->_y[win->_cury][win->_curx] & 0177) | |
1b7ae9b8 | 169 | |
ddf60ab8 KB |
170 | /* Public function prototypes. */ |
171 | void __cputchar __P((int)); | |
172 | int _sprintw __P((WINDOW *, const char *, _BSD_VA_LIST_)); | |
173 | int box __P((WINDOW *, int, int)); | |
174 | int cbreak __P((void)); | |
175 | int delwin __P((WINDOW *)); | |
176 | int echo __P((void)); | |
177 | int endwin __P((void)); | |
178 | char *fullname __P((char *, char *)); | |
179 | char *getcap __P((char *)); | |
180 | int gettmode __P((void)); | |
181 | void idlok __P((WINDOW *, int)); | |
182 | WINDOW *initscr __P((void)); | |
183 | char *longname __P((char *, char *)); | |
184 | int mvcur __P((int, int, int, int)); | |
185 | int mvprintw __P((int, int, const char *, ...)); | |
186 | int mvscanw __P((int, int, const char *, ...)); | |
187 | int mvwin __P((WINDOW *, int, int)); | |
188 | int mvwprintw __P((WINDOW *, int, int, const char *, ...)); | |
189 | int mvwscanw __P((WINDOW *, int, int, const char *, ...)); | |
190 | WINDOW *newwin __P((int, int, int, int)); | |
191 | int nl __P((void)); | |
192 | int nocbreak __P((void)); | |
193 | int noecho __P((void)); | |
194 | int nonl __P((void)); | |
195 | int noraw __P((void)); | |
196 | int overlay __P((WINDOW *, WINDOW *)); | |
197 | int overwrite __P((WINDOW *, WINDOW *)); | |
198 | int printw __P((const char *, ...)); | |
199 | int raw __P((void)); | |
200 | int resetty __P((void)); | |
201 | int savetty __P((void)); | |
202 | int scanw __P((const char *, ...)); | |
203 | int scroll __P((WINDOW *)); | |
204 | int setterm __P((char *)); | |
205 | int sscans __P((WINDOW *, const char *, _BSD_VA_LIST_)); | |
206 | WINDOW *subwin __P((WINDOW *, int, int, int, int)); | |
207 | int suspendwin __P((void)); | |
208 | int touchline __P((WINDOW *, int, int, int)); | |
209 | int touchoverlap __P((WINDOW *, WINDOW *)); | |
210 | int touchwin __P((WINDOW *)); | |
211 | void tstp __P((int)); | |
212 | int waddch __P((WINDOW *, int)); | |
213 | int waddstr __P((WINDOW *, char *)); | |
214 | int wclear __P((WINDOW *)); | |
215 | int wclrtobot __P((WINDOW *)); | |
216 | int wclrtoeol __P((WINDOW *)); | |
217 | int wdelch __P((WINDOW *)); | |
218 | int wdeleteln __P((WINDOW *)); | |
219 | int werase __P((WINDOW *)); | |
220 | int wgetch __P((WINDOW *)); | |
221 | int wgetstr __P((WINDOW *, char *)); | |
222 | int winsch __P((WINDOW *, int)); | |
223 | int winsertln __P((WINDOW *)); | |
224 | int wmove __P((WINDOW *, int, int)); | |
225 | int wprintw __P((WINDOW *, const char *, ...)); | |
226 | int wrefresh __P((WINDOW *)); | |
227 | int wscanw __P((WINDOW *, const char *, ...)); | |
228 | char *wstandend __P((WINDOW *)); | |
229 | char *wstandout __P((WINDOW *)); | |
1b7ae9b8 | 230 | |
ddf60ab8 KB |
231 | #ifdef _CURSES_PRIVATE |
232 | /* Private function prototypes. */ | |
233 | void __id_subwins __P((WINDOW *)); | |
234 | void __set_subwin __P((WINDOW *, WINDOW *)); | |
235 | void __swflags __P((WINDOW *)); | |
236 | void __TRACE __P((const char *, ...)); | |
237 | int waddbytes __P((WINDOW *, char *, int)); | |
1b7ae9b8 | 238 | |
ddf60ab8 KB |
239 | /* Private #defines. */ |
240 | #define min(a,b) (a < b ? a : b) | |
241 | #define max(a,b) (a > b ? a : b) | |
1b7ae9b8 | 242 | |
ddf60ab8 KB |
243 | /* Private externs. */ |
244 | extern int __echoit; | |
245 | extern int __endwin; | |
246 | extern int __pfast; | |
247 | extern int __rawmode; | |
248 | #endif | |
1b7ae9b8 | 249 | |
ddf60ab8 KB |
250 | /* Termcap functions. */ |
251 | int tgetent __P((char *, char *)); | |
252 | int tgetnum __P((char *)); | |
253 | int tgetflag __P((char *)); | |
254 | char *tgetstr __P((char *, char **)); | |
255 | char *tgoto __P((char *, int, int)); | |
256 | int tputs __P((char *, int, void (*)(int))); | |
7781fc01 | 257 | |
ddf60ab8 | 258 | #endif /* !_CURSES_H_ */ |