home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / internet / tcpipsrc / h / if / syslog / vterm < prev   
Encoding:
Text File  |  1994-12-21  |  10.2 KB  |  257 lines

  1. #ifndef _vterm_h
  2. #define _vterm_h
  3.  
  4. #include <stdarg.h>
  5.  
  6. #include "wimp.h"
  7. #include "menu.h"
  8.  
  9. /* Defintions for VT terminal module
  10.    The display buffer is based upon a three buffers as follows:
  11.    132 or 80 x 25 words display and attributes buffer.
  12.    132 or 80 byte for tabs.
  13.    25 x 1 byte for line attributes.
  14.  */
  15.  
  16. /* Various buffer limits
  17.  */
  18. #define vterm_MAXESCSEQ    16
  19. #define VT_CMDBUF_SIZE     80
  20. #define VT_ICONBUF_SIZE    1024
  21. #define VT_HISTBUF_MAX     16
  22. #define CHAT_BUF_SIZE      32
  23.  
  24.  
  25. #define VTWIN_CLOSED       -1
  26. #define VTWIN_OPENED       -2
  27.  
  28.  
  29. /* Escape sequence decoder states
  30.  */
  31. #define S_NONE              0       /* No ESC sequence pending */
  32. #define S_ESC               1       /* Escape char seen */
  33. #define S_CSI               2       /* CSI or ESC'[' seen */
  34. #define S_ESCHASH           3       /* ESC'#' seen */
  35. #define S_CSIQ              4       /* ESC'[''?' seen - switch change */
  36. #define S_XG0               5       /* ESC ')' seen Change G0 */
  37. #define S_XG1               6       /* ESC ')' seen - Change G1 */
  38. #define S_VT52CSR_L         7       /* Part of VT52 pos cursor seq */
  39. #define S_SS3               9       /* ESC[O received */
  40.  
  41. /* Character sets currently supported
  42.  */
  43. #define CSET_ASCII          0       /* This is the default G0 character set */
  44. #define CSET_UK             1
  45. #define CSET_GRAPHICS0      2       /* This is the default G1 character set */
  46.  
  47. /* Character attributes
  48.  */
  49. #define ATTRIB_SPECIAL      (1<<0)  /* Flag for special graphics chars */
  50.  
  51. #define ATTRIB_STYLE        (3<<1)  /* Mask for setting the style */
  52. #define ATTRIB_SHIFT        1
  53. #define ATTRIB_NORM         (0<<1)  /* Normal characters */
  54. #define ATTRIB_BOLD         (1<<1)  /* Bold characters (actually bright) */
  55. #define ATTRIB_DIM          (2<<1)  /* Dim characters */
  56. #define ATTRIB_INVIS        (3<<1)  /* Implemented - needs a reveal mode */
  57.  
  58. #define ATTRIB_ULINE        (1<<3)  /* NYA: Underline - done as colour */
  59. #define ATTRIB_FLASH        (1<<4)  /* NYA: Flashing - done as colour */
  60. #define ATTRIB_REVERSE      (1<<5)  /* Reverse ie swap fg and bg colours */
  61. #define ATTRIB_ERASE        (1<<6)  /* Selectivly Erasable */
  62. #define ATTRIB_LNMD         (1<<7)  /* Command line mode colour */
  63.  
  64. /* Line attributes
  65.  */
  66. #define LNATTR_SIZE         (7<<0)   /* Data extraction mask */
  67. #define LNATTR_SHSW         0        /* Single width, single height */
  68. #define LNATTR_SHDW         1        /* Double width, single height */
  69. #define LNATTR_DHSWT        2        /* Double height, single width (top) */
  70. #define LNATTR_DHDWT        3        /* Double height, double width (top) */
  71. #define LNATTR_DHSWB        4        /* Double height, single width (bottom) */
  72. #define LNATTR_DHDWB        5        /* Double height, double width (bottom) */
  73. #define LNATTR_DWM          1        /* Double width bit mask */
  74.  
  75. /* VT Terminal switches
  76.  */
  77. #define VTSW_APPCSR         (1<<0)   /* Application Cursor */
  78. #define VTSW_APPKEY         (1<<1)   /* Application keypad */
  79. #define VTSW_VT52           (1<<2)   /* VT52 mode ? */
  80. #define VTSW_ORIGIN         (1<<3)   /* Cursor Relative to region */
  81. #define VTSW_WRAP           (1<<4)   /* Auto wrap */
  82. #define VTSW_WIDE           (1<<5)   /* 132 column display */
  83. #define VTSW_REVERSE        (1<<6)   /* Reverse video */
  84. #define VTSW_CURSOR         (1<<7)   /* Cursor on/off */
  85. #define VTSW_SHIFT          (1<<8)   /* Shift in/out (G0/G1 selection) */
  86. #define VTSW_NEWLINE        (1<<9)   /* LF = CR+LF */
  87. #define VTSW_SMOOTH         (1<<10)  /* Smooth scrolling */
  88. #define VTSW_SCRLLOCK       (1<<11)  /* Lock at scroll */
  89. #define VTSW_CHAT           (1<<12)  /* Split window chat mode */
  90. #define VTSW_NOFOLLOW       (1<<13)  /* Dont follow cursor */
  91. #define VTSW_HOLD           (1<<14)  /* XON/XOFF flag sent state */
  92. #define VTSW_HELD           (1<<15)  /* Screen in hold mode */
  93. #define VTSW_ECHO           (1<<16)  /* Local echo chars to user */
  94. #define VTSW_PAGE           (1<<17)  /* Page mode on */
  95. #define VTSW_LINE           (1<<18)  /* Line mode */
  96. #define VTSW_PROC           (1<<19)  /* Command process mode */
  97. #define VTSW_VIEW           (1<<20)  /* View only mode */
  98. #define VTSW_LOOP           (1<<21)  /* Test loop types sequences */
  99. #define VTSW_CMDW           (1<<22)  /* Command pane open */
  100. #define VTSW_PLAY           (1<<23)  /* Replaying a file */
  101. #define VTSW_SPOOL          (1<<24)  /* Spooling to file */
  102. #define VTSW_STRIP          (1<<25)  /* Strip codes form spool */
  103. #define VTSW_CMDWB          (1<<26)  /* Command pane at bottom */
  104. #define VTSW_NEWW           (1<<27)  /* Window not yet opened (for positioning) */
  105. #define VTSW_AUTOX          (1<<28)  /* Auto extend height */
  106.  
  107. /* Terminal types
  108.  */
  109. #define VTTYPE_UNKNOWN      0        /* Unknown type (for telnet options) */
  110. #define VTTYPE_NVT          1        /* NYA: Network Virtual Terminal */
  111. #define VTTYPE_VT52         2        /* VT52 terminal */
  112. #define VTTYPE_VT100        3        /* VT100 terminal */
  113. #define VTTYPE_VT220        4        /* NYA: VT220 terminal */
  114.  
  115. /* A few useful structures
  116.  */
  117. typedef struct pos_str {
  118.   int x, y;
  119. } pos_str;
  120.  
  121. typedef struct box_str {
  122.   int x0, y0, x1, y1;
  123. } box_str;
  124.  
  125. typedef struct chat_str {
  126.   int argc;      /* Number of strings */
  127.   int argp;      /* Current string number */
  128.   char **argv;   /* List of expect, send strings */
  129.   int len;       /* Length of current arg being checked */
  130.   int ptr;       /* Insert pointer into circular buffer */
  131.   char buf[CHAT_BUF_SIZE];  /* Circular buffer */
  132. } chat_str;
  133.  
  134. typedef struct macro_str {
  135.   int argc;      /* Number of user entries in menu */
  136.   char **argv;   /* Command list */
  137.   menu popup;    /* Menu */
  138.   struct macro_str **subm; /* Macros sub menu list */
  139. } macro_str;
  140.  
  141. typedef struct histbuf_str {
  142.   int count;
  143.   int max;
  144.   int size;
  145. } histbuf_str;
  146.  
  147. typedef struct vterm_str *vterm;
  148. typedef BOOL (*vterm_user_proc)(void *handle, char *buffer, int length);
  149. typedef void (*vterm_menu_proc)(vterm vt, char* hit);
  150.  
  151. /* The terminal display structure
  152.    The actual buffers are kept in flex memory
  153.    Ordering of this is such that upto 'screen' contains
  154.    the bits relevent to the redraw routine.
  155.  */
  156. typedef struct vterm_str {
  157.   wimp_w window;      /* Window handle */
  158.   pos_str cursor;     /* Current cursor position */
  159.   int mode;           /* ANSI, VT52, 100, 220, 320, 340 etc */
  160.   int switches;       /* Global terminal options */
  161.   int width;          /* Buffer width */
  162.   int height;         /* Buffer height */
  163.   char *screen;       /* (flex) Pointer to memory for screen buffers */
  164.  
  165.   int selstart;       /* Offset to start of selection */
  166.   int selend;         /* Offset to end of selection */
  167.  
  168.   vterm next;         /* For linked lists */
  169.   int entry;          /* Entry code to tie structure with a menu entry */
  170.  
  171.   wimp_w cmdwin;      /* Window handle of command pane */
  172.   menu cmdmenu;       /* Command menu pointer and handler */
  173.   vterm_menu_proc cmdmenuproc;
  174.   menu submenu;       /* Sub menu pointer and handler */
  175.   vterm_menu_proc submenuproc;
  176.  
  177.   wimp_w iicwin;      /* Window handle of iconise gadget */
  178.  
  179.   FILE *spool;        /* File handle of spool file */
  180.   FILE *replay;       /* File handle of replay file */
  181.  
  182.   box_str update;     /* Region that requires updating */
  183.   char *title;        /* Window title */
  184.   char *iconbuf;      /* Command box buffer */
  185.   char *cmdbuf;       /* Line buffer for command icon */
  186.   int cmdptr;         /* Pointer into command buffer */
  187.  
  188.   histbuf_str *histbuf;      /* (flex) Buffer to hold command history */
  189.   int histptr;        /* recall pointer for command history */
  190.  
  191.   void *handle;       /* User handle and input handler proc */
  192.   vterm_user_proc handlerproc;
  193.  
  194.   int split;          /* Chat mode split point */
  195.   int region_top;     /* Top line of scroll region */
  196.   int region_bottom;  /* Bottom line of scroll region */
  197.   int attrib;         /* Current state and display attributes */
  198.  
  199.   pos_str old_cursor; /* Stored cursor position */
  200.   int old_top;        /* Stored region top */
  201.   int old_bottom;     /* Stored region bottom */
  202.   int old_attrib;     /* Stored attributes and mode */
  203.   int old_switches;   /* Stored swicth states */
  204.   int old_mode;       /* Stored mode */
  205.   short *old_map[2];  /* Stored maps */
  206.  
  207.   int esc_state;      /* Esc sequence process state */
  208.   char numptr;        /* Numeric codes buffer pointer */
  209.   char numbuf[30];    /* Numeric codes buffer */
  210.   short *map[2];      /* Character maps currenty assigned to G0 to G1 */
  211.  
  212.   char *tmpnam;       /* Name of temporary spool file */
  213.   char *sendbuf;      /* (flex) Buffer to hold text to send */
  214.   int sendptr;        /* Offset to next char to send */
  215.   chat_str *chat;     /* Chat buffer and send/expect pair list (if active) */
  216.   macro_str *macro;   /* Currently attached macro set */
  217.  
  218.   char *holdbuf;      /* Flex buffer for storing incomming data in hold mode */
  219.   int holdremptr;     /* Offset into buffer for removing data */
  220.   int holdinsptr;     /* Offset into buffer for adding more data */
  221.   int linespeed;      /* Time between lines, or 0 for full speed */
  222.   int lastlinetime;   /* Time of last newline */
  223.   int pagelen;
  224.   int linenum;
  225.  
  226. } vterm_str;
  227.  
  228. int vterm_initialise(void);
  229. vterm vterm_create(int flags);
  230. void vterm_destroy(vterm vt);
  231. BOOL vterm_process_key(vterm vt, int key, char *buf, int *n);
  232. int vterm_process_char(vterm vt, char c, char *buf);
  233. void vterm_attach_panemenu(vterm vt, menu m, vterm_menu_proc proc);
  234. void vterm_attach_mainmenu(vterm vt, menu m, vterm_menu_proc proc);
  235. void vterm_register_handler(vterm vt, vterm_user_proc proc, void *handle);
  236. void vterm_printf(vterm vt, int attrib, char *format, ...);
  237. void vterm_vprintf(vterm vt, int attrib, char *format, va_list args);
  238. void vterm_write(vterm vt, int attrib, char *s, int n);
  239. void vterm_title(vterm vt, char *fmt, ...);
  240. void vterm_vtitle(vterm vt, char *format, va_list args);
  241. void vterm_open(vterm vt);
  242. void vterm_close(vterm vt);
  243. void vterm_setflags(vterm vt, int clear, int value);
  244. void vterm_coloursdbox(void);
  245. int vterm_command(vterm vt, char *command, int length);
  246. void vterm_keypad(void);
  247. void vterm_padkeys(int *list);
  248. void vterm_parse(vterm vt, int argc, char *argv[]);
  249. BOOL vterm_resize(vterm vt, int x, int y);
  250. void vterm_replay(char *name);
  251. void vterm_visible(vterm vt, int x, int y);
  252. int vterm_nametotype(char *name);
  253. char *vterm_typetoname(int type);
  254. void vterm_selecttype(vterm vt, int type);
  255.  
  256. #endif
  257.