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