Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
5.0 KiB

  1. /*** filter.c - Microsoft Editor Filter Extension
  2. *
  3. * Purpose:
  4. * Provides a new editting function, filter, which replaces its argument with
  5. * the the argument run through an arbitrary operating system filter program.
  6. *
  7. * Modifications
  8. * 12-Sep-1988 mz Made WhenLoaded match declaration
  9. *
  10. *************************************************************************/
  11. #define EXT_ID " Z Extensions 1.00 "##__DATE__##" "##__TIME__
  12. #include <stdlib.h> /* min macro definition */
  13. #include <string.h> /* prototypes for string fcns */
  14. #include "zext.h"
  15. void pascal id (char *);
  16. void pascal EXTERNAL SetFilter (char far *);
  17. flagType pascal EXTERNAL filter (CMDDATA, ARG far *, flagType);
  18. void pascal filterWhenLoaded (void);
  19. flagType pascal EXTERNAL justify (CMDDATA, ARG far *, flagType);
  20. void pascal justifyWhenLoaded (void);
  21. flagType pascal EXTERNAL StartExt (CMDDATA, ARG far *, flagType);
  22. flagType pascal EXTERNAL Case (CMDDATA, ARG far *, flagType);
  23. flagType pascal EXTERNAL ShowBuildMessage (CMDDATA, ARG far *, flagType);
  24. flagType pascal EXTERNAL SlmOut (CMDDATA, ARG far *, flagType);
  25. void pascal partyWhenLoaded (void);
  26. flagType pascal EXTERNAL PMatch (CMDDATA, ARG far *, flagType);
  27. void pascal PMatchWhenLoaded (void);
  28. flagType pascal EXTERNAL tglcase (CMDDATA, ARG far *, flagType);
  29. void pascal tglcaseWhenLoaded (void);
  30. flagType pascal EXTERNAL ucase (CMDDATA, ARG far *, flagType);
  31. flagType pascal EXTERNAL lcase (CMDDATA, ARG far *, flagType);
  32. void pascal ulcaseWhenLoaded (void);
  33. flagType pascal EXTERNAL wincopy (CMDDATA, ARG far *, flagType);
  34. flagType pascal EXTERNAL wincut (CMDDATA, ARG far *, flagType);
  35. flagType pascal EXTERNAL windel (CMDDATA, ARG far *, flagType);
  36. flagType pascal EXTERNAL winpaste (CMDDATA, ARG far *, flagType);
  37. void pascal winclipWhenLoaded (void);
  38. extern flagType just2space;
  39. extern int justwidth;
  40. extern flagType iconizeOnExit;
  41. /*** WhenLoaded - Extension Initialization
  42. *
  43. * Purpose:
  44. * Executed when extension gets loaded. Identify self, create <filter-file>,
  45. * and assign default keystroke.
  46. *
  47. * Input:
  48. * none
  49. *
  50. * Output:
  51. * Returns nothing. Initializes various data.
  52. *
  53. *************************************************************************/
  54. void EXTERNAL
  55. WhenLoaded (
  56. void
  57. )
  58. {
  59. filterWhenLoaded();
  60. justifyWhenLoaded();
  61. partyWhenLoaded();
  62. PMatchWhenLoaded();
  63. tglcaseWhenLoaded();
  64. ulcaseWhenLoaded();
  65. winclipWhenLoaded();
  66. id ("ZEXTENS: ");
  67. }
  68. /*** id - identify extension
  69. *
  70. * Purpose:
  71. * identify ourselves, along with any passed informative message.
  72. *
  73. * Input:
  74. * pszMsg = Pointer to asciiz message, to which the extension name
  75. * and version are appended prior to display.
  76. *
  77. * Output:
  78. * Returns nothing. Message displayed.
  79. *
  80. *************************************************************************/
  81. void pascal id (
  82. char *pszFcn /* function name */
  83. )
  84. {
  85. char buf[BUFLEN]; /* message buffer */
  86. strcpy (buf,pszFcn);
  87. strcat (buf,EXT_ID);
  88. DoMessage (buf);
  89. }
  90. //
  91. // Switch communication table to the editor
  92. //
  93. struct swiDesc swiTable[] = {
  94. {"filtcmd", (PIF)SetFilter, SWI_SPECIAL},
  95. {"just2space", toPIF(just2space), SWI_BOOLEAN},
  96. {"justwidth", toPIF(justwidth), SWI_NUMERIC | RADIX10},
  97. {"iconizeonexit", toPIF(iconizeOnExit), SWI_BOOLEAN},
  98. {0, 0, 0}
  99. };
  100. //
  101. // Command communiation table to the editor
  102. //
  103. struct cmdDesc cmdTable[] = {
  104. {"filter", filter, 0, KEEPMETA | NOARG | BOXARG | NULLARG | LINEARG | MARKARG | NUMARG | TEXTARG | MODIFIES},
  105. {"justify", justify, 0, MODIFIES | NOARG | NULLARG | LINEARG | BOXARG | TEXTARG },
  106. {"startext", StartExt, 0, NOARG },
  107. {"MapCase", Case, 0, NOARG | NULLARG | LINEARG | BOXARG | NUMARG },
  108. {"BuildMessage",ShowBuildMessage, 0, NOARG | NULLARG | TEXTARG },
  109. {"SlmOut", SlmOut, 0, NOARG | NULLARG | TEXTARG },
  110. {"pmatch", PMatch, 0, CURSORFUNC },
  111. {"tglcase", tglcase, 0, KEEPMETA | NOARG | BOXARG | NULLARG | LINEARG | MARKARG | NUMARG | MODIFIES},
  112. {"ucase", ucase, 0, MODIFIES | KEEPMETA | NOARG | BOXARG | NULLARG | LINEARG },
  113. {"lcase", lcase, 0, MODIFIES | KEEPMETA | NOARG | BOXARG | NULLARG | LINEARG },
  114. {"wincopy", wincopy, 0, KEEPMETA | NOARG | BOXARG | LINEARG | STREAMARG | MARKARG | NULLEOL | NUMARG },
  115. {"wincut", wincut, 0, NOARG | BOXARG | LINEARG | STREAMARG | MARKARG | NULLEOL | NUMARG | MODIFIES},
  116. {"windel", windel, 0, NOARG | BOXARG | LINEARG | STREAMARG | NULLARG | MODIFIES},
  117. {"winpaste", winpaste, 0, KEEPMETA | NOARG | BOXARG | LINEARG | STREAMARG | TEXTARG | MODIFIES},
  118. {0, 0, 0}
  119. };