1 /* 2 * Copyright 1997 Sun Microsystems, Inc. All rights reserved. 3 * Use is subject to license terms. 4 */ 5 6 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 7 /* All Rights Reserved */ 8 9 /* 10 * Copyright (c) 1980 Regents of the University of California. 11 * All rights reserved. The Berkeley software License Agreement 12 * specifies the terms and conditions for redistribution. 13 */ 14 15 #ifndef _CURSES_H 16 #define _CURSES_H 17 18 #pragma ident "%Z%%M% %I% %E% SMI" 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 #ifndef WINDOW 25 26 #include <stdio.h> 27 #include <sgtty.h> 28 29 #undef HZ /* in case they've included <sys/param.h> */ 30 31 #if !(defined(__cplusplus) && defined(_BOOL)) 32 #define bool char 33 #endif 34 35 #define reg register 36 37 #define TRUE (1) 38 #define FALSE (0) 39 #define ERR (0) 40 #define OK (1) 41 42 #define _ENDLINE 001 43 #define _FULLWIN 002 44 #define _SCROLLWIN 004 45 #define _FLUSH 010 46 #define _FULLLINE 020 47 #define _IDLINE 040 48 #define _STANDOUT 0200 49 #define _NOCHANGE -1 50 51 #define _puts(s) tputs(s, 0, _putchar) 52 53 typedef struct sgttyb SGTTY; 54 55 /* 56 * Capabilities from termcap 57 */ 58 59 extern bool AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL, 60 XB, XN, XT, XS, XX; 61 extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, 62 *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6, 63 *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL, 64 *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF, 65 *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS, 66 *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, 67 *LEFT_PARM, *RIGHT_PARM; 68 extern char PC; 69 70 /* 71 * From the tty modes... 72 */ 73 74 extern bool GT, NONL, UPPERCASE, normtty, _pfast; 75 76 struct _win_st { 77 short _cury, _curx; 78 short _maxy, _maxx; 79 short _begy, _begx; 80 short _flags; 81 short _ch_off; 82 bool _clear; 83 bool _leave; 84 bool _scroll; 85 char **_y; 86 short *_firstch; 87 short *_lastch; 88 struct _win_st *_nextp, *_orig; 89 }; 90 91 #define WINDOW struct _win_st 92 93 extern bool My_term, _echoit, _rawmode, _endwin; 94 95 extern char *Def_term, ttytype[50]; 96 97 extern int LINES, COLS, _tty_ch, _res_flg; 98 99 extern SGTTY _tty; 100 101 extern WINDOW *stdscr, *curscr; 102 103 #define VOID(x) (x) 104 105 /* 106 * pseudo functions for standard screen 107 */ 108 #define addch(ch) VOID(waddch(stdscr, ch)) 109 #define getch() VOID(wgetch(stdscr)) 110 #define addstr(str) VOID(waddstr(stdscr, str)) 111 #define getstr(str) VOID(wgetstr(stdscr, str)) 112 #define move(y, x) VOID(wmove(stdscr, y, x)) 113 #define clear() VOID(wclear(stdscr)) 114 #define erase() VOID(werase(stdscr)) 115 #define clrtobot() VOID(wclrtobot(stdscr)) 116 #define clrtoeol() VOID(wclrtoeol(stdscr)) 117 #define insertln() VOID(winsertln(stdscr)) 118 #define deleteln() VOID(wdeleteln(stdscr)) 119 #define refresh() VOID(wrefresh(stdscr)) 120 #define inch() VOID(winch(stdscr)) 121 #define insch(c) VOID(winsch(stdscr, c)) 122 #define delch() VOID(wdelch(stdscr)) 123 #define standout() VOID(wstandout(stdscr)) 124 #define standend() VOID(wstandend(stdscr)) 125 126 /* 127 * mv functions 128 */ 129 #define mvwaddch(win, y, x, ch) VOID(wmove(win, y, x) == ERR ? \ 130 ERR:waddch(win, ch)) 131 #define mvwgetch(win, y, x) VOID(wmove(win, y, x) == ERR?ERR:wgetch(win)) 132 #define mvwaddstr(win, y, x, str) VOID(wmove(win, y, x) == ERR? \ 133 ERR:waddstr(win, str)) 134 #define mvwgetstr(win, y, x, str) VOID(wmove(win, y, x) == ERR? \ 135 ERR:wgetstr(win, str)) 136 #define mvwinch(win, y, x) VOID(wmove(win, y, x) == ERR ? ERR : winch(win)) 137 #define mvwdelch(win, y, x) VOID(wmove(win, y, x) == ERR ? \ 138 ERR : wdelch(win)) 139 #define mvwinsch(win, y, x, c) VOID(wmove(win, y, x) == ERR ? \ 140 ERR:winsch(win, c)) 141 #define mvaddch(y, x, ch) mvwaddch(stdscr, y, x, ch) 142 #define mvgetch(y, x) mvwgetch(stdscr, y, x) 143 #define mvaddstr(y, x, str) mvwaddstr(stdscr, y, x, str) 144 #define mvgetstr(y, x, str) mvwgetstr(stdscr, y, x, str) 145 #define mvinch(y, x) mvwinch(stdscr, y, x) 146 #define mvdelch(y, x) mvwdelch(stdscr, y, x) 147 #define mvinsch(y, x, c) mvwinsch(stdscr, y, x, c) 148 149 /* 150 * pseudo functions 151 */ 152 153 #define clearok(win, bf) (win->_clear = bf) 154 #define leaveok(win, bf) (win->_leave = bf) 155 #define scrollok(win, bf) (win->_scroll = bf) 156 #define flushok(win, bf) (bf ? (win->_flags |= _FLUSH): \ 157 (win->_flags &= ~_FLUSH)) 158 #define getyx(win, y, x) y = win->_cury, x = win->_curx 159 #define winch(win) (win->_y[win->_cury][win->_curx] & 0177) 160 161 #define raw() (_tty.sg_flags |= RAW, _pfast = _rawmode = TRUE, \ 162 (void) stty(_tty_ch, &_tty)) 163 #define noraw() (_tty.sg_flags &= ~RAW, _rawmode = FALSE, \ 164 _pfast = !(_tty.sg_flags & CRMOD), (void) stty(_tty_ch, &_tty)) 165 #define cbreak() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, \ 166 (void) stty(_tty_ch, &_tty)) 167 #define nocbreak() (_tty.sg_flags &= ~CBREAK, _rawmode = FALSE, \ 168 (void) stty(_tty_ch, &_tty)) 169 #define crmode() cbreak() /* backwards compatability */ 170 #define nocrmode() nocbreak() /* backwards compatability */ 171 #define echo() (_tty.sg_flags |= ECHO, _echoit = TRUE, \ 172 (void) stty(_tty_ch, &_tty)) 173 #define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, \ 174 (void) stty(_tty_ch, &_tty)) 175 #define nl() (_tty.sg_flags |= CRMOD, _pfast = _rawmode, \ 176 (void) stty(_tty_ch, &_tty)) 177 #define nonl() (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, \ 178 (void) stty(_tty_ch, &_tty)) 179 #define savetty() ((void) gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags) 180 #define resetty() (_tty.sg_flags = _res_flg, (void) stty(_tty_ch, &_tty)) 181 182 #define erasechar() (_tty.sg_erase) 183 #define killchar() (_tty.sg_kill) 184 #define baudrate() (_tty.sg_ospeed) 185 186 /* 187 * chtype is the type used to store a character together with attributes. 188 * It can be set to "char" to save space, or "int" to get more attributes. 189 */ 190 #ifdef CHTYPE 191 typedef CHTYPE chtype; 192 #else 193 typedef unsigned int chtype; 194 #endif 195 196 #ifndef __STDC__ 197 WINDOW *initscr(), *newwin(), *subwin(); 198 char *longname(), *getcap(); 199 #else 200 extern WINDOW *initscr(void); 201 extern WINDOW *newwin(int, int, int, int); 202 extern WINDOW *subwin(WINDOW *, int, int, int, int); 203 extern char *longname(char *, char *); 204 extern char *getcap(char *); 205 extern char *wstandout(WINDOW *); 206 extern char *wstandend(WINDOW *); 207 extern int gettmode(void); 208 extern int idlok(WINDOW *, bool); 209 extern int box(WINDOW *, char, char); 210 extern int touchwin(WINDOW *); 211 extern int touchline(WINDOW *, int, int, int); 212 extern int mvcur(int, int, int, int); 213 extern int wmove(WINDOW *, int, int); 214 extern int scroll(WINDOW *); 215 extern int werase(WINDOW *); 216 extern int wrefresh(WINDOW *); 217 extern int endwin(void); 218 extern int mvwin(WINDOW *, int, int); 219 extern int delwin(WINDOW *); 220 extern int overlay(WINDOW *, WINDOW *); 221 extern int overwrite(WINDOW *, WINDOW *); 222 extern int winsertln(WINDOW *); 223 extern int wdeleteln(WINDOW *); 224 extern int wgetstr(WINDOW *, char *); 225 extern int wgetch(WINDOW *); 226 extern int waddch(WINDOW *, char); 227 extern int waddstr(WINDOW *, char *); 228 extern int winsch(WINDOW *, char); 229 extern int wdelch(WINDOW *); 230 extern int wclear(WINDOW *); 231 extern int wclrtobot(WINDOW *); 232 extern int wclrtoeol(WINDOW *); 233 extern int printw(char *, ...); 234 extern int wprintw(WINDOW *, char *, ...); 235 extern int mvprintw(int, int, char *, ...); 236 extern int mvwprintw(WINDOW *, int, int, char *, ...); 237 extern int scanw(char *, ...); 238 extern int wscanw(WINDOW *, char *, ...); 239 extern int mvscanw(int, int, char *, ...); 240 extern int mvwscanw(WINDOW *, int, int, char *, ...); 241 extern int setterm(char *); 242 #endif /* __STDC__ */ 243 244 /* 245 * Used to be in unctrl.h. 246 */ 247 #define unctrl(c) _unctrl[(c) & 0177] 248 extern char *_unctrl[]; 249 #endif 250 251 #ifdef __cplusplus 252 } 253 #endif 254 255 #endif /* _CURSES_H */ 256