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