home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / EFFO / pd7.lzh / DEFS / curses.h next >
Text File  |  1990-04-01  |  8KB  |  230 lines

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