home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / c / msc51 / ext / ext.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  8.5 KB  |  260 lines

  1. /*  extension definitions
  2.  *
  3.  *  Modifications:
  4.  *
  5.  *    16-Jan-1987 mz    Add pascal typing
  6.  *            Exportable switch lists
  7.  *    10-Feb-1987 mz    Add fExecute
  8.  *    22-Oct-1987 mz    Correct definitions as headers
  9.  *    23-Oct-1987 bw    long LINE
  10.  *    15-Dec-1987 bw    Add ReadCmd and ReadChar
  11.  *            Add KbHook and KbUnHook
  12.  *            Add toPIF() macro
  13.  */
  14.  
  15. #define EXTERNAL    far
  16.  
  17. #define BUFLEN    250
  18.  
  19. /* Use this in a swiDesc table to eliminate C 5.X compiler warnings.
  20.  * For example: { "Switchname", toPIF(switchvar), SWI_BOOLEAN },
  21. */
  22. #define toPIF(x)  (PIF)(long)(void far *)&x
  23.  
  24. typedef char buffer[BUFLEN];
  25.  
  26. typedef char flagType;
  27.  
  28. typedef long LINE;
  29. typedef int  COL;
  30.  
  31. struct cmdDesc {
  32.     char far *name;
  33.     flagType (pascal EXTERNAL *func)();
  34.     unsigned arg;
  35.     unsigned argType;
  36.     };
  37.  
  38. typedef struct cmdDesc far *PCMD;
  39.  
  40. typedef flagType (pascal EXTERNAL *PIF)(char far *);
  41.  
  42. union swiAct {
  43.     flagType (pascal EXTERNAL *pFunc)(char far *);
  44.     int far *ival;
  45.     flagType far *fval;
  46.     };
  47.  
  48. struct swiDesc {
  49.     char far *name;
  50.     union swiAct act;
  51.     int type;
  52.     };
  53.  
  54. typedef struct swiDesc far *PSWI;
  55.  
  56. #define SWI_BOOLEAN 0
  57. #define SWI_NUMERIC 1
  58. #define SWI_SCREEN  4
  59. #define SWI_SPECIAL 5
  60.  
  61. /*  The following need to be added to SWI_NUMERIC to control interpretation
  62.  *  and display of the values
  63.  */
  64. #define RADIX10 (0x0A << 8)
  65. #define RADIX16 (0x10 << 8)
  66.  
  67. typedef unsigned PFILE;
  68.  
  69. flagType    pascal Replace        (char, COL, LINE, PFILE, flagType);
  70. void        pascal MoveCur        (COL, LINE);
  71. void        pascal DelLine        (PFILE, LINE, LINE);
  72. void        pascal DelBox        (PFILE, COL, LINE, COL, LINE);
  73. void        pascal DelStream        (PFILE, COL, LINE, COL, LINE);
  74. PFILE        pascal AddFile        (char far *);
  75. void        pascal DelFile        (PFILE);
  76. flagType    pascal RemoveFile        (PFILE);
  77. void        pascal CopyBox        (PFILE, PFILE, COL, LINE, COL, LINE, COL, LINE);
  78. void        pascal CopyLine        (PFILE, PFILE, LINE, LINE, LINE);
  79. void        pascal CopyStream        (PFILE, PFILE, COL, LINE, COL, LINE, COL, LINE);
  80. void        pascal pFileToTop        (PFILE);
  81. void        pascal Display        (void);
  82. void        pascal GetCursor        (COL far *, LINE far *);
  83. LINE        pascal FileLength        (PFILE);
  84. int        pascal GetLine        (LINE, char far *, PFILE);
  85. PFILE        pascal FileNameToHandle (char far *, char far *);
  86. flagType    pascal FileRead        (char far *, PFILE);
  87. flagType    pascal FileWrite        (char far *, PFILE);
  88. flagType    pascal SetKey        (char far *, char far *);
  89. int        pascal DoMessage        (char far *);
  90. void        pascal PutLine        (LINE, char far *, PFILE);
  91. flagType    pascal BadArg        (void);
  92. flagType    pascal fExecute        (char far *);
  93. PSWI        pascal ReadCmd        (void);
  94. long        pascal ReadChar        (void);
  95. void        pascal KbHook        (void);
  96. void        pascal KbUnHook        (void);
  97.  
  98. /*  Each function has a definition of how arguments are to be processed.
  99.  *  This definition is comprised of a bitmap describing which arguments are
  100.  *  legal and, if so, how they are to be interpreted.  The definitions are:
  101.  *
  102.  *  KEEPMETA    The function being executed does not take the <meta>
  103.  *        prefix.  The state of the <meta> flag is preserved
  104.  *        across this editor function.
  105.  *
  106.  *  CURSORFUNC    The function being executed is a cursor movement
  107.  *        function.  It is allowed within the context of
  108.  *        an <arg> to select a file range on the screen; it
  109.  *        cannot take an <arg>.  It does not remove highlighting
  110.  *        that is present on the screen.
  111.  *
  112.  *  WINDOWFUNC    The function being executed is a window movement
  113.  *        function.  It does not remove highlighting that is
  114.  *        present on the screen.
  115.  *
  116.  *  NOARG    The function accepts the absence of an <arg> function.
  117.  *        When called the function receives a pointer to a
  118.  *        structure containing the location where the function
  119.  *        is expected to be applied.
  120.  *
  121.  *  TEXTARG    The function accepts a textual argument that may
  122.  *        be typed in or selected on the screen.    The function is
  123.  *        called with a far pointer to the asciz text of the
  124.  *        argument.  See NULLEOL, NULLEOW, BOXSTR.
  125.  *
  126.  *  NULLARG    The function accepts an <arg> with no discernable
  127.  *        cursor movement (cursor is on <arg> position).    The
  128.  *        function is called with a pointer to a structure
  129.  *        containing the location of the arg within the file.
  130.  *
  131.  *  NULLEOL    The function accepts an <arg> with no discernable
  132.  *        cursor movement (cursor is on <arg> position).    The
  133.  *        function is called with a pointer to a structure
  134.  *        indicating TEXTARG and containing a pointer to the
  135.  *        asciz text of the line from the cursor to end-of-line.
  136.  *
  137.  *  NULLEOW    The function accepts an <arg> with no discernable
  138.  *        cursor movement (cursor is on <arg> position).    The
  139.  *        function is called with a pointer to a structure
  140.  *        indicating TEXTARG and containing a pointer to the
  141.  *        asciz text of the line from the cursor to the next
  142.  *        whitespace.
  143.  *
  144.  *  LINEARG    The function accepts an <arg> that is in the same
  145.  *        column as the cursor.  The function is expected to be
  146.  *        applied to all lines beginning in the range <arg> to
  147.  *        cursor inclusive.  The function is called with a
  148.  *        pointer to a structure containing the beginning
  149.  *        line of the range and the ending line of the range
  150.  *
  151.  *  STREAMARG    The function accepts an <arg> that is considered to
  152.  *        apply beginning at a specific file location and
  153.  *        proceeding through all intervening lines and line-
  154.  *        breaks up until just to the left of the ending file
  155.  *        position.  The function is called with a pointer to
  156.  *        a structure containing the beginning point of the range
  157.  *        and the first point just beyond the end of the range.
  158.  *
  159.  *  BOXARG    The function accepts an <arg> that is considered to
  160.  *        apply to a rectangle on the screen.  The function is
  161.  *        called with a pointer to a structure containing the
  162.  *        left and right column boundaries (inclusive) and the
  163.  *        top and bottom line numbers (inclusive) that describe
  164.  *        the region.
  165.  *
  166.  *  BOXSTR    If a BOXARG is presented to the function and the box
  167.  *        contains only a single line, the function is called
  168.  *        with a pointer to a structure marked TEXTARG and
  169.  *        containing a far pointer to the selection as an asciz
  170.  *        string.
  171.  *
  172.  *  NUMARG    If text was specified and is numeric, it is considered
  173.  *        to represent a number of lines offset from the cursor
  174.  *        and represents the other end of an arg.  The
  175.  *        above tests are then applied, excluding TEXTARG.
  176.  *
  177.  *  MARKARG    If text was specified and interpreted as a mark, it is
  178.  *        considered to be the other end of an arg.  The above
  179.  *        tests are then applied, excluding TEXTARG.
  180.  */
  181.  
  182. #define NOARG        0x0001        /* no argument specified          */
  183. #define TEXTARG     0x0002        /* text specified              */
  184. #define NULLARG     0x0004        /* arg + no cursor movement          */
  185. #define NULLEOL     0x0008        /* null arg => text from arg->eol     */
  186. #define NULLEOW     0x0010        /* null arg => text from arg->end word*/
  187. #define LINEARG     0x0020        /* range of entire lines          */
  188. #define STREAMARG   0x0040        /* from low-to-high, viewed 1-D       */
  189. #define BOXARG        0x0080        /* box delimited by arg, cursor       */
  190.  
  191. #define NUMARG        0x0100        /* text => delta to y position          */
  192. #define MARKARG     0x0200        /* text => mark at end of argument    */
  193.  
  194. #define BOXSTR        0x0400        /* single-line box => text          */
  195.  
  196. #define KEEPMETA    0x2000        /* do not eat meta flag           */
  197. #define WINDOWFUNC  0x4000        /* moves window               */
  198. #define CURSORFUNC  0x8000        /* moves cursor               */
  199.  
  200.  
  201. /*  no argument specified                              */
  202. struct    noargType {
  203.     LINE    y;
  204.     COL     x;
  205.     };
  206.  
  207. /*  text argument specified                              */
  208. struct textargType {
  209.     int     cArg;
  210.     LINE    y;
  211.     COL     x;
  212.     char far *pText;
  213.     };
  214.  
  215. /*  null argument specified                              */
  216. struct    nullargType {
  217.     int     cArg;
  218.     LINE    y;
  219.     COL     x;
  220.     };
  221.  
  222. /*  line   argument specified                              */
  223. struct lineargType {
  224.     int     cArg;
  225.     LINE yStart;
  226.     LINE yEnd;
  227.     };
  228.  
  229. /*  stream argument specified                              */
  230. struct streamargType {
  231.     int     cArg;
  232.     LINE yStart;
  233.     COL  xStart;
  234.     LINE yEnd;
  235.     COL  xEnd;
  236.     };
  237.  
  238. /*  box argument specified                              */
  239. struct boxargType {
  240.     int     cArg;
  241.     LINE yTop;
  242.     LINE yBottom;
  243.     COL  xLeft;
  244.     COL  xRight;
  245.     };
  246.  
  247. struct    argType {
  248.     int     argType;
  249.     union   {
  250.     struct    noargType    noarg;
  251.     struct    textargType    textarg;
  252.     struct    nullargType    nullarg;
  253.     struct    lineargType    linearg;
  254.     struct    streamargType    streamarg;
  255.     struct    boxargType    boxarg;
  256.     } arg;
  257.     };
  258.  
  259. typedef struct argType ARG;
  260.