home *** CD-ROM | disk | FTP | other *** search
/ IRIS Development Option 6.2 / IRIS_Development_Option_6.2_814-0478-001.iso / dist / dev.idb / usr / include / cursesBSD.h.z / cursesBSD.h
C/C++ Source or Header  |  1996-03-14  |  7KB  |  233 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 are permitted provided
  6.  * that: (1) source distributions retain this entire copyright notice and
  7.  * comment, and (2) distributions including binaries display the following
  8.  * acknowledgement:  ``This product includes software developed by the
  9.  * University of California, Berkeley and its contributors'' in the
  10.  * documentation or other materials provided with the distribution and in
  11.  * all advertising materials mentioning features or use of this software.
  12.  * Neither the name of the University nor the names of its contributors may
  13.  * be used to endorse or promote products derived from this software without
  14.  * specific prior written permission.
  15.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  16.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  17.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  18.  *
  19.  *    @(#)curses.h    5.9 (Berkeley) 7/1/90
  20.  */
  21.  
  22. #ifndef WINDOW
  23.  
  24. #include    <stdio.h>
  25.  
  26. #ifndef sgi
  27. #define USE_OLD_TTY
  28. #include    <sys/ttioctl.h>
  29. #undef USE_OLD_TTY
  30. #endif
  31.  
  32. #define    bool    char
  33. #define    reg    register
  34.  
  35. #define    TRUE    (1)
  36. #define    FALSE    (0)
  37. #define    ERR    (0)
  38. #define    OK    (1)
  39.  
  40. #define    _ENDLINE    001
  41. #define    _FULLWIN    002
  42. #define    _SCROLLWIN    004
  43. #define    _FLUSH        010
  44. #define    _FULLLINE    020
  45. #define    _IDLINE        040
  46. #define    _STANDOUT    0200
  47. #define    _NOCHANGE    -1
  48.  
  49. #define    _puts(s)    tputs(s, 0, _putchar)
  50.  
  51. #ifdef sgi
  52.  
  53. struct sgttyb {
  54.     char    sg_ispeed;              /* input speed */
  55.     char    sg_ospeed;              /* output speed */
  56.     char    sg_erase;               /* erase character */
  57.     char    sg_kill;                /* kill character */
  58.     int     sg_flags;               /* mode flags */
  59. };
  60.  
  61. #define XTABS    02
  62. #define LCASE    04
  63. #define ECHO    010
  64. #define CRMOD    020
  65. #define RAW    040
  66. #define CBREAK    0100
  67.  
  68. #define TIOCGETP    0x101
  69. #define TIOCSETP    0x102
  70. #endif
  71.  
  72. typedef    struct sgttyb    SGTTY;
  73.  
  74. /*
  75.  * Capabilities from termcap
  76.  */
  77.  
  78. extern bool     AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL,
  79.         XB, XN, XT, XS, XX;
  80. extern char    *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
  81.         *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
  82.         *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
  83.         *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
  84.         *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
  85.         *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM,
  86.         *LEFT_PARM, *RIGHT_PARM;
  87. extern char    PC;
  88.  
  89. /*
  90.  * From the tty modes...
  91.  */
  92.  
  93. extern bool    GT, NONL, UPPERCASE, normtty, _pfast;
  94.  
  95. struct _win_st {
  96.     short        _cury, _curx;
  97.     short        _maxy, _maxx;
  98.     short        _begy, _begx;
  99.     short        _flags;
  100.     short        _ch_off;
  101.     bool        _clear;
  102.     bool        _leave;
  103.     bool        _scroll;
  104.     char        **_y;
  105.     short        *_firstch;
  106.     short        *_lastch;
  107.     struct _win_st    *_nextp, *_orig;
  108. };
  109.  
  110. #define    WINDOW    struct _win_st
  111.  
  112. extern bool    My_term, _echoit, _rawmode, _endwin;
  113.  
  114. extern char    *Def_term, ttytype[];
  115.  
  116. extern int    LINES, COLS, _tty_ch, _res_flg;
  117.  
  118. extern SGTTY    _tty;
  119.  
  120. extern WINDOW    *stdscr, *curscr;
  121.  
  122. /*
  123.  *    Define VOID to stop lint from generating "null effect"
  124.  * comments.
  125.  */
  126. #ifdef lint
  127. int    __void__;
  128. #define    VOID(x)    (__void__ = (int) (x))
  129. #else
  130. #define    VOID(x)    (x)
  131. #endif
  132.  
  133. /*
  134.  * psuedo functions for standard screen
  135.  */
  136. #define    addch(ch)    VOID(waddch(stdscr, ch))
  137. #define    getch()        VOID(wgetch(stdscr))
  138. #define    addbytes(da,co)    VOID(waddbytes(stdscr, da,co))
  139. #define    getstr(str)    VOID(wgetstr(stdscr, str))
  140. #define    move(y, x)    VOID(wmove(stdscr, y, x))
  141. #define    clear()        VOID(wclear(stdscr))
  142. #define    erase()        VOID(werase(stdscr))
  143. #define    clrtobot()    VOID(wclrtobot(stdscr))
  144. #define    clrtoeol()    VOID(wclrtoeol(stdscr))
  145. #define    insertln()    VOID(winsertln(stdscr))
  146. #define    deleteln()    VOID(wdeleteln(stdscr))
  147. #define    refresh()    VOID(wrefresh(stdscr))
  148. #define    inch()        VOID(winch(stdscr))
  149. #define    insch(c)    VOID(winsch(stdscr,c))
  150. #define    delch()        VOID(wdelch(stdscr))
  151. #define    standout()    VOID(wstandout(stdscr))
  152. #define    standend()    VOID(wstandend(stdscr))
  153.  
  154. #define waddstr(win,str)    VOID(waddbytes(win,str,strlen(str)))
  155. #define wmove(win,y,x) \
  156.     (((x) < 0 || (y) < 0 || (x) >= (win)->_maxx || (y) >= (win)->_maxy) ? \
  157.      ERR : ((win)->_curx = (x), (win)->_cury = (y), OK))
  158.     
  159.  
  160. /*
  161.  * mv functions
  162.  */
  163. #define    mvwaddch(win,y,x,ch)    VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
  164. #define    mvwgetch(win,y,x)    VOID(wmove(win,y,x)==ERR?ERR:wgetch(win))
  165. #define    mvwaddbytes(win,y,x,da,co) \
  166.         VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,da,co))
  167. #define    mvwaddstr(win,y,x,str) \
  168.         VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,str,strlen(str)))
  169. #define mvwgetstr(win,y,x,str)  VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
  170. #define    mvwinch(win,y,x)    VOID(wmove(win,y,x) == ERR ? ERR : winch(win))
  171. #define    mvwdelch(win,y,x)    VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win))
  172. #define    mvwinsch(win,y,x,c)    VOID(wmove(win,y,x) == ERR ? ERR:winsch(win,c))
  173. #define    mvaddch(y,x,ch)        mvwaddch(stdscr,y,x,ch)
  174. #define    mvgetch(y,x)        mvwgetch(stdscr,y,x)
  175. #define    mvaddbytes(y,x,da,co)    mvwaddbytes(stdscr,y,x,da,co)
  176. #define    mvaddstr(y,x,str) \
  177.         VOID(wmove(stdscr,y,x)==ERR?ERR:addstr(str))
  178. #define mvgetstr(y,x,str)       mvwgetstr(stdscr,y,x,str)
  179. #define    mvinch(y,x)        mvwinch(stdscr,y,x)
  180. #define    mvdelch(y,x)        mvwdelch(stdscr,y,x)
  181. #define    mvinsch(y,x,c)        mvwinsch(stdscr,y,x,c)
  182.  
  183. /*
  184.  * psuedo functions
  185.  */
  186.  
  187. #define    clearok(win,bf)     (win->_clear = bf)
  188. #define    leaveok(win,bf)     (win->_leave = bf)
  189. #define    scrollok(win,bf) (win->_scroll = bf)
  190. #define flushok(win,bf)     (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH))
  191. #define    getyx(win,y,x)     y = win->_cury, x = win->_curx
  192. #define    winch(win)     (win->_y[win->_cury][win->_curx] & 0177)
  193.  
  194. #define raw()     (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, \
  195.     ttioctl(_tty_ch, TIOCSETP, &_tty))
  196. #define noraw()     (_tty.sg_flags&=~RAW,_rawmode=FALSE,\
  197.     _pfast=!(_tty.sg_flags&CRMOD),ttioctl(_tty_ch, TIOCSETP, &_tty))
  198. #define cbreak() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, \
  199.     ttioctl(_tty_ch, TIOCSETP, &_tty))
  200. #define nocbreak() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE, \
  201.     ttioctl(_tty_ch, TIOCSETP, &_tty))
  202. #define crmode() cbreak()    /* backwards compatability */
  203. #define nocrmode() nocbreak()    /* backwards compatability */
  204. #define echo()     (_tty.sg_flags |= ECHO, _echoit = TRUE, \
  205.     ttioctl(_tty_ch, TIOCSETP, &_tty))
  206. #define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, \
  207.     ttioctl(_tty_ch, TIOCSETP, &_tty))
  208. #define nl()     (_tty.sg_flags |= CRMOD,_pfast = _rawmode, \
  209.     ttioctl(_tty_ch, TIOCSETP, &_tty))
  210. #define nonl()     (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, \
  211.     ttioctl(_tty_ch, TIOCSETP, &_tty))
  212. #define    savetty() ((void) ttioctl(_tty_ch, TIOCGETP, &_tty), \
  213.     _res_flg = _tty.sg_flags)
  214. #define    resetty() (_tty.sg_flags = _res_flg, \
  215.     _echoit = ((_res_flg & ECHO) == ECHO), \
  216.     _rawmode = ((_res_flg & (CBREAK|RAW)) != 0), \
  217.     _pfast = ((_res_flg & CRMOD) ? _rawmode : TRUE), \
  218.     (void) ttioctl(_tty_ch, TIOCSETP, &_tty))
  219.  
  220. #define    erasechar()    (_tty.sg_erase)
  221. #define    killchar()    (_tty.sg_kill)
  222. #define baudrate()    (_tty.sg_ospeed)
  223.  
  224. WINDOW    *initscr(), *newwin(), *subwin();
  225. char    *longname(), *getcap();
  226.  
  227. /*
  228.  * Used to be in unctrl.h.
  229.  */
  230. #define    unctrl(c)    _unctrl[(c) & 0177]
  231. extern char *_unctrl[];
  232. #endif
  233.