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