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