home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / curses_391.lzh / Curses / curses.h < prev    next >
C/C++ Source or Header  |  1990-10-27  |  7KB  |  198 lines

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