xref: /csrg-svn/lib/libcurses/curses.h (revision 56647)
122686Sdist /*
234677Sbostic  * Copyright (c) 1981 Regents of the University of California.
334677Sbostic  * All rights reserved.
422686Sdist  *
542653Sbostic  * %sccs.include.redist.c%
634677Sbostic  *
7*56647Selan  *	@(#)curses.h	5.17 (Berkeley) 10/26/92
822686Sdist  */
922686Sdist 
1055990Sbostic #ifndef _CURSES_H_
1155990Sbostic #define	_CURSES_H_
122244Sarnold 
1355990Sbostic #include <stdio.h>
142244Sarnold 
1555990Sbostic /*
1655990Sbostic  * The following #defines and #includes are present for backward
1755990Sbostic  * compatibility only.  They should not be used in future code.
1855990Sbostic  *
1955990Sbostic  * START BACKWARD COMPATIBILITY ONLY.
2055990Sbostic  */
2155990Sbostic #ifndef _CURSES_PRIVATE
2238839Skarels #define	bool	char
2338839Skarels #define	reg	register
242244Sarnold 
2555990Sbostic #ifndef TRUE
2638839Skarels #define	TRUE	(1)
2755990Sbostic #endif
2855990Sbostic #ifndef FALSE
2938839Skarels #define	FALSE	(0)
3055990Sbostic #endif
312244Sarnold 
3256116Selan #define	_puts(s)	tputs(s, 0, __cputchar)
3355990Sbostic #define	_putchar(c)	__cputchar(c)
342244Sarnold 
3555990Sbostic /* Old-style terminal modes access. */
3656116Selan #define	baudrate()	(cfgetospeed(&origtermio))
3755990Sbostic #define	crmode()	cbreak()
3855990Sbostic #define	erasechar()	(origtermio.c_cc[VERASE])
3955990Sbostic #define	killchar()	(origtermio.c_cc[VKILL])
4055990Sbostic #define	nocrmode()	nocbreak()
4156116Selan #define	ospeed		(cfgetospeed(&origtermio))
4255990Sbostic #endif /* _CURSES_PRIVATE */
432244Sarnold 
4455990Sbostic extern int	 My_term;		/* Use Def_term regardless. */
4555990Sbostic extern char	*Def_term;		/* Default terminal type. */
4655990Sbostic 
4755990Sbostic /* END BACKWARD COMPATIBILITY ONLY. */
4855990Sbostic 
4955990Sbostic /* 7-bit ASCII characters. */
5055990Sbostic #define	unctrl(c)		__unctrl[(c) & 0x7f]
5155990Sbostic #define	unctrllen(ch)		__unctrllen[(ch) & 0x7f]
5255990Sbostic 
5356238Selan /*
54*56647Selan  * A window an array of __LINE structures pointed to by the 'lines' pointer.
55*56647Selan  * A line is an array of __LDATA structures pointed to by the 'line' pointer.
56*56647Selan  *
57*56647Selan  * IMPORTANT: the __LDATA structure must NOT induce any padding, so if new
58*56647Selan  * fields are added -- padding fields with *constant values* should ensure
59*56647Selan  * that the compiler will not generate any padding when storing an array of
60*56647Selan  *  __LDATA structures.  This is to enable consistent use of bcmp, and bcopy
61*56647Selan  * for comparing and copying arrays.
6256238Selan  */
6355990Sbostic 
64*56647Selan typedef struct {
65*56647Selan 	char ch;			/* the actual character */
66*56647Selan 
67*56647Selan #define	__STANDOUT	0x01  		/* Added characters are standout. */
68*56647Selan 	char attr;			/* attributes of character */
69*56647Selan } __LDATA;
70*56647Selan 
71*56647Selan #define __LDATASIZE	(sizeof(__LDATA))
72*56647Selan 
73*56647Selan typedef struct {
7456238Selan #define	__ISDIRTY	0x01		/* Line is dirty. */
7556300Selan #define __ISPASTEOL	0x02		/* Cursor is past end of line */
7656238Selan 	u_int flags;
7756238Selan 	u_int hash;			/* Hash value for the line. */
7856238Selan 	size_t firstch, lastch;		/* First and last changed columns. */
79*56647Selan 	__LDATA *line;			/* Pointer to the line text. */
80*56647Selan } __LINE;
8156596Selan 
8256238Selan typedef struct __window {		/* Window structure. */
8356238Selan 	struct __window	*nextp, *orig;	/* Subwindows list and parent. */
8456238Selan 	size_t begy, begx;		/* Window home. */
8556238Selan 	size_t cury, curx;		/* Current x, y coordinates. */
8656238Selan 	size_t maxy, maxx;		/* Maximum values for curx, cury. */
8756238Selan 	short ch_off;			/* x offset for firstch/lastch. */
88*56647Selan 	__LINE **lines;			/* Array of pointers to the lines */
89*56647Selan 	__LINE  *lspace;		/* line space (for cleanup) */
90*56647Selan 	__LDATA *wspace;		/* window space (for cleanup) */
9155990Sbostic 
9256238Selan #define	__ENDLINE	0x001		/* End of screen. */
9356238Selan #define	__FLUSH		0x002		/* Fflush(stdout) after refresh. */
9456238Selan #define	__FULLLINE	0x004		/* Line width = terminal width. */
9556238Selan #define	__FULLWIN	0x008		/* Window is a screen. */
9656238Selan #define	__IDLINE	0x010		/* Insert/delete sequences. */
9756238Selan #define	__SCROLLWIN	0x020		/* Last char will scroll window. */
9856238Selan #define	__SCROLLOK	0x040		/* Scrolling ok. */
9956238Selan #define	__CLEAROK	0x080		/* Clear on next refresh. */
10056238Selan #define __WSTANDOUT	0x100		/* Standout window */
10156238Selan #define __LEAVEOK	0x200		/* If curser left */
10256238Selan 	u_int flags;
10355990Sbostic } WINDOW;
10455990Sbostic 
10555990Sbostic /* Termcap capabilities. */
10655990Sbostic extern char	AM, BS, CA, DA, EO, HC, HZ, IN, MI, MS, NC, NS, OS,
10755990Sbostic 		PC, UL, XB, XN, XT, XS, XX;
10819900Sbloom extern char	*AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
10919900Sbloom 		*DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
11019900Sbloom 		*K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
11119900Sbloom 		*KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
11219900Sbloom 		*SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
11356300Selan 		*VE, *al, *dl, *sf, *sr,
11455990Sbostic 		*AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM,
11555990Sbostic 		*RIGHT_PARM;
1162244Sarnold 
11755990Sbostic /* Curses external declarations. */
11855990Sbostic extern WINDOW	*curscr;		/* Current screen. */
11955990Sbostic extern WINDOW	*stdscr;		/* Standard screen. */
1202244Sarnold 
12155990Sbostic extern struct termios origtermio;	/* Original terminal modes. */
1222244Sarnold 
12355990Sbostic extern int	 COLS;			/* Columns on the screen. */
12455990Sbostic extern int	 LINES;			/* Lines on the screen. */
1252244Sarnold 
12655990Sbostic extern char	 GT;			/* Gtty indicates tabs. */
12755990Sbostic extern char	 NONL;			/* Term can't hack LF doing a CR. */
12855990Sbostic extern char	 UPPERCASE;		/* Terminal is uppercase only. */
12955990Sbostic extern char	*ttytype;		/* Full name of current terminal. */
13055990Sbostic extern char	*__unctrl[0x80];	/* Control strings. */
13155990Sbostic extern char	 __unctrllen[0x80];	/* Control strings length. */
1322244Sarnold 
13355990Sbostic #define	ERR	(0)			/* Error return. */
13455990Sbostic #define	OK	(1)			/* Success return. */
1352244Sarnold 
13655990Sbostic /* Standard screen pseudo functions. */
13755990Sbostic #define	addbytes(da, co)	waddbytes(stdscr, da, co)
13855990Sbostic #define	addch(ch)		waddch(stdscr, ch)
13955990Sbostic #define	addstr(str)		waddbytes(stdscr, str, strlen(str))
14055990Sbostic #define	clear()			wclear(stdscr)
14155990Sbostic #define	clrtobot()		wclrtobot(stdscr)
14255990Sbostic #define	clrtoeol()		wclrtoeol(stdscr)
14355990Sbostic #define	delch()			wdelch(stdscr)
14455990Sbostic #define	deleteln()		wdeleteln(stdscr)
14555990Sbostic #define	erase()			werase(stdscr)
14655990Sbostic #define	getch()			wgetch(stdscr)
14755990Sbostic #define	getstr(str)		wgetstr(stdscr, str)
14855990Sbostic #define	inch()			winch(stdscr)
14955990Sbostic #define	insch(ch))		winsch(stdscr, ch)
15055990Sbostic #define	insertln()		winsertln(stdscr)
15155990Sbostic #define	move(y, x)		wmove(stdscr, y, x)
15255990Sbostic #define	refresh()		wrefresh(stdscr)
15355990Sbostic #define	standend()		wstandend(stdscr)
15455990Sbostic #define	standout()		wstandout(stdscr)
1552244Sarnold 
15655990Sbostic /* Standard screen plus movement pseudo functions. */
15755990Sbostic #define	mvaddbytes(y, x, da, co) \
15855990Sbostic 				mvwaddbytes(stdscr, y, x, da, co)
15955990Sbostic #define	mvaddch(y, x, ch)	mvwaddch(stdscr, y, x, ch)
16055990Sbostic #define	mvaddstr(y, x, str)	mvwaddstr(stdscr, y, x, str)
16155990Sbostic #define	mvdelch(y, x)		mvwdelch(stdscr, y, x)
16255990Sbostic #define	mvgetch(y, x)		mvwgetch(stdscr, y, x)
16355990Sbostic #define	mvgetstr(y, x, str)	mvwgetstr(stdscr, y, x, str)
16455990Sbostic #define	mvinch(y, x)		mvwinch(stdscr, y, x)
16555990Sbostic #define	mvinsch(y, x, c)	mvwinsch(stdscr, y, x, c)
16655990Sbostic #define	mvwaddbytes(win, y, x, da, co) \
16755990Sbostic 				(wmove(win, y, x) == ERR ? \
16855990Sbostic 				    ERR : waddbytes(win, da, co))
16955990Sbostic #define	mvwaddch(win, y, x, ch)	(wmove(win, y, x) == ERR ? \
17055990Sbostic 				    ERR : waddch(win, ch))
17155990Sbostic #define	mvwaddstr(win, y, x, str) \
17255990Sbostic 				(wmove(win, y, x) == ERR ? \
17355990Sbostic 				    ERR : waddbytes(win, str, strlen(str)))
17455990Sbostic #define	mvwdelch(win, y, x)	(wmove(win, y, x) == ERR ? ERR : wdelch(win))
17555990Sbostic #define	mvwgetch(win, y, x)	(wmove(win, y, x) == ERR ? ERR : wgetch(win))
17655990Sbostic #define	mvwgetstr(win, y, x, str) \
17755990Sbostic 				(wmove(win, y, x) == ERR ? \
17855990Sbostic 				    ERR : wgetstr(win, str))
17955990Sbostic #define	mvwinch(win, y, x)	(wmove(win, y, x) == ERR ? ERR : winch(win))
18055990Sbostic #define	mvwinsch(win, y, x, c)	(wmove(win, y, x) == ERR ? ERR : winsch(win, c))
1812244Sarnold 
18255990Sbostic /* Random psuedo functions. */
18356238Selan #define	clearok(win, bf)  ((bf) ? (win->flags |= __CLEAROK) : \
18456238Selan 				  (win->flags &= ~__CLEAROK))
18556238Selan #define	flushok(win, bf)  ((bf) ? (win->flags |= __FLUSH) : \
18656238Selan 				  (win->flags &= ~__FLUSH))
18756238Selan #define	scrollok(win, bf) ((bf) ? (win->flags |= __SCROLLOK) : \
18856238Selan 				  (win->flags &= ~__SCROLLOK))
18956238Selan #define	leaveok(win, bf)  ((bf) ? (win->flags |= __LEAVEOK) : \
19056238Selan 				  (win->flags &= ~__LEAVEOK))
19156238Selan #define	getyx(win, y, x)	(y) = win->cury, (x) = win->curx
19256238Selan #define	winch(win)		(win->lines[win->cury]->line[win->curx] & 0177)
1932244Sarnold 
19455990Sbostic /* Public function prototypes. */
19555990Sbostic void	 __cputchar __P((int));
19655990Sbostic int	 _sprintw __P((WINDOW *, const char *, _BSD_VA_LIST_));
19755990Sbostic int	 box __P((WINDOW *, int, int));
19855990Sbostic int	 cbreak __P((void));
19955990Sbostic int	 delwin __P((WINDOW *));
20055990Sbostic int	 echo __P((void));
20155990Sbostic int	 endwin __P((void));
20255990Sbostic char	*fullname __P((char *, char *));
20355990Sbostic char	*getcap __P((char *));
20455990Sbostic int	 gettmode __P((void));
20555990Sbostic void	 idlok __P((WINDOW *, int));
20655990Sbostic WINDOW	*initscr __P((void));
20755990Sbostic char	*longname __P((char *, char *));
20855990Sbostic int	 mvcur __P((int, int, int, int));
20955990Sbostic int	 mvprintw __P((int, int, const char *, ...));
21055990Sbostic int	 mvscanw __P((int, int, const char *, ...));
21155990Sbostic int	 mvwin __P((WINDOW *, int, int));
21255990Sbostic int	 mvwprintw __P((WINDOW *, int, int, const char *, ...));
21355990Sbostic int	 mvwscanw __P((WINDOW *, int, int, const char *, ...));
21455990Sbostic WINDOW	*newwin __P((int, int, int, int));
21555990Sbostic int	 nl __P((void));
21655990Sbostic int	 nocbreak __P((void));
21755990Sbostic int	 noecho __P((void));
21855990Sbostic int	 nonl __P((void));
21955990Sbostic int	 noraw __P((void));
22055990Sbostic int	 overlay __P((WINDOW *, WINDOW *));
22155990Sbostic int	 overwrite __P((WINDOW *, WINDOW *));
22255990Sbostic int	 printw __P((const char *, ...));
22355990Sbostic int	 raw __P((void));
22455990Sbostic int	 resetty __P((void));
22555990Sbostic int	 savetty __P((void));
22655990Sbostic int	 scanw __P((const char *, ...));
22755990Sbostic int	 scroll __P((WINDOW *));
22855990Sbostic int	 setterm __P((char *));
22955990Sbostic int	 sscans __P((WINDOW *, const char *, _BSD_VA_LIST_));
23055990Sbostic WINDOW	*subwin __P((WINDOW *, int, int, int, int));
23155990Sbostic int	 suspendwin __P((void));
23255990Sbostic int	 touchline __P((WINDOW *, int, int, int));
23355990Sbostic int	 touchoverlap __P((WINDOW *, WINDOW *));
23455990Sbostic int	 touchwin __P((WINDOW *));
23555990Sbostic void	 tstp __P((int));
23655990Sbostic int	 waddch __P((WINDOW *, int));
23755990Sbostic int	 waddstr __P((WINDOW *, char *));
23855990Sbostic int	 wclear __P((WINDOW *));
23955990Sbostic int	 wclrtobot __P((WINDOW *));
24055990Sbostic int	 wclrtoeol __P((WINDOW *));
24155990Sbostic int	 wdelch __P((WINDOW *));
24255990Sbostic int	 wdeleteln __P((WINDOW *));
24355990Sbostic int	 werase __P((WINDOW *));
24455990Sbostic int	 wgetch __P((WINDOW *));
24555990Sbostic int	 wgetstr __P((WINDOW *, char *));
24655990Sbostic int	 winsch __P((WINDOW *, int));
24755990Sbostic int	 winsertln __P((WINDOW *));
24855990Sbostic int	 wmove __P((WINDOW *, int, int));
24955990Sbostic int	 wprintw __P((WINDOW *, const char *, ...));
25055990Sbostic int	 wrefresh __P((WINDOW *));
25155990Sbostic int	 wscanw __P((WINDOW *, const char *, ...));
25255990Sbostic char	*wstandend __P((WINDOW *));
25355990Sbostic char	*wstandout __P((WINDOW *));
2542244Sarnold 
25555990Sbostic #ifdef _CURSES_PRIVATE
25655990Sbostic /* Private function prototypes. */
25755990Sbostic void	 __id_subwins __P((WINDOW *));
25855990Sbostic void	 __set_subwin __P((WINDOW *, WINDOW *));
25955990Sbostic void	 __swflags __P((WINDOW *));
26055990Sbostic void	 __TRACE __P((const char *, ...));
26155990Sbostic int	 waddbytes __P((WINDOW *, char *, int));
26256300Selan char	*tscroll __P((const char *, int));
2632244Sarnold 
26455990Sbostic /* Private #defines. */
26555990Sbostic #define	min(a,b)	(a < b ? a : b)
26655990Sbostic #define	max(a,b)	(a > b ? a : b)
2672244Sarnold 
26855990Sbostic /* Private externs. */
26955990Sbostic extern int	 __echoit;
27055990Sbostic extern int	 __endwin;
27155990Sbostic extern int	 __pfast;
27255990Sbostic extern int	 __rawmode;
27356300Selan extern int	 __noqch;
27455990Sbostic #endif
2752244Sarnold 
27655990Sbostic /* Termcap functions. */
27755990Sbostic int	 tgetent __P((char *, char *));
27855990Sbostic int	 tgetnum __P((char *));
27955990Sbostic int	 tgetflag __P((char *));
28055990Sbostic char	*tgetstr __P((char *, char **));
28155990Sbostic char	*tgoto __P((char *, int, int));
28255990Sbostic int	 tputs __P((char *, int, void (*)(int)));
2832244Sarnold 
28455990Sbostic #endif /* !_CURSES_H_ */
285