home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 472b.lha / Curses_v1.22 / curses.h < prev    next >
C/C++ Source or Header  |  1991-02-09  |  8KB  |  213 lines

  1. /*
  2.  *
  3.  *    Author    : Simon J Raybould.    (sie@fulcrum.bt.co.uk).
  4.  *
  5.  *    Date      : v1.00a    16th Feb 1990
  6.  *                v1.10     30th Sep 1990
  7.  *                v1.20a     4th Oct 1990 (very limited distribution)
  8.  *                v1.20      7th Nov 1990
  9.  *                v1.21      2nd Dec 1990
  10.  *
  11.  *    Desc    : Header file for my AMIGA CURSES package.
  12.  *              This should be included instead of stdio.h, this will
  13.  *              include stdio.h for you.
  14.  *              This file is Public Domain but please leave the name
  15.  *              of the author intact.
  16.  *
  17.  */
  18.  
  19. #ifndef CURSES_H
  20. #define CURSES_H
  21.  
  22. #ifndef stdin    /* May be a better way to do this !! */
  23. #include <stdio.h>
  24. #endif /* stdin */
  25.  
  26. #ifndef TRUE
  27. #define TRUE      1 
  28. #define FALSE     0 
  29. #endif /* TRUE */
  30.  
  31. #define ERR      -1
  32. #define OK        0
  33.  
  34. extern int LINES, COLS;
  35.  
  36.  
  37. /*
  38.  *    Macros
  39.  */
  40.  
  41. #define addch(c)                   waddch(stdscr, (c))
  42. #define addstr(str)                waddstr(stdscr, (str))
  43. #define attrset(attr)              wattrset(stdscr, (attr))
  44. #define attron(attr)               wattron(stdscr, (attr))
  45. #define attroff(attr)              wattroff(stdscr, (attr))
  46. #define clear()                    wclear(stdscr)
  47. #define clrtoeol()                 wclrtoeol(stdscr)
  48. #define clrtobot()                 wclrtobot(stdscr)
  49. #define delch()                    wdelch(stdscr)
  50. #define deleteln()                 wdeleteln(stdscr)
  51. #define erase()                    werase(stdscr)
  52. #define inch()                     winch(stdscr)
  53. #define insch(c)                   winsch(stdscr, (c))
  54. #define insertln()                 winsertln(stdscr)
  55. #define getch()                    wgetch(stdscr)
  56. #define getstr(ptr)                wgetstr(stdscr, (ptr))
  57. #define getyx(win,y,x)             ((y) = getcury(win), (x) = getcurx(win))
  58. #define getbegyx(win,y,x)          ((y) = getbegy(win), (x) = getbegx(win))
  59. #define getmaxyx(win,y,x)          ((y) = getmaxy(win), (x) = getmaxx(win))
  60. #define getparyx(win,y,x)          ((y) = getpary(win), (x) = getparx(win))
  61. #define getcury(win)               ((win)->_cury)
  62. #define getcurx(win)               ((win)->_curx)
  63. #define getbegy(win)               ((win)->_begy)
  64. #define getbegx(win)               ((win)->_begx)
  65. #define getmaxy(win)               ((win)->_maxy)
  66. #define getmaxx(win)               ((win)->_maxx)
  67. #define getpary(win)               ((win)->_pary)
  68. #define getparx(win)               ((win)->_parx)
  69. #define getbkgd(win)               ((win)->_bkgd)
  70. #define getattrs(win)              ((win)->_attrs)
  71. #define move(line, col)            wmove(stdscr, (line), (col))
  72. #define mvdelch(y, x)              (move((y), (x)), delch())
  73. #define mvwdelch(win, y, x)        (wmove((win),(y),(x)),wdelch((win)))
  74. #define mvgetch(y, x)              (move((y), (x)), getch())
  75. #define mvwgetch(win, y, x)        (wmove((win),(y),(x)),wgetch((win)))
  76. #define mvgetstr(y, x, ptr)        (move((y), (x)), getstr((ptr)))
  77. #define mvwgetstr(win, y, x, ptr)  (wmove((win), (y), (x)), \
  78.                    wgetstr((win), (ptr)))
  79. #define mvinsch(y, x, c)           (move((y), (x)), insch((c)))
  80. #define mvwinsch(win, y, x, c)     (wmove((win), (y), (x)), \
  81.                    winsch((win), (c)))
  82. #define mvinch(y, x)               (move((y), (x)), inch())
  83. #define mvwinch(win, y, x)         (wmove((win), (y), (x)),winch((win)))
  84. #define mvaddch(y, x, c)           (move((y), (x)), addch((c)))
  85. #define mvwaddch(win, y, x, c)     (wmove((win), (y), (x)), \
  86.                    waddch((win), (c)))
  87. #define mvaddstr(y, x, str)        (move((y), (x)), addstr((str)))
  88. #define mvwaddstr(win, y, x, str)  (wmove((win), (y), (x)), \
  89.                    waddstr((win), (str)))
  90. #define refresh()                  wrefresh(stdscr)
  91. #define noutrefresh()              wnoutrefresh(stdscr)
  92. #define setscrreg(top, bottom)     wsetscrreg(stdscr, (top), (bottom))
  93. #define standend()                 wstandend(stdscr)
  94. #define standout()                 wstandout(stdscr)
  95.  
  96. /*
  97.  *    NON STANDARD MACROS
  98.  */
  99.  
  100. #define pencolour(n)    wpencolour(stdscr, (n))
  101.  
  102. /*
  103.  *    Colours
  104.  */
  105.  
  106. #define COLOR_BLACK     0     /* Black */
  107. #define COLOR_WHITE     1     /* White */
  108. #define COLOR_YELLOW    2     /* Yellow */
  109. #define COLOR_ORANGE    3     /* Orange */
  110. #define COLOR_BLUE      4     /* Blue */
  111. #define COLOR_MAGENTA   5     /* Magenta */
  112. #define COLOR_CYAN      6     /* Cyan */
  113. #define COLOR_PWHITE    7     /* Paper White */
  114. #define COLOR_BROWN     8     /* Brown */
  115. #define COLOR_RED       9     /* Red */
  116. #define COLOR_LGREEN    10    /* Light Green */
  117. #define COLOR_TAN       11    /* Well err Tan really */
  118. #define COLOR_BBLUE     12    /* Different to BLUE */
  119. #define COLOR_PURPLE    13    /* Pomegranate colour */
  120. #define COLOR_GREEN     14    /* The Bla Bla Grass of home and all that */
  121. #define COLOR_GREY      15    /* Dead giveaway that one */
  122.  
  123.  
  124. /*
  125.  *    Video Attributes.
  126.  */
  127.  
  128. #define A_NORMAL      0000000
  129. #define A_STANDOUT    0000200
  130. #define _STANDOUT     A_STANDOUT    /* for compatibility with old curses */
  131. #define A_UNDERLINE   0000400
  132. #define A_REVERSE     0001000
  133. #define A_BLINK       0002000
  134. #define A_DIM         0004000
  135. #define A_BOLD        0010000
  136.  
  137. #define A_ATTRIBUTES  0377600
  138. #define A_CHARTEXT    0000177
  139.  
  140.  
  141.  
  142. #define bool    char
  143. #define reg     register
  144.  
  145. struct _win_st {
  146.   short   _cury, _curx;
  147.   short   _maxy, _maxx;
  148.   short   _begy, _begx;
  149.   short   _flags;
  150.   short   _attrs;
  151.   bool    _clear;    /* T=clear on every refresh set by clearok() */
  152.   bool    _cls;    /* T=clear on next refresh set by clear() */
  153.   bool    _leave;
  154.   bool    _scroll;
  155.   bool    _use_idl;
  156.   bool    _use_keypad;    /* 0=no, 1=yes, 2=yes/timeout */
  157.   bool    _use_meta;      /* T=use the meta key */
  158.   bool    _nodelay;       /* T=don't wait for tty input */
  159.   char    **_y;
  160.   short   *_firstch;
  161.   short   *_lastch;
  162.   short   _tmarg,_bmarg;
  163.   char    *_WinStat;        /* Window state SJR */
  164. };
  165.  
  166. typedef struct _win_st  WINDOW;
  167. extern WINDOW *stdscr, *curscr;
  168.  
  169. /* Funny "characters" enabled for various special function keys for input */
  170. #define KEY_BREAK       0401            /* break key (unreliable) */
  171. #define KEY_DOWN        0402            /* The four arrow keys ... */
  172. #define KEY_UP          0403
  173. #define KEY_LEFT        0404
  174. #define KEY_RIGHT       0405            /* ... */
  175. #define KEY_HOME        0406            /* Home key (upward+left arrow) */
  176. #define KEY_BACKSPACE   0407            /* backspace (unreliable) */
  177. #define KEY_F0          0410            /* Function keys.  Space for 64 */
  178. #define KEY_F(n)        (KEY_F0+(n))    /* keys is reserved. */
  179. #define KEY_DL          0510            /* Delete line */
  180. #define KEY_IL          0511            /* Insert line */
  181. #define KEY_DC          0512            /* Delete character */
  182. #define KEY_IC          0513            /* Insert char or enter insert mode */
  183. #define KEY_EIC         0514            /* Exit insert char mode */
  184. #define KEY_CLEAR       0515            /* Clear screen */
  185. #define KEY_EOS         0516            /* Clear to end of screen */
  186. #define KEY_EOL         0517            /* Clear to end of line */
  187. #define KEY_SF          0520            /* Scroll 1 line forward */
  188. #define KEY_SR          0521            /* Scroll 1 line backwards (reverse) */
  189. #define KEY_NPAGE       0522            /* Next page */
  190. #define KEY_PPAGE       0523            /* Previous page */
  191. #define KEY_STAB        0524            /* Set tab */
  192. #define KEY_CTAB        0525            /* Clear tab */
  193. #define KEY_CATAB       0526            /* Clear all tabs */
  194. #define KEY_ENTER       0527            /* Enter or send (unreliable) */
  195. #define KEY_SRESET      0530            /* soft (partial) reset (unreliable) */
  196. #define KEY_RESET       0531            /* reset or hard reset (unreliable) */
  197. #define KEY_PRINT       0532            /* print or copy */
  198. #define KEY_LL          0533            /* home down or bottom (lower left) */
  199. /* The keypad is arranged like this: */
  200. /*    a1    up    a3   */
  201. /*   left   b2  right  */
  202. /*    c1   down   c3   */
  203. #define KEY_A1          0534            /* upper left of keypad */
  204. #define KEY_A3          0535            /* upper right of keypad */
  205. #define KEY_B2          0536            /* center of keypad */
  206. #define KEY_C1          0537            /* lower left of keypad */
  207. #define KEY_C3          0540            /* lower right of keypad */
  208. #define KEY_HELP        0553            /* Help Key */
  209.  
  210. WINDOW *newwin(), *subwin();
  211.  
  212. #endif /* CURSES_H */
  213.