home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 11 / 11.iso / n / n002 / 4.ddi / ECLHEAD.ZIP / XC_TERM.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-19  |  5.7 KB  |  140 lines

  1. #ifndef ECL_TERMHEAD
  2. #define ECL_TERMHEAD
  3.  
  4. /* Return Values of xc_terminal()*/
  5. #define        TERM_OUT_OF_MEM            -1
  6.  
  7. /* always start scanning receive character node arrays with member zero */
  8. #define TERM_BASE_STATE    0
  9.  
  10. /* maximum number of digits in row and column (including NULL terminator) */
  11. #define TERM_MAX_SIZE      4
  12.  
  13.  
  14. /* Transmit keypress information structure */
  15. typedef struct xkeypressinfo  {
  16.     char  *buffer;   /* Sequence of chars to Xmit when Associated key is hit */
  17.     int    num_chars; /* Number of characters in the sequence */
  18.     int   padding;   /* padding (in clock ticks) needed for keypress */
  19. }XKeypressInfo;
  20.  
  21.  
  22. /* Terminal Structure type */
  23. typedef struct term_info  TERM_INFO;
  24.  
  25. /* Pointer to Terminal Structure type */
  26. typedef TERM_INFO  *TERM_PTR;
  27.  
  28. /* Pointer to function (with one argument: pointer to  
  29.    Terminal structure) returning an integer */
  30. typedef int (*TERM_FPTR)(TERM_PTR);
  31.  
  32.  
  33. /* Transmit character action structure : Xmit character node */
  34. typedef struct xcharnode  {
  35.     unsigned int        key;                    /* key press: scan code + key code */
  36.     TERM_FPTR            action_ptr;            /* Associated function to perform */
  37. }XCharNode;
  38.  
  39. /* pointer to transmit character node */
  40. typedef XCharNode *XCharNode_Ptr;
  41.  
  42. /* Transmit Key Information Structure */
  43. typedef struct xcharinfo  {
  44.     int                    num_keys;                /* number of transmit key nodes */
  45.     XCharNode            *key_info_array;     /* array of Xmit Char Nodes */
  46. }XCharInfo;
  47.  
  48. /* Received character action structure : Received character node */
  49. typedef struct rcharnode  {
  50.     int        ch_code;                              /* Received character */
  51.     int               next_state_array;  /* index of next array to scan */
  52.     TERM_FPTR            node_action_ptr;   /* function performed if not NULL */
  53. }RCharNode;
  54.  
  55. /* pointer to recieved character node */
  56. typedef RCharNode *RCharNode_Ptr;
  57.  
  58. /* Receive Character Information Structure */
  59. typedef struct rcharinfo  {
  60.     int                    num_nodes;           /* number of character action nodes */
  61.     RCharNode_Ptr        node_array;          /* array of character action nodes */ 
  62.     TERM_FPTR            default_action_ptr;  /* function performed if not NULL 
  63.                                              and match did not occur       */
  64. }RCharInfo;
  65.  
  66.  
  67. /* Terminal structure */
  68. struct term_info{
  69.     int port;      /* Comm port being used */
  70.     int upl_row;      /* Upper left row of terminal screen */
  71.     int upl_col;   /* Upper left column of terminal screen */
  72.     int max_row;   /* lower right row of terminal screen */
  73.     int max_col;   /* lower right column of terminal screen */
  74.     int terminal_mode;   /* Display Attribute of characters:
  75.                                    Underscore, Standout */
  76.     int video_mode;        /* Color or Mono monitor */
  77.     char printer_status;  /* flag to print to screen(=0) / printer (=1) */
  78.     char insert_mode;     /* Indicates if terminal in insert mode: 0=no; 1=yes */
  79.     char keypad_mode;     /* Indicates if keypad is: 1=on (default); 0=off */
  80.     int save_row;        /* Absolute cursor row saved when change scrolling region */
  81.     int save_col;        /* Absolute cursor column saved when change scrolling region */
  82.     int scrl_upl_row;      /* Upper row of scrolling region */
  83.     int scrl_max_row;    /* Lower row of scrolling region */
  84.     int current_state;   /* Index into correct Receive character node array 
  85.                                     to scan. Used to receive escape sequences */
  86.     int tab_width;       /* size of Tab: must be >0 */
  87.    unsigned int current_val;  /* current keypress or current incoming char */
  88.     char num[2][TERM_MAX_SIZE]; /* Two numbers, of TERM_MAX_SIZE each */
  89.     int  return_key;     /* special key to force return */
  90.     char abort_flag;   /* Control Break Support: 0=no; 1=yes */
  91.     char pad_flag;     /* Indicates if padding character is used: 0=no; 1=yes */
  92.     char pad_char;          /* specifies padding character */
  93.     int  ic_delay;     /* inter-character delay used to xmit escape sequences */
  94.     XKeypressInfo *xkeypress_ptr;  /* escape sequence to xmit when user 
  95.                                                  hits a key : must load before using */
  96.     TERM_FPTR   xmit_funct_ptr; /* function used to transmit keypress characters 
  97.                                and escape sequences */
  98.     TERM_FPTR   idle_time_funct_ptr; /* function used to perform idle time processing */
  99.     XCharInfo      *key_info_ptr;        /* ptr to user action key info */
  100.     XCharInfo      *xkey_info_ptr;          /* ptr to Xmit Char info Nodes */
  101.     RCharInfo      *rchar_info_array; /* array of Receive Char info Nodes */
  102. };
  103.  
  104.  
  105. /* Macro Expansion Definitions for readablity */
  106.  
  107. /* number of user defined action keys */
  108. #define        TERM_USER_NUM_KEYS(term_ptr)    ((term_ptr->key_info_ptr)->num_keys)
  109.  
  110. /* current keypress or current incoming char */
  111. #define        TERM_CURRENT_VAL(term_ptr)     (term_ptr->current_val)
  112.  
  113. /* Array of XCharNodes to match */
  114. #define        TERM_USER_KEY_ARRAY(term_ptr)        ((term_ptr->key_info_ptr)->key_info_array)
  115.  
  116. /* Current Terminal COMM port */
  117. #define        TERM_PORT(term_ptr)        (term_ptr->port)
  118.  
  119. /* number of Terminal keyboard action keys defined */
  120. #define        TERM_XMIT_NUM_KEYS(term_ptr)    ((term_ptr->xkey_info_ptr)->num_keys)
  121.  
  122. /* Array of XCharNodes to match */
  123. #define        TERM_XMIT_KEY_ARRAY(term_ptr)        ((term_ptr->xkey_info_ptr)->key_info_array)
  124.  
  125. /* Current terminal receive state */
  126. #define     TERM_CURRENT_STATE(term_ptr)     (term_ptr->current_state)
  127.  
  128. /* number of character nodes present in array for current state */
  129. #define     TERM_REC_NUM_NODES(term_ptr)    ((term_ptr->rchar_info_array)[(term_ptr->current_state)].num_nodes)
  130.  
  131. /* Array of XCharNodes to match */
  132. #define        TERM_REC_NODE_ARRAY(term_ptr) ((term_ptr->rchar_info_array)[(term_ptr->current_state)].node_array)
  133.  
  134. /* pointer to function to preform if there was no match in the current
  135.    receive character array */
  136. #define        TERM_REC_DEFAULT_ACTION(term_ptr) ((term_ptr->rchar_info_array)[(term_ptr->current_state)].default_action_ptr)
  137.  
  138.  
  139. #endif
  140.