home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Spezial / SPEZIAL2_97.zip / SPEZIAL2_97.iso / ANWEND / EDITOR / NVI179B / NVI179B.ZIP / curses / curses.h < prev    next >
C/C++ Source or Header  |  1996-06-14  |  11KB  |  348 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.5 (Berkeley) 4/29/95
  34.  */
  35.  
  36. #ifndef _CURSES_H_
  37. #define    _CURSES_H_
  38.  
  39. #ifdef _CURSES_PRIVATE
  40. #include "config.h"
  41. #endif
  42.  
  43. #include <sys/types.h>
  44. #include <stdio.h>
  45.  
  46. #ifdef _CURSES_PRIVATE
  47. #include "port.h"
  48. #endif
  49.  
  50. /*
  51.  * The following #defines and #includes are present for backward
  52.  * compatibility only.  They should not be used in future code.
  53.  *
  54.  * START BACKWARD COMPATIBILITY ONLY.
  55.  */
  56. #ifndef _CURSES_PRIVATE
  57. #ifndef __cplusplus
  58. #define    bool    char
  59. #endif
  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. /* END BACKWARD COMPATIBILITY ONLY. */
  101.  
  102. /* 8-bit ASCII characters. */
  103. #define    unctrl(c)        __unctrl[(c) & 0xff]
  104. #define    unctrllen(ch)        __unctrllen[(ch) & 0xff]
  105.  
  106. extern char    *__unctrl[256];    /* Control strings. */
  107. extern char     __unctrllen[256];    /* Control strings length. */
  108.  
  109. /*
  110.  * A window an array of __LINE structures pointed to by the 'lines' pointer.
  111.  * A line is an array of __LDATA structures pointed to by the 'line' pointer.
  112.  *
  113.  * IMPORTANT: the __LDATA structure must NOT induce any padding, so if new
  114.  * fields are added -- padding fields with *constant values* should ensure 
  115.  * that the compiler will not generate any padding when storing an array of
  116.  *  __LDATA structures.  This is to enable consistent use of memcmp, and memcpy
  117.  * for comparing and copying arrays.
  118.  */
  119. typedef struct {
  120.     char ch;            /* the actual character */
  121.  
  122. #define    __STANDOUT    0x01          /* Added characters are standout. */
  123.     char attr;            /* attributes of character */
  124. } __LDATA;
  125.  
  126. #define __LDATASIZE    (sizeof(__LDATA))
  127.  
  128. typedef struct {
  129. #define    __ISDIRTY    0x01        /* Line is dirty. */
  130. #define __ISPASTEOL    0x02        /* Cursor is past end of line */
  131. #define __FORCEPAINT    0x04        /* Force a repaint of the line */
  132.     unsigned int flags;
  133.     unsigned int hash;        /* Hash value for the line. */
  134.     size_t *firstchp, *lastchp;    /* First and last chngd columns ptrs */
  135.     size_t firstch, lastch;        /* First and last changed columns. */
  136.     __LDATA *line;            /* Pointer to the line text. */
  137. } __LINE;
  138.  
  139. typedef struct __window {        /* Window structure. */
  140.     struct __window    *nextp, *orig;    /* Subwindows list and parent. */
  141.     size_t begy, begx;        /* Window home. */
  142.     size_t cury, curx;        /* Current x, y coordinates. */
  143.     size_t maxy, maxx;        /* Maximum values for curx, cury. */
  144.     short ch_off;            /* x offset for firstch/lastch. */
  145.     __LINE **lines;            /* Array of pointers to the lines */
  146.     __LINE  *lspace;        /* line space (for cleanup) */
  147.     __LDATA *wspace;        /* window space (for cleanup) */
  148.  
  149. #define    __ENDLINE    0x001        /* End of screen. */
  150. #define    __FLUSH        0x002        /* Fflush(stdout) after refresh. */
  151. #define    __FULLWIN    0x004        /* Window is a screen. */
  152. #define    __IDLINE    0x008        /* Insert/delete sequences. */
  153. #define    __SCROLLWIN    0x010        /* Last char will scroll window. */
  154. #define    __SCROLLOK    0x020        /* Scrolling ok. */
  155. #define    __CLEAROK    0x040        /* Clear on next refresh. */
  156. #define __WSTANDOUT    0x080        /* Standout window */
  157. #define __LEAVEOK    0x100        /* If curser left */    
  158.     unsigned int flags;
  159. } WINDOW;
  160.  
  161. /* Curses external declarations. */
  162. extern WINDOW    *curscr;        /* Current screen. */
  163. extern WINDOW    *stdscr;        /* Standard screen. */
  164.  
  165. extern struct termios __orig_termios;    /* Terminal state before curses */
  166. extern struct termios __baset;        /* Our base terminal state */
  167. extern int __tcaction;            /* If terminal hardware set. */
  168.  
  169. extern int     COLS;            /* Columns on the screen. */
  170. extern int     LINES;            /* Lines on the screen. */
  171.  
  172. #define    ERR    (0)            /* Error return. */
  173. #define    OK    (1)            /* Success return. */
  174.  
  175. /* Standard screen pseudo functions. */
  176. #define    addbytes(s, n)            __waddbytes(stdscr, s, n, 0)
  177. #define    addch(ch)            waddch(stdscr, ch)
  178. #define    addnstr(s, n)            waddnstr(stdscr, s, n)
  179. #define    addstr(s)            __waddbytes(stdscr, s, strlen(s), 0)
  180. #define    clear()                wclear(stdscr)
  181. #define    clrtobot()            wclrtobot(stdscr)
  182. #define    clrtoeol()            wclrtoeol(stdscr)
  183. #define    delch()                wdelch(stdscr)
  184. #define    deleteln()            wdeleteln(stdscr)
  185. #define    erase()                werase(stdscr)
  186. #define    getch()                wgetch(stdscr)
  187. #define    getstr(s)            wgetstr(stdscr, s)
  188. #define    inch()                winch(stdscr)
  189. #define    insch(ch)            winsch(stdscr, ch)
  190. #define    insertln()            winsertln(stdscr)
  191. #define    move(y, x)            wmove(stdscr, y, x)
  192. #define    refresh()            wrefresh(stdscr)
  193. #define    standend()            wstandend(stdscr)
  194. #define    standout()            wstandout(stdscr)
  195. #define    waddbytes(w, s, n)        __waddbytes(w, s, n, 0)
  196. #define    waddstr(w, s)            __waddbytes(w, s, strlen(s), 0)
  197.  
  198. /* Standard screen plus movement pseudo functions. */
  199. #define    mvaddbytes(y, x, s, n)        mvwaddbytes(stdscr, y, x, s, n)
  200. #define    mvaddch(y, x, ch)        mvwaddch(stdscr, y, x, ch)
  201. #define    mvaddnstr(y, x, s, n)        mvwaddnstr(stdscr, y, x, s, n)
  202. #define    mvaddstr(y, x, s)        mvwaddstr(stdscr, y, x, s)
  203. #define    mvdelch(y, x)            mvwdelch(stdscr, y, x)
  204. #define    mvgetch(y, x)            mvwgetch(stdscr, y, x)
  205. #define    mvgetstr(y, x, s)        mvwgetstr(stdscr, y, x, s)
  206. #define    mvinch(y, x)            mvwinch(stdscr, y, x)
  207. #define    mvinsch(y, x, c)        mvwinsch(stdscr, y, x, c)
  208. #define    mvwaddbytes(w, y, x, s, n) \
  209.     (wmove(w, y, x) == ERR ? ERR : __waddbytes(w, s, n, 0))
  210. #define    mvwaddch(w, y, x, ch) \
  211.     (wmove(w, y, x) == ERR ? ERR : waddch(w, ch))
  212. #define    mvwaddnstr(w, y, x, s, n) \
  213.     (wmove(w, y, x) == ERR ? ERR : waddnstr(w, s, n))
  214. #define    mvwaddstr(w, y, x, s) \
  215.     (wmove(w, y, x) == ERR ? ERR : __waddbytes(w, s, strlen(s), 0))
  216. #define    mvwdelch(w, y, x) \
  217.     (wmove(w, y, x) == ERR ? ERR : wdelch(w))
  218. #define    mvwgetch(w, y, x) \
  219.     (wmove(w, y, x) == ERR ? ERR : wgetch(w))
  220. #define    mvwgetstr(w, y, x, s) \
  221.     (wmove(w, y, x) == ERR ? ERR : wgetstr(w, s))
  222. #define    mvwinch(w, y, x) \
  223.     (wmove(w, y, x) == ERR ? ERR : winch(w))
  224. #define    mvwinsch(w, y, x, c) \
  225.     (wmove(w, y, x) == ERR ? ERR : winsch(w, c))
  226.  
  227. /* Psuedo functions. */
  228. #define    clearok(w, bf) \
  229.     ((bf) ? ((w)->flags |= __CLEAROK) : ((w)->flags &= ~__CLEAROK))
  230. #define    flushok(w, bf) \
  231.     ((bf) ? ((w)->flags |= __FLUSH) : ((w)->flags &= ~__FLUSH))
  232. #define    getyx(w, y, x) \
  233.     (y) = (w)->cury, (x) = (w)->curx
  234. #define    leaveok(w, bf) \
  235.     ((bf) ? ((w)->flags |= __LEAVEOK) : ((w)->flags &= ~__LEAVEOK))
  236. #define    scrollok(w, bf) \
  237.     ((bf) ? ((w)->flags |= __SCROLLOK) : ((w)->flags &= ~__SCROLLOK))
  238. #define    winch(w) \
  239.     ((w)->lines[(w)->cury]->line[(w)->curx].ch & 0177)
  240.  
  241. /* Public function prototypes. */
  242. int     box();
  243. int     cbreak();
  244. int     delwin();
  245. int     echo();
  246. int     endwin();
  247. char    *fullname();
  248. char    *getcap();
  249. int     gettmode();
  250. void     idlok();
  251. WINDOW    *initscr();
  252. char    *longname();
  253. int     mvcur();
  254. int     mvprintw();
  255. int     mvscanw();
  256. int     mvwin();
  257. int     mvwprintw();
  258. int     mvwscanw();
  259. WINDOW    *newwin();
  260. int     nl();
  261. int     nocbreak();
  262. int     noecho();
  263. int     nonl();
  264. int     noraw();
  265. int     overlay();
  266. int     overwrite();
  267. int     printw();
  268. int     raw();
  269. int     resetty();
  270. int     savetty();
  271. int     scanw();
  272. int     scroll();
  273. int     setterm();
  274. int     sscans();
  275. WINDOW    *subwin();
  276. int     suspendwin();
  277. int     touchline();
  278. int     touchoverlap();
  279. int     touchwin();
  280. int      vwprintw();
  281. int      vwscanw();
  282. int     waddch();
  283. int     waddnstr();
  284. int     wclear();
  285. int     wclrtobot();
  286. int     wclrtoeol();
  287. int     wdelch();
  288. int     wdeleteln();
  289. int     werase();
  290. int     wgetch();
  291. int     wgetstr();
  292. int     winsch();
  293. int     winsertln();
  294. int     wmove();
  295. int     wprintw();
  296. int     wrefresh();
  297. int     wscanw();
  298. int     wstandend();
  299. int     wstandout();
  300. int     vwprintw();
  301.  
  302. /* Private functions that are needed for user programs prototypes. */
  303. void     __cputchar();
  304. int     __waddbytes();
  305.  
  306. /* Private functions. */
  307. #ifdef _CURSES_PRIVATE
  308. void     __CTRACE();
  309. unsigned int __hash();
  310. void     __id_subwins();
  311. int     __mvcur();
  312. void     __restore_stophandler();
  313. void     __set_stophandler();
  314. void     __set_subwin();
  315. void     __startwin();
  316. void     __stop_signal_handler();
  317. void     __swflags();
  318. int     __touchline();
  319. int     __touchwin();
  320. char    *__tscroll();
  321. int     __waddch();
  322.  
  323. /* Private #defines. */
  324. #ifndef min
  325. #define    min(a,b)    (a < b ? a : b)
  326. #endif
  327. #ifndef max
  328. #define    max(a,b)    (a > b ? a : b)
  329. #endif
  330.  
  331. /* Private externs. */
  332. extern int     __echoit;
  333. extern int     __endwin;
  334. extern int     __pfast;
  335. extern int     __rawmode;
  336. extern int     __noqch;
  337. #endif
  338.  
  339. /* Termcap functions. */
  340. int     tgetent();
  341. int     tgetnum();
  342. int     tgetflag();
  343. char    *tgetstr();
  344. char    *tgoto();
  345. int     tputs();
  346.  
  347. #endif /* !_CURSES_H_ */
  348.