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.

309 lines
9.3 KiB

  1. /*** mh.h - common include file for the MS Editor help extension
  2. *
  3. * Copyright <C> 1988, Microsoft Corporation
  4. *
  5. * Revision History:
  6. * 24-Feb-1989 ln Increase max open help files to 20
  7. * 13-Jan-1989 ln PWIN->PWND
  8. * 09-Dec-1988 ln Changes for Dialog help
  9. * 28-Sep-1988 ln Correct GrabWord return value
  10. * 13-Sep-1988 Make EVTargs param a pointer
  11. * [] 17-May-1988 Created
  12. *
  13. *************************************************************************/
  14. #ifndef EXTINT
  15. #include "ext.h" /* z extension include file */
  16. #include <stdio.h>
  17. #include <windows.h>
  18. #if defined (DEBUG )
  19. #define ORGDBG DEBUG
  20. #else
  21. #undef ORGDBG
  22. #endif
  23. #if defined (_INCLUDE_TOOLS_ )
  24. #define _FLAGTYPE_DEFINED_ 1
  25. #include "tools.h"
  26. #if defined (ORGDBG)
  27. #define DEBUG ORGDBG
  28. #else
  29. #undef DEBUG
  30. #endif
  31. #else
  32. struct findType {
  33. unsigned type; /* type of object being searched */
  34. HANDLE dir_handle; /* Dir search handle for FindNext */
  35. WIN32_FIND_DATA fbuf; /* Aligned structure for Cruiser and NT */
  36. };
  37. #endif
  38. #endif // EXTINT
  39. #include "help.h" /* help system include file */
  40. #ifndef TRUE
  41. #define TRUE 1
  42. #define FALSE 0
  43. #endif
  44. #define MAXFILES 20 /* max open helpfiles */
  45. #define MAXEXT 10 /* max default search extensions*/
  46. #if defined(PWB)
  47. #define CLISTMAX 20 /* max number of duplicates */
  48. #endif
  49. #define WIN_MIN 5 /* min number of lines in window*/
  50. //
  51. // Editor color indexes
  52. //
  53. #define C_BOLD USERCOLORMIN
  54. #define C_ITALICS (1 + C_BOLD)
  55. #define C_UNDERLINE (1 + C_ITALICS)
  56. #define C_WARNING (1 + C_UNDERLINE)
  57. #define C_NORM (1 + C_WARNING)
  58. //
  59. // Info we keep for every helpfile
  60. //
  61. typedef struct {
  62. nc ncInit; /* initial context */
  63. uchar exts[MAXEXT][4]; /* extensions */
  64. } helpfile;
  65. //
  66. // Forward Declarations of help extension routines
  67. //
  68. void pascal near appTitle (char far *, nc);
  69. uchar pascal near atrmap (ushort);
  70. flagType pascal EXTERNAL CloseWin (EVTargs far *);
  71. flagType pascal near closehelp (char *);
  72. flagType pascal near errstat (char *, char *);
  73. flagType pascal near fContextCommand (char *);
  74. flagType pascal near fDisplayNc (nc, flagType, flagType, flagType);
  75. flagType pascal near fReadNc (nc);
  76. flagType pascal near fHelpCmd (char *, flagType, flagType);
  77. PWND pascal near FindHelpWin (flagType);
  78. void pascal near GrabWord (void);
  79. flagType pascal EXTERNAL IdleProc (EVTargs far *);
  80. flagType pascal EXTERNAL keyevent (EVTargs far *);
  81. flagType pascal EXTERNAL LooseFocus (EVTargs far *);
  82. void pascal near mhcwinit (void);
  83. void pascal near mhevtinit (void);
  84. nc pascal near ncSearch (uchar far *, uchar far *, nc, flagType, flagType);
  85. void pascal near opendefault (void);
  86. void pascal near openhelp (char *, struct findType*, void*);
  87. PWND pascal near OpenWin (ushort);
  88. void pascal near PlaceColor (int, COL, COL);
  89. int pascal near procArgs (ARG far *);
  90. void pascal near ProcessKeys (void);
  91. void pascal near procExt(int, char *);
  92. flagType pascal EXTERNAL prochelpfiles (char *);
  93. void pascal near stat (char *);
  94. flagType pascal near wordSepar (int);
  95. char far * pascal near xrefCopy (char far *, char far *);
  96. #if defined(PWB)
  97. nc pascal near ncChoose (char far *);
  98. #endif
  99. #ifdef DEBUG
  100. void pascal near debend (flagType);
  101. void pascal near debhex (long);
  102. void pascal near debmsg (char far *);
  103. /*
  104. * assertion support
  105. *
  106. * assert - assertion macro. We define our own, because if we abort we need
  107. * to be able to shut down cleanly (or at least die trying). This
  108. * version also saves us some code over the C library one.
  109. *
  110. * asserte - version of assert that always executes the expression, regardless
  111. * of debug state.
  112. */
  113. void pascal near _mhassertexit (char *, char *, int);
  114. #define assert(exp) { \
  115. if (!(exp)) \
  116. _mhassertexit (#exp, __FILE__, __LINE__); \
  117. }
  118. #define asserte(exp) assert(exp)
  119. #else
  120. #define debend(x)
  121. #define debhex(x)
  122. #define debmsg(x)
  123. #define assert(exp)
  124. #define asserte(exp) ((exp) != 0)
  125. #endif
  126. //
  127. // Global Data
  128. //
  129. // results of procArgs.
  130. //
  131. extern int cArg; /* number of <args> hit */
  132. extern rn rnArg; /* range of argument */
  133. extern char *pArgText; /* ptr to any single line text */
  134. extern char *pArgWord; /* ptr to context-sens word */
  135. extern PFILE pFileCur; /* file handle of user file */
  136. //
  137. // Global State
  138. //
  139. extern flagType fInOpen; /* TRUE=> currently opening win */
  140. extern flagType fInPopUp; /* TRUE=> currently in popup */
  141. extern flagType fSplit; /* TRUE=> window was split open */
  142. extern flagType fCreateWindow; /* TRUE=> create window */
  143. extern buffer fnCur; /* Current file being editted */
  144. extern char *fnExtCur; /* ptr to it's extension */
  145. extern int ifileCur; /* Current index into files */
  146. extern nc ncCur; /* most recently accessed */
  147. extern nc ncInitLast; /* ncInit of most recent topic */
  148. extern nc ncInitLastFile; /* ncInit of most recent, our files*/
  149. extern nc ncLast; /* most recently displayed topic*/
  150. extern PFILE pHelp; /* help PFILE */
  151. extern PWND pWinHelp; /* handle to window w/ help in */
  152. extern PWND pWinUser; /* User's most recent window */
  153. extern buffer szLastFound; /* last context string found */
  154. //
  155. // Global Misc
  156. //
  157. extern buffer buf; /* utility buffer */
  158. extern helpfile files[MAXFILES]; /* help file structs */
  159. helpinfo hInfoCur; /* information on the help file */
  160. extern uchar far *pTopic; /* mem for topic */
  161. extern fl flIdle; /* last position of idle check */
  162. //
  163. // Multiple search list
  164. //
  165. extern flagType fList; /* TRUE=> search for and list dups*/
  166. #if defined(PWB)
  167. extern nc rgncList[CLISTMAX]; /* list of found nc's */
  168. extern int cList; /* number of entries */
  169. #endif
  170. extern flagType ExtensionLoaded;
  171. //
  172. // colors
  173. //
  174. extern int hlColor; /* normal: white on black */
  175. extern int blColor; /* bold: high white on black */
  176. extern int itColor; /* italics: high green on black */
  177. extern int ulColor; /* underline: high red on black */
  178. extern int wrColor; /* warning: black on white */
  179. #if defined(PWB)
  180. extern uchar far *rgsa; /* pointer to color table */
  181. #endif
  182. //
  183. // Debugging
  184. //
  185. #ifdef DEBUG
  186. extern int delay; /* message delay */
  187. #endif
  188. //
  189. // The extension accesses the entry points in the engine thru a table
  190. // which is initialize by DosGetProcAddr.
  191. //
  192. typedef void pascal (*void_F) (void);
  193. typedef int pascal (*int_F) (void);
  194. typedef ushort pascal (*ushort_F) (void);
  195. typedef f pascal (*f_F) (void);
  196. typedef char * pascal (*pchar_F) (void);
  197. typedef nc pascal (*nc_F) (void);
  198. typedef mh pascal (*mh_F) (void);
  199. #if defined( HELP_HACK )
  200. #else
  201. #define HelpcLines ((int pascal (*)(PB)) (pHelpEntry[P_HelpcLines ]))
  202. #define HelpClose ((void pascal (*)(nc)) (pHelpEntry[P_HelpClose ]))
  203. #define HelpCtl ((void pascal (*)(PB, f)) (pHelpEntry[P_HelpCtl ]))
  204. #define HelpDecomp ((f pascal (*)(PB, PB, nc)) (pHelpEntry[P_HelpDecomp ]))
  205. #define HelpGetCells ((int pascal (*)(int, int, char *, pb, uchar *)) (pHelpEntry[P_HelpGetCells ]))
  206. #define HelpGetInfo ((int pascal (*)(nc, helpinfo *, int)) (pHelpEntry[P_HelpGetInfo ]))
  207. #define HelpGetLine ((ushort pascal (*)(ushort, ushort, uchar *, PB)) (pHelpEntry[P_HelpGetLine ]))
  208. #define HelpGetLineAttr ((ushort pascal (*)(ushort, int, lineattr *, PB)) (pHelpEntry[P_HelpGetLineAttr]))
  209. #define HelpHlNext ((f pascal (*)(int, PB, hotspot *)) (pHelpEntry[P_HelpHlNext ]))
  210. #define HelpLook ((ushort pascal (*)(nc, PB)) (pHelpEntry[P_HelpLook ]))
  211. #define HelpNc ((nc pascal (*)(char *, nc)) (pHelpEntry[P_HelpNc ]))
  212. #define HelpNcBack ((nc pascal (*)(void)) (pHelpEntry[P_HelpNcBack ]))
  213. #define HelpNcCb ((ushort pascal (*)(nc)) (pHelpEntry[P_HelpNcCb ]))
  214. #define HelpNcCmp ((nc pascal (*)(char *, nc, f (pascal *)(uchar *, uchar *, ushort, f, f) ) (pHelpEntry[P_HelpNcCmp ]))
  215. #define HelpNcNext ((nc pascal (*)(nc)) (pHelpEntry[P_HelpNcNext ]))
  216. #define HelpNcPrev ((nc pascal (*)(nc)) (pHelpEntry[P_HelpNcPrev ]))
  217. #define HelpNcRecord ((void pascal (*)(nc)) (pHelpEntry[P_HelpNcRecord ]))
  218. #define HelpNcUniq ((nc pascal (*)(nc)) (pHelpEntry[P_HelpNcUniq ]))
  219. #define HelpOpen ((nc pascal (*)(char *)) (pHelpEntry[P_HelpOpen ]))
  220. #define HelpShrink ((void pascal (*)(void)) (pHelpEntry[P_HelpShrink ]))
  221. #define HelpSzContext ((f pascal (*)(uchar *, nc))(pHelpEntry[P_HelpSzContext ]))
  222. #define HelpXRef ((char * pascal (*)(PB, hotspot *)) (pHelpEntry[P_HelpXRef ]))
  223. //#define LoadFdb ((f_F) (pHelpEntry[P_LoadFdb ]))
  224. //#define LoadPortion ((mh_F) (pHelpEntry[P_LoadPortion ]))
  225. #endif // HELP_HACK
  226. // Some functions return an error code in the nc structure
  227. // (yuck!)
  228. //
  229. #define ISERROR(x) (((x).mh == 0L) && ((x).cn <= HELPERR_MAX))
  230. enum {
  231. P_HelpcLines,
  232. P_HelpClose,
  233. P_HelpCtl,
  234. P_HelpDecomp,
  235. P_HelpGetCells,
  236. P_HelpGetInfo,
  237. P_HelpGetLine,
  238. P_HelpGetLineAttr,
  239. P_HelpHlNext,
  240. P_HelpLook,
  241. P_HelpNc,
  242. P_HelpNcBack,
  243. P_HelpNcCb,
  244. P_HelpNcCmp,
  245. P_HelpNcNext,
  246. P_HelpNcPrev,
  247. P_HelpNcRecord,
  248. P_HelpNcUniq,
  249. P_HelpOpen,
  250. P_HelpShrink,
  251. P_HelpSzContext,
  252. P_HelpXRef,
  253. P_LoadFdb,
  254. P_LoadPortion,
  255. LASTENTRYPOINT
  256. } ENTRYPOINTS;
  257. #define NUM_ENTRYPOINTS (LASTENTRYPOINT - P_HelpcLines)
  258. //
  259. // Name of the help engine
  260. //
  261. #define HELPDLL_NAME "MSHELP.DLL"
  262. #define HELPDLL_BASE "mshelp"
  263. typedef nc pascal (*PHF) (void);
  264. HANDLE hModule;
  265. PHF pHelpEntry[NUM_ENTRYPOINTS];