Commit | Line | Data |
---|---|---|
87c6fcf8 | 1 | /* |
2f14f200 KB |
2 | * Copyright (c) 1981 Regents of the University of California. |
3 | * All rights reserved. | |
87c6fcf8 | 4 | * |
af359dea C |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
13 | * 3. All advertising materials mentioning features or use of this software | |
14 | * must display the following acknowledgement: | |
15 | * This product includes software developed by the University of | |
16 | * California, Berkeley and its contributors. | |
17 | * 4. Neither the name of the University nor the names of its contributors | |
18 | * may be used to endorse or promote products derived from this software | |
19 | * without specific prior written permission. | |
2f14f200 | 20 | * |
af359dea C |
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
31 | * SUCH DAMAGE. | |
2f14f200 | 32 | * |
1c15e888 | 33 | * @(#)curses.h 5.9 (Berkeley) 7/1/90 |
87c6fcf8 DF |
34 | */ |
35 | ||
512c20d0 | 36 | #ifndef WINDOW |
1b7ae9b8 | 37 | |
512c20d0 | 38 | #include <stdio.h> |
1b7ae9b8 | 39 | |
53f01b9b | 40 | #define USE_OLD_TTY |
512c20d0 | 41 | #include <sys/ioctl.h> |
53f01b9b | 42 | #undef USE_OLD_TTY |
1b7ae9b8 | 43 | |
512c20d0 MK |
44 | #define bool char |
45 | #define reg register | |
1b7ae9b8 | 46 | |
512c20d0 MK |
47 | #define TRUE (1) |
48 | #define FALSE (0) | |
49 | #define ERR (0) | |
50 | #define OK (1) | |
1b7ae9b8 | 51 | |
512c20d0 MK |
52 | #define _ENDLINE 001 |
53 | #define _FULLWIN 002 | |
54 | #define _SCROLLWIN 004 | |
55 | #define _FLUSH 010 | |
56 | #define _FULLLINE 020 | |
57 | #define _IDLINE 040 | |
58 | #define _STANDOUT 0200 | |
59 | #define _NOCHANGE -1 | |
1b7ae9b8 | 60 | |
512c20d0 | 61 | #define _puts(s) tputs(s, 0, _putchar) |
1b7ae9b8 KA |
62 | |
63 | typedef struct sgttyb SGTTY; | |
64 | ||
1b7ae9b8 KA |
65 | /* |
66 | * Capabilities from termcap | |
67 | */ | |
68 | ||
f70d219c | 69 | extern bool AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL, |
2b6e3652 | 70 | XB, XN, XT, XS, XX; |
f70d219c JB |
71 | extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, |
72 | *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6, | |
73 | *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL, | |
74 | *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF, | |
75 | *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS, | |
76 | *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, | |
77 | *LEFT_PARM, *RIGHT_PARM; | |
78 | extern char PC; | |
1b7ae9b8 KA |
79 | |
80 | /* | |
81 | * From the tty modes... | |
82 | */ | |
1b7ae9b8 | 83 | |
f70d219c | 84 | extern bool GT, NONL, UPPERCASE, normtty, _pfast; |
e7f97876 KA |
85 | |
86 | struct _win_st { | |
60d72089 KA |
87 | short _cury, _curx; |
88 | short _maxy, _maxx; | |
89 | short _begy, _begx; | |
90 | short _flags; | |
f70d219c | 91 | short _ch_off; |
60d72089 KA |
92 | bool _clear; |
93 | bool _leave; | |
94 | bool _scroll; | |
95 | char **_y; | |
96 | short *_firstch; | |
97 | short *_lastch; | |
98 | struct _win_st *_nextp, *_orig; | |
1b7ae9b8 KA |
99 | }; |
100 | ||
512c20d0 | 101 | #define WINDOW struct _win_st |
1b7ae9b8 | 102 | |
e7f97876 | 103 | extern bool My_term, _echoit, _rawmode, _endwin; |
1b7ae9b8 | 104 | |
e7f97876 | 105 | extern char *Def_term, ttytype[]; |
1b7ae9b8 | 106 | |
e7f97876 | 107 | extern int LINES, COLS, _tty_ch, _res_flg; |
1b7ae9b8 | 108 | |
f5cca68f | 109 | extern SGTTY _tty; |
1b7ae9b8 | 110 | |
f5cca68f | 111 | extern WINDOW *stdscr, *curscr; |
1b7ae9b8 KA |
112 | |
113 | /* | |
114 | * Define VOID to stop lint from generating "null effect" | |
115 | * comments. | |
116 | */ | |
512c20d0 | 117 | #ifdef lint |
e7f97876 | 118 | int __void__; |
512c20d0 MK |
119 | #define VOID(x) (__void__ = (int) (x)) |
120 | #else | |
121 | #define VOID(x) (x) | |
122 | #endif | |
1b7ae9b8 | 123 | |
1b7ae9b8 KA |
124 | /* |
125 | * psuedo functions for standard screen | |
126 | */ | |
512c20d0 MK |
127 | #define addch(ch) VOID(waddch(stdscr, ch)) |
128 | #define getch() VOID(wgetch(stdscr)) | |
129 | #define addbytes(da,co) VOID(waddbytes(stdscr, da,co)) | |
130 | #define addstr(str) VOID(waddbytes(stdscr, str, strlen(str))) | |
131 | #define getstr(str) VOID(wgetstr(stdscr, str)) | |
132 | #define move(y, x) VOID(wmove(stdscr, y, x)) | |
133 | #define clear() VOID(wclear(stdscr)) | |
134 | #define erase() VOID(werase(stdscr)) | |
135 | #define clrtobot() VOID(wclrtobot(stdscr)) | |
136 | #define clrtoeol() VOID(wclrtoeol(stdscr)) | |
137 | #define insertln() VOID(winsertln(stdscr)) | |
138 | #define deleteln() VOID(wdeleteln(stdscr)) | |
139 | #define refresh() VOID(wrefresh(stdscr)) | |
140 | #define inch() VOID(winch(stdscr)) | |
141 | #define insch(c) VOID(winsch(stdscr,c)) | |
142 | #define delch() VOID(wdelch(stdscr)) | |
143 | #define standout() VOID(wstandout(stdscr)) | |
144 | #define standend() VOID(wstandend(stdscr)) | |
1b7ae9b8 KA |
145 | |
146 | /* | |
147 | * mv functions | |
148 | */ | |
149 | #define mvwaddch(win,y,x,ch) VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch)) | |
150 | #define mvwgetch(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetch(win)) | |
b500698c GM |
151 | #define mvwaddbytes(win,y,x,da,co) \ |
152 | VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,da,co)) | |
153 | #define mvwaddstr(win,y,x,str) \ | |
154 | VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,str,strlen(str))) | |
6dd2bba9 | 155 | #define mvwgetstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str)) |
1b7ae9b8 | 156 | #define mvwinch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : winch(win)) |
6a1aa6bb | 157 | #define mvwdelch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win)) |
ca10091d | 158 | #define mvwinsch(win,y,x,c) VOID(wmove(win,y,x) == ERR ? ERR:winsch(win,c)) |
1b7ae9b8 KA |
159 | #define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch) |
160 | #define mvgetch(y,x) mvwgetch(stdscr,y,x) | |
b500698c | 161 | #define mvaddbytes(y,x,da,co) mvwaddbytes(stdscr,y,x,da,co) |
1b7ae9b8 | 162 | #define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str) |
6dd2bba9 | 163 | #define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str) |
85957a31 | 164 | #define mvinch(y,x) mvwinch(stdscr,y,x) |
6a1aa6bb | 165 | #define mvdelch(y,x) mvwdelch(stdscr,y,x) |
ca10091d | 166 | #define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c) |
1b7ae9b8 KA |
167 | |
168 | /* | |
169 | * psuedo functions | |
170 | */ | |
171 | ||
172 | #define clearok(win,bf) (win->_clear = bf) | |
173 | #define leaveok(win,bf) (win->_leave = bf) | |
174 | #define scrollok(win,bf) (win->_scroll = bf) | |
175 | #define flushok(win,bf) (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH)) | |
176 | #define getyx(win,y,x) y = win->_cury, x = win->_curx | |
34318855 | 177 | #define winch(win) (win->_y[win->_cury][win->_curx] & 0177) |
1b7ae9b8 | 178 | |
d6e8b8ca KB |
179 | #define raw() (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, \ |
180 | ioctl(_tty_ch, TIOCSETP, &_tty)) | |
181 | #define noraw() (_tty.sg_flags&=~RAW,_rawmode=FALSE,\ | |
182 | _pfast=!(_tty.sg_flags&CRMOD),ioctl(_tty_ch, TIOCSETP, &_tty)) | |
183 | #define cbreak() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, \ | |
184 | ioctl(_tty_ch, TIOCSETP, &_tty)) | |
185 | #define nocbreak() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE, \ | |
186 | ioctl(_tty_ch, TIOCSETP, &_tty)) | |
f70d219c JB |
187 | #define crmode() cbreak() /* backwards compatability */ |
188 | #define nocrmode() nocbreak() /* backwards compatability */ | |
d6e8b8ca KB |
189 | #define echo() (_tty.sg_flags |= ECHO, _echoit = TRUE, \ |
190 | ioctl(_tty_ch, TIOCSETP, &_tty)) | |
191 | #define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, \ | |
192 | ioctl(_tty_ch, TIOCSETP, &_tty)) | |
193 | #define nl() (_tty.sg_flags |= CRMOD,_pfast = _rawmode, \ | |
194 | ioctl(_tty_ch, TIOCSETP, &_tty)) | |
195 | #define nonl() (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, \ | |
196 | ioctl(_tty_ch, TIOCSETP, &_tty)) | |
197 | #define savetty() ((void) ioctl(_tty_ch, TIOCGETP, &_tty), \ | |
198 | _res_flg = _tty.sg_flags) | |
199 | #define resetty() (_tty.sg_flags = _res_flg, \ | |
f3b914b4 KB |
200 | _echoit = ((_res_flg & ECHO) == ECHO), \ |
201 | _rawmode = ((_res_flg & (CBREAK|RAW)) != 0), \ | |
202 | _pfast = ((_res_flg & CRMOD) ? _rawmode : TRUE), \ | |
d6e8b8ca | 203 | (void) ioctl(_tty_ch, TIOCSETP, &_tty)) |
f70d219c JB |
204 | |
205 | #define erasechar() (_tty.sg_erase) | |
206 | #define killchar() (_tty.sg_kill) | |
207 | #define baudrate() (_tty.sg_ospeed) | |
1b7ae9b8 KA |
208 | |
209 | WINDOW *initscr(), *newwin(), *subwin(); | |
d037dc33 | 210 | char *longname(), *getcap(); |
7781fc01 | 211 | |
7e8a00f3 SL |
212 | /* |
213 | * Used to be in unctrl.h. | |
214 | */ | |
215 | #define unctrl(c) _unctrl[(c) & 0177] | |
74ac3b5d | 216 | extern char *_unctrl[]; |
512c20d0 | 217 | #endif |