| 1 | /*
|
|---|
| 2 | * Copyright (c) 1981 Regents of the University of California.
|
|---|
| 3 | * All rights reserved.
|
|---|
| 4 | *
|
|---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 6 | * modification, are permitted provided that the following conditions
|
|---|
| 7 | * are met:
|
|---|
| 8 | * 1. Redistributions of source code must retain the above copyright
|
|---|
| 9 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 10 | * 2. Redistributions in binary form must reproduce the above copyright
|
|---|
| 11 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 12 | * documentation and/or other materials provided with the distribution.
|
|---|
| 13 | * 3. All advertising materials mentioning features or use of this software
|
|---|
| 14 | * must display the following acknowledgement:
|
|---|
| 15 | * This product includes software developed by the University of
|
|---|
| 16 | * California, Berkeley and its contributors.
|
|---|
| 17 | * 4. Neither the name of the University nor the names of its contributors
|
|---|
| 18 | * may be used to endorse or promote products derived from this software
|
|---|
| 19 | * without specific prior written permission.
|
|---|
| 20 | *
|
|---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|---|
| 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|---|
| 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|---|
| 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|---|
| 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|---|
| 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|---|
| 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|---|
| 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|---|
| 31 | * SUCH DAMAGE.
|
|---|
| 32 | *
|
|---|
| 33 | * @(#)curses.h 5.9 (Berkeley) 7/1/90
|
|---|
| 34 | */
|
|---|
| 35 |
|
|---|
| 36 | #if defined (__cplusplus)
|
|---|
| 37 | extern "C" {
|
|---|
| 38 | #endif
|
|---|
| 39 |
|
|---|
| 40 | #ifndef WINDOW
|
|---|
| 41 |
|
|---|
| 42 | #include <stdio.h>
|
|---|
| 43 | #include <sys/ioctl.h>
|
|---|
| 44 | #include <sys/termio.h>
|
|---|
| 45 | typedef struct termio SGTTY;
|
|---|
| 46 |
|
|---|
| 47 | #define bool char
|
|---|
| 48 | #define reg register
|
|---|
| 49 |
|
|---|
| 50 | #define TRUE (1)
|
|---|
| 51 | #define FALSE (0)
|
|---|
| 52 | #define ERR (0)
|
|---|
| 53 | #define OK (1)
|
|---|
| 54 |
|
|---|
| 55 | #define _ENDLINE 001
|
|---|
| 56 | #define _FULLWIN 002
|
|---|
| 57 | #define _SCROLLWIN 004
|
|---|
| 58 | #define _FLUSH 010
|
|---|
| 59 | #define _FULLLINE 020
|
|---|
| 60 | #define _IDLINE 040
|
|---|
| 61 | #define _STANDOUT 0200
|
|---|
| 62 | #define _NOCHANGE -1
|
|---|
| 63 |
|
|---|
| 64 | #define _puts(s) tputs(s, 0, _putchar)
|
|---|
| 65 |
|
|---|
| 66 | /*
|
|---|
| 67 | * Capabilities from termcap
|
|---|
| 68 | */
|
|---|
| 69 |
|
|---|
| 70 | extern bool AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL,
|
|---|
| 71 | XB, XN, XT, XS, XX;
|
|---|
| 72 | extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
|
|---|
| 73 | *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
|
|---|
| 74 | *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
|
|---|
| 75 | *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
|
|---|
| 76 | *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
|
|---|
| 77 | *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM,
|
|---|
| 78 | *LEFT_PARM, *RIGHT_PARM;
|
|---|
| 79 | extern char PC;
|
|---|
| 80 |
|
|---|
| 81 | /*
|
|---|
| 82 | * From the tty modes...
|
|---|
| 83 | */
|
|---|
| 84 |
|
|---|
| 85 | extern bool GT, NONL, UPPERCASE, normtty, _pfast;
|
|---|
| 86 |
|
|---|
| 87 | struct _win_st {
|
|---|
| 88 | short _cury, _curx;
|
|---|
| 89 | short _maxy, _maxx;
|
|---|
| 90 | short _begy, _begx;
|
|---|
| 91 | short _flags;
|
|---|
| 92 | short _ch_off;
|
|---|
| 93 | bool _clear;
|
|---|
| 94 | bool _leave;
|
|---|
| 95 | bool _scroll;
|
|---|
| 96 | char **_y;
|
|---|
| 97 | short *_firstch;
|
|---|
| 98 | short *_lastch;
|
|---|
| 99 | struct _win_st *_nextp, *_orig;
|
|---|
| 100 | };
|
|---|
| 101 |
|
|---|
| 102 | #define WINDOW struct _win_st
|
|---|
| 103 |
|
|---|
| 104 | extern bool My_term, _echoit, _rawmode, _endwin;
|
|---|
| 105 | extern char *Def_term, ttytype[];
|
|---|
| 106 | extern int LINES, COLS, _tty_ch, _res_flg;
|
|---|
| 107 | extern SGTTY _tty;
|
|---|
| 108 | extern WINDOW *stdscr, *curscr;
|
|---|
| 109 |
|
|---|
| 110 | #define VOID(x) (x)
|
|---|
| 111 |
|
|---|
| 112 | /*
|
|---|
| 113 | * pseudo functions for standard screen
|
|---|
| 114 | */
|
|---|
| 115 | #define addch(ch) VOID(waddch(stdscr, ch))
|
|---|
| 116 | #define getch() VOID(wgetch(stdscr))
|
|---|
| 117 | #define addbytes(da,co) VOID(waddbytes(stdscr, da,co))
|
|---|
| 118 | #define addstr(str) VOID(waddbytes(stdscr, str, strlen(str)))
|
|---|
| 119 | #define getstr(str) VOID(wgetstr(stdscr, str))
|
|---|
| 120 | #define move(y, x) VOID(wmove(stdscr, y, x))
|
|---|
| 121 | #define clear() VOID(wclear(stdscr))
|
|---|
| 122 | #define erase() VOID(werase(stdscr))
|
|---|
| 123 | #define clrtobot() VOID(wclrtobot(stdscr))
|
|---|
| 124 | #define clrtoeol() VOID(wclrtoeol(stdscr))
|
|---|
| 125 | #define insertln() VOID(winsertln(stdscr))
|
|---|
| 126 | #define deleteln() VOID(wdeleteln(stdscr))
|
|---|
| 127 | #define refresh() VOID(wrefresh(stdscr))
|
|---|
| 128 | #define inch() VOID(winch(stdscr))
|
|---|
| 129 | #define insch(c) VOID(winsch(stdscr,c))
|
|---|
| 130 | #define delch() VOID(wdelch(stdscr))
|
|---|
| 131 | #define standout() VOID(wstandout(stdscr))
|
|---|
| 132 | #define standend() VOID(wstandend(stdscr))
|
|---|
| 133 |
|
|---|
| 134 | /*
|
|---|
| 135 | * mv functions
|
|---|
| 136 | */
|
|---|
| 137 | #define mvwaddch(win,y,x,ch) VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
|
|---|
| 138 | #define mvwgetch(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetch(win))
|
|---|
| 139 | #define mvwaddbytes(win,y,x,da,co) \
|
|---|
| 140 | VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,da,co))
|
|---|
| 141 | #define mvwaddstr(win,y,x,str) \
|
|---|
| 142 | VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,str,strlen(str)))
|
|---|
| 143 | #define mvwgetstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
|
|---|
| 144 | #define mvwinch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : winch(win))
|
|---|
| 145 | #define mvwdelch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win))
|
|---|
| 146 | #define mvwinsch(win,y,x,c) VOID(wmove(win,y,x) == ERR ? ERR:winsch(win,c))
|
|---|
| 147 | #define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch)
|
|---|
| 148 | #define mvgetch(y,x) mvwgetch(stdscr,y,x)
|
|---|
| 149 | #define mvaddbytes(y,x,da,co) mvwaddbytes(stdscr,y,x,da,co)
|
|---|
| 150 | #define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str)
|
|---|
| 151 | #define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str)
|
|---|
| 152 | #define mvinch(y,x) mvwinch(stdscr,y,x)
|
|---|
| 153 | #define mvdelch(y,x) mvwdelch(stdscr,y,x)
|
|---|
| 154 | #define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c)
|
|---|
| 155 |
|
|---|
| 156 | /*
|
|---|
| 157 | * pseudo functions
|
|---|
| 158 | */
|
|---|
| 159 |
|
|---|
| 160 | #define clearok(win,bf) (win->_clear = bf)
|
|---|
| 161 | #define leaveok(win,bf) (win->_leave = bf)
|
|---|
| 162 | #define scrollok(win,bf) (win->_scroll = bf)
|
|---|
| 163 | #define flushok(win,bf) (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH))
|
|---|
| 164 | #define getyx(win,y,x) y = win->_cury, x = win->_curx
|
|---|
| 165 | #define winch(win) (win->_y[win->_cury][win->_curx])
|
|---|
| 166 |
|
|---|
| 167 | #define crmode() cbreak() /* backwards compatability */
|
|---|
| 168 | #define nocrmode() nocbreak() /* backwards compatability */
|
|---|
| 169 |
|
|---|
| 170 | #define noraw() _setraw(0)
|
|---|
| 171 | #define raw() _setraw(1)
|
|---|
| 172 | #define nocbreak() _setraw(2)
|
|---|
| 173 | #define cbreak() _setraw(3)
|
|---|
| 174 | #define echo() _setecho(1)
|
|---|
| 175 | #define noecho() _setecho(0)
|
|---|
| 176 | #define nl() _setnl(1)
|
|---|
| 177 | #define nonl() _setnl(0)
|
|---|
| 178 |
|
|---|
| 179 | /*
|
|---|
| 180 | * Used to be in unctrl.h.
|
|---|
| 181 | */
|
|---|
| 182 | #define unctrl(c) _unctrl[(c) & 0377]
|
|---|
| 183 | extern char *_unctrl[];
|
|---|
| 184 |
|
|---|
| 185 | int baudrate (void);
|
|---|
| 186 | int box (WINDOW *win, int vert, int hor);
|
|---|
| 187 | int delwin (WINDOW *win);
|
|---|
| 188 | int endwin (void);
|
|---|
| 189 | int erasechar (void);
|
|---|
| 190 | char *getcap (char *name);
|
|---|
| 191 | int gettmode (void);
|
|---|
| 192 | WINDOW *initscr (void);
|
|---|
| 193 | int killchar (void);
|
|---|
| 194 | char *longname (char *bp, char *def);
|
|---|
| 195 | int mvcur (int ly, int lx, int y, int x);
|
|---|
| 196 | int mvprintw (int y, int x, const char *fmt, ...);
|
|---|
| 197 | int mvscanw (int y, int x, const char *fmt, ...);
|
|---|
| 198 | int mvwin (WINDOW *win, int by, int bx);
|
|---|
| 199 | int mvwprintw (WINDOW *win, int y, int x, const char *fmt, ...);
|
|---|
| 200 | int mvwscanw (WINDOW *win, int y, int x, const char *fmt, ...);
|
|---|
| 201 | WINDOW *newwin (int num_lines, int num_cols, int begy, int begx);
|
|---|
| 202 | int overlay (WINDOW *win1, WINDOW *win2);
|
|---|
| 203 | int overwrite (WINDOW *win1, WINDOW *win2);
|
|---|
| 204 | int printw (const char *fmt, ...);
|
|---|
| 205 | int resetty (void);
|
|---|
| 206 | int savetty (void);
|
|---|
| 207 | int scanw (const char *fmt, ...);
|
|---|
| 208 | int scroll (WINDOW *win);
|
|---|
| 209 | int setterm (char *type);
|
|---|
| 210 | WINDOW *subwin (WINDOW *orig, int num_lines, int num_cols, int begy, int begx);
|
|---|
| 211 | int touchline (WINDOW *win, int y, int sx, int ex);
|
|---|
| 212 | int touchwin (WINDOW *win);
|
|---|
| 213 | int waddbytes (reg WINDOW *win, reg char *bytes, reg int count);
|
|---|
| 214 | int waddch (WINDOW *win, int c);
|
|---|
| 215 | int waddstr (reg WINDOW *win, reg char *str);
|
|---|
| 216 | int wclear (WINDOW *win);
|
|---|
| 217 | int wclrtobot (WINDOW *win);
|
|---|
| 218 | int wclrtoeol (WINDOW *win);
|
|---|
| 219 | int wdelch (WINDOW *win);
|
|---|
| 220 | int wdeleteln (WINDOW *win);
|
|---|
| 221 | int werase (WINDOW *win);
|
|---|
| 222 | int wgetch (WINDOW *win);
|
|---|
| 223 | int wgetstr (WINDOW *win, char *str);
|
|---|
| 224 | int winsch (WINDOW *win, int c);
|
|---|
| 225 | int winsertln (WINDOW *win);
|
|---|
| 226 | int wmove (WINDOW *win, int y, int x);
|
|---|
| 227 | int wprintw (WINDOW *win, const char *fmt, ...);
|
|---|
| 228 | int wrefresh (WINDOW *win);
|
|---|
| 229 | int wscanw (WINDOW *win, const char *fmt, ...);
|
|---|
| 230 | char *wstandend (WINDOW *win);
|
|---|
| 231 | char *wstandout (WINDOW *win);
|
|---|
| 232 | char _putchar (int c);
|
|---|
| 233 | int _setecho (int on);
|
|---|
| 234 | int _setnl (int on);
|
|---|
| 235 | int _setraw (int on);
|
|---|
| 236 |
|
|---|
| 237 | #if defined (__cplusplus)
|
|---|
| 238 | }
|
|---|
| 239 | #endif
|
|---|
| 240 |
|
|---|
| 241 | #endif
|
|---|