| 1 | /* %G% (Berkeley) @(#)curses.h 1.3 */ |
| 2 | # ifndef WINDOW |
| 3 | |
| 4 | # include <stdio.h> |
| 5 | |
| 6 | # include <sgtty.h> |
| 7 | |
| 8 | # define bool char |
| 9 | # define reg register |
| 10 | |
| 11 | # define TRUE (1) |
| 12 | # define FALSE (0) |
| 13 | # define ERR (0) |
| 14 | # define OK (1) |
| 15 | |
| 16 | # define _SUBWIN 01 |
| 17 | # define _ENDLINE 02 |
| 18 | # define _FULLWIN 04 |
| 19 | # define _SCROLLWIN 010 |
| 20 | # define _FLUSH 020 |
| 21 | # define _STANDOUT 0200 |
| 22 | # define _NOCHANGE -1 |
| 23 | |
| 24 | # define _puts(s) tputs(s, 0, _putchar); |
| 25 | |
| 26 | typedef struct sgttyb SGTTY; |
| 27 | |
| 28 | /* |
| 29 | * Capabilities from termcap |
| 30 | */ |
| 31 | |
| 32 | bool AM, BS, CA, DA, DB, EO, GT, HZ, IN, MI, MS, NC, OS, UL, XN; |
| 33 | char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *DC, *DL, *DM, *DO, *ED, |
| 34 | *EI, *HO, *IC, *IM, *IP, *LL, *MA, *ND, *SE, *SF, *SO, *SR, |
| 35 | *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VE, *VS, PC; |
| 36 | |
| 37 | /* |
| 38 | * From the tty modes... |
| 39 | */ |
| 40 | |
| 41 | bool NONL, UPPERCASE; |
| 42 | |
| 43 | bool normtty, _pfast; |
| 44 | |
| 45 | struct _win_st { |
| 46 | short _cury, _curx; |
| 47 | short _maxy, _maxx; |
| 48 | short _begy, _begx; |
| 49 | short _flags; |
| 50 | bool _clear; |
| 51 | bool _leave; |
| 52 | bool _scroll; |
| 53 | char **_y; |
| 54 | short *_firstch; |
| 55 | short *_lastch; |
| 56 | }; |
| 57 | |
| 58 | # define WINDOW struct _win_st |
| 59 | |
| 60 | extern bool My_term, _echoit, _rawmode, _endwin; |
| 61 | |
| 62 | extern char *Def_term, ttytype[]; |
| 63 | |
| 64 | extern int LINES, COLS, _tty_ch, _res_flg; |
| 65 | |
| 66 | SGTTY _tty; |
| 67 | |
| 68 | WINDOW *stdscr, *curscr; |
| 69 | |
| 70 | /* |
| 71 | * Define VOID to stop lint from generating "null effect" |
| 72 | * comments. |
| 73 | */ |
| 74 | # ifdef lint |
| 75 | int __void__; |
| 76 | # define VOID(x) (__void__ = (int) (x)) |
| 77 | # else |
| 78 | # define VOID(x) (x) |
| 79 | # endif |
| 80 | |
| 81 | /* |
| 82 | * psuedo functions for standard screen |
| 83 | */ |
| 84 | # define addch(ch) VOID(waddch(stdscr, ch)) |
| 85 | # define getch() VOID(wgetch(stdscr)) |
| 86 | # define addstr(str) VOID(waddstr(stdscr, str)) |
| 87 | # define getstr(str) VOID(wgetstr(stdscr, str)) |
| 88 | # define move(y, x) VOID(wmove(stdscr, y, x)) |
| 89 | # define clear() VOID(wclear(stdscr)) |
| 90 | # define erase() VOID(werase(stdscr)) |
| 91 | # define clrtobot() VOID(wclrtobot(stdscr)) |
| 92 | # define clrtoeol() VOID(wclrtoeol(stdscr)) |
| 93 | # define insertln() VOID(winsertln(stdscr)) |
| 94 | # define deleteln() VOID(wdeleteln(stdscr)) |
| 95 | # define refresh() VOID(wrefresh(stdscr)) |
| 96 | # define inch() VOID(winch(stdscr)) |
| 97 | # define standout() VOID(wstandout(stdscr)) |
| 98 | # define standend() VOID(wstandend(stdscr)) |
| 99 | |
| 100 | /* |
| 101 | * mv functions |
| 102 | */ |
| 103 | #define mvwaddch(win,y,x,ch) VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch)) |
| 104 | #define mvwgetch(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetch(win)) |
| 105 | #define mvwaddstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:waddstr(win,str)) |
| 106 | #define mvwgetstr(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win)) |
| 107 | #define mvwinch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : winch(win)) |
| 108 | #define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch) |
| 109 | #define mvgetch(y,x) mvwgetch(stdscr,y,x) |
| 110 | #define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str) |
| 111 | #define mvgetstr(y,x) mvwgetstr(stdscr,y,x) |
| 112 | #define mvinch(y,x) mvwinch(win,y,x) |
| 113 | |
| 114 | /* |
| 115 | * psuedo functions |
| 116 | */ |
| 117 | |
| 118 | #define clearok(win,bf) (win->_clear = bf) |
| 119 | #define leaveok(win,bf) (win->_leave = bf) |
| 120 | #define scrollok(win,bf) (win->_scroll = bf) |
| 121 | #define flushok(win,bf) (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH)) |
| 122 | #define getyx(win,y,x) y = win->_cury, x = win->_curx |
| 123 | #define winch(win) (win->_y[win->_cury][win->_curx]) |
| 124 | |
| 125 | #define raw() (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, stty(_tty_ch,&_tty)) |
| 126 | #define noraw() (_tty.sg_flags&=~RAW,_rawmode=FALSE,_pfast=!(_tty.sg_flags&CRMOD),stty(_tty_ch,&_tty)) |
| 127 | #define crmode() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, stty(_tty_ch,&_tty)) |
| 128 | #define nocrmode() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE,stty(_tty_ch,&_tty)) |
| 129 | #define echo() (_tty.sg_flags |= ECHO, _echoit = TRUE, stty(_tty_ch, &_tty)) |
| 130 | #define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, stty(_tty_ch, &_tty)) |
| 131 | #define nl() (_tty.sg_flags |= CRMOD,_pfast = _rawmode,stty(_tty_ch, &_tty)) |
| 132 | #define nonl() (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, stty(_tty_ch, &_tty)) |
| 133 | #define savetty() (gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags) |
| 134 | #define resetty() (_tty.sg_flags = _res_flg, stty(_tty_ch, &_tty)) |
| 135 | |
| 136 | WINDOW *initscr(), *newwin(), *subwin(); |
| 137 | char *longname(); |
| 138 | |
| 139 | # endif |