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.

179 lines
4.5 KiB

  1. /*----------------------------------------------------------------------------
  2. %%File: INTERP\EM.RUL
  3. %%Unit: Event Monitor (mntr)
  4. %%Contact: daleg
  5. Event Monitor Sample Rule Base.
  6. This is a source file to the Rule Compiler to demonstrate how to process
  7. events.
  8. ----------------------------------------------------------------------------
  9. NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
  10. There are *two* rule syntaxes used here, simple rules, and rule patterns.
  11. Simple rules appear as ordinary C "if" statements, and follow the same
  12. syntax rules. Example of a simple rule:
  13. if ("x")
  14. {
  15. Say("You just typed \"x\"");
  16. }
  17. In Rule patterns, the test clause is enclosed by square
  18. brackets [ ] instead of the parentheses ( ) used in simple rules.
  19. Example of a rule pattern:
  20. if ["d" "e" "m" "o"] ... (LCheckButton2)
  21. {
  22. Say("You just typed \"demo\"");
  23. }
  24. The pattern is a regular expression, with the following allowable
  25. operators:
  26. operator Marks Example
  27. ------------------------------------------------------------------------
  28. | Alternatives "a" "b" | "c" "d"
  29. [ ] Optional sequences [ "a" "b" "c" ]
  30. { } Required sequence { "a" "b" | "c" "d" }
  31. Note that required or optional (sub) sequences can always have alternatives
  32. ----------------------------------------------------------------------------
  33. ----------------------------------------------------------------------------
  34. Note also that there are two forms of rules, "if" rules, and "and_if"
  35. rules.
  36. Rules marked with "if" are primary rules, and are automatically sheduled
  37. to run whenever any of their primary events are scheduled.
  38. Rules marked with "and_if" are secondary rules, and must be explicitly
  39. scheduled from another rule or from the application. The "..." syntax
  40. and the "then ()" function are used to schedule rules from within the
  41. rule.base
  42. See the document "Writing Rules In The Event Monitor" for details.
  43. ----------------------------------------------------------------------------*/
  44. // #include "genrules.rul"
  45. #pragma argv "-d -f -a -m128 -s128 -xl -xo -pEm"
  46. #include "libem.h" // configure genem.c and other client-side stuff
  47. #include "uemevt.h"
  48. declare group ALWAYS;
  49. declare event_type _YYSTD : ALWAYS;
  50. declare event_type IE : ALWAYS;
  51. // BUGBUG MsoPact doesn't enqueue
  52. declare action NoArgs(0) MSOACT *MsoPact( // Declare action cons
  53. MSOACTTBL *pacttbl,
  54. int actt,
  55. ...
  56. );
  57. #if YY_DELAYED // BUGBUG tmp #if
  58. #define TraceMB PactTraceMB
  59. #endif
  60. // {
  61. //*** _YYSTD -- standard events
  62. In event_type _YYSTD;
  63. declare _YYSTD_INIT export; // OnInit
  64. declare _YYSTD_LOADING_RULEBASE export; // OnRulesLoaded
  65. declare _YYSTD_GENERIC export; // generic
  66. declare _YYSTD_UNKNOWN export; // unknown
  67. if (_YYSTD_INIT) {
  68. TraceMB("init");
  69. }
  70. // }
  71. // {
  72. //*** IE -- IE-specific events
  73. In event_type IE;
  74. declare keytable IE_KEYTABLE integer /*prefix("IE")*/ // Declare char keys
  75. default (irulIE_UNKNOWN);
  76. declare IE_ALPHA generic(alpha) export; // ALPHA tk event
  77. declare IE_UNKNOWN export; // unknown
  78. declare IE_GENERIC export; // generic
  79. declare IE_UIGENERIC;
  80. declare IE_UIMENU key(UEME_UIMENU) IE_UIGENERIC export; //
  81. declare IE_UIQCUT key(UEME_UIQCUT) IE_UIGENERIC export; //
  82. declare IE_UISCUT key(UEME_UISCUT) IE_UIGENERIC export; //
  83. declare IE_UIHOTKEY key(UEME_UIHOTKEY) IE_UIGENERIC export; //
  84. declare IE_RUNGENERIC;
  85. declare IE_RUNWMCMD key(UEME_RUNWMCMD) IE_RUNGENERIC export;
  86. if (IE_GENERIC) {
  87. TraceMB("generic");
  88. }
  89. if (IE_UIGENERIC) {
  90. TraceMB("ui*");
  91. }
  92. if [IE_UIMENU IE_RUNGENERIC] {
  93. TraceMB("ui run*");
  94. }
  95. if (IE_RUNGENERIC) {
  96. TraceMB("run*");
  97. }
  98. // }
  99. #if 0 // {
  100. #if 0
  101. #include "clock.rul"
  102. #endif
  103. #endif // }
  104. //*** code
  105. //
  106. #ifdef TraceMB
  107. action NoArgs msoactfNonEdit
  108. MSOACT *TraceMB(char *str) // PactTraceMB
  109. #undef TraceMB
  110. {
  111. TraceMB(str);
  112. //return 0;
  113. }
  114. #endif
  115. FUNCTION void TraceMB(char *str)
  116. {
  117. TraceMsg(DM_TRACE, "em: %s", str);
  118. #if 0
  119. // can't call this since MSOEM isn't reentrant
  120. MessageBox(NULL, str, "em", MB_OKCANCEL);
  121. #endif
  122. return;
  123. }