home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / lib / libcurses / curses.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-01  |  10.2 KB  |  284 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.12 (Berkeley) 9/1/92
  34.  */
  35.  
  36. #ifndef _CURSES_H_
  37. #define    _CURSES_H_
  38.  
  39. #include <stdio.h>
  40.  
  41. /*
  42.  * The following #defines and #includes are present for backward
  43.  * compatibility only.  They should not be used in future code.
  44.  *
  45.  * START BACKWARD COMPATIBILITY ONLY.
  46.  */
  47. #ifndef _CURSES_PRIVATE
  48. #define    bool    char
  49. #define    reg    register
  50.  
  51. #ifndef TRUE
  52. #define    TRUE    (1)
  53. #endif
  54. #ifndef FALSE
  55. #define    FALSE    (0)
  56. #endif
  57.  
  58. #define    _puts(s)    tputs(s, 0, __cputchar)
  59. #define    _putchar(c)    __cputchar(c)
  60.  
  61. /* Old-style terminal modes access. */
  62. #define    baudrate()    (cfgetospeed(&origtermio))
  63. #define    crmode()    cbreak()
  64. #define    erasechar()    (origtermio.c_cc[VERASE])
  65. #define    killchar()    (origtermio.c_cc[VKILL])
  66. #define    nocrmode()    nocbreak()
  67. #define    ospeed        (cfgetospeed(&origtermio))
  68. #endif /* _CURSES_PRIVATE */
  69.  
  70. extern int     My_term;        /* Use Def_term regardless. */
  71. extern char    *Def_term;        /* Default terminal type. */
  72.  
  73. /* END BACKWARD COMPATIBILITY ONLY. */
  74.  
  75. /* 7-bit ASCII characters. */
  76. #define    unctrl(c)        __unctrl[(c) & 0x7f]
  77. #define    unctrllen(ch)        __unctrllen[(ch) & 0x7f]
  78.  
  79. typedef struct _win_st {        /* Window structure. */
  80.     short        _cury, _curx;    /* Current x, y coordinates. */
  81.     short        _maxy, _maxx;    /* Maximum values for curx, cury. */
  82.     short        _begy, _begx;    /* Window home. */
  83.  
  84. #define    _ENDLINE    0x001        /* End of screen. */
  85. #define    _FLUSH        0x002        /* fflush(stdout) after refresh. */
  86. #define    _FULLLINE    0x004        /* Line width = terminal width. */
  87. #define    _FULLWIN    0x008        /* Window is a screen. */
  88. #define    _IDLINE        0x010        /* Insert/delete sequences. */
  89. #define    _SCROLLWIN    0x020        /* Last char will scroll window. */
  90. /* 
  91.  * XXX
  92.  * _STANDOUT is the 8th bit, characters themselves are encoded.
  93.  */
  94. #define    _STANDOUT    0x080        /* Added characters are standout. */
  95.     unsigned short    _flags;
  96.  
  97.     short        _ch_off;    /* x offset for firstch/lastch. */
  98.     char        _clear;        /* If clear on next refresh. */
  99.     char        _leave;        /* If cursor left. */
  100.     char        _scroll;    /* If scrolling permitted. */
  101.     char        **_y;        /* Line describing the window. */
  102.  
  103. #define    _NOCHANGE    -1        /* No change since last refresh. */
  104.     short        *_firstch;    /* First and last changed in line. */
  105.     short        *_lastch;
  106.     struct _win_st    *_nextp, *_orig;/* Subwindows list and parent. */
  107. } WINDOW;
  108.  
  109. /* Termcap capabilities. */
  110. extern char    AM, BS, CA, DA, EO, HC, HZ, IN, MI, MS, NC, NS, OS,
  111.         PC, UL, XB, XN, XT, XS, XX;
  112. extern char    *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
  113.         *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
  114.         *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
  115.         *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
  116.         *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
  117.         *VE,
  118.         *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM,
  119.         *RIGHT_PARM;
  120.  
  121. /* Curses external declarations. */
  122. extern WINDOW    *curscr;        /* Current screen. */
  123. extern WINDOW    *stdscr;        /* Standard screen. */
  124.  
  125. extern struct termios origtermio;    /* Original terminal modes. */
  126.  
  127. extern int     COLS;            /* Columns on the screen. */
  128. extern int     LINES;            /* Lines on the screen. */
  129.  
  130. extern char     GT;            /* Gtty indicates tabs. */
  131. extern char     NONL;            /* Term can't hack LF doing a CR. */
  132. extern char     UPPERCASE;        /* Terminal is uppercase only. */
  133. extern char    *ttytype;        /* Full name of current terminal. */
  134. extern char    *__unctrl[0x80];    /* Control strings. */
  135. extern char     __unctrllen[0x80];    /* Control strings length. */
  136.  
  137. #define    ERR    (0)            /* Error return. */
  138. #define    OK    (1)            /* Success return. */
  139.  
  140. /* Standard screen pseudo functions. */
  141. #define    addbytes(da, co)    waddbytes(stdscr, da, co)
  142. #define    addch(ch)        waddch(stdscr, ch)
  143. #define    addstr(str)        waddbytes(stdscr, str, strlen(str))
  144. #define    clear()            wclear(stdscr)
  145. #define    clrtobot()        wclrtobot(stdscr)
  146. #define    clrtoeol()        wclrtoeol(stdscr)
  147. #define    delch()            wdelch(stdscr)
  148. #define    deleteln()        wdeleteln(stdscr)
  149. #define    erase()            werase(stdscr)
  150. #define    getch()            wgetch(stdscr)
  151. #define    getstr(str)        wgetstr(stdscr, str)
  152. #define    inch()            winch(stdscr)
  153. #define    insch(ch))        winsch(stdscr, ch)
  154. #define    insertln()        winsertln(stdscr)
  155. #define    move(y, x)        wmove(stdscr, y, x)
  156. #define    refresh()        wrefresh(stdscr)
  157. #define    standend()        wstandend(stdscr)
  158. #define    standout()        wstandout(stdscr)
  159.  
  160. /* Standard screen plus movement pseudo functions. */
  161. #define    mvaddbytes(y, x, da, co) \
  162.                 mvwaddbytes(stdscr, y, x, da, co)
  163. #define    mvaddch(y, x, ch)    mvwaddch(stdscr, y, x, ch)
  164. #define    mvaddstr(y, x, str)    mvwaddstr(stdscr, y, x, str)
  165. #define    mvdelch(y, x)        mvwdelch(stdscr, y, x)
  166. #define    mvgetch(y, x)        mvwgetch(stdscr, y, x)
  167. #define    mvgetstr(y, x, str)    mvwgetstr(stdscr, y, x, str)
  168. #define    mvinch(y, x)        mvwinch(stdscr, y, x)
  169. #define    mvinsch(y, x, c)    mvwinsch(stdscr, y, x, c)
  170. #define    mvwaddbytes(win, y, x, da, co) \
  171.                 (wmove(win, y, x) == ERR ? \
  172.                     ERR : waddbytes(win, da, co))
  173. #define    mvwaddch(win, y, x, ch)    (wmove(win, y, x) == ERR ? \
  174.                     ERR : waddch(win, ch))
  175. #define    mvwaddstr(win, y, x, str) \
  176.                 (wmove(win, y, x) == ERR ? \
  177.                     ERR : waddbytes(win, str, strlen(str)))
  178. #define    mvwdelch(win, y, x)    (wmove(win, y, x) == ERR ? ERR : wdelch(win))
  179. #define    mvwgetch(win, y, x)    (wmove(win, y, x) == ERR ? ERR : wgetch(win))
  180. #define    mvwgetstr(win, y, x, str) \
  181.                 (wmove(win, y, x) == ERR ? \
  182.                     ERR : wgetstr(win, str))
  183. #define    mvwinch(win, y, x)    (wmove(win, y, x) == ERR ? ERR : winch(win))
  184. #define    mvwinsch(win, y, x, c)    (wmove(win, y, x) == ERR ? ERR : winsch(win, c))
  185.  
  186. /* Random psuedo functions. */
  187. #define    clearok(win, bf)     (win->_clear = (bf))
  188. #define    flushok(win, bf)    ((bf) ? (win->_flags |= _FLUSH) : \
  189.                     (win->_flags &= ~_FLUSH))
  190. #define    getyx(win, y, x)    (y) = win->_cury, (x) = win->_curx
  191. #define    leaveok(win, bf)    (win->_leave = (bf))
  192. #define    scrollok(win, bf)    (win->_scroll = (bf))
  193. #define    winch(win)        (win->_y[win->_cury][win->_curx] & 0177)
  194.  
  195. /* Public function prototypes. */
  196. void     __cputchar __P((int));
  197. int     _sprintw __P((WINDOW *, const char *, _BSD_VA_LIST_));
  198. int     box __P((WINDOW *, int, int));
  199. int     cbreak __P((void));
  200. int     delwin __P((WINDOW *));
  201. int     echo __P((void));
  202. int     endwin __P((void));
  203. char    *fullname __P((char *, char *));
  204. char    *getcap __P((char *));
  205. int     gettmode __P((void));
  206. void     idlok __P((WINDOW *, int));
  207. WINDOW    *initscr __P((void));
  208. char    *longname __P((char *, char *));
  209. int     mvcur __P((int, int, int, int));
  210. int     mvprintw __P((int, int, const char *, ...));
  211. int     mvscanw __P((int, int, const char *, ...));
  212. int     mvwin __P((WINDOW *, int, int));
  213. int     mvwprintw __P((WINDOW *, int, int, const char *, ...));
  214. int     mvwscanw __P((WINDOW *, int, int, const char *, ...));
  215. WINDOW    *newwin __P((int, int, int, int));
  216. int     nl __P((void));
  217. int     nocbreak __P((void));
  218. int     noecho __P((void));
  219. int     nonl __P((void));
  220. int     noraw __P((void));
  221. int     overlay __P((WINDOW *, WINDOW *));
  222. int     overwrite __P((WINDOW *, WINDOW *));
  223. int     printw __P((const char *, ...));
  224. int     raw __P((void));
  225. int     resetty __P((void));
  226. int     savetty __P((void));
  227. int     scanw __P((const char *, ...));
  228. int     scroll __P((WINDOW *));
  229. int     setterm __P((char *));
  230. int     sscans __P((WINDOW *, const char *, _BSD_VA_LIST_));
  231. WINDOW    *subwin __P((WINDOW *, int, int, int, int));
  232. int     suspendwin __P((void));
  233. int     touchline __P((WINDOW *, int, int, int));
  234. int     touchoverlap __P((WINDOW *, WINDOW *));
  235. int     touchwin __P((WINDOW *));
  236. void     tstp __P((int));
  237. int     waddch __P((WINDOW *, int));
  238. int     waddstr __P((WINDOW *, char *));
  239. int     wclear __P((WINDOW *));
  240. int     wclrtobot __P((WINDOW *));
  241. int     wclrtoeol __P((WINDOW *));
  242. int     wdelch __P((WINDOW *));
  243. int     wdeleteln __P((WINDOW *));
  244. int     werase __P((WINDOW *));
  245. int     wgetch __P((WINDOW *));
  246. int     wgetstr __P((WINDOW *, char *));
  247. int     winsch __P((WINDOW *, int));
  248. int     winsertln __P((WINDOW *));
  249. int     wmove __P((WINDOW *, int, int));
  250. int     wprintw __P((WINDOW *, const char *, ...));
  251. int     wrefresh __P((WINDOW *));
  252. int     wscanw __P((WINDOW *, const char *, ...));
  253. char    *wstandend __P((WINDOW *));
  254. char    *wstandout __P((WINDOW *));
  255.  
  256. #ifdef _CURSES_PRIVATE
  257. /* Private function prototypes. */
  258. void     __id_subwins __P((WINDOW *));
  259. void     __set_subwin __P((WINDOW *, WINDOW *));
  260. void     __swflags __P((WINDOW *));
  261. void     __TRACE __P((const char *, ...));
  262. int     waddbytes __P((WINDOW *, char *, int));
  263.  
  264. /* Private #defines. */
  265. #define    min(a,b)    (a < b ? a : b)
  266. #define    max(a,b)    (a > b ? a : b)
  267.  
  268. /* Private externs. */
  269. extern int     __echoit;
  270. extern int     __endwin;
  271. extern int     __pfast;
  272. extern int     __rawmode;
  273. #endif
  274.  
  275. /* Termcap functions. */
  276. int     tgetent __P((char *, char *));
  277. int     tgetnum __P((char *));
  278. int     tgetflag __P((char *));
  279. char    *tgetstr __P((char *, char **));
  280. char    *tgoto __P((char *, int, int));
  281. int     tputs __P((char *, int, void (*)(int)));
  282.  
  283. #endif /* !_CURSES_H_ */
  284.