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