home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / c / gcc233.lha / include / curses.h < prev    next >
C/C++ Source or Header  |  1992-09-12  |  9KB  |  271 lines

  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. #ifndef WINDOW
  37.  
  38. #include <sys/cdefs.h>
  39.  
  40. #include    <stdio.h>
  41.  
  42. #define USE_OLD_TTY
  43. #include    <sys/ioctl.h>
  44. #undef USE_OLD_TTY
  45.  
  46. #define    bool    char
  47. #define    reg    register
  48.  
  49. #define    TRUE    (1)
  50. #define    FALSE    (0)
  51. #define    ERR    (0)
  52. #define    OK    (1)
  53.  
  54. #define    _ENDLINE    001
  55. #define    _FULLWIN    002
  56. #define    _SCROLLWIN    004
  57. #define    _FLUSH        010
  58. #define    _FULLLINE    020
  59. #define    _IDLINE        040
  60. #define    _STANDOUT    0200
  61. #define    _NOCHANGE    -1
  62.  
  63. #define    _puts(s)    tputs(s, 0, _putchar)
  64.  
  65. typedef    struct sgttyb    SGTTY;
  66.  
  67. /*
  68.  * Capabilities from termcap
  69.  */
  70.  
  71. extern bool     AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL,
  72.         XB, XN, XT, XS, XX;
  73. extern char    *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
  74.         *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
  75.         *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
  76.         *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
  77.         *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
  78.         *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM,
  79.         *LEFT_PARM, *RIGHT_PARM;
  80. extern char    PC;
  81.  
  82. /*
  83.  * From the tty modes...
  84.  */
  85.  
  86. extern bool    GT, NONL, UPPERCASE, normtty, _pfast;
  87.  
  88. struct _win_st {
  89.     short        _cury, _curx;
  90.     short        _maxy, _maxx;
  91.     short        _begy, _begx;
  92.     short        _flags;
  93.     short        _ch_off;
  94.     bool        _clear;
  95.     bool        _leave;
  96.     bool        _scroll;
  97.     char        **_y;
  98.     short        *_firstch;
  99.     short        *_lastch;
  100.     struct _win_st    *_nextp, *_orig;
  101. };
  102.  
  103. #define    WINDOW    struct _win_st
  104.  
  105. extern bool    My_term, _echoit, _rawmode, _endwin;
  106.  
  107. extern char    *Def_term, ttytype[];
  108.  
  109. extern int    LINES, COLS, _tty_ch, _res_flg;
  110.  
  111. extern SGTTY    _tty;
  112.  
  113. extern WINDOW    *stdscr, *curscr;
  114.  
  115. /*
  116.  *    Define VOID to stop lint from generating "null effect"
  117.  * comments.
  118.  */
  119. #ifdef lint
  120. int    __void__;
  121. #define    VOID(x)    (__void__ = (int) (x))
  122. #else
  123. #define    VOID(x)    (x)
  124. #endif
  125.  
  126. /*
  127.  * psuedo functions for standard screen
  128.  */
  129. #define    addch(ch)    VOID(waddch(stdscr, ch))
  130. #define    getch()        VOID(wgetch(stdscr))
  131. #define    addbytes(da,co)    VOID(waddbytes(stdscr, da,co))
  132. #define    addstr(str)    VOID(waddbytes(stdscr, str, strlen(str)))
  133. #define    getstr(str)    VOID(wgetstr(stdscr, str))
  134. #define    move(y, x)    VOID(wmove(stdscr, y, x))
  135. #define    clear()        VOID(wclear(stdscr))
  136. #define    erase()        VOID(werase(stdscr))
  137. #define    clrtobot()    VOID(wclrtobot(stdscr))
  138. #define    clrtoeol()    VOID(wclrtoeol(stdscr))
  139. #define    insertln()    VOID(winsertln(stdscr))
  140. #define    deleteln()    VOID(wdeleteln(stdscr))
  141. #define    refresh()    VOID(wrefresh(stdscr))
  142. #define    inch()        VOID(winch(stdscr))
  143. #define    insch(c)    VOID(winsch(stdscr,c))
  144. #define    delch()        VOID(wdelch(stdscr))
  145. #define    standout()    VOID(wstandout(stdscr))
  146. #define    standend()    VOID(wstandend(stdscr))
  147.  
  148. /*
  149.  * mv functions
  150.  */
  151. #define    mvwaddch(win,y,x,ch)    VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
  152. #define    mvwgetch(win,y,x)    VOID(wmove(win,y,x)==ERR?ERR:wgetch(win))
  153. #define    mvwaddbytes(win,y,x,da,co) \
  154.         VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,da,co))
  155. #define    mvwaddstr(win,y,x,str) \
  156.         VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,str,strlen(str)))
  157. #define mvwgetstr(win,y,x,str)  VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
  158. #define    mvwinch(win,y,x)    VOID(wmove(win,y,x) == ERR ? ERR : winch(win))
  159. #define    mvwdelch(win,y,x)    VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win))
  160. #define    mvwinsch(win,y,x,c)    VOID(wmove(win,y,x) == ERR ? ERR:winsch(win,c))
  161. #define    mvaddch(y,x,ch)        mvwaddch(stdscr,y,x,ch)
  162. #define    mvgetch(y,x)        mvwgetch(stdscr,y,x)
  163. #define    mvaddbytes(y,x,da,co)    mvwaddbytes(stdscr,y,x,da,co)
  164. #define    mvaddstr(y,x,str)    mvwaddstr(stdscr,y,x,str)
  165. #define mvgetstr(y,x,str)       mvwgetstr(stdscr,y,x,str)
  166. #define    mvinch(y,x)        mvwinch(stdscr,y,x)
  167. #define    mvdelch(y,x)        mvwdelch(stdscr,y,x)
  168. #define    mvinsch(y,x,c)        mvwinsch(stdscr,y,x,c)
  169.  
  170. /*
  171.  * psuedo functions
  172.  */
  173.  
  174. #define    clearok(win,bf)     (win->_clear = bf)
  175. #define    leaveok(win,bf)     (win->_leave = bf)
  176. #define    scrollok(win,bf) (win->_scroll = bf)
  177. #define flushok(win,bf)     (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH))
  178. #define    getyx(win,y,x)     y = win->_cury, x = win->_curx
  179. #define    winch(win)     (win->_y[win->_cury][win->_curx] & 0177)
  180.  
  181. #define raw()     (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, \
  182.     ioctl(_tty_ch, TIOCSETP, &_tty))
  183. #define noraw()     (_tty.sg_flags&=~RAW,_rawmode=FALSE,\
  184.     _pfast=!(_tty.sg_flags&CRMOD),ioctl(_tty_ch, TIOCSETP, &_tty))
  185. #define cbreak() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, \
  186.     ioctl(_tty_ch, TIOCSETP, &_tty))
  187. #define nocbreak() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE, \
  188.     ioctl(_tty_ch, TIOCSETP, &_tty))
  189. #define crmode() cbreak()    /* backwards compatability */
  190. #define nocrmode() nocbreak()    /* backwards compatability */
  191. #define echo()     (_tty.sg_flags |= ECHO, _echoit = TRUE, \
  192.     ioctl(_tty_ch, TIOCSETP, &_tty))
  193. #define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, \
  194.     ioctl(_tty_ch, TIOCSETP, &_tty))
  195. #define nl()     (_tty.sg_flags |= CRMOD,_pfast = _rawmode, \
  196.     ioctl(_tty_ch, TIOCSETP, &_tty))
  197. #define nonl()     (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, \
  198.     ioctl(_tty_ch, TIOCSETP, &_tty))
  199. #define    savetty() ((void) ioctl(_tty_ch, TIOCGETP, &_tty), \
  200.     _res_flg = _tty.sg_flags)
  201. #define    resetty() (_tty.sg_flags = _res_flg, \
  202.     _echoit = ((_res_flg & ECHO) == ECHO), \
  203.     _rawmode = ((_res_flg & (CBREAK|RAW)) != 0), \
  204.     _pfast = ((_res_flg & CRMOD) ? _rawmode : TRUE), \
  205.     (void) ioctl(_tty_ch, TIOCSETP, &_tty))
  206.  
  207. #define    erasechar()    (_tty.sg_erase)
  208. #define    killchar()    (_tty.sg_kill)
  209. #define baudrate()    (_tty.sg_ospeed)
  210.  
  211. __BEGIN_DECLS
  212.  
  213. int    waddbytes __P((WINDOW *win, char *bytes, int count));  
  214. int    waddch __P((WINDOW *win, int c));  
  215. int    waddstr __P((WINDOW *win, char *str));  
  216. int    box __P((WINDOW *win, int vert, int hor));  
  217. int    wclear __P((WINDOW *win));  
  218. int    wclrtobot __P((WINDOW *win));  
  219. int    wclrtoeol __P((WINDOW *win));  
  220. int    mvcur __P((int ly, int lx, int y, int x));  
  221. int    fgoto __P((void));  
  222. int    plodput __P((int c));  
  223. int    plod __P((int cnt));  
  224. int    tabcol __P((int col, int ts));  
  225. int    gettmode __P((void));  
  226. int    setterm __P((char *type));  
  227. int    zap __P((void));  
  228. char   *getcap __P((char *name));  
  229. int    wdelch __P((WINDOW *win));  
  230. int    wdeleteln __P((WINDOW *win));  
  231. int    delwin __P((WINDOW *win));  
  232. int    endwin __P((void));  
  233. int    werase __P((WINDOW *win));  
  234. char   *fullname __P((char *bp, char *def));  
  235. int    wgetch __P((WINDOW *win));  
  236. int    wgetstr __P((WINDOW *win, char *str));  
  237. int    _id_subwins __P((WINDOW *orig));  
  238. int    idlok __P((WINDOW *win, int bf));  
  239. WINDOW *initscr __P((void));  
  240. int    winsch __P((WINDOW *win, int c));  
  241. int    winsertln __P((WINDOW *win));  
  242. char   *longname __P((char *bp, char *def));  
  243. int    wmove __P((WINDOW *win, int y, int x));  
  244. int    mvwin __P((WINDOW *win, int by, int bx));  
  245. WINDOW *newwin __P((int num_lines, int num_cols, int begy, int begx));  
  246. WINDOW *subwin __P((WINDOW *orig, int num_lines, int num_cols, int begy, int begx));  
  247. int    _set_subwin_ __P((WINDOW *orig, WINDOW *win));  
  248. int    _swflags_ __P((WINDOW *win));  
  249. int    overlay __P((WINDOW *win1, WINDOW *win2));  
  250. int    overwrite __P((WINDOW *win1, WINDOW *win2));  
  251. int    _sprintw __P((WINDOW *win, const char *fmt, _VA_LIST_));
  252. int    _putchar __P((int c));  
  253. int    wrefresh __P((WINDOW *win));  
  254. int    _sscans __P((WINDOW *win, const char *fmt, ...));  
  255. int    scroll __P((WINDOW *win));  
  256. char   *wstandout __P((WINDOW *win));  
  257. char   *wstandend __P((WINDOW *win));  
  258. int    touchoverlap __P((WINDOW *win1, WINDOW *win2));  
  259. int    touchwin __P((WINDOW *win));  
  260. int    touchline __P((WINDOW *win, int y, int sx, int ex));  
  261. void    tstp __P((void));  
  262.  
  263. __END_DECLS
  264.  
  265. /*
  266.  * Used to be in unctrl.h.
  267.  */
  268. #define    unctrl(c)    _unctrl[(c) & 0177]
  269. extern char *_unctrl[];
  270. #endif
  271.