fpmsrch.inc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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.3 2002-09-07 15:40:44 peter
  209. * old logs removed and tabs fixed
  210. }