home *** CD-ROM | disk | FTP | other *** search
- #ifndef _vterm_h
- #define _vterm_h
-
- #include <stdarg.h>
-
- #include "wimp.h"
- #include "menu.h"
-
- /* Defintions for VT terminal module
- The display buffer is based upon a three buffers as follows:
- 132 or 80 x 25 words display and attributes buffer.
- 132 or 80 byte for tabs.
- 25 x 1 byte for line attributes.
- */
-
- /* Various buffer limits
- */
- #define vterm_MAXESCSEQ 16
- #define VT_CMDBUF_SIZE 80
- #define VT_ICONBUF_SIZE 1024
- #define VT_HISTBUF_MAX 16
- #define CHAT_BUF_SIZE 32
-
-
- #define VTWIN_CLOSED -1
- #define VTWIN_OPENED -2
-
-
- /* Escape sequence decoder states
- */
- #define S_NONE 0 /* No ESC sequence pending */
- #define S_ESC 1 /* Escape char seen */
- #define S_CSI 2 /* CSI or ESC'[' seen */
- #define S_ESCHASH 3 /* ESC'#' seen */
- #define S_CSIQ 4 /* ESC'[''?' seen - switch change */
- #define S_XG0 5 /* ESC ')' seen Change G0 */
- #define S_XG1 6 /* ESC ')' seen - Change G1 */
- #define S_VT52CSR_L 7 /* Part of VT52 pos cursor seq */
- #define S_SS3 9 /* ESC[O received */
-
- /* Character sets currently supported
- */
- #define CSET_ASCII 0 /* This is the default G0 character set */
- #define CSET_UK 1
- #define CSET_GRAPHICS0 2 /* This is the default G1 character set */
-
- /* Character attributes
- */
- #define ATTRIB_SPECIAL (1<<0) /* Flag for special graphics chars */
-
- #define ATTRIB_STYLE (3<<1) /* Mask for setting the style */
- #define ATTRIB_SHIFT 1
- #define ATTRIB_NORM (0<<1) /* Normal characters */
- #define ATTRIB_BOLD (1<<1) /* Bold characters (actually bright) */
- #define ATTRIB_DIM (2<<1) /* Dim characters */
- #define ATTRIB_INVIS (3<<1) /* Implemented - needs a reveal mode */
-
- #define ATTRIB_ULINE (1<<3) /* NYA: Underline - done as colour */
- #define ATTRIB_FLASH (1<<4) /* NYA: Flashing - done as colour */
- #define ATTRIB_REVERSE (1<<5) /* Reverse ie swap fg and bg colours */
- #define ATTRIB_ERASE (1<<6) /* Selectivly Erasable */
- #define ATTRIB_LNMD (1<<7) /* Command line mode colour */
-
- /* Line attributes
- */
- #define LNATTR_SIZE (7<<0) /* Data extraction mask */
- #define LNATTR_SHSW 0 /* Single width, single height */
- #define LNATTR_SHDW 1 /* Double width, single height */
- #define LNATTR_DHSWT 2 /* Double height, single width (top) */
- #define LNATTR_DHDWT 3 /* Double height, double width (top) */
- #define LNATTR_DHSWB 4 /* Double height, single width (bottom) */
- #define LNATTR_DHDWB 5 /* Double height, double width (bottom) */
- #define LNATTR_DWM 1 /* Double width bit mask */
-
- /* VT Terminal switches
- */
- #define VTSW_APPCSR (1<<0) /* Application Cursor */
- #define VTSW_APPKEY (1<<1) /* Application keypad */
- #define VTSW_VT52 (1<<2) /* VT52 mode ? */
- #define VTSW_ORIGIN (1<<3) /* Cursor Relative to region */
- #define VTSW_WRAP (1<<4) /* Auto wrap */
- #define VTSW_WIDE (1<<5) /* 132 column display */
- #define VTSW_REVERSE (1<<6) /* Reverse video */
- #define VTSW_CURSOR (1<<7) /* Cursor on/off */
- #define VTSW_SHIFT (1<<8) /* Shift in/out (G0/G1 selection) */
- #define VTSW_NEWLINE (1<<9) /* LF = CR+LF */
- #define VTSW_SMOOTH (1<<10) /* Smooth scrolling */
- #define VTSW_SCRLLOCK (1<<11) /* Lock at scroll */
- #define VTSW_CHAT (1<<12) /* Split window chat mode */
- #define VTSW_NOFOLLOW (1<<13) /* Dont follow cursor */
- #define VTSW_HOLD (1<<14) /* XON/XOFF flag sent state */
- #define VTSW_HELD (1<<15) /* Screen in hold mode */
- #define VTSW_ECHO (1<<16) /* Local echo chars to user */
- #define VTSW_PAGE (1<<17) /* Page mode on */
- #define VTSW_LINE (1<<18) /* Line mode */
- #define VTSW_PROC (1<<19) /* Command process mode */
- #define VTSW_VIEW (1<<20) /* View only mode */
- #define VTSW_LOOP (1<<21) /* Test loop types sequences */
- #define VTSW_CMDW (1<<22) /* Command pane open */
- #define VTSW_PLAY (1<<23) /* Replaying a file */
- #define VTSW_SPOOL (1<<24) /* Spooling to file */
- #define VTSW_STRIP (1<<25) /* Strip codes form spool */
- #define VTSW_CMDWB (1<<26) /* Command pane at bottom */
- #define VTSW_NEWW (1<<27) /* Window not yet opened (for positioning) */
- #define VTSW_AUTOX (1<<28) /* Auto extend height */
-
- /* Terminal types
- */
- #define VTTYPE_UNKNOWN 0 /* Unknown type (for telnet options) */
- #define VTTYPE_NVT 1 /* NYA: Network Virtual Terminal */
- #define VTTYPE_VT52 2 /* VT52 terminal */
- #define VTTYPE_VT100 3 /* VT100 terminal */
- #define VTTYPE_VT220 4 /* NYA: VT220 terminal */
-
- /* A few useful structures
- */
- typedef struct pos_str {
- int x, y;
- } pos_str;
-
- typedef struct box_str {
- int x0, y0, x1, y1;
- } box_str;
-
- typedef struct chat_str {
- int argc; /* Number of strings */
- int argp; /* Current string number */
- char **argv; /* List of expect, send strings */
- int len; /* Length of current arg being checked */
- int ptr; /* Insert pointer into circular buffer */
- char buf[CHAT_BUF_SIZE]; /* Circular buffer */
- } chat_str;
-
- typedef struct macro_str {
- int argc; /* Number of user entries in menu */
- char **argv; /* Command list */
- menu popup; /* Menu */
- struct macro_str **subm; /* Macros sub menu list */
- } macro_str;
-
- typedef struct histbuf_str {
- int count;
- int max;
- int size;
- } histbuf_str;
-
- typedef struct vterm_str *vterm;
- typedef BOOL (*vterm_user_proc)(void *handle, char *buffer, int length);
- typedef void (*vterm_menu_proc)(vterm vt, char* hit);
-
- /* The terminal display structure
- The actual buffers are kept in flex memory
- Ordering of this is such that upto 'screen' contains
- the bits relevent to the redraw routine.
- */
- typedef struct vterm_str {
- wimp_w window; /* Window handle */
- pos_str cursor; /* Current cursor position */
- int mode; /* ANSI, VT52, 100, 220, 320, 340 etc */
- int switches; /* Global terminal options */
- int width; /* Buffer width */
- int height; /* Buffer height */
- char *screen; /* (flex) Pointer to memory for screen buffers */
-
- int selstart; /* Offset to start of selection */
- int selend; /* Offset to end of selection */
-
- vterm next; /* For linked lists */
- int entry; /* Entry code to tie structure with a menu entry */
-
- wimp_w cmdwin; /* Window handle of command pane */
- menu cmdmenu; /* Command menu pointer and handler */
- vterm_menu_proc cmdmenuproc;
- menu submenu; /* Sub menu pointer and handler */
- vterm_menu_proc submenuproc;
-
- wimp_w iicwin; /* Window handle of iconise gadget */
-
- FILE *spool; /* File handle of spool file */
- FILE *replay; /* File handle of replay file */
-
- box_str update; /* Region that requires updating */
- char *title; /* Window title */
- char *iconbuf; /* Command box buffer */
- char *cmdbuf; /* Line buffer for command icon */
- int cmdptr; /* Pointer into command buffer */
-
- histbuf_str *histbuf; /* (flex) Buffer to hold command history */
- int histptr; /* recall pointer for command history */
-
- void *handle; /* User handle and input handler proc */
- vterm_user_proc handlerproc;
-
- int split; /* Chat mode split point */
- int region_top; /* Top line of scroll region */
- int region_bottom; /* Bottom line of scroll region */
- int attrib; /* Current state and display attributes */
-
- pos_str old_cursor; /* Stored cursor position */
- int old_top; /* Stored region top */
- int old_bottom; /* Stored region bottom */
- int old_attrib; /* Stored attributes and mode */
- int old_switches; /* Stored swicth states */
- int old_mode; /* Stored mode */
- short *old_map[2]; /* Stored maps */
-
- int esc_state; /* Esc sequence process state */
- char numptr; /* Numeric codes buffer pointer */
- char numbuf[30]; /* Numeric codes buffer */
- short *map[2]; /* Character maps currenty assigned to G0 to G1 */
-
- char *tmpnam; /* Name of temporary spool file */
- char *sendbuf; /* (flex) Buffer to hold text to send */
- int sendptr; /* Offset to next char to send */
- chat_str *chat; /* Chat buffer and send/expect pair list (if active) */
- macro_str *macro; /* Currently attached macro set */
-
- char *holdbuf; /* Flex buffer for storing incomming data in hold mode */
- int holdremptr; /* Offset into buffer for removing data */
- int holdinsptr; /* Offset into buffer for adding more data */
- int linespeed; /* Time between lines, or 0 for full speed */
- int lastlinetime; /* Time of last newline */
- int pagelen;
- int linenum;
-
- } vterm_str;
-
- int vterm_initialise(void);
- vterm vterm_create(int flags);
- void vterm_destroy(vterm vt);
- BOOL vterm_process_key(vterm vt, int key, char *buf, int *n);
- int vterm_process_char(vterm vt, char c, char *buf);
- void vterm_attach_panemenu(vterm vt, menu m, vterm_menu_proc proc);
- void vterm_attach_mainmenu(vterm vt, menu m, vterm_menu_proc proc);
- void vterm_register_handler(vterm vt, vterm_user_proc proc, void *handle);
- void vterm_printf(vterm vt, int attrib, char *format, ...);
- void vterm_vprintf(vterm vt, int attrib, char *format, va_list args);
- void vterm_write(vterm vt, int attrib, char *s, int n);
- void vterm_title(vterm vt, char *fmt, ...);
- void vterm_vtitle(vterm vt, char *format, va_list args);
- void vterm_open(vterm vt);
- void vterm_close(vterm vt);
- void vterm_setflags(vterm vt, int clear, int value);
- void vterm_coloursdbox(void);
- int vterm_command(vterm vt, char *command, int length);
- void vterm_keypad(void);
- void vterm_padkeys(int *list);
- void vterm_parse(vterm vt, int argc, char *argv[]);
- BOOL vterm_resize(vterm vt, int x, int y);
- void vterm_replay(char *name);
- void vterm_visible(vterm vt, int x, int y);
- int vterm_nametotype(char *name);
- char *vterm_typetoname(int type);
- void vterm_selecttype(vterm vt, int type);
-
- #endif
-