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