fpmsrch.inc 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  5. Search menu entries
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. function ProcedureDialog(S : string) : PDialog;
  13. var D: PDialog;
  14. R,R1,R2: TRect;
  15. IL: PInputLine;
  16. begin
  17. R.Assign(0,0,40,8);
  18. New(D, Init(R, dialog_proceduredialog));
  19. with D^ do
  20. begin
  21. Options:=Options or ofCentered;
  22. GetExtent(R); R.Grow(-3,-2); R.B.Y:=R.A.Y+1;
  23. R1.Copy(R);
  24. R2.Copy(R); Inc(R2.A.Y);Inc(R2.B.Y);
  25. New(IL, Init(R2,255));
  26. Insert(IL);
  27. IL^.SetData(S);
  28. Insert(New(PLabel, Init(R1, label_enterproceduretofind, IL)));
  29. GetExtent(R); R.Grow(-8,-1); R.A.Y:=R.B.Y-2; R.B.X:=R.A.X+10;
  30. Insert(New(PButton, Init(R, button_OK, cmOK, bfDefault)));
  31. R.Move(15,0);
  32. Insert(New(PButton, Init(R, button_Cancel, cmCancel, bfNormal)));
  33. end;
  34. IL^.Select;
  35. ProcedureDialog:=D;
  36. end;
  37. procedure TIDEApp.FindProcedure;
  38. var R: TRect;
  39. S: PSortedSymbolCollection;
  40. Overflow: boolean;
  41. ProcS : string;
  42. Level : longint;
  43. function NameMatches(const St : string) : boolean;
  44. begin
  45. NameMatches:=(ProcS='') or (Pos(ProcS,UpcaseStr(St)) > 0);
  46. end;
  47. procedure InsertInS(P: PSymbol); {$ifndef FPC}far;{$endif}
  48. procedure InsertItemsInS(P: PSymbolCollection);
  49. var I: Sw_integer;
  50. begin
  51. for I:=0 to P^.Count-1 do
  52. InsertInS(P^.At(I));
  53. end;
  54. begin
  55. Inc(level);
  56. if S^.Count=MaxCollectionSize then
  57. begin Overflow:=true; Exit; end;
  58. if {(P^.typ = procsym) this needs symconst unit which I prefer to avoid }
  59. ((P^.GetTypeName='proc') or (P^.GetTypeName='func'))
  60. and NameMatches(P^.GetName) then
  61. S^.Insert(P);
  62. { this is wrong because it inserted args or locals of proc
  63. in the globals list !! PM}
  64. if (P^.Items<>nil) and (level=1) then
  65. InsertItemsInS(P^.Items);
  66. Dec(level);
  67. end;
  68. var
  69. EditorWindow : PSourceWindow;
  70. begin
  71. level:=0;
  72. if BrowCol.Modules=nil then
  73. begin ErrorBox(msg_nodebuginfoavailable,nil); Exit; end;
  74. EditorWindow:=FirstEditorWindow;
  75. If assigned(EditorWindow) then
  76. ProcS:=LowerCaseStr(EditorWindow^.Editor^.GetCurrentWord)
  77. else
  78. ProcS:='';
  79. if ExecuteDialog(ProcedureDialog(ProcS),@ProcS)=cmCancel then
  80. exit;
  81. ProcS:=UpcaseStr(ProcS);
  82. Overflow:=false;
  83. if assigned(ProcedureCollection) then
  84. begin
  85. ProcedureCollection^.deleteAll;
  86. Dispose(ProcedureCollection,done);
  87. end;
  88. New(S, Init(500,500));
  89. ProcedureCollection:=S;
  90. BrowCol.Modules^.ForEach(@InsertInS);
  91. if Overflow then
  92. WarningBox(msg_toomanysymbolscantdisplayall,nil);
  93. Desktop^.GetExtent(R); R.A.X:=R.B.X-35;
  94. Desktop^.Insert(New(PBrowserWindow, Init(R,
  95. label_sym_findprocedure,SearchFreeWindowNo,nil,label_sym_findprocedure2+ProcS,'',S,nil,nil,nil)));
  96. end;
  97. procedure TIDEApp.Objects;
  98. begin
  99. if ObjectTree=nil then
  100. begin ErrorBox(msg_nodebuginfoavailable,nil); Exit; end;
  101. OpenSymbolBrowser(0,0,label_sym_objects,label_sym_globalscope,nil,nil,nil,nil,ObjectTree,nil);
  102. end;
  103. procedure TIDEApp.Globals;
  104. var R: TRect;
  105. S: PSortedSymbolCollection;
  106. Overflow: boolean;
  107. Level : longint;
  108. procedure InsertInS(P: PSymbol); {$ifndef FPC}far;{$endif}
  109. procedure InsertItemsInS(P: PSymbolCollection);
  110. var I: Sw_integer;
  111. begin
  112. for I:=0 to P^.Count-1 do
  113. InsertInS(P^.At(I));
  114. end;
  115. begin
  116. Inc(level);
  117. if S^.Count=MaxCollectionSize then
  118. begin Overflow:=true; Exit; end;
  119. S^.Insert(P);
  120. { this is wrong because it inserted args or locals of proc
  121. in the globals list !! PM}
  122. if (P^.Items<>nil) and (level=1) then
  123. InsertItemsInS(P^.Items);
  124. Dec(level);
  125. end;
  126. begin
  127. level:=0;
  128. if BrowCol.Modules=nil then
  129. begin ErrorBox(msg_nodebuginfoavailable,nil); Exit; end;
  130. Overflow:=false;
  131. if assigned(GlobalsCollection) then
  132. begin
  133. GlobalsCollection^.deleteAll;
  134. Dispose(GlobalsCollection,done);
  135. end;
  136. New(S, Init(500,500));
  137. GlobalsCollection:=S;
  138. BrowCol.Modules^.ForEach(@InsertInS);
  139. if Overflow then
  140. WarningBox(msg_toomanysymbolscantdisplayall,nil);
  141. Desktop^.GetExtent(R); R.A.X:=R.B.X-35;
  142. Desktop^.Insert(New(PBrowserWindow, Init(R,
  143. label_sym_globals,SearchFreeWindowNo,nil,label_sym_globalscope,'',S,nil,nil,nil)));
  144. end;
  145. procedure TIDEApp.Modules;
  146. var
  147. R: TRect;
  148. S: PSortedSymbolCollection;
  149. procedure InsertInS(P: PSymbol); {$ifndef FPC}far;{$endif}
  150. begin
  151. S^.Insert(P);
  152. end;
  153. begin
  154. if BrowCol.Modules=nil then
  155. begin ErrorBox(msg_nodebuginfoavailable,nil); Exit; end;
  156. if assigned(ModulesCollection) then
  157. begin
  158. ModulesCollection^.deleteAll;
  159. Dispose(ModulesCollection,done);
  160. end;
  161. New(S, Init(500,500));
  162. ModulesCollection:=S;
  163. BrowCol.Modules^.ForEach(@InsertInS);
  164. Desktop^.GetExtent(R); R.A.X:=R.B.X-35;
  165. Desktop^.Insert(New(PBrowserWindow, Init(R,
  166. dialog_units,SearchFreeWindowNo,nil,label_sym_globalscope,'',S,nil,nil,nil)));
  167. end;
  168. function SymbolDialog(S : string) : PDialog;
  169. var D: PDialog;
  170. R,R1,R2: TRect;
  171. IL: PInputLine;
  172. begin
  173. R.Assign(0,0,40,8);
  174. New(D, Init(R, dialog_browsesymbol));
  175. with D^ do
  176. begin
  177. Options:=Options or ofCentered;
  178. GetExtent(R); R.Grow(-3,-2); R.B.Y:=R.A.Y+1;
  179. R1.Copy(R);
  180. R2.Copy(R); Inc(R2.A.Y);Inc(R2.B.Y);
  181. New(IL, Init(R2,255));
  182. Insert(IL);
  183. IL^.SetData(S);
  184. Insert(New(PLabel, Init(R1, label_entersymboltobrowse, IL)));
  185. GetExtent(R); R.Grow(-8,-1); R.A.Y:=R.B.Y-2; R.B.X:=R.A.X+10;
  186. Insert(New(PButton, Init(R, button_OK, cmOK, bfDefault)));
  187. R.Move(15,0);
  188. Insert(New(PButton, Init(R, button_Cancel, cmCancel, bfNormal)));
  189. end;
  190. IL^.Select;
  191. SymbolDialog:=D;
  192. end;
  193. procedure TIDEApp.SearchSymbol;
  194. var
  195. EditorWindow : PSourceWindow;
  196. S : string;
  197. begin
  198. EditorWindow:=FirstEditorWindow;
  199. If assigned(EditorWindow) then
  200. S:=LowerCaseStr(EditorWindow^.Editor^.GetCurrentWord)
  201. else
  202. S:='';
  203. if ExecuteDialog(SymbolDialog(S),@S)<>cmCancel then
  204. OpenOneSymbolBrowser(S);
  205. end;
  206. {
  207. $Log$
  208. Revision 1.2 2001-10-24 21:49:56 pierre
  209. + FindProcedure implemented
  210. Revision 1.1 2001/08/04 11:30:23 peter
  211. * ide works now with both compiler versions
  212. Revision 1.1.2.1 2001/03/20 00:20:42 pierre
  213. * fix some memory leaks + several small enhancements
  214. Revision 1.1 2000/07/13 09:48:35 michael
  215. + Initial import
  216. Revision 1.13 2000/05/02 08:42:28 pierre
  217. * new set of Gabor changes: see fixes.txt
  218. Revision 1.12 2000/03/07 21:57:01 pierre
  219. * adapted to change of OpenSymbolBrowser
  220. Revision 1.11 1999/07/28 23:11:21 peter
  221. * fixes from gabor
  222. Revision 1.10 1999/06/29 12:49:55 pierre
  223. * SearchSymbol works
  224. Revision 1.9 1999/06/28 19:32:22 peter
  225. * fixes from gabor
  226. Revision 1.8 1999/06/28 12:38:19 pierre
  227. * Globals(Modules)Collection tracing
  228. Revision 1.7 1999/06/25 00:34:50 pierre
  229. + SearchSymbol function
  230. Revision 1.6 1999/04/07 21:55:51 peter
  231. + object support for browser
  232. * html help fixes
  233. * more desktop saving things
  234. * NODEBUG directive to exclude debugger
  235. Revision 1.5 1999/03/01 15:41:59 peter
  236. + Added dummy entries for functions not yet implemented
  237. * MenuBar didn't update itself automatically on command-set changes
  238. * Fixed Debugging/Profiling options dialog
  239. * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
  240. set
  241. * efBackSpaceUnindents works correctly
  242. + 'Messages' window implemented
  243. + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros
  244. + Added TP message-filter support (for ex. you can call GREP thru
  245. GREP2MSG and view the result in the messages window - just like in TP)
  246. * A 'var' was missing from the param-list of THelpFacility.TopicSearch,
  247. so topic search didn't work...
  248. * In FPHELP.PAS there were still context-variables defined as word instead
  249. of THelpCtx
  250. * StdStatusKeys() was missing from the statusdef for help windows
  251. + Topic-title for index-table can be specified when adding a HTML-files
  252. Revision 1.4 1999/02/10 09:51:03 pierre
  253. * Adapted to TBrowserWindow changes
  254. Revision 1.3 1999/02/04 13:32:08 pierre
  255. * Several things added (I cannot commit them independently !)
  256. + added TBreakpoint and TBreakpointCollection
  257. + added cmResetDebugger,cmGrep,CmToggleBreakpoint
  258. + Breakpoint list in INIFile
  259. * Select items now also depend of SwitchMode
  260. * Reading of option '-g' was not possible !
  261. + added search for -Fu args pathes in TryToOpen
  262. + added code for automatic opening of FileDialog
  263. if source not found
  264. Revision 1.2 1999/01/14 21:42:23 peter
  265. * source tracking from Gabor
  266. Revision 1.1 1999/01/12 14:29:37 peter
  267. + Implemented still missing 'switch' entries in Options menu
  268. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  269. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  270. ASCII chars and inserted directly in the text.
  271. + Added symbol browser
  272. * splitted fp.pas to fpide.pas
  273. Revision 1.9 1999/01/09 18:00:47 peter
  274. Original implementation
  275. }