home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / armlinux / alpha / PARTITIONS / USR_GZ / usr / include / curses.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-14  |  12.5 KB  |  357 lines

  1. /*
  2.  * Copyright (c) 1981, 1993, 1994
  3.  *    The Regents of the University of California.  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    8.4 (Berkeley) 8/10/94
  34.  */
  35.  
  36. #ifndef _CURSES_H_
  37. #define    _CURSES_H_
  38.  
  39. #include <features.h>
  40. #include <sys/types.h>
  41. #include <stdio.h>
  42. #include <termcap.h>
  43.  
  44. #ifndef _BSD_VA_LIST_
  45. #define _BSD_VA_LIST_    _G_va_list
  46. #endif
  47.  
  48. #ifndef TCSASOFT
  49. #define TCSASOFT    0
  50. #endif
  51.  
  52. /*
  53.  * The following #defines and #includes are present for backward
  54.  * compatibility only.  They should not be used in future code.
  55.  *
  56.  * START BACKWARD COMPATIBILITY ONLY.
  57.  */
  58. #ifndef _CURSES_PRIVATE
  59. #define    bool    char
  60. #define    reg    register
  61.  
  62. #ifndef TRUE
  63. #define    TRUE    (1)
  64. #endif
  65. #ifndef FALSE
  66. #define    FALSE    (0)
  67. #endif
  68.  
  69. #define    _puts(s)    tputs(s, 0, __cputchar)
  70. #define    _putchar(c)    __cputchar(c)
  71.  
  72. /* Old-style terminal modes access. */
  73. #define    baudrate()    (cfgetospeed(&__baset))
  74. #define    crmode()    cbreak()
  75. #define    erasechar()    (__baset.c_cc[VERASE])
  76. #define    killchar()    (__baset.c_cc[VKILL])
  77. #define    nocrmode()    nocbreak()
  78. #define    ospeed        (cfgetospeed(&__baset))
  79. #endif /* _CURSES_PRIVATE */
  80.  
  81. extern char     GT;            /* Gtty indicates tabs. */
  82. extern char     NONL;            /* Term can't hack LF doing a CR. */
  83. extern char     UPPERCASE;        /* Terminal is uppercase only. */
  84.  
  85. extern int     My_term;        /* Use Def_term regardless. */
  86. extern char    *Def_term;        /* Default terminal type. */
  87.  
  88. /* Termcap capabilities. */
  89. extern char    AM, BS, CA, DA, EO, HC, IN, MI, MS, NC, NS, OS,
  90.         PC, UL, XB, XN, XT, XS, XX;
  91. extern char    *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
  92.         *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
  93.         *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
  94.         *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
  95.         *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
  96.         *VE, *al, *dl, *sf, *sr,
  97.         *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM,
  98.         *RIGHT_PARM;
  99.  
  100. #define _begx    begx
  101. #define _begy    begy
  102. #define _maxx    maxx
  103. #define _maxy    maxy
  104.  
  105. /* END BACKWARD COMPATIBILITY ONLY. */
  106.  
  107. /* 8-bit ASCII characters. */
  108. #define    unctrl(c)        __unctrl[(c) & 0xff]
  109. #define    unctrllen(ch)        __unctrllen[(ch) & 0xff]
  110.  
  111. extern char    *__unctrl[256];    /* Control strings. */
  112. extern char     __unctrllen[256];    /* Control strings length. */
  113.  
  114. /*
  115.  * A window an array of __LINE structures pointed to by the 'lines' pointer.
  116.  * A line is an array of __LDATA structures pointed to by the 'line' pointer.
  117.  *
  118.  * IMPORTANT: the __LDATA structure must NOT induce any padding, so if new
  119.  * fields are added -- padding fields with *constant values* should ensure 
  120.  * that the compiler will not generate any padding when storing an array of
  121.  *  __LDATA structures.  This is to enable consistent use of memcmp, and memcpy
  122.  * for comparing and copying arrays.
  123.  */
  124. typedef struct {
  125.     char ch;            /* the actual character */
  126.  
  127. #define    __STANDOUT    0x01          /* Added characters are standout. */
  128.     char attr;            /* attributes of character */
  129. } __LDATA;
  130.  
  131. #define __LDATASIZE    (sizeof(__LDATA))
  132.  
  133. typedef struct {
  134. #define    __ISDIRTY    0x01        /* Line is dirty. */
  135. #define __ISPASTEOL    0x02        /* Cursor is past end of line */
  136. #define __FORCEPAINT    0x04        /* Force a repaint of the line */
  137.     u_int flags;
  138.     u_int hash;            /* Hash value for the line. */
  139.     size_t *firstchp, *lastchp;    /* First and last chngd columns ptrs */
  140.     size_t firstch, lastch;        /* First and last changed columns. */
  141.     __LDATA *line;            /* Pointer to the line text. */
  142. } __LINE;
  143.  
  144. typedef struct __window {        /* Window structure. */
  145.     struct __window    *nextp, *orig;    /* Subwindows list and parent. */
  146.     size_t begy, begx;        /* Window home. */
  147.     size_t cury, curx;        /* Current x, y coordinates. */
  148.     size_t maxy, maxx;        /* Maximum values for curx, cury. */
  149.     short ch_off;            /* x offset for firstch/lastch. */
  150.     __LINE **lines;            /* Array of pointers to the lines */
  151.     __LINE  *lspace;        /* line space (for cleanup) */
  152.     __LDATA *wspace;        /* window space (for cleanup) */
  153.  
  154. #define    __ENDLINE    0x001        /* End of screen. */
  155. #define    __FLUSH        0x002        /* Fflush(stdout) after refresh. */
  156. #define    __FULLWIN    0x004        /* Window is a screen. */
  157. #define    __IDLINE    0x008        /* Insert/delete sequences. */
  158. #define    __SCROLLWIN    0x010        /* Last char will scroll window. */
  159. #define    __SCROLLOK    0x020        /* Scrolling ok. */
  160. #define    __CLEAROK    0x040        /* Clear on next refresh. */
  161. #define __WSTANDOUT    0x080        /* Standout window */
  162. #define __LEAVEOK    0x100        /* If curser left */    
  163.     u_int flags;
  164. } WINDOW;
  165.  
  166. /* Curses external declarations. */
  167. extern WINDOW    *curscr;        /* Current screen. */
  168. extern WINDOW    *stdscr;        /* Standard screen. */
  169.  
  170. extern struct termios __orig_termios;    /* Terminal state before curses */
  171. extern struct termios __baset;        /* Our base terminal state */
  172. extern int __tcaction;            /* If terminal hardware set. */
  173.  
  174. extern int     COLS;            /* Columns on the screen. */
  175. extern int     LINES;            /* Lines on the screen. */
  176.  
  177. extern char    *ttytype;        /* Full name of current terminal. */
  178.  
  179. #define    ERR    (0)            /* Error return. */
  180. #define    OK    (1)            /* Success return. */
  181.  
  182. /* Standard screen pseudo functions. */
  183. #define    addbytes(s, n)            __waddbytes(stdscr, s, n, 0)
  184. #define    addch(ch)            waddch(stdscr, ch)
  185. #define    addnstr(s, n)            waddnstr(stdscr, s, n)
  186. #define    addstr(s)            __waddbytes(stdscr, s, strlen(s), 0)
  187. #define    clear()                wclear(stdscr)
  188. #define    clrtobot()            wclrtobot(stdscr)
  189. #define    clrtoeol()            wclrtoeol(stdscr)
  190. #define    delch()                wdelch(stdscr)
  191. #define    deleteln()            wdeleteln(stdscr)
  192. #define    erase()                werase(stdscr)
  193. #define    getch()                wgetch(stdscr)
  194. #define    getstr(s)            wgetstr(stdscr, s)
  195. #define    inch()                winch(stdscr)
  196. #define    insch(ch)            winsch(stdscr, ch)
  197. #define    insertln()            winsertln(stdscr)
  198. #define    move(y, x)            wmove(stdscr, y, x)
  199. #define    refresh()            wrefresh(stdscr)
  200. #define    standend()            wstandend(stdscr)
  201. #define    standout()            wstandout(stdscr)
  202. #define    waddbytes(w, s, n)        __waddbytes(w, s, n, 0)
  203. #define    waddstr(w, s)            __waddbytes(w, s, strlen(s), 0)
  204.  
  205. /* Standard screen plus movement pseudo functions. */
  206. #define    mvaddbytes(y, x, s, n)        mvwaddbytes(stdscr, y, x, s, n)
  207. #define    mvaddch(y, x, ch)        mvwaddch(stdscr, y, x, ch)
  208. #define    mvaddnstr(y, x, s, n)        mvwaddnstr(stdscr, y, x, s, n)
  209. #define    mvaddstr(y, x, s)        mvwaddstr(stdscr, y, x, s)
  210. #define    mvdelch(y, x)            mvwdelch(stdscr, y, x)
  211. #define    mvgetch(y, x)            mvwgetch(stdscr, y, x)
  212. #define    mvgetstr(y, x, s)        mvwgetstr(stdscr, y, x, s)
  213. #define    mvinch(y, x)            mvwinch(stdscr, y, x)
  214. #define    mvinsch(y, x, c)        mvwinsch(stdscr, y, x, c)
  215. #define    mvwaddbytes(w, y, x, s, n) \
  216.     (wmove(w, y, x) == ERR ? ERR : __waddbytes(w, s, n, 0))
  217. #define    mvwaddch(w, y, x, ch) \
  218.     (wmove(w, y, x) == ERR ? ERR : waddch(w, ch))
  219. #define    mvwaddnstr(w, y, x, s, n) \
  220.     (wmove(w, y, x) == ERR ? ERR : waddnstr(w, s, n))
  221. #define    mvwaddstr(w, y, x, s) \
  222.     (wmove(w, y, x) == ERR ? ERR : __waddbytes(w, s, strlen(s), 0))
  223. #define    mvwdelch(w, y, x) \
  224.     (wmove(w, y, x) == ERR ? ERR : wdelch(w))
  225. #define    mvwgetch(w, y, x) \
  226.     (wmove(w, y, x) == ERR ? ERR : wgetch(w))
  227. #define    mvwgetstr(w, y, x, s) \
  228.     (wmove(w, y, x) == ERR ? ERR : wgetstr(w, s))
  229. #define    mvwinch(w, y, x) \
  230.     (wmove(w, y, x) == ERR ? ERR : winch(w))
  231. #define    mvwinsch(w, y, x, c) \
  232.     (wmove(w, y, x) == ERR ? ERR : winsch(w, c))
  233.  
  234. /* Psuedo functions. */
  235. #define    clearok(w, bf) \
  236.     ((bf) ? ((w)->flags |= __CLEAROK) : ((w)->flags &= ~__CLEAROK))
  237. #define    flushok(w, bf) \
  238.     ((bf) ? ((w)->flags |= __FLUSH) : ((w)->flags &= ~__FLUSH))
  239. #define    getyx(w, y, x) \
  240.     (y) = (w)->cury, (x) = (w)->curx
  241. #define    leaveok(w, bf) \
  242.     ((bf) ? ((w)->flags |= __LEAVEOK) : ((w)->flags &= ~__LEAVEOK))
  243. #define    scrollok(w, bf) \
  244.     ((bf) ? ((w)->flags |= __SCROLLOK) : ((w)->flags &= ~__SCROLLOK))
  245. #define    winch(w) \
  246.     ((w)->lines[(w)->cury]->line[(w)->curx].ch & 0177)
  247.  
  248. __BEGIN_DECLS
  249.  
  250. /* Public function prototypes. */
  251. int     box __P((WINDOW *, int, int));
  252. int     cbreak __P((void));
  253. int     delwin __P((WINDOW *));
  254. int     echo __P((void));
  255. int     endwin __P((void));
  256. char    *fullname __P((char *, char *));
  257. char    *getcap __P((char *));
  258. int     gettmode __P((void));
  259. void     idlok __P((WINDOW *, int));
  260. WINDOW    *initscr __P((void));
  261. char    *longname __P((char *, char *));
  262. int     mvcur __P((int, int, int, int));
  263. int     mvprintw __P((int, int, const char *, ...));
  264. int     mvscanw __P((int, int, const char *, ...));
  265. int     mvwin __P((WINDOW *, int, int));
  266. int     mvwprintw __P((WINDOW *, int, int, const char *, ...));
  267. int     mvwscanw __P((WINDOW *, int, int, const char *, ...));
  268. WINDOW    *newwin __P((int, int, int, int));
  269. int     nl __P((void));
  270. int     nocbreak __P((void));
  271. int     noecho __P((void));
  272. int     nonl __P((void));
  273. int     noraw __P((void));
  274. int     overlay __P((WINDOW *, WINDOW *));
  275. int     overwrite __P((WINDOW *, WINDOW *));
  276. int     printw __P((const char *, ...));
  277. int     raw __P((void));
  278. int     resetty __P((void));
  279. int     savetty __P((void));
  280. int     scanw __P((const char *, ...));
  281. int     scroll __P((WINDOW *));
  282. int     setterm __P((char *));
  283. int     sscans __P((WINDOW *, const char *, ...));
  284. WINDOW    *subwin __P((WINDOW *, int, int, int, int));
  285. int     suspendwin __P((void));
  286. int     touchline __P((WINDOW *, int, int, int));
  287. int     touchoverlap __P((WINDOW *, WINDOW *));
  288. int     touchwin __P((WINDOW *));
  289. int      vwprintw __P((WINDOW *, const char *, _BSD_VA_LIST_));
  290. int      vwscanw __P((WINDOW *, const char *, _BSD_VA_LIST_));
  291. int     waddch __P((WINDOW *, int));
  292. int     waddnstr __P((WINDOW *, const char *, int));
  293. int     wclear __P((WINDOW *));
  294. int     wclrtobot __P((WINDOW *));
  295. int     wclrtoeol __P((WINDOW *));
  296. int     wdelch __P((WINDOW *));
  297. int     wdeleteln __P((WINDOW *));
  298. int     werase __P((WINDOW *));
  299. int     wgetch __P((WINDOW *));
  300. int     wgetstr __P((WINDOW *, char *));
  301. int     winsch __P((WINDOW *, int));
  302. int     winsertln __P((WINDOW *));
  303. int     wmove __P((WINDOW *, int, int));
  304. int     wprintw __P((WINDOW *, const char *, ...));
  305. int     wrefresh __P((WINDOW *));
  306. int     wscanw __P((WINDOW *, const char *, ...));
  307. int     wstandend __P((WINDOW *));
  308. int     wstandout __P((WINDOW *));
  309. int     vwprintw __P((WINDOW *, const char *, _BSD_VA_LIST_));
  310.  
  311. /* Private functions that are needed for user programs prototypes. */
  312. void     __cputchar __P((int));
  313. int     __waddbytes __P((WINDOW *, const char *, int, int));
  314.  
  315. /* Private functions. */
  316. #ifdef _CURSES_PRIVATE
  317. void     __CTRACE __P((const char *, ...));
  318. u_int     __hash __P((char *, int));
  319. void     __id_subwins __P((WINDOW *));
  320. int     __mvcur __P((int, int, int, int, int));
  321. void     __restore_stophandler __P((void));
  322. void     __set_stophandler __P((void));
  323. void     __set_subwin __P((WINDOW *, WINDOW *));
  324. void     __startwin __P((void));
  325. void     __stop_signal_handler __P((int));
  326. void     __swflags __P((WINDOW *));
  327. int     __touchline __P((WINDOW *, int, int, int, int));
  328. int     __touchwin __P((WINDOW *));
  329. char    *__tscroll __P((const char *, int, int));
  330. int     __waddch __P((WINDOW *, __LDATA *));
  331.  
  332. /* Private #defines. */
  333. #define    min(a,b)    (a < b ? a : b)
  334. #define    max(a,b)    (a > b ? a : b)
  335.  
  336. /* Private externs. */
  337. extern int     __echoit;
  338. extern int     __endwin;
  339. extern int     __pfast;
  340. extern int     __rawmode;
  341. extern int     __noqch;
  342. #endif
  343.  
  344. #if 0
  345. /* Termcap functions. */
  346. int     tgetent __P((char *, char *));
  347. int     tgetnum __P((char *));
  348. int     tgetflag __P((char *));
  349. char    *tgetstr __P((char *, char **));
  350. char    *tgoto __P((char *, int, int));
  351. int     tputs __P((char *, int, void (*)(int)));
  352. #endif
  353.  
  354. __END_DECLS
  355.  
  356. #endif /* !_CURSES_H_ */
  357.