xref: /csrg-svn/lib/libcurses/curses.h (revision 19900)
1 /* 05/01/85 (Berkeley) @(#)curses.h	1.15 */
2 # ifndef WINDOW
3 
4 # include	<stdio.h>
5 
6 # include	<sgtty.h>
7 
8 # define	bool	char
9 # define	reg	register
10 
11 # define	TRUE	(1)
12 # define	FALSE	(0)
13 # define	ERR	(0)
14 # define	OK	(1)
15 
16 # define	_ENDLINE	001
17 # define	_FULLWIN	002
18 # define	_SCROLLWIN	004
19 # define	_FLUSH		010
20 # define	_FULLLINE	020
21 # define	_IDLINE		040
22 # define	_STANDOUT	0200
23 # define	_NOCHANGE	-1
24 
25 # define	_puts(s)	tputs(s, 0, _putchar)
26 
27 typedef	struct sgttyb	SGTTY;
28 
29 /*
30  * Capabilities from termcap
31  */
32 
33 extern bool     AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL,
34 		XB, XN, XT, XX;
35 extern char	*AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
36 		*DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
37 		*K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
38 		*KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
39 		*SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
40 		*VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM,
41 		*LEFT_PARM, *RIGHT_PARM;
42 extern char	PC;
43 
44 /*
45  * From the tty modes...
46  */
47 
48 extern bool	GT, NONL, UPPERCASE, normtty, _pfast;
49 
50 struct _win_st {
51 	short		_cury, _curx;
52 	short		_maxy, _maxx;
53 	short		_begy, _begx;
54 	short		_flags;
55 	short		_ch_off;
56 	bool		_clear;
57 	bool		_leave;
58 	bool		_scroll;
59 	char		**_y;
60 	short		*_firstch;
61 	short		*_lastch;
62 	struct _win_st	*_nextp, *_orig;
63 };
64 
65 # define	WINDOW	struct _win_st
66 
67 extern bool	My_term, _echoit, _rawmode, _endwin;
68 
69 extern char	*Def_term, ttytype[];
70 
71 extern int	LINES, COLS, _tty_ch, _res_flg;
72 
73 extern SGTTY	_tty;
74 
75 extern WINDOW	*stdscr, *curscr;
76 
77 /*
78  *	Define VOID to stop lint from generating "null effect"
79  * comments.
80  */
81 # ifdef lint
82 int	__void__;
83 # define	VOID(x)	(__void__ = (int) (x))
84 # else
85 # define	VOID(x)	(x)
86 # endif
87 
88 /*
89  * psuedo functions for standard screen
90  */
91 # define	addch(ch)	VOID(waddch(stdscr, ch))
92 # define	getch()		VOID(wgetch(stdscr))
93 # define	addstr(str)	VOID(waddstr(stdscr, str))
94 # define	getstr(str)	VOID(wgetstr(stdscr, str))
95 # define	move(y, x)	VOID(wmove(stdscr, y, x))
96 # define	clear()		VOID(wclear(stdscr))
97 # define	erase()		VOID(werase(stdscr))
98 # define	clrtobot()	VOID(wclrtobot(stdscr))
99 # define	clrtoeol()	VOID(wclrtoeol(stdscr))
100 # define	insertln()	VOID(winsertln(stdscr))
101 # define	deleteln()	VOID(wdeleteln(stdscr))
102 # define	refresh()	VOID(wrefresh(stdscr))
103 # define	inch()		VOID(winch(stdscr))
104 # define	insch(c)	VOID(winsch(stdscr,c))
105 # define	delch()		VOID(wdelch(stdscr))
106 # define	standout()	VOID(wstandout(stdscr))
107 # define	standend()	VOID(wstandend(stdscr))
108 
109 /*
110  * mv functions
111  */
112 #define	mvwaddch(win,y,x,ch)	VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
113 #define	mvwgetch(win,y,x)	VOID(wmove(win,y,x)==ERR?ERR:wgetch(win))
114 #define	mvwaddstr(win,y,x,str)	VOID(wmove(win,y,x)==ERR?ERR:waddstr(win,str))
115 #define mvwgetstr(win,y,x,str)  VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
116 #define	mvwinch(win,y,x)	VOID(wmove(win,y,x) == ERR ? ERR : winch(win))
117 #define	mvwdelch(win,y,x)	VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win))
118 #define	mvwinsch(win,y,x,c)	VOID(wmove(win,y,x) == ERR ? ERR:winsch(win,c))
119 #define	mvaddch(y,x,ch)		mvwaddch(stdscr,y,x,ch)
120 #define	mvgetch(y,x)		mvwgetch(stdscr,y,x)
121 #define	mvaddstr(y,x,str)	mvwaddstr(stdscr,y,x,str)
122 #define mvgetstr(y,x,str)       mvwgetstr(stdscr,y,x,str)
123 #define	mvinch(y,x)		mvwinch(stdscr,y,x)
124 #define	mvdelch(y,x)		mvwdelch(stdscr,y,x)
125 #define	mvinsch(y,x,c)		mvwinsch(stdscr,y,x,c)
126 
127 /*
128  * psuedo functions
129  */
130 
131 #define	clearok(win,bf)	 (win->_clear = bf)
132 #define	leaveok(win,bf)	 (win->_leave = bf)
133 #define	scrollok(win,bf) (win->_scroll = bf)
134 #define flushok(win,bf)	 (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH))
135 #define	getyx(win,y,x)	 y = win->_cury, x = win->_curx
136 #define	winch(win)	 (win->_y[win->_cury][win->_curx] & 0177)
137 
138 #define raw()	 (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, stty(_tty_ch,&_tty))
139 #define noraw()	 (_tty.sg_flags&=~RAW,_rawmode=FALSE,_pfast=!(_tty.sg_flags&CRMOD),stty(_tty_ch,&_tty))
140 #define cbreak() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, stty(_tty_ch,&_tty))
141 #define nocbreak() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE,stty(_tty_ch,&_tty))
142 #define crmode() cbreak()	/* backwards compatability */
143 #define nocrmode() nocbreak()	/* backwards compatability */
144 #define echo()	 (_tty.sg_flags |= ECHO, _echoit = TRUE, stty(_tty_ch, &_tty))
145 #define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, stty(_tty_ch, &_tty))
146 #define nl()	 (_tty.sg_flags |= CRMOD,_pfast = _rawmode,stty(_tty_ch, &_tty))
147 #define nonl()	 (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, stty(_tty_ch, &_tty))
148 #define	savetty() ((void) gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags)
149 #define	resetty() (_tty.sg_flags = _res_flg, (void) stty(_tty_ch, &_tty))
150 
151 #define	erasechar()	(_tty.sg_erase)
152 #define	killchar()	(_tty.sg_kill)
153 #define baudrate()	(_tty.sg_ospeed)
154 
155 WINDOW	*initscr(), *newwin(), *subwin();
156 char	*longname(), *getcap();
157 
158 /*
159  * Used to be in unctrl.h.
160  */
161 #define	unctrl(c)	_unctrl[(c) & 0177]
162 extern char *_unctrl[];
163 # endif
164