home *** CD-ROM | disk | FTP | other *** search
/ The Best of Mecomp Multimedia 2 / MECOMP-CD-II.iso / amiga / tools / workbench / fv-220 / curses.h next >
Encoding:
C/C++ Source or Header  |  1997-12-09  |  7.5 KB  |  228 lines

  1. /*        header defs just for OS-9 and OS-9000 curses.l */
  2.  
  3. #include <stdio.h>
  4. #include <errno.h>
  5.  
  6. /* private stuff */
  7. extern FILE *_stdin, *_stdout;
  8.  
  9. #define ECHOON 1
  10. #define ECHOOFF 0
  11. #define    TRUE    (1)
  12. #define    FALSE    (0)
  13. #define    ERR    (0)
  14. #define    OK    (1)
  15. #define SCFDEV        0
  16. #define OTHERDEV    1
  17. #define TCAPSLEN 300
  18. #define TTYNAMESIZE 50
  19.  
  20. #define bool char
  21. #define reg register
  22.  
  23. /*    Termcap defs */
  24.  
  25. char *tgetstr(), *tgoto();
  26. char *getenv();
  27.  
  28.  
  29. extern bool        AM, BS, CA, DA, DB, EO, GT, HZ, IN, MI, MS, NC, OS, UL, XN;
  30.  
  31. extern char        *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *DC, *DL, *DM, *DO,
  32.         *ED, *EI, *HO, *IC, *IM, *IP, *LL, *MA, *ND, *NL, *SE, *SF,
  33.         *SO, *SR_, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VE, *VS;
  34.  
  35. extern char PC_;
  36.  
  37. extern int SG;
  38. extern int LINES, COLS;  /* lines and columns on physical terminal screen */
  39.  
  40.  
  41. extern short ospeed;
  42. extern char termbuf[1024], tcapbuf[TCAPSLEN];
  43.  
  44.  
  45. /* physical terminal defs */
  46.  
  47.  
  48. extern NONL, UPPERCASE;
  49. extern _devtype;
  50.  
  51. extern int ttcol, ttrow;  /* cursor location */
  52. extern int tt_tabsiz;
  53.  
  54. int tt_mv(), tt_clrln(), tt_clrscr(), tt_clrpag(), tt_so(), tt_se();
  55. int tt_init(), tt_putc(), tt_puts(), tt_flush();
  56.  
  57. #define tt_mvputc(r,c,ch) (tt_mv(r,c)==ERR ? ERR : tt_putc(ch))
  58. #define tt_mvputs(r,c,str) (tt_mv(r,c) == ERR ? ERR : tt_puts(str))
  59. #define tt_mvclrln(r,c) (tt_mv(r,c) == ERR : ERR : tt_clrln())
  60. #define tt_mvclrpag(r,c) (tt_mv(r,c) == ERR ? ERR : tt_clrpag())
  61. #define tt_mvso(r,c) (tt_mv(r,c) == ERR ? ERR : tt_so())
  62. #define tt_mvse(r,c) (tt_mv(r,c) == ERR ? ERR : tt_se())
  63.  
  64. /* curses defs */
  65.  
  66. typedef struct WINDOW {
  67.     struct WINDOW    *w_next,  /* next window in list */
  68.                     *w_prev;  /* previous window */
  69.     struct WINBUF    *w_buf;  /* text buffer for this window */
  70.     int                w_hrow,  /* home row on screen */
  71.                     w_hcol,  /* home column on screen */
  72.                     w_orow,  /* offset row in buffer */
  73.                     w_ocol,  /* offset column in buffer */
  74.                     w_rows,  /* number of lines of window on screen */
  75.                     w_cols,  /* number of columns of window on screen */
  76.                     w_wrow,  /* cursor row location in the window */
  77.                     w_wcol,  /* cursor column */
  78.                     w_sflag,  /* flags used by the windowing system */
  79.                     w_aflag;  /* flags for use by the application */
  80.     bool            w_clear,  /* clear screen flag */
  81.                     w_scroll,  /* scroll flag */
  82.                     w_leave;  /* leave cursor flag */
  83.     struct WINLIN    *w_bline;  /* a pointer to the buffer line the cursor is on*/
  84. } WINDOW;
  85.  
  86. #define W_HIDE    0x01  /* flag that says window should not be displayed */
  87. #define W_SCREEN    0x02  /* window is a screen */
  88. #define W_TOUCH        0x04  /* ignore output optimization */
  89. #define W_NODELAY    0x08  /* if set, getch will return if no data */
  90. #define W_SCROLL    0x10  /* window has very recently been scrolled */
  91.                           /* i.e., no writes have occurred since scroll */
  92. #define W_STANDOUT    0x0100  /* output to window should be in standout mode */
  93.  
  94.  
  95. typedef struct WINBUF {
  96.     struct WINBUF    *b_next,  /* next buffer in list */
  97.                     *b_prev;  /* previous buffer */
  98.     struct WINLIN    *b_text;  /* the first line of text in this buffer */
  99.     int                b_wcnt,  /* number of windows looking at this buffer */
  100.                     b_lines,  /* number of lines in this buffer */
  101.                     b_lsize,  /* default size to allocate for new lines */
  102.                     b_sflag,  /* flags used by the windowing system */
  103.                     b_aflag;  /* flags for use by the application */
  104. } WINBUF;
  105.  
  106. typedef struct WINLIN {
  107.     struct WINLIN    *l_next,  /* next line of buffer */
  108.                     *l_prev;  /* previous line */
  109.     int                l_size,  /* space allocated for line */
  110.                     l_sflag,  /* flags used by windowing system */
  111.                     l_aflag;  /* flags for use by the application */
  112.     char            l_text[1];  /* the characters in the line */
  113. } WINLIN;
  114.  
  115. #define L_CLEAR    0x01  /* line contains all blanks */
  116.  
  117. extern WINDOW *winhead;  /* the root of the window list */
  118. extern WINBUF *bufhead;  /* the root of the buffer list */
  119.  
  120. extern WINDOW *curscr, *virscr, *stdscr;  /* standard windows */
  121.  
  122. extern FILE *bufin;
  123.  
  124. extern bool _echo, _crmode, _rawmode, _typeahead, _nlmode, My_term;
  125.  
  126. extern char *Def_term, ttytype[TTYNAMESIZE];
  127.  
  128. WINDOW *newwin(), *subwin(), *w_open(), *w_linkbuf();
  129.  
  130. WINBUF *w_bufopen(), *newbuf();
  131.  
  132. char *w_addline();
  133.  
  134.  
  135. /* macro functions */
  136. #define clearok(win,b) (win->w_clear = b)
  137. #define leaveok(win,b) (win->w_leave = b)
  138. #define scrollok(win,b) (win->w_scroll = b)
  139. #define getyx(win,r,c) (r = win->w_wrow, c = win->w_wcol)
  140. #define winch(win) (win->w_bline->l_text[win->w_ocol + win->w_wcol] & 0x7f)
  141. #define wnoutrefresh(win) paint(win)
  142. #define doupdate() update(virscr)
  143. #define hide(win) (win->w_sflag |= W_HIDE)
  144. #define unhide(win) (win->w_sflag &= ~W_HIDE)
  145.  
  146. /* stdscr functions */
  147.  
  148. #define    addch(ch)    (waddch(stdscr, ch))
  149. #define    getch()        (wgetch(stdscr))
  150. #define    addstr(str)    (waddstr(stdscr, str))
  151. #define    getstr(str)    (wgetstr(stdscr, str))
  152. #define    move(y, x)    (wmove(stdscr, y, x))
  153. #define    clear()        (wclear(stdscr))
  154. #define    erase()        (werase(stdscr))
  155. #define    clrtobot()    (wclrtobot(stdscr))
  156. #define    clrtoeol()    (wclrtoeol(stdscr))
  157. #define    insertln()    (winsertln(stdscr))
  158. #define    deleteln()    (wdeleteln(stdscr))
  159. #define    refresh()    (wrefresh(stdscr))
  160. #define    inch()        (winch(stdscr))
  161. #define    insch(c)    (winsch(stdscr,c))
  162. #define    delch()        (wdelch(stdscr))
  163. #define    standout()    (wattron(stdscr, W_STANDOUT))
  164. #define    standend()    (wattrset(stdscr,0))
  165. #define    wstandout(win)    (wattron(win, W_STANDOUT))
  166. #define    wstandend(win)    (wattrset(win, 0))
  167.  
  168. /* mv function defines */
  169.  
  170. #define    mvwaddch(win,y,x,ch)    (wmove(win,y,x)==ERR?ERR:waddch(win,ch))
  171. #define    mvwgetch(win,y,x)    (wmove(win,y,x)==ERR?ERR:wgetch(win))
  172. #define    mvwaddstr(win,y,x,str)    (wmove(win,y,x)==ERR?ERR:waddstr(win,str))
  173. #define mvwgetstr(win,y,x,str)  (wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
  174. #define    mvwinch(win,y,x)    (wmove(win,y,x) == ERR? ERR : winch(win))
  175. #define    mvwdelch(win,y,x)    (wmove(win,y,x) == ERR? ERR : wdelch(win))
  176. #define    mvwinsch(win,y,x,c)    (wmove(win,y,x) == ERR? ERR : winsch(win,c))
  177. #define mvwclrtobot(win,r,c) (wmove(win,r,c) == ERR? ERR: wclrtobot(win))
  178. #define mvwclrtoeol(win,r,c) (wmove(win,r,c)== ERR? ERR: wclrtoeol(win))
  179. #define mvwinsertln(win,r,c) (wmove(win,r,c) == ERR? ERR: winsertln(win))
  180. #define mvwdeleteln(win,r,c) (wmove(win,r,c) == ERR? ERR: wdeleteln(win))
  181.  
  182. #define    mvaddch(y,x,ch)        mvwaddch(stdscr,y,x,ch)
  183. #define    mvgetch(y,x)        mvwgetch(stdscr,y,x)
  184. #define    mvaddstr(y,x,str)    mvwaddstr(stdscr,y,x,str)
  185. #define mvgetstr(y,x,str)       mvwgetstr(stdscr,y,x,str)
  186. #define    mvinch(y,x)        mvwinch(stdscr,y,x)
  187. #define    mvdelch(y,x)        mvwdelch(stdscr,y,x)
  188. #define    mvinsch(y,x,c)        mvwinsch(stdscr,y,x,c)
  189. #define mvclrtobot(r,c) mvwclrtobot(stdscr,r,c)
  190. #define mvclrtoeol(r,c) mvwclrtoeol(stdscr,r,c)
  191. #define mvinsertln(r,c) mvwinsertln(stdscr,r,c)
  192. #define mvdeleteln(r,c) mvwdeleteln(stdscr,r,c)
  193.  
  194. #define crmode() _crmode = TRUE
  195. #define nocrmode() _crmode = FALSE
  196. #define raw() _rawmode = TRUE
  197. #define noraw() _rawmode = FALSE
  198.  
  199. #define restoremodes() (_echo ? echo() : noecho())
  200.  
  201.  
  202. /* some system five functions */
  203. #define REFRESH 256
  204. #define OUT 257
  205. #define prefresh(pad, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol) \
  206. _pfresh(pad, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol, REFRESH)
  207. #define pnoutrefresh(pad, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol) \
  208. _pfresh(pad, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol, OUT)
  209.  
  210. #define tbreak() (_typeahead && chkin())
  211.  
  212. #define cbreak() crmode()
  213. #define nocbreak() nocrmode()
  214.  
  215. #define A_STANDOUT W_STANDOUT
  216. #define A_REVERSE 0
  217. #define A_BOLD 0
  218. #define A_DIM 0
  219. #define A_BLINK 0
  220. #define A_UNDERLINE 0
  221. #define A_MASK (A_STANDOUT|A_REVERSE|A_BOLD|A_DIM|A_BLINK|A_UNDERLINE)
  222.  
  223. #define attron(attr) wattron(stdscr, attr)
  224. #define attroff(attr) wattroff(stdscr, attr)
  225. #define attrset(attr) wattrset(stdscr, attr)
  226.  
  227.  
  228.