xref: /csrg-svn/lib/libcurses/curses.h (revision 55990)
122686Sdist /*
234677Sbostic  * Copyright (c) 1981 Regents of the University of California.
334677Sbostic  * All rights reserved.
422686Sdist  *
542653Sbostic  * %sccs.include.redist.c%
634677Sbostic  *
7*55990Sbostic  *	@(#)curses.h	5.10 (Berkeley) 08/23/92
822686Sdist  */
922686Sdist 
10*55990Sbostic #ifndef _CURSES_H_
11*55990Sbostic #define	_CURSES_H_
122244Sarnold 
13*55990Sbostic #include <stdio.h>
142244Sarnold 
15*55990Sbostic /*
16*55990Sbostic  * The following #defines and #includes are present for backward
17*55990Sbostic  * compatibility only.  They should not be used in future code.
18*55990Sbostic  *
19*55990Sbostic  * START BACKWARD COMPATIBILITY ONLY.
20*55990Sbostic  */
21*55990Sbostic #ifndef _CURSES_PRIVATE
2238839Skarels #define	bool	char
2338839Skarels #define	reg	register
242244Sarnold 
25*55990Sbostic #ifndef TRUE
2638839Skarels #define	TRUE	(1)
27*55990Sbostic #endif
28*55990Sbostic #ifndef FALSE
2938839Skarels #define	FALSE	(0)
30*55990Sbostic #endif
312244Sarnold 
3238839Skarels #define	_puts(s)	tputs(s, 0, _putchar)
33*55990Sbostic #define	_putchar(c)	__cputchar(c)
342244Sarnold 
35*55990Sbostic /* Old-style terminal modes access. */
36*55990Sbostic #define	baudrate()	(cfgetospeed(origtermio))
37*55990Sbostic #define	crmode()	cbreak()
38*55990Sbostic #define	erasechar()	(origtermio.c_cc[VERASE])
39*55990Sbostic #define	killchar()	(origtermio.c_cc[VKILL])
40*55990Sbostic #define	nocrmode()	nocbreak()
41*55990Sbostic #define	ospeed		(cfgetospeed(origtermio))
42*55990Sbostic #endif /* _CURSES_PRIVATE */
432244Sarnold 
44*55990Sbostic extern int	 My_term;		/* Use Def_term regardless. */
45*55990Sbostic extern char	*Def_term;		/* Default terminal type. */
46*55990Sbostic 
47*55990Sbostic /* END BACKWARD COMPATIBILITY ONLY. */
48*55990Sbostic 
49*55990Sbostic /* 7-bit ASCII characters. */
50*55990Sbostic #define	unctrl(c)		__unctrl[(c) & 0x7f]
51*55990Sbostic #define	unctrllen(ch)		__unctrllen[(ch) & 0x7f]
52*55990Sbostic 
53*55990Sbostic typedef struct _win_st {		/* Window structure. */
54*55990Sbostic 	short		_cury, _curx;	/* Current x, y coordinates. */
55*55990Sbostic 	short		_maxy, _maxx;	/* Maximum values for curx, cury. */
56*55990Sbostic 	short		_begy, _begx;	/* Window home. */
57*55990Sbostic 
58*55990Sbostic #define	_ENDLINE	0x001		/* End of screen. */
59*55990Sbostic #define	_FLUSH		0x002		/* fflush(stdout) after refresh. */
60*55990Sbostic #define	_FULLLINE	0x004		/* Line width = terminal width. */
61*55990Sbostic #define	_FULLWIN	0x008		/* Window is a screen. */
62*55990Sbostic #define	_IDLINE		0x010		/* Insert/delete sequences. */
63*55990Sbostic #define	_SCROLLWIN	0x020		/* Last char will scroll window. */
64*55990Sbostic /*
65*55990Sbostic  * XXX
66*55990Sbostic  * _STANDOUT is the 8th bit, characters themselves are encoded.
672244Sarnold  */
68*55990Sbostic #define	_STANDOUT	0x080		/* Added characters are standout. */
69*55990Sbostic 	unsigned short	_flags;
702244Sarnold 
71*55990Sbostic 	short		scroll;		/* Scrolling offset. */
72*55990Sbostic 	short		_ch_off;	/* x offset for firstch/lastch. */
73*55990Sbostic 	char		_clear;		/* If clear on next refresh. */
74*55990Sbostic 	char		_leave;		/* If cursor left. */
75*55990Sbostic 	char		_scroll;	/* If scrolling permitted. */
76*55990Sbostic 	char		**_y;		/* Line describing the window. */
77*55990Sbostic 
78*55990Sbostic #define	_NOCHANGE	-1		/* No change since last refresh. */
79*55990Sbostic 	short		*_firstch;	/* First and last changed in line. */
80*55990Sbostic 	short		*_lastch;
81*55990Sbostic 	struct _win_st	*_nextp, *_orig;/* Subwindows list and parent. */
82*55990Sbostic } WINDOW;
83*55990Sbostic 
84*55990Sbostic /* Termcap capabilities. */
85*55990Sbostic extern char	AM, BS, CA, DA, EO, HC, HZ, IN, MI, MS, NC, NS, OS,
86*55990Sbostic 		PC, UL, XB, XN, XT, XS, XX;
8719900Sbloom extern char	*AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
8819900Sbloom 		*DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
8919900Sbloom 		*K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
9019900Sbloom 		*KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
9119900Sbloom 		*SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
92*55990Sbostic 		*VE,
93*55990Sbostic 		*AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM,
94*55990Sbostic 		*RIGHT_PARM;
952244Sarnold 
96*55990Sbostic /* Curses external declarations. */
97*55990Sbostic extern WINDOW	*curscr;		/* Current screen. */
98*55990Sbostic extern WINDOW	*stdscr;		/* Standard screen. */
992244Sarnold 
100*55990Sbostic extern struct termios origtermio;	/* Original terminal modes. */
1012244Sarnold 
102*55990Sbostic extern int	 COLS;			/* Columns on the screen. */
103*55990Sbostic extern int	 LINES;			/* Lines on the screen. */
1042244Sarnold 
105*55990Sbostic extern char	 GT;			/* Gtty indicates tabs. */
106*55990Sbostic extern char	 NONL;			/* Term can't hack LF doing a CR. */
107*55990Sbostic extern char	 UPPERCASE;		/* Terminal is uppercase only. */
108*55990Sbostic extern char	*ttytype;		/* Full name of current terminal. */
109*55990Sbostic extern char	*__unctrl[0x80];	/* Control strings. */
110*55990Sbostic extern char	 __unctrllen[0x80];	/* Control strings length. */
1112244Sarnold 
112*55990Sbostic #define	ERR	(0)			/* Error return. */
113*55990Sbostic #define	OK	(1)			/* Success return. */
1142244Sarnold 
115*55990Sbostic /* Standard screen pseudo functions. */
116*55990Sbostic #define	addbytes(da, co)	waddbytes(stdscr, da, co)
117*55990Sbostic #define	addch(ch)		waddch(stdscr, ch)
118*55990Sbostic #define	addstr(str)		waddbytes(stdscr, str, strlen(str))
119*55990Sbostic #define	clear()			wclear(stdscr)
120*55990Sbostic #define	clrtobot()		wclrtobot(stdscr)
121*55990Sbostic #define	clrtoeol()		wclrtoeol(stdscr)
122*55990Sbostic #define	delch()			wdelch(stdscr)
123*55990Sbostic #define	deleteln()		wdeleteln(stdscr)
124*55990Sbostic #define	erase()			werase(stdscr)
125*55990Sbostic #define	getch()			wgetch(stdscr)
126*55990Sbostic #define	getstr(str)		wgetstr(stdscr, str)
127*55990Sbostic #define	inch()			winch(stdscr)
128*55990Sbostic #define	insch(ch))		winsch(stdscr, ch)
129*55990Sbostic #define	insertln()		winsertln(stdscr)
130*55990Sbostic #define	move(y, x)		wmove(stdscr, y, x)
131*55990Sbostic #define	refresh()		wrefresh(stdscr)
132*55990Sbostic #define	standend()		wstandend(stdscr)
133*55990Sbostic #define	standout()		wstandout(stdscr)
1342244Sarnold 
135*55990Sbostic /* Standard screen plus movement pseudo functions. */
136*55990Sbostic #define	mvaddbytes(y, x, da, co) \
137*55990Sbostic 				mvwaddbytes(stdscr, y, x, da, co)
138*55990Sbostic #define	mvaddch(y, x, ch)	mvwaddch(stdscr, y, x, ch)
139*55990Sbostic #define	mvaddstr(y, x, str)	mvwaddstr(stdscr, y, x, str)
140*55990Sbostic #define	mvdelch(y, x)		mvwdelch(stdscr, y, x)
141*55990Sbostic #define	mvgetch(y, x)		mvwgetch(stdscr, y, x)
142*55990Sbostic #define	mvgetstr(y, x, str)	mvwgetstr(stdscr, y, x, str)
143*55990Sbostic #define	mvinch(y, x)		mvwinch(stdscr, y, x)
144*55990Sbostic #define	mvinsch(y, x, c)	mvwinsch(stdscr, y, x, c)
145*55990Sbostic #define	mvwaddbytes(win, y, x, da, co) \
146*55990Sbostic 				(wmove(win, y, x) == ERR ? \
147*55990Sbostic 				    ERR : waddbytes(win, da, co))
148*55990Sbostic #define	mvwaddch(win, y, x, ch)	(wmove(win, y, x) == ERR ? \
149*55990Sbostic 				    ERR : waddch(win, ch))
150*55990Sbostic #define	mvwaddstr(win, y, x, str) \
151*55990Sbostic 				(wmove(win, y, x) == ERR ? \
152*55990Sbostic 				    ERR : waddbytes(win, str, strlen(str)))
153*55990Sbostic #define	mvwdelch(win, y, x)	(wmove(win, y, x) == ERR ? ERR : wdelch(win))
154*55990Sbostic #define	mvwgetch(win, y, x)	(wmove(win, y, x) == ERR ? ERR : wgetch(win))
155*55990Sbostic #define	mvwgetstr(win, y, x, str) \
156*55990Sbostic 				(wmove(win, y, x) == ERR ? \
157*55990Sbostic 				    ERR : wgetstr(win, str))
158*55990Sbostic #define	mvwinch(win, y, x)	(wmove(win, y, x) == ERR ? ERR : winch(win))
159*55990Sbostic #define	mvwinsch(win, y, x, c)	(wmove(win, y, x) == ERR ? ERR : winsch(win, c))
1602244Sarnold 
161*55990Sbostic /* Random psuedo functions. */
162*55990Sbostic #define	clearok(win, bf) 	(win->_clear = (bf))
163*55990Sbostic #define	flushok(win, bf)	((bf) ? (win->_flags |= _FLUSH) : \
164*55990Sbostic 				    (win->_flags &= ~_FLUSH))
165*55990Sbostic #define	getyx(win, y, x)	(y) = win->_cury, (x) = win->_curx
166*55990Sbostic #define	leaveok(win, bf)	(win->_leave = (bf))
167*55990Sbostic #define	scrollok(win, bf)	(win->_scroll = (bf))
168*55990Sbostic #define	winch(win)		(win->_y[win->_cury][win->_curx] & 0177)
1692244Sarnold 
170*55990Sbostic /* Public function prototypes. */
171*55990Sbostic void	 __cputchar __P((int));
172*55990Sbostic int	 _sprintw __P((WINDOW *, const char *, _BSD_VA_LIST_));
173*55990Sbostic int	 box __P((WINDOW *, int, int));
174*55990Sbostic int	 cbreak __P((void));
175*55990Sbostic int	 delwin __P((WINDOW *));
176*55990Sbostic int	 echo __P((void));
177*55990Sbostic int	 endwin __P((void));
178*55990Sbostic char	*fullname __P((char *, char *));
179*55990Sbostic char	*getcap __P((char *));
180*55990Sbostic int	 gettmode __P((void));
181*55990Sbostic void	 idlok __P((WINDOW *, int));
182*55990Sbostic WINDOW	*initscr __P((void));
183*55990Sbostic char	*longname __P((char *, char *));
184*55990Sbostic int	 mvcur __P((int, int, int, int));
185*55990Sbostic int	 mvprintw __P((int, int, const char *, ...));
186*55990Sbostic int	 mvscanw __P((int, int, const char *, ...));
187*55990Sbostic int	 mvwin __P((WINDOW *, int, int));
188*55990Sbostic int	 mvwprintw __P((WINDOW *, int, int, const char *, ...));
189*55990Sbostic int	 mvwscanw __P((WINDOW *, int, int, const char *, ...));
190*55990Sbostic WINDOW	*newwin __P((int, int, int, int));
191*55990Sbostic int	 nl __P((void));
192*55990Sbostic int	 nocbreak __P((void));
193*55990Sbostic int	 noecho __P((void));
194*55990Sbostic int	 nonl __P((void));
195*55990Sbostic int	 noraw __P((void));
196*55990Sbostic int	 overlay __P((WINDOW *, WINDOW *));
197*55990Sbostic int	 overwrite __P((WINDOW *, WINDOW *));
198*55990Sbostic int	 printw __P((const char *, ...));
199*55990Sbostic int	 raw __P((void));
200*55990Sbostic int	 resetty __P((void));
201*55990Sbostic int	 savetty __P((void));
202*55990Sbostic int	 scanw __P((const char *, ...));
203*55990Sbostic int	 scroll __P((WINDOW *));
204*55990Sbostic int	 setterm __P((char *));
205*55990Sbostic int	 sscans __P((WINDOW *, const char *, _BSD_VA_LIST_));
206*55990Sbostic WINDOW	*subwin __P((WINDOW *, int, int, int, int));
207*55990Sbostic int	 suspendwin __P((void));
208*55990Sbostic int	 touchline __P((WINDOW *, int, int, int));
209*55990Sbostic int	 touchoverlap __P((WINDOW *, WINDOW *));
210*55990Sbostic int	 touchwin __P((WINDOW *));
211*55990Sbostic void	 tstp __P((int));
212*55990Sbostic int	 waddch __P((WINDOW *, int));
213*55990Sbostic int	 waddstr __P((WINDOW *, char *));
214*55990Sbostic int	 wclear __P((WINDOW *));
215*55990Sbostic int	 wclrtobot __P((WINDOW *));
216*55990Sbostic int	 wclrtoeol __P((WINDOW *));
217*55990Sbostic int	 wdelch __P((WINDOW *));
218*55990Sbostic int	 wdeleteln __P((WINDOW *));
219*55990Sbostic int	 werase __P((WINDOW *));
220*55990Sbostic int	 wgetch __P((WINDOW *));
221*55990Sbostic int	 wgetstr __P((WINDOW *, char *));
222*55990Sbostic int	 winsch __P((WINDOW *, int));
223*55990Sbostic int	 winsertln __P((WINDOW *));
224*55990Sbostic int	 wmove __P((WINDOW *, int, int));
225*55990Sbostic int	 wprintw __P((WINDOW *, const char *, ...));
226*55990Sbostic int	 wrefresh __P((WINDOW *));
227*55990Sbostic int	 wscanw __P((WINDOW *, const char *, ...));
228*55990Sbostic char	*wstandend __P((WINDOW *));
229*55990Sbostic char	*wstandout __P((WINDOW *));
2302244Sarnold 
231*55990Sbostic #ifdef _CURSES_PRIVATE
232*55990Sbostic /* Private function prototypes. */
233*55990Sbostic void	 __id_subwins __P((WINDOW *));
234*55990Sbostic void	 __set_subwin __P((WINDOW *, WINDOW *));
235*55990Sbostic void	 __swflags __P((WINDOW *));
236*55990Sbostic void	 __TRACE __P((const char *, ...));
237*55990Sbostic int	 waddbytes __P((WINDOW *, char *, int));
2382244Sarnold 
239*55990Sbostic /* Private #defines. */
240*55990Sbostic #define	min(a,b)	(a < b ? a : b)
241*55990Sbostic #define	max(a,b)	(a > b ? a : b)
2422244Sarnold 
243*55990Sbostic /* Private externs. */
244*55990Sbostic extern int	 __echoit;
245*55990Sbostic extern int	 __endwin;
246*55990Sbostic extern int	 __pfast;
247*55990Sbostic extern int	 __rawmode;
248*55990Sbostic #endif
2492244Sarnold 
250*55990Sbostic /* Termcap functions. */
251*55990Sbostic int	 tgetent __P((char *, char *));
252*55990Sbostic int	 tgetnum __P((char *));
253*55990Sbostic int	 tgetflag __P((char *));
254*55990Sbostic char	*tgetstr __P((char *, char **));
255*55990Sbostic char	*tgoto __P((char *, int, int));
256*55990Sbostic int	 tputs __P((char *, int, void (*)(int)));
2572244Sarnold 
258*55990Sbostic #endif /* !_CURSES_H_ */
259