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.

422 lines
7.3 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. mbrdlg.c
  5. Abstract:
  6. Top-level functions that implement the commands supported by the
  7. MS Editor browser extension.
  8. Author:
  9. Ramon Juan San Andres (ramonsa) 06-Nov-1990
  10. Revision History:
  11. --*/
  12. #include "mbr.h"
  13. /**************************************************************************/
  14. flagType
  15. pascal
  16. EXTERNAL
  17. mBRdoSetBsc (
  18. IN USHORT argData,
  19. IN ARG far *pArg,
  20. IN flagType fMeta
  21. )
  22. /*++
  23. Routine Description:
  24. Opens a browser database.
  25. Arguments:
  26. Standard arguments for MEP Editing functions
  27. Return Value:
  28. FALSE if error, TRUE otherwise
  29. --*/
  30. {
  31. PBYTE pName;
  32. procArgs(pArg);
  33. pName = pArgText ? pArgText : BscName;
  34. if (pName) {
  35. if (! OpenDataBase(pName)) {
  36. return errstat(MBRERR_CANNOT_OPEN_BSC, pName);
  37. }
  38. strcpy(BscName, pName);
  39. BscArg[0] = '\0';
  40. BscCmnd = CMND_NONE;
  41. }
  42. return TRUE;
  43. }
  44. /**************************************************************************/
  45. flagType
  46. pascal
  47. EXTERNAL
  48. mBRdoNext (
  49. IN USHORT argData,
  50. IN ARG far *pArg,
  51. IN flagType fMeta
  52. )
  53. /*++
  54. Routine Description:
  55. Displays next reference or definition.
  56. Arguments:
  57. Standard arguments for MEP editing functions
  58. Return Value:
  59. TRUE
  60. --*/
  61. {
  62. NextDefRef();
  63. return TRUE;
  64. }
  65. /**************************************************************************/
  66. flagType
  67. pascal
  68. EXTERNAL
  69. mBRdoPrev (
  70. IN USHORT argData,
  71. IN ARG far *pArg,
  72. IN flagType fMeta
  73. )
  74. /*++
  75. Routine Description:
  76. Displays previous reference or definition.
  77. Arguments:
  78. Standard arguments for MEP editing functions
  79. Return Value:
  80. TRUE
  81. --*/
  82. {
  83. PrevDefRef();
  84. return TRUE;
  85. }
  86. /**************************************************************************/
  87. flagType
  88. pascal
  89. EXTERNAL
  90. mBRdoDef (
  91. IN USHORT argData,
  92. IN ARG far *pArg,
  93. IN flagType fMeta
  94. )
  95. /*++
  96. Routine Description:
  97. Displays first definition of a symbol.
  98. Arguments:
  99. Standard arguments for MEP editing functions
  100. Return Value:
  101. TRUE
  102. --*/
  103. {
  104. procArgs(pArg);
  105. if (BscInUse && pArgText) {
  106. InitDefRef(Q_DEFINITION, pArgText);
  107. NextDefRef();
  108. }
  109. return TRUE;
  110. }
  111. /**************************************************************************/
  112. flagType
  113. pascal
  114. EXTERNAL
  115. mBRdoRef (
  116. IN USHORT argData,
  117. IN ARG far *pArg,
  118. IN flagType fMeta
  119. )
  120. /*++
  121. Routine Description:
  122. Displays first reference of a symbol.
  123. Arguments:
  124. Standard arguments for MEP editing functions
  125. Return Value:
  126. TRUE
  127. --*/
  128. {
  129. procArgs(pArg);
  130. if (BscInUse && pArgText) {
  131. InitDefRef(Q_REFERENCE, pArgText);
  132. NextDefRef();
  133. }
  134. return TRUE;
  135. }
  136. /**************************************************************************/
  137. flagType
  138. pascal
  139. EXTERNAL
  140. mBRdoLstRef (
  141. IN USHORT argData,
  142. IN ARG far *pArg,
  143. IN flagType fMeta
  144. )
  145. /*++
  146. Routine Description:
  147. List all references in database matching an MBF criteria.
  148. Arguments:
  149. Standard arguments for MEP editing functions
  150. Return Value:
  151. TRUE
  152. --*/
  153. {
  154. MBF mbfReqd;
  155. // The matching criteria may be specified as an argument.
  156. //
  157. procArgs(pArg);
  158. if (procArgs(pArg) != NOARG) {
  159. mbfReqd = GetMbf(pArgText);
  160. }
  161. if (BscInUse) {
  162. if ((BscCmnd == CMND_LISTREF) && (mbfReqd == mbfNil)) {
  163. //
  164. // Pseudofile already has the information we want
  165. //
  166. ShowBrowse();
  167. } else {
  168. //
  169. // Generate list
  170. //
  171. OpenBrowse();
  172. if (mbfReqd == mbfNil) {
  173. mbfReqd = BscMbf;
  174. } else {
  175. BscMbf = mbfReqd; // Matching criteria becomes default
  176. }
  177. ListRefs(mbfReqd);
  178. BscCmnd = CMND_LISTREF;
  179. BscArg[0] = '\0';
  180. }
  181. MoveCur(0,0);
  182. }
  183. return TRUE;
  184. }
  185. /**************************************************************************/
  186. flagType
  187. pascal
  188. EXTERNAL
  189. mBRdoOutlin (
  190. IN USHORT argData,
  191. IN ARG far *pArg,
  192. IN flagType fMeta
  193. )
  194. /*++
  195. Routine Description:
  196. Generate outline of a module.
  197. Arguments:
  198. Standard arguments for MEP editing functions.
  199. Return Value:
  200. FALSE if symbol is not a module,
  201. TRUE otherwise.
  202. --*/
  203. {
  204. PFILE pCurFile;
  205. procArgs(pArg);
  206. if (BscInUse) {
  207. if ((BscCmnd == CMND_OUTLINE) && (!strcmp(pArgText, BscArg))) {
  208. //
  209. // pseudofile already has the information we want
  210. //
  211. ShowBrowse();
  212. MoveCur(0,0);
  213. } else if (pArgText) {
  214. //
  215. // Make sure that the the symbol is a valid module
  216. //
  217. if (ImodFrLsz(pArgText) == imodNil) {
  218. return errstat(MBRERR_NOT_MODULE, pArgText);
  219. } else {
  220. pCurFile = FileNameToHandle("", NULL);
  221. OpenBrowse();
  222. if (FOutlineModuleLsz(pArgText,BscMbf)) {
  223. //
  224. // Function worked, set command state.
  225. //
  226. BscCmnd = CMND_OUTLINE;
  227. strcpy(BscArg, pArgText);
  228. MoveCur(0,0);
  229. } else {
  230. //
  231. // Function failed, restore previous file and reset
  232. // command state.
  233. //
  234. pFileToTop(pCurFile);
  235. BscCmnd = CMND_NONE;
  236. BscArg[0] = '\0';
  237. }
  238. }
  239. }
  240. }
  241. return TRUE;
  242. }
  243. /**************************************************************************/
  244. flagType
  245. pascal
  246. EXTERNAL
  247. mBRdoCalTre (
  248. IN USHORT argData,
  249. IN ARG far *pArg,
  250. IN flagType fMeta
  251. )
  252. /*++
  253. Routine Description:
  254. Displays calltree of a symbol.
  255. Arguments:
  256. Standard arguments for MEP editing functions.
  257. Return Value:
  258. TRUE
  259. --*/
  260. {
  261. PFILE pCurFile;
  262. BOOL FunctionWorked;
  263. procArgs(pArg);
  264. if (BscInUse) {
  265. if ((BscCmnd == CMND_CALLTREE) && (!strcmp(pArgText, BscArg))) {
  266. //
  267. // pseudofile already has the information we want.
  268. //
  269. ShowBrowse();
  270. MoveCur(0,0);
  271. } else if (pArgText) {
  272. pCurFile = FileNameToHandle("", NULL);
  273. OpenBrowse();
  274. //
  275. // Generate the tree forward or backward depending on
  276. // the value of the direction switch.
  277. //
  278. if (BscCalltreeDir == CALLTREE_FORWARD) {
  279. FunctionWorked = FCallTreeLsz(pArgText);
  280. } else {
  281. FunctionWorked = FRevTreeLsz(pArgText);
  282. }
  283. if (FunctionWorked) {
  284. //
  285. // Function worked, set command state.
  286. //
  287. BscCmnd = CMND_CALLTREE;
  288. strcpy(BscArg, pArgText);
  289. MoveCur(0,0);
  290. } else {
  291. //
  292. // Function failed, restore previous file and
  293. // reset command state.
  294. //
  295. pFileToTop(pCurFile);
  296. BscCmnd = CMND_NONE;
  297. BscArg[0] = '\00';
  298. }
  299. }
  300. }
  301. return TRUE;
  302. }