home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / mincom15.zip / window.h < prev    next >
C/C++ Source or Header  |  1993-10-14  |  5KB  |  228 lines

  1. /*
  2.  * This file is part of the Minicom Communications Program,
  3.  * written by Miquel van Smoorenburg 1991/1992/1993.
  4.  *
  5.  * Window Header File.
  6.  *
  7.  * 1991/10/09 Miquel van Smoorenburg.
  8.  */
  9.  
  10. /*
  11.  * One character is contained in a "ELM"
  12.  */
  13. typedef struct _elm {
  14.   char value;
  15.   char attr;
  16.   char color;
  17. } ELM;
  18.  
  19. /*
  20.  * Control struct of a window
  21.  */
  22. typedef struct _win {
  23.   int x1, y1, x2, y2;    /* Coordinates */
  24.   int sy1, sy2;        /* Scrolling region */
  25.   int xs, ys;        /* x and y size */
  26.   char border;        /* type of border */
  27.   char cursor;        /* Does it have a cursor */
  28.   char attr;        /* Current attribute of window */
  29.   char color;        /* Current color of window */
  30.   char autocr;        /* With '\n', do an automatic '\r' */
  31.   char doscroll;    /* Automatically scroll up */
  32.   char wrap;        /* Wrap around edge */
  33.   char direct;        /* Direct write to screen ? */
  34.   short curx, cury;    /* current x and y */
  35.   char o_cursor;
  36.   short o_curx;
  37.   short o_cury;
  38.   char o_attr;
  39.   char o_color;        /* Position & attributes before window was opened */
  40.   ELM *map;        /* Map of contents */
  41.   ELM *histbuf;        /* History buffer. */
  42.   int histlines;    /* How many lines we keep in the history buffer */
  43.   int histline;        /* Current line in the history buffer. */
  44. } WIN;
  45.  
  46. /*
  47.  * Stdwin is the whole screen
  48.  */
  49. extern WIN *stdwin;    /* Whole screen */
  50. extern int LINES, COLS; /* Size of sreen */
  51. extern int usecolor;    /* Use ansi color escape sequences */
  52. extern int useattr;    /* Use attributes (reverse, bold etc. ) */
  53. extern int dirflush;    /* Direct flush after write */
  54. extern int literal;    /* Literal pass-through of all characters? */
  55. extern int w_init;    /* Already initialized? */
  56.  
  57. /*
  58.  * Possible attributes.
  59.  */
  60. #define A_NORMAL     0 
  61. #define A_BLINK         1
  62. #define A_BOLD         2
  63. #define A_REVERSE     4
  64. #define A_STANDOUT     8
  65. #define A_UNDERLINE    16
  66. #define A_ALTCHARSET    32
  67. #define A_BLANK        64
  68.  
  69. /*
  70.  * Possible colors
  71.  */
  72. #define BLACK        0
  73. #define RED        1
  74. #define GREEN        2
  75. #define YELLOW        3
  76. #define BLUE        4
  77. #define MAGENTA        5
  78. #define CYAN        6
  79. #define WHITE        7
  80.  
  81. #define COLATTR(fg, bg) (((fg) << 4) + (bg))
  82. #define COLFG(ca)    ((ca) >> 4)
  83. #define COLBG(ca)    ((ca) % 16)
  84.  
  85. /*
  86.  * Possible borders.
  87.  */
  88. #define BNONE    0
  89. #define BSINGLE 1
  90. #define BDOUBLE 2
  91.  
  92. /*
  93.  * Scrolling directions.
  94.  */
  95. #define S_UP    1
  96. #define S_DOWN    2
  97.  
  98. /*
  99.  * Cursor types.
  100.  */
  101. #define CNONE    0
  102. #define CNORMAL    1
  103.  
  104. /*
  105.  * Title Positions
  106.  */
  107. #define TLEFT    0
  108. #define TMID    1
  109. #define TRIGHT    2
  110.  
  111. /*
  112.  * For wselect.
  113.  */
  114. #define NIL_FUNLIST    ((void (**)()) 0)
  115. #define NIL_FUN        ((void (*)()) 0)
  116. #define MENU_END    ((char *) 0)
  117.  
  118. #define CNULL        ((char *)0)
  119. #define NIL_WIN         (WIN *) 0
  120.  
  121. /*
  122.  * Function prototypes.
  123.  */
  124.  
  125. #ifndef _PROTO
  126. #  if __STDC__
  127. #    define _PROTO(fun, args) fun args
  128. #  else
  129. #  define _PROTO(fun, args) fun()
  130. #  endif
  131. #endif
  132.  
  133. _PROTO( int getch, ( void ));
  134.  
  135. _PROTO(void wflush, ( void ));
  136. _PROTO(WIN *wopen, ( int x1 , int y1 , int x2 , int y2 , int border ,
  137.         int attr , int fg , int bg , int direct , int hl , int rel ));
  138. _PROTO(void wclose, ( WIN *win , int replace ));
  139. _PROTO(void wleave, ( void ));
  140. _PROTO(void wreturn, ( void ));
  141. _PROTO(void wresize, (WIN *w, int x, int y ));
  142. _PROTO(void wredraw, ( WIN *w , int newdirect ));
  143. _PROTO(void wscroll, ( WIN *win , int dir ));
  144. _PROTO(void wlocate, ( WIN *win , int x , int y ));
  145. _PROTO(void wputc, ( WIN *win , int c ));
  146. _PROTO(void wdrawelm, ( WIN *win, int y, ELM *e ));
  147. _PROTO(void wputs, ( WIN *win , char *s ));
  148. /* Should use stdarg et al. */
  149. int wprintf();
  150. _PROTO(void wbell, ( void ));
  151. _PROTO(void wcursor, ( WIN *win , int type ));
  152. _PROTO(void wtitle, ( WIN *w , int pos , char *s ));
  153. _PROTO(void wcurbar, ( WIN *w , int y , int attr ));
  154. _PROTO(int wselect, ( int x , int y , char **choices , void (**funlist)() ,
  155.     char *title , int attr , int fg , int bg ));
  156. _PROTO(void wclrel, ( WIN *w ));
  157. _PROTO(void wclreol, ( WIN *w ));
  158. _PROTO(void wclrbol, ( WIN *w ));
  159. _PROTO(void wclreos, ( WIN *w ));
  160. _PROTO(void wclrbos, ( WIN *w ));
  161. _PROTO(void winclr, ( WIN *w ));
  162. _PROTO(void winsline, ( WIN *w ));
  163. _PROTO(void wdelline, ( WIN *w ));
  164. _PROTO(void winschar, ( WIN *w ));
  165. _PROTO(void wdelchar, ( WIN *w ));
  166. _PROTO(int wgets, ( WIN *win , char *s , int linemax, int totmax ));
  167. _PROTO(void win_end, ( void ));
  168. #ifdef BBS
  169. _PROTO(int win_init, ( char *term, int lines ));
  170. #else
  171. _PROTO(int win_init, ( int fg , int bg , int attr ));
  172. #endif
  173.  
  174. /*
  175.  * Some macro's that can be used as functions.
  176.  */
  177. #define wsetregion(w, z1, z2) (((w)->sy1=(w)->y1+(z1)),((w)->sy2=(w)->y1+(z2)))
  178. #define wresetregion(w) ( (w)->sy1 = (w)->y1, (w)->sy2 = (w)->y2 )
  179. #define wgetattr(w) ( (w)->attr )
  180. #define wsetattr(w, a) ( (w)->attr = (a) )
  181. #define wsetfgcol(w, fg) ( (w)->color = ((w)->color & 15) + ((fg) << 4))
  182. #define wsetbgcol(w, bg) ( (w)->color = ((w)->color & 240) + (bg) )
  183. #define wsetam(w) ( (w)->wrap = 1 )
  184. #define wresetam(w) ( (w)->wrap = 0 )
  185.  
  186. /*
  187.  * Allright, now the macro's for our keyboard routines.
  188.  */
  189. #define K_BS        8
  190. #define K_ESC        27
  191. #define K_STOP        256
  192. #define K_F1        257
  193. #define K_F2        258
  194. #define K_F3        259
  195. #define K_F4        260
  196. #define K_F5        261
  197. #define K_F6        262
  198. #define K_F7        263
  199. #define K_F8        264
  200. #define K_F9        265
  201. #define K_F10        266
  202. #define K_HOME        267
  203. #define K_PGUP        268
  204. #define K_UP        269
  205. #define K_LT        270
  206. #define K_RT        271
  207. #define K_DN        272
  208. #define K_END        273
  209. #define K_PGDN        274
  210. #define K_INS        275
  211. #define K_DEL        276
  212.  
  213. #define NUM_KEYS    21
  214. #define KEY_OFFS    256
  215.  
  216. #ifndef EOF
  217. #  define EOF        ((int) -1)
  218. #endif
  219. #define K_ERA        '\b'
  220. #define K_KILL        ((int) -2)
  221.  
  222. /* Internal structure. */
  223. struct key {
  224.     char *cap;
  225.     char len;
  226. };
  227.  
  228.