fpsymbol.pas 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  5. Symbol browse support routines for the IDE
  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. {$i globdir.inc}
  13. unit FPSymbol;
  14. interface
  15. uses Objects,Drivers,Views,Menus,Dialogs,
  16. {$ifdef HASOUTLINE}
  17. Outline,
  18. {$endif HASOUTLINE}
  19. BrowCol,
  20. WViews,
  21. FPViews;
  22. const
  23. { Browser tab constants }
  24. btScope = 0;
  25. btReferences = 1;
  26. btInheritance = 2;
  27. btMemInfo = 3;
  28. btUnitInfo = 4;
  29. btBreakWatch = 7;
  30. type
  31. PBrowserWindow = ^TBrowserWindow;
  32. PGDBValueCollection = ^TGDBValueCollection;
  33. PGDBValue = ^TGDBValue;
  34. TGDBValue = Object(TObject)
  35. constructor Init(Const AExpr : String;ASym : PSymbol);
  36. procedure GetValue;
  37. function GetText : String;
  38. destructor Done;virtual;
  39. private
  40. expr : Pstring;
  41. St : Pstring;
  42. S : PSymbol;
  43. GDBI : longint;
  44. end;
  45. TGDBValueCollection = Object(TCollection)
  46. function At(Index: sw_Integer): PGDBValue;
  47. end;
  48. PSymbolView = ^TSymbolView;
  49. TSymbolView = object(TLocalMenuListBox)
  50. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  51. destructor Done;virtual;
  52. procedure HandleEvent(var Event: TEvent); virtual;
  53. procedure SetState(AState: Word; Enable: Boolean); virtual;
  54. function GotoItem(Item: sw_integer): boolean; virtual;
  55. function TrackItem(Item: sw_integer; AutoTrack: boolean): boolean; virtual;
  56. function GetPalette: PPalette; virtual;
  57. function GetLocalMenu: PMenu; virtual;
  58. procedure ClearHighlights;
  59. procedure AutoTrackSource; virtual;
  60. procedure Browse; virtual;
  61. procedure GotoSource; virtual;
  62. procedure TrackSource; virtual;
  63. procedure OptionsDlg; virtual;
  64. private
  65. MyBW : PBrowserWindow;
  66. function TrackReference(R: PReference; AutoTrack: boolean): boolean; virtual;
  67. function GotoReference(R: PReference): boolean; virtual;
  68. end;
  69. PSymbolScopeView = ^TSymbolScopeView;
  70. TSymbolScopeView = object(TSymbolView)
  71. constructor Init(var Bounds: TRect; ASymbols: PSymbolCollection; AHScrollBar, AVScrollBar: PScrollBar);
  72. destructor Done; virtual;
  73. procedure SetGDBCol;
  74. function GetText(Item,MaxLen: Sw_Integer): String; virtual;
  75. procedure HandleEvent(var Event: TEvent); virtual;
  76. procedure Draw; virtual;
  77. procedure LookUp(S: string); virtual;
  78. function GotoItem(Item: sw_integer): boolean; virtual;
  79. function TrackItem(Item: sw_integer; AutoTrack: boolean): boolean; virtual;
  80. private
  81. Symbols: PSymbolCollection;
  82. SymbolsValue : PGDBValueCollection;
  83. LookupStr: string;
  84. end;
  85. PSymbolReferenceView = ^TSymbolReferenceView;
  86. TSymbolReferenceView = object(TSymbolView)
  87. constructor Init(var Bounds: TRect; AReferences: PReferenceCollection; AHScrollBar, AVScrollBar: PScrollBar);
  88. destructor Done; virtual;
  89. procedure HandleEvent(var Event: TEvent); virtual;
  90. function GetText(Item,MaxLen: Sw_Integer): String; virtual;
  91. procedure SelectItem(Item: Sw_Integer); virtual;
  92. function GotoItem(Item: sw_integer): boolean; virtual;
  93. function TrackItem(Item: sw_integer; AutoTrack: boolean): boolean; virtual;
  94. procedure Browse; virtual;
  95. private
  96. References: PReferenceCollection;
  97. end;
  98. PSymbolMemInfoView = ^TSymbolMemInfoView;
  99. TSymbolMemInfoView = object(TStaticText)
  100. constructor Init(var Bounds: TRect; AMemInfo: PSymbolMemInfo);
  101. destructor Done; virtual;
  102. procedure GetText(var S: String); virtual;
  103. function GetPalette: PPalette; virtual;
  104. private
  105. MemInfo: PSymbolMemInfo;
  106. MyBW : PBrowserWindow;
  107. end;
  108. PSymbolMemoView = ^TSymbolMemoView;
  109. TSymbolMemoView = object(TFPMemo)
  110. function GetPalette: PPalette; virtual;
  111. end;
  112. {$ifdef HASOUTLINE}
  113. PSymbolInheritanceView = ^TSymbolInheritanceView;
  114. TSymbolInheritanceView = object(TOutlineViewer)
  115. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar; ARoot: PObjectSymbol);
  116. destructor Done; virtual;
  117. function GetRoot: Pointer; virtual;
  118. function HasChildren(Node: Pointer): Boolean; virtual;
  119. function GetChild(Node: Pointer; I: Integer): Pointer; virtual;
  120. function GetNumChildren(Node: Pointer): Integer; virtual;
  121. function GetText(Node: Pointer): String; virtual;
  122. procedure Adjust(Node: Pointer; Expand: Boolean); virtual;
  123. function IsExpanded(Node: Pointer): Boolean; virtual;
  124. procedure Selected(I: Integer); virtual;
  125. procedure HandleEvent(var Event: TEvent); virtual;
  126. function GetPalette: PPalette; virtual;
  127. private
  128. Root : PObjectSymbol;
  129. MyBW : PBrowserWindow;
  130. end;
  131. {$endif HASOUTLINE}
  132. PBrowserTabItem = ^TBrowserTabItem;
  133. TBrowserTabItem = record
  134. Sign : char;
  135. Link : PView;
  136. Next : PBrowserTabItem;
  137. end;
  138. PBrowserTab = ^TBrowserTab;
  139. TBrowserTab = object(TView)
  140. Items: PBrowserTabItem;
  141. constructor Init(var Bounds: TRect; AItems: PBrowserTabItem);
  142. function GetItemCount: sw_integer; virtual;
  143. function GetItem(Index: sw_integer): PBrowserTabItem; virtual;
  144. procedure SetParams(AFlags: word; ACurrent: Sw_integer); virtual;
  145. procedure SelectItem(Index: Sw_integer); virtual;
  146. procedure Draw; virtual;
  147. function GetPalette: PPalette; virtual;
  148. procedure HandleEvent(var Event: TEvent); virtual;
  149. destructor Done; virtual;
  150. private
  151. Flags : word;
  152. Current : Sw_integer;
  153. end;
  154. PUnitInfoPanel = ^TUnitInfoPanel;
  155. TUnitInfoPanel = object(TPanel)
  156. InOwnerCall: boolean;
  157. procedure HandleEvent(var Event: TEvent); virtual;
  158. end;
  159. TBrowserWindow = object(TFPWindow)
  160. constructor Init(var Bounds: TRect; ATitle: TTitleStr; ANumber: Sw_Integer;ASym : PSymbol;
  161. const AName,APrefix: string; ASymbols: PSymbolCollection; AReferences: PReferenceCollection;
  162. AInheritance: PObjectSymbol; AMemInfo: PSymbolMemInfo);
  163. procedure HandleEvent(var Event: TEvent); virtual;
  164. procedure SetState(AState: Word; Enable: Boolean); virtual;
  165. procedure Close; virtual;
  166. procedure SelectTab(BrowserTab: Sw_integer); virtual;
  167. function GetPalette: PPalette; virtual;
  168. function Disassemble : boolean;
  169. destructor Done;virtual;
  170. private
  171. PageTab : PBrowserTab;
  172. ST : PStaticText;
  173. Sym : PSymbol;
  174. ScopeView : PSymbolScopeView;
  175. ReferenceView : PSymbolReferenceView;
  176. {$ifdef HASOUTLINE}
  177. InheritanceView: PSymbolInheritanceView;
  178. {$endif HASOUTLIEN}
  179. MemInfoView : PSymbolMemInfoView;
  180. UnitInfoText : PSymbolMemoView;
  181. UnitInfoUsed : PSymbolScopeView;
  182. UnitInfoDependent : PSymbolScopeView;
  183. UnitInfo : PUnitInfoPanel;
  184. Prefix : PString;
  185. IsValid : boolean;
  186. DebuggerValue : PGDBValue;
  187. end;
  188. procedure OpenSymbolBrowser(X,Y: Sw_integer;const Name,Line: string;S : PSymbol;
  189. ParentBrowser : PBrowserWindow;
  190. Symbols: PSymbolCollection; References: PReferenceCollection;
  191. Inheritance: PObjectSymbol; MemInfo: PSymbolMemInfo);
  192. function IsSymbolInfoAvailable: boolean;
  193. procedure OpenOneSymbolBrowser(Name : String);
  194. procedure CloseAllBrowsers;
  195. procedure RemoveBrowsersCollection;
  196. const
  197. GlobalsCollection : PSortedCollection = nil;
  198. ProcedureCollection : PSortedCollection = nil;
  199. ModulesCollection : PSortedCollection = nil;
  200. implementation
  201. uses App,Strings,
  202. FVConsts,
  203. {$ifdef BROWSERCOL}
  204. symconst,
  205. {$endif BROWSERCOL}
  206. WUtils,WEditor,
  207. FPConst,FPString,FPUtils,FPVars,{$ifndef FPDEBUG}FPDebug{$endif},FPIDE;
  208. procedure CloseAllBrowsers;
  209. procedure SendCloseIfBrowser(P: PView); {$ifndef FPC}far;{$endif}
  210. begin
  211. if assigned(P) and
  212. ((TypeOf(P^)=TypeOf(TBrowserWindow)) or
  213. (TypeOf(P^)=TypeOf(TSymbolView)) or
  214. (TypeOf(P^)=TypeOf(TSymbolScopeView)) or
  215. (TypeOf(P^)=TypeOf(TSymbolReferenceView)) or
  216. (TypeOf(P^)=TypeOf(TSymbolMemInfoView)) or
  217. {$ifdef HASOUTLINE}
  218. (TypeOf(P^)=TypeOf(TSymbolInheritanceView)) or
  219. {$endif HASOUTLINE}
  220. (TypeOf(P^)=TypeOf(TSymbolMemoView))) then
  221. Message(P,evCommand,cmClose,nil);
  222. end;
  223. begin
  224. Desktop^.ForEach(@SendCloseIfBrowser);
  225. end;
  226. procedure RemoveBrowsersCollection;
  227. begin
  228. if assigned(GlobalsCollection) then
  229. begin
  230. GlobalsCollection^.deleteAll;
  231. Dispose(GlobalsCollection,done);
  232. GlobalsCollection:=nil;
  233. end;
  234. if assigned(ProcedureCollection) then
  235. begin
  236. ProcedureCollection^.deleteAll;
  237. Dispose(ProcedureCollection,done);
  238. ProcedureCollection:=nil;
  239. end;
  240. if assigned(ModulesCollection) then
  241. begin
  242. ModulesCollection^.deleteAll;
  243. Dispose(ModulesCollection,done);
  244. ModulesCollection:=nil;
  245. end;
  246. end;
  247. function NewBrowserTabItem(ASign: char; ALink: PView; ANext: PBrowserTabItem): PBrowserTabItem;
  248. var P: PBrowserTabItem;
  249. begin
  250. New(P); FillChar(P^,SizeOf(P^),0);
  251. with P^ do begin Sign:=ASign; Link:=ALink; Next:=ANext; end;
  252. NewBrowserTabItem:=P;
  253. end;
  254. procedure DisposeBrowserTabItem(P: PBrowserTabItem);
  255. begin
  256. if P<>nil then Dispose(P);
  257. end;
  258. procedure DisposeBrowserTabList(P: PBrowserTabItem);
  259. begin
  260. if P<>nil then
  261. begin
  262. if P^.Next<>nil then DisposeBrowserTabList(P^.Next);
  263. DisposeBrowserTabItem(P);
  264. end;
  265. end;
  266. function IsSymbolInfoAvailable: boolean;
  267. begin
  268. IsSymbolInfoAvailable:=BrowCol.Modules<>nil;
  269. end;
  270. procedure OpenOneSymbolBrowser(Name : String);
  271. var Index : sw_integer;
  272. PS,S : PSymbol;
  273. Anc : PObjectSymbol;
  274. P : Pstring;
  275. Symbols: PSymbolCollection;
  276. function Search(P : PSymbol) : boolean;
  277. begin
  278. Search:=UpcaseStr(P^.Items^.LookUp(Name,Index))=Name;
  279. end;
  280. begin
  281. Name:=UpcaseStr(Name);
  282. If BrowCol.Modules<>nil then
  283. begin
  284. PS:=BrowCol.Modules^.FirstThat(@Search);
  285. If assigned(PS) then
  286. begin
  287. S:=PS^.Items^.At(Index);
  288. Symbols:=S^.Items;
  289. if (not assigned(symbols) or (symbols^.count=0)) and
  290. assigned(S^.Ancestor) then
  291. Symbols:=S^.Ancestor^.Items;
  292. if (S^.Flags and sfObject)=0 then
  293. Anc:=nil
  294. else if S^.Ancestor=nil then
  295. Anc:=ObjectTree
  296. else
  297. Anc:=SearchObjectForSymbol(S^.Ancestor);
  298. OpenSymbolBrowser(0,20,
  299. PS^.Items^.At(Index)^.GetName,
  300. PS^.Items^.At(Index)^.GetText,
  301. PS^.Items^.At(Index),nil,
  302. Symbols,PS^.Items^.At(Index)^.References,Anc,PS^.MemInfo);
  303. end
  304. else
  305. begin
  306. P:=@Name;
  307. ErrorBox(msg_symbolnotfound,@P);
  308. end;
  309. end
  310. else
  311. ErrorBox(msg_nobrowserinfoavailable,nil);
  312. end;
  313. (*procedure ReadBrowseLog(FileName: string);
  314. var f: text;
  315. IOOK,EndOfFile: boolean;
  316. Line: string;
  317. procedure NextLine;
  318. begin
  319. readln(f,Line);
  320. EndOfFile:=Eof(f);
  321. end;
  322. var Level: integer;
  323. procedure ProcessSymTable(Indent: integer; Owner: PSymbolCollection);
  324. var IndentS,S,Source: string;
  325. Sym: PSymbol;
  326. Ref: PSymbolReference;
  327. P: byte;
  328. PX: TPoint;
  329. PS: PString;
  330. PCount: integer;
  331. Params: array[0..30] of PString;
  332. Typ: tsymtyp;
  333. ExitBack: boolean;
  334. begin
  335. Inc(Level);
  336. IndentS:=CharStr(' ',Indent); ExitBack:=false;
  337. Sym:=nil;
  338. repeat
  339. if copy(Line,1,length(IndentS))<>IndentS then ExitBack:=true else
  340. if copy(Line,Indent+1,3)='***' then
  341. { new symbol }
  342. begin
  343. S:=copy(Line,Indent+1+3,255);
  344. P:=Pos('***',S); if P=0 then P:=length(S)+1;
  345. S:=Trim(copy(S,1,P-1));
  346. if (copy(S,1,1)='_') and (Pos('$$',S)>0) then
  347. begin
  348. repeat
  349. P:=Pos('$$',S);
  350. if P>0 then Delete(S,1,P+1);
  351. until P=0;
  352. P:=Pos('$',S);
  353. Delete(S,1,P);
  354. PCount:=0;
  355. repeat
  356. P:=Pos('$',S); if P=0 then P:=length(S)+1;
  357. Params[PCount]:=TypeNames^.Add(copy(S,1,P-1));
  358. Inc(PCount);
  359. Delete(S,1,P);
  360. until S='';
  361. Sym^.Typ:=procsym;
  362. Sym^.SetParams(PCount,@Params);
  363. end
  364. else
  365. New(Sym, Init(S, varsym, 0, nil));
  366. Owner^.Insert(Sym);
  367. NextLine;
  368. end else
  369. if copy(Line,Indent+1,3)='---' then
  370. { child symtable }
  371. begin
  372. S:=Trim(copy(Line,Indent+1+12,255));
  373. if Level=1 then Typ:=unitsym else
  374. Typ:=typesym;
  375. if (Sym<>nil) and (Sym^.GetName=S) then
  376. else
  377. begin
  378. New(Sym, Init(S, Typ, 0, nil));
  379. Owner^.Insert(Sym);
  380. end;
  381. Sym^.Typ:=Typ;
  382. NextLine;
  383. New(Sym^.Items, Init(0,50));
  384. ProcessSymTable(Indent+2,Sym^.Items);
  385. end else
  386. { if Sym<>nil then}
  387. if copy(Line,Indent+1,1)=' ' then
  388. { reference }
  389. begin
  390. S:=copy(Line,Indent+1+2,255);
  391. P:=Pos('(',S); if P=0 then P:=length(S)+1;
  392. Source:=Trim(copy(S,1,P-1)); Delete(S,1,P);
  393. P:=Pos(',',S); if P=0 then P:=length(S)+1;
  394. PX.Y:=StrToInt(copy(S,1,P-1)); Delete(S,1,P);
  395. P:=Pos(')',S); if P=0 then P:=length(S)+1;
  396. PX.X:=StrToInt(copy(S,1,P-1)); Delete(S,1,P);
  397. PS:=ModuleNames^.Add(Source);
  398. New(Ref, Init(PS, PX));
  399. if Sym^.References=nil then
  400. New(Sym^.References, Init(10,50));
  401. Sym^.References^.Insert(Ref);
  402. end;
  403. if ExitBack=false then
  404. NextLine;
  405. until EndOfFile or ExitBack;
  406. Dec(Level);
  407. end;
  408. begin
  409. DoneSymbolBrowser;
  410. InitSymbolBrowser;
  411. {$I-}
  412. Assign(f,FileName);
  413. Reset(f);
  414. Level:=0;
  415. NextLine;
  416. while (IOResult=0) and (EndOfFile=false) do
  417. ProcessSymTable(0,Modules);
  418. Close(f);
  419. EatIO;
  420. {$I+}
  421. end;*)
  422. {****************************************************************************
  423. TGDBValue
  424. ****************************************************************************}
  425. constructor TGDBValue.Init(Const AExpr : String;ASym : PSymbol);
  426. begin
  427. St := nil;
  428. S := ASym;
  429. Expr:=NewStr(AExpr);
  430. GDBI:=-1;
  431. end;
  432. destructor TGDBValue.Done;
  433. begin
  434. If Assigned(St) then
  435. begin
  436. DisposeStr(St);
  437. st:=nil;
  438. end;
  439. If Assigned(Expr) then
  440. begin
  441. DisposeStr(Expr);
  442. Expr:=nil;
  443. end;
  444. end;
  445. procedure TGDBValue.GetValue;
  446. var
  447. p : pchar;
  448. begin
  449. {$ifdef BROWSERCOL}
  450. {$ifndef NODEBUG}
  451. if not assigned(Debugger) then
  452. exit;
  453. if not Debugger^.IsRunning then
  454. exit;
  455. if (S^.typ<>varsym) or (GDBI=Debugger^.RunCount) then
  456. exit;
  457. If Assigned(St) then
  458. DisposeStr(St);
  459. if assigned(Expr) then
  460. begin
  461. p:=Debugger^.GetValue(Expr^);
  462. St:=NewStr(GetPChar(p));
  463. if assigned(p) then
  464. StrDispose(p);
  465. GDBI:=Debugger^.RunCount;
  466. end;
  467. {$endif ndef NODEBUG}
  468. {$endif BROWSERCOL}
  469. end;
  470. function TGDBValue.GetText : String;
  471. begin
  472. GetValue;
  473. if assigned(St) then
  474. GetText:=S^.GetText+' = '+GetStr(St)
  475. else
  476. GetText:=S^.GetText;
  477. end;
  478. {****************************************************************************
  479. TGDBValueCollection
  480. ****************************************************************************}
  481. function TGDBValueCollection.At(Index: sw_Integer): PGDBValue;
  482. begin
  483. At:= Inherited At(Index);
  484. end;
  485. {****************************************************************************
  486. TSymbolView
  487. ****************************************************************************}
  488. constructor TSymbolView.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  489. begin
  490. inherited Init(Bounds,1,AVScrollBar);
  491. HScrollBar:=AHScrollBar;
  492. MyBW:=nil;
  493. if assigned(HScrollBar) then
  494. begin
  495. HScrollBar^.SetRange(1,80);
  496. end;
  497. Options:=Options or (ofSelectable+ofTopSelect);
  498. EventMask:=EventMask or evBroadcast;
  499. end;
  500. procedure TSymbolView.ClearHighlights;
  501. begin
  502. Message(Desktop,evBroadcast,cmClearLineHighlights,nil);
  503. end;
  504. procedure TSymbolView.AutoTrackSource;
  505. begin
  506. if Range>0 then
  507. TrackSource;
  508. end;
  509. procedure TSymbolView.OptionsDlg;
  510. begin
  511. { Abstract }
  512. end;
  513. destructor TSymbolView.Done;
  514. begin
  515. EventMask:=EventMask and not evBroadcast;
  516. Inherited Done;
  517. end;
  518. procedure TSymbolView.SetState(AState: Word; Enable: Boolean);
  519. var OState: longint;
  520. begin
  521. OState:=State;
  522. inherited SetState(AState,Enable);
  523. if ((OState xor State) and sfFocused)<>0 then
  524. if GetState(sfFocused) then
  525. begin
  526. if (MiscOptions and moAutoTrackSource)<>0 then
  527. AutoTrackSource;
  528. end
  529. else
  530. Message(Desktop,evBroadcast,cmClearLineHighlights,nil);
  531. end;
  532. procedure TSymbolView.Browse;
  533. begin
  534. SelectItem(Focused);
  535. end;
  536. procedure TSymbolView.GotoSource;
  537. begin
  538. if GotoItem(Focused) then
  539. PutCommand(Owner,evCommand,cmClose,nil);
  540. end;
  541. procedure TSymbolView.TrackSource;
  542. begin
  543. TrackItem(Focused,false);
  544. end;
  545. procedure TSymbolView.HandleEvent(var Event: TEvent);
  546. var DontClear: boolean;
  547. begin
  548. case Event.What of
  549. evKeyDown :
  550. begin
  551. DontClear:=false;
  552. case Event.KeyCode of
  553. kbEnter :
  554. Browse;
  555. kbCtrlEnter :
  556. GotoSource;
  557. kbSpaceBar :
  558. TrackSource;
  559. kbRight,kbLeft :
  560. if HScrollBar<>nil then
  561. HScrollBar^.HandleEvent(Event);
  562. else DontClear:=true;
  563. end;
  564. if DontClear=false then ClearEvent(Event);
  565. end;
  566. evMouseDown :
  567. begin
  568. if Event.double then
  569. begin
  570. Browse;
  571. ClearEvent(Event);
  572. end;
  573. end;
  574. evCommand :
  575. begin
  576. DontClear:=false;
  577. case Event.Command of
  578. cmSymBrowse :
  579. Browse;
  580. cmSymGotoSource :
  581. GotoSource;
  582. cmSymTrackSource :
  583. TrackSource;
  584. cmSymOptions :
  585. OptionsDlg;
  586. else DontClear:=true;
  587. end;
  588. if DontClear=false then ClearEvent(Event);
  589. end;
  590. evBroadcast :
  591. case Event.Command of
  592. cmListFocusChanged :
  593. if Event.InfoPtr=@Self then
  594. if (MiscOptions and moAutoTrackSource)<>0 then
  595. if GetState(sfFocused) then
  596. AutoTrackSource;
  597. end;
  598. end;
  599. inherited HandleEvent(Event);
  600. end;
  601. function TSymbolView.GetPalette: PPalette;
  602. const
  603. P: string[length(CBrowserListBox)] = CBrowserListBox;
  604. begin
  605. GetPalette:=@P;
  606. end;
  607. function TSymbolView.GetLocalMenu: PMenu;
  608. begin
  609. GetLocalMenu:=NewMenu(
  610. NewItem(menu_symlocal_browse,'',kbNoKey,cmSymBrowse,hcSymBrowse,
  611. NewItem(menu_symlocal_gotosource,'',kbNoKey,cmSymGotoSource,hcSymGotoSource,
  612. NewItem(menu_symlocal_tracksource,'',kbNoKey,cmSymTrackSource,hcSymTrackSource,
  613. NewLine(
  614. NewItem(menu_symlocal_options,'',kbNoKey,cmSymOptions,hcSymOptions,
  615. nil))))));
  616. end;
  617. function TSymbolView.GotoItem(Item: sw_integer): boolean;
  618. begin
  619. SelectItem(Item);
  620. GotoItem:=true;
  621. end;
  622. function TSymbolView.TrackItem(Item: sw_integer; AutoTrack: boolean): boolean;
  623. begin
  624. SelectItem(Item);
  625. TrackItem:=true;
  626. end;
  627. function LastBrowserWindow: PBrowserWindow;
  628. var BW: PBrowserWindow;
  629. procedure IsBW(P: PView); {$ifndef FPC}far;{$endif}
  630. begin
  631. if (P^.HelpCtx=hcBrowserWindow) then
  632. BW:=pointer(P);
  633. end;
  634. begin
  635. BW:=nil;
  636. Desktop^.ForEach(@IsBW);
  637. LastBrowserWindow:=BW;
  638. end;
  639. function TSymbolView.TrackReference(R: PReference; AutoTrack: boolean): boolean;
  640. var W: PSourceWindow;
  641. BW: PBrowserWindow;
  642. P: TPoint;
  643. begin
  644. ClearHighlights;
  645. Desktop^.Lock;
  646. P.X:=R^.Position.X-1; P.Y:=R^.Position.Y-1;
  647. if AutoTrack then
  648. W:=SearchOnDesktop(R^.GetFileName,false)
  649. else
  650. W:=TryToOpenFile(nil,R^.GetFileName,P.X,P.Y,true);
  651. if not assigned(W) then
  652. begin
  653. Desktop^.Unlock;
  654. if IDEApp.OpenSearch(R^.GetFileName+'*') then
  655. begin
  656. W:=TryToOpenFile(nil,R^.GetFileName,R^.Position.X-1,R^.Position.Y-1,true);
  657. if Assigned(W) then
  658. W^.Select;
  659. end;
  660. Desktop^.Lock;
  661. end;
  662. if W<>nil then
  663. begin
  664. BW:=LastBrowserWindow;
  665. if BW=nil then
  666. W^.Select
  667. else
  668. begin
  669. Desktop^.Delete(W);
  670. Desktop^.InsertBefore(W,BW^.NextView);
  671. end;
  672. W^.Editor^.SetLineFlagExclusive(lfHighlightRow,P.Y);
  673. end;
  674. Desktop^.UnLock;
  675. if Assigned(W)=false then
  676. ErrorBox(FormatStrStr(msg_cantfindfile,R^.GetFileName),nil);
  677. TrackReference:=W<>nil;
  678. end;
  679. function TSymbolView.GotoReference(R: PReference): boolean;
  680. var W: PSourceWindow;
  681. begin
  682. Desktop^.Lock;
  683. W:=TryToOpenFile(nil,R^.GetFileName,R^.Position.X-1,R^.Position.Y-1,true);
  684. if Assigned(W) then
  685. W^.Select
  686. else
  687. begin
  688. Desktop^.Unlock;
  689. if IDEApp.OpenSearch(R^.GetFileName+'*') then
  690. begin
  691. W:=TryToOpenFile(nil,R^.GetFileName,R^.Position.X-1,R^.Position.Y-1,true);
  692. if Assigned(W) then
  693. W^.Select;
  694. end;
  695. Desktop^.Lock;
  696. end;
  697. Desktop^.UnLock;
  698. if Assigned(W)=false then
  699. ErrorBox(FormatStrStr(msg_cantfindfile,R^.GetFileName),nil);
  700. GotoReference:=W<>nil;
  701. end;
  702. {****************************************************************************
  703. TSymbolScopeView
  704. ****************************************************************************}
  705. constructor TSymbolScopeView.Init(var Bounds: TRect; ASymbols: PSymbolCollection; AHScrollBar, AVScrollBar: PScrollBar);
  706. begin
  707. inherited Init(Bounds,AHScrollBar, AVScrollBar);
  708. Symbols:=ASymbols;
  709. NewList(ASymbols);
  710. New(SymbolsValue,Init(50,50));
  711. SetRange(Symbols^.Count);
  712. end;
  713. destructor TSymbolScopeView.Done;
  714. begin
  715. {if assigned(Symbols) then
  716. begin
  717. the elements belong to other lists
  718. Symbols^.DeleteAll;
  719. dispose(Symbols,done);
  720. end;}
  721. if Assigned(SymbolsValue) then
  722. begin
  723. Dispose(SymbolsValue,Done);
  724. SymbolsValue:=nil;
  725. end;
  726. Inherited Done;
  727. end;
  728. procedure TSymbolScopeView.HandleEvent(var Event: TEvent);
  729. var OldFocus: sw_integer;
  730. begin
  731. case Event.What of
  732. evKeyDown :
  733. case Event.KeyCode of
  734. kbBack :
  735. begin
  736. LookUp(copy(LookUpStr,1,length(LookUpStr)-1));
  737. ClearEvent(Event);
  738. end;
  739. else
  740. if Event.CharCode in[#33..#255] then
  741. begin
  742. LookUp(LookUpStr+Event.CharCode);
  743. ClearEvent(Event);
  744. end;
  745. end;
  746. end;
  747. OldFocus:=Focused;
  748. inherited HandleEvent(Event);
  749. if OldFocus<>Focused then
  750. Lookup('');
  751. end;
  752. procedure TSymbolScopeView.Draw;
  753. var DeltaX: sw_integer;
  754. begin
  755. inherited Draw;
  756. if Assigned(HScrollBar)=false then DeltaX:=0 else
  757. DeltaX:=HScrollBar^.Value-HScrollBar^.Min;
  758. SetCursor(2+SymbolTypLen+length(LookUpStr)-DeltaX,Focused-TopItem);
  759. end;
  760. procedure TSymbolScopeView.LookUp(S: string);
  761. var Idx,Slength: Sw_integer;
  762. NS: string;
  763. begin
  764. NS:=LookUpStr;
  765. Slength:=Length(S);
  766. if (Symbols=nil) or (S='') then NS:='' else
  767. begin
  768. S:=Symbols^.LookUp(S,Idx);
  769. if Idx<>-1 then
  770. begin
  771. NS:=S;
  772. FocusItem(Idx);
  773. end;
  774. end;
  775. LookUpStr:=Copy(NS,1,Slength);
  776. SetState(sfCursorVis,LookUpStr<>'');
  777. DrawView;
  778. end;
  779. function TSymbolScopeView.GotoItem(Item: sw_integer): boolean;
  780. var S: PSymbol;
  781. OK: boolean;
  782. begin
  783. OK:=Range>0;
  784. if OK then
  785. begin
  786. S:=List^.At(Item);
  787. OK:=(S^.References<>nil) and (S^.References^.Count>0);
  788. if OK then
  789. OK:=GotoReference(S^.References^.At(0));
  790. end;
  791. GotoItem:=OK;
  792. end;
  793. function TSymbolScopeView.TrackItem(Item: sw_integer; AutoTrack: boolean): boolean;
  794. var S: PSymbol;
  795. OK: boolean;
  796. begin
  797. OK:=Range>0;
  798. if OK then
  799. begin
  800. S:=List^.At(Item);
  801. OK:=(S^.References<>nil) and (S^.References^.Count>0);
  802. if OK then
  803. OK:=TrackReference(S^.References^.At(0),AutoTrack);
  804. end;
  805. TrackItem:=OK;
  806. end;
  807. procedure TSymbolScopeView.SetGDBCol;
  808. var S : PSymbol;
  809. I : sw_integer;
  810. begin
  811. if assigned(MyBW) and (SymbolsValue^.Count=0) then
  812. begin
  813. For i:=0 to Symbols^.Count-1 do
  814. begin
  815. S:=Symbols^.At(I);
  816. SymbolsValue^.Insert(New(PGDBValue,Init(GetStr(MyBW^.Prefix)+S^.GetName,S)));
  817. end;
  818. end;
  819. end;
  820. function TSymbolScopeView.GetText(Item,MaxLen: Sw_Integer): String;
  821. var S1: string;
  822. S : PSymbol;
  823. SG : PGDBValue;
  824. begin
  825. S:=Symbols^.At(Item);
  826. if Assigned(SymbolsValue) and (SymbolsValue^.Count>Item) then
  827. SG:=SymbolsValue^.At(Item)
  828. else
  829. SG:=nil;
  830. if assigned(SG) then
  831. S1:=SG^.getText
  832. else
  833. S1:=S^.GetText;
  834. GetText:=copy(S1,1,MaxLen);
  835. end;
  836. {****************************************************************************
  837. TSymbolReferenceView
  838. ****************************************************************************}
  839. constructor TSymbolReferenceView.Init(var Bounds: TRect; AReferences: PReferenceCollection;
  840. AHScrollBar, AVScrollBar: PScrollBar);
  841. begin
  842. inherited Init(Bounds,AHScrollBar, AVScrollBar);
  843. References:=AReferences;
  844. NewList(AReferences);
  845. SetRange(References^.Count);
  846. end;
  847. destructor TSymbolReferenceView.Done;
  848. begin
  849. Inherited Done;
  850. end;
  851. procedure TSymbolReferenceView.HandleEvent(var Event: TEvent);
  852. var OldFocus: sw_integer;
  853. DontClear: boolean;
  854. begin
  855. OldFocus:=Focused;
  856. case Event.What of
  857. evKeyDown :
  858. begin
  859. DontClear:=false;
  860. case Event.KeyCode of
  861. kbEnter :
  862. TrackItem(Focused,false);
  863. kbCtrlEnter :
  864. GotoItem(Focused);
  865. else DontClear:=true;
  866. end;
  867. if DontClear=false then ClearEvent(Event);
  868. end;
  869. end;
  870. inherited HandleEvent(Event);
  871. if OldFocus<>Focused then
  872. if (MiscOptions and moAutoTrackSource)=0 then
  873. ClearHighlights;
  874. end;
  875. procedure TSymbolReferenceView.Browse;
  876. begin
  877. { do nothing here }
  878. end;
  879. function TSymbolReferenceView.GetText(Item,MaxLen: Sw_Integer): String;
  880. var S: string;
  881. P: PReference;
  882. begin
  883. P:=References^.At(Item);
  884. S:=P^.GetFileName+'('+IntToStr(P^.Position.Y)+','+IntToStr(P^.Position.X)+')';
  885. GetText:=copy(S,1,MaxLen);
  886. end;
  887. function TSymbolReferenceView.GotoItem(Item: sw_integer): boolean;
  888. var OK: boolean;
  889. begin
  890. OK:=Range>0;
  891. if OK then
  892. OK:=GotoReference(List^.At(Item));
  893. GotoItem:=OK;
  894. end;
  895. function TSymbolReferenceView.TrackItem(Item: sw_integer; AutoTrack: boolean): boolean;
  896. var OK: boolean;
  897. begin
  898. OK:=Range>0;
  899. if OK then
  900. OK:=TrackReference(List^.At(Item),AutoTrack);
  901. TrackItem:=OK;
  902. end;
  903. procedure TSymbolReferenceView.SelectItem(Item: Sw_Integer);
  904. begin
  905. GotoItem(Item);
  906. end;
  907. constructor TSymbolMemInfoView.Init(var Bounds: TRect; AMemInfo: PSymbolMemInfo);
  908. begin
  909. inherited Init(Bounds,'');
  910. Options:=Options or (ofSelectable+ofTopSelect);
  911. MemInfo:=AMemInfo;
  912. MyBW:=nil;
  913. end;
  914. destructor TSymbolMemInfoView.Done;
  915. begin
  916. { if assigned(MemInfo) then
  917. dispose(MemInfo);}
  918. Inherited Done;
  919. end;
  920. procedure TSymbolMemInfoView.GetText(var S: String);
  921. function SizeStr(Size: longint): string;
  922. var S: string[40];
  923. begin
  924. S:=IntToStrL(Size,7);
  925. S:=S+' byte';
  926. if Size>1 then S:=S+'s';
  927. if Size=-1 then
  928. SizeStr:='variable'
  929. else
  930. SizeStr:=S;
  931. end;
  932. function AddrStr(Addr: longint): string;
  933. { Warning this is endian specific code !! (PM) }
  934. type TLongint = record LoW,HiW: word; end;
  935. begin
  936. with TLongint(Addr) do
  937. AddrStr:='$'+IntToHex(HiW,4)+IntToHex(LoW,4);
  938. end;
  939. begin
  940. ClearFormatParams;
  941. AddFormatParamStr(msg_sizeinmemory);
  942. AddFormatParamStr(msg_sizeonstack);
  943. S:=
  944. FormatStrF(
  945. #13+
  946. { ' Memory location: '+AddrStr(MemInfo^.Addr)+#13+
  947. ' Local address: '+AddrStr(MemInfo^.LocalAddr)+#13+}
  948. { ??? internal linker ??? }
  949. '%18s: '+SizeStr(MemInfo^.Size)+#13+
  950. '%18s: '+SizeStr(MemInfo^.PushSize)+#13+
  951. '',
  952. FormatParams);
  953. end;
  954. function TSymbolMemInfoView.GetPalette: PPalette;
  955. begin
  956. GetPalette:=inherited GetPalette;
  957. end;
  958. function TSymbolMemoView.GetPalette: PPalette;
  959. const P: string[length(CFPSymbolMemo)] = CFPSymbolMemo;
  960. begin
  961. GetPalette:=@P;
  962. end;
  963. {****************************************************************************
  964. TSymbolInheritanceView
  965. ****************************************************************************}
  966. {$ifdef HASOUTLINE}
  967. constructor TSymbolInheritanceView.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar; ARoot: PObjectSymbol);
  968. begin
  969. inherited Init(Bounds,AHScrollBar,AVScrollBar);
  970. Options:=Options or (ofSelectable+ofTopSelect);
  971. Root:=ARoot;
  972. MyBW:=nil;
  973. ExpandAll(GetRoot);
  974. Update;
  975. end;
  976. destructor TSymbolInheritanceView.Done;
  977. begin
  978. { do not dispose,
  979. belongs to a symbolcollection (PM)
  980. if assigned(Root) then
  981. dispose(Root,done); }
  982. Inherited Done;
  983. end;
  984. function TSymbolInheritanceView.GetRoot: Pointer;
  985. begin
  986. GetRoot:=Root;
  987. end;
  988. function TSymbolInheritanceView.HasChildren(Node: Pointer): Boolean;
  989. begin
  990. HasChildren:=GetNumChildren(Node)>0;
  991. end;
  992. function TSymbolInheritanceView.GetChild(Node: Pointer; I: Integer): Pointer;
  993. begin
  994. GetChild:=PObjectSymbol(Node)^.GetDescendant(I);
  995. end;
  996. function TSymbolInheritanceView.GetNumChildren(Node: Pointer): Integer;
  997. begin
  998. GetNumChildren:=PObjectSymbol(Node)^.GetDescendantCount;
  999. end;
  1000. function TSymbolInheritanceView.GetText(Node: Pointer): String;
  1001. begin
  1002. GetText:=PObjectSymbol(Node)^.GetName;
  1003. end;
  1004. procedure TSymbolInheritanceView.Adjust(Node: Pointer; Expand: Boolean);
  1005. begin
  1006. PObjectSymbol(Node)^.Expanded:=Expand;
  1007. end;
  1008. function TSymbolInheritanceView.IsExpanded(Node: Pointer): Boolean;
  1009. begin
  1010. IsExpanded:=PObjectSymbol(Node)^.Expanded;
  1011. end;
  1012. procedure TSymbolInheritanceView.HandleEvent(var Event: TEvent);
  1013. var DontClear: boolean;
  1014. begin
  1015. case Event.What of
  1016. evKeyDown :
  1017. begin
  1018. DontClear:=false;
  1019. case Event.KeyCode of
  1020. kbLeft,kbRight,
  1021. kbCtrlLeft,kbCtrlRight :
  1022. if Assigned(HScrollBar) then
  1023. HScrollBar^.HandleEvent(Event)
  1024. else
  1025. DontClear:=true;
  1026. else DontClear:=true;
  1027. end;
  1028. if DontClear=false then ClearEvent(Event);
  1029. end;
  1030. evMouseDown :
  1031. begin
  1032. if Event.double then
  1033. begin
  1034. Message(@Self,evKeyDown,kbEnter,nil);
  1035. ClearEvent(Event);
  1036. end;
  1037. end;
  1038. end;
  1039. inherited HandleEvent(Event);
  1040. end;
  1041. function TSymbolInheritanceView.GetPalette: PPalette;
  1042. const P: string[length(CBrowserOutline)] = CBrowserOutline;
  1043. begin
  1044. GetPalette:=@P;
  1045. end;
  1046. procedure TSymbolInheritanceView.Selected(I: Integer);
  1047. var P: pointer;
  1048. S: PSymbol;
  1049. St : String;
  1050. Anc: PObjectSymbol;
  1051. begin
  1052. P:=GetNode(I);
  1053. if P=nil then Exit;
  1054. S:=PObjectSymbol(P)^.Symbol;
  1055. { this happens for the top objects view (PM) }
  1056. if S=nil then exit;
  1057. st:=S^.GetName;
  1058. if S^.Ancestor=nil then
  1059. Anc:=ObjectTree
  1060. else
  1061. Anc:=SearchObjectForSymbol(S^.Ancestor);
  1062. OpenSymbolBrowser(Origin.X-1,FOC-Delta.Y+1,
  1063. st,
  1064. S^.GetText,S,nil,
  1065. S^.Items,S^.References,Anc,S^.MemInfo);
  1066. end;
  1067. {$endif HASOUTLINE}
  1068. {****************************************************************************
  1069. TBrowserTab
  1070. ****************************************************************************}
  1071. constructor TBrowserTab.Init(var Bounds: TRect; AItems: PBrowserTabItem);
  1072. begin
  1073. inherited Init(Bounds);
  1074. Options:=Options or ofPreProcess;
  1075. Items:=AItems;
  1076. SetParams(0,0);
  1077. end;
  1078. procedure TBrowserTab.SetParams(AFlags: word; ACurrent: Sw_integer);
  1079. begin
  1080. Flags:=AFlags;
  1081. SelectItem(ACurrent);
  1082. end;
  1083. procedure TBrowserTab.SelectItem(Index: Sw_integer);
  1084. var P: PBrowserTabItem;
  1085. begin
  1086. Current:=Index;
  1087. P:=GetItem(Current);
  1088. if (P<>nil) and (P^.Link<>nil) then
  1089. P^.Link^.Focus;
  1090. DrawView;
  1091. end;
  1092. function TBrowserTab.GetItemCount: sw_integer;
  1093. var Count: integer;
  1094. P: PBrowserTabItem;
  1095. begin
  1096. Count:=0; P:=Items;
  1097. while (P<>nil) do
  1098. begin
  1099. Inc(Count);
  1100. P:=P^.Next;
  1101. end;
  1102. GetItemCount:=Count;
  1103. end;
  1104. function TBrowserTab.GetItem(Index: sw_integer): PBrowserTabItem;
  1105. var Counter: integer;
  1106. P: PBrowserTabItem;
  1107. begin
  1108. P:=Items; Counter:=0;
  1109. while (P<>nil) and (Counter<Index) do
  1110. begin
  1111. P:=P^.Next;
  1112. Inc(Counter);
  1113. end;
  1114. GetItem:=P;
  1115. end;
  1116. procedure TBrowserTab.Draw;
  1117. var B: TDrawBuffer;
  1118. SelColor, NormColor, C: word;
  1119. I,CurX,Count: Sw_integer;
  1120. function Names(Idx: integer): char;
  1121. begin
  1122. Names:=GetItem(Idx)^.Sign;
  1123. end;
  1124. begin
  1125. NormColor:=GetColor(1); SelColor:=GetColor(2);
  1126. MoveChar(B,'Ä',SelColor,Size.X);
  1127. CurX:=0; Count:=0;
  1128. for I:=0 to GetItemCount-1 do
  1129. if (Flags and (1 shl I))<>0 then
  1130. begin
  1131. Inc(Count);
  1132. if Current=I then C:=SelColor
  1133. else C:=NormColor;
  1134. if Count=1 then MoveChar(B[CurX],'´',SelColor,1)
  1135. else MoveChar(B[CurX],'³',SelColor,1);
  1136. MoveCStr(B[CurX+1],' '+Names(I)+' ',C);
  1137. Inc(CurX,4);
  1138. end;
  1139. if Count>0 then
  1140. MoveChar(B[CurX],'Ã',SelColor,1);
  1141. WriteLine(0,0,Size.X,Size.Y,B);
  1142. end;
  1143. procedure TBrowserTab.HandleEvent(var Event: TEvent);
  1144. var I,Idx: integer;
  1145. DontClear: boolean;
  1146. P: TPoint;
  1147. function GetItemForCoord(X: integer): integer;
  1148. var I,CurX,Idx: integer;
  1149. begin
  1150. CurX:=0; Idx:=-1;
  1151. for I:=0 to GetItemCount-1 do
  1152. if (Flags and (1 shl I))<>0 then
  1153. begin
  1154. if (CurX+1<=X) and (X<=CurX+3) then
  1155. begin Idx:=I; Break; end;
  1156. Inc(CurX,4);
  1157. end;
  1158. GetItemForCoord:=Idx;
  1159. end;
  1160. begin
  1161. case Event.What of
  1162. evMouseDown :
  1163. if MouseInView(Event.Where) then
  1164. begin
  1165. repeat
  1166. MakeLocal(Event.Where,P);
  1167. Idx:=GetItemForCoord(P.X);
  1168. if Idx<>-1 then
  1169. SelectItem(Idx);
  1170. until not MouseEvent(Event, evMouseMove);
  1171. ClearEvent(Event);
  1172. end;
  1173. evKeyDown :
  1174. begin
  1175. DontClear:=false; Idx:=-1;
  1176. for I:=0 to GetItemCount-1 do
  1177. if GetCtrlCode(GetItem(I)^.Sign)=Event.KeyCode then
  1178. if (Flags and (1 shl I))<>0 then
  1179. begin
  1180. Idx:=I;
  1181. Break;
  1182. end;
  1183. if Idx=-1 then
  1184. DontClear:=true
  1185. else
  1186. SelectItem(Idx);
  1187. if DontClear=false then ClearEvent(Event);
  1188. end;
  1189. end;
  1190. inherited HandleEvent(Event);
  1191. end;
  1192. function TBrowserTab.GetPalette: PPalette;
  1193. const P: string[length(CBrowserTab)] = CBrowserTab;
  1194. begin
  1195. GetPalette:=@P;
  1196. end;
  1197. destructor TBrowserTab.Done;
  1198. begin
  1199. if Items<>nil then DisposeBrowserTabList(Items);
  1200. inherited Done;
  1201. end;
  1202. procedure TUnitInfoPanel.HandleEvent(var Event: TEvent);
  1203. begin
  1204. if (Event.What=evBroadcast) and (Event.Command=cmListItemSelected) and
  1205. (InOwnerCall=false) then
  1206. begin
  1207. InOwnerCall:=true;
  1208. if Assigned(Owner) then
  1209. Owner^.HandleEvent(Event);
  1210. InOwnerCall:=false;
  1211. end;
  1212. inherited HandleEvent(Event);
  1213. end;
  1214. constructor TBrowserWindow.Init(var Bounds: TRect; ATitle: TTitleStr; ANumber: Sw_Integer;ASym : PSymbol;
  1215. const AName,APrefix: string; ASymbols: PSymbolCollection; AReferences: PReferenceCollection;
  1216. AInheritance: PObjectSymbol; AMemInfo: PSymbolMemINfo);
  1217. var R,R2,R3: TRect;
  1218. HSB,VSB: PScrollBar;
  1219. CST: PColorStaticText;
  1220. I: sw_integer;
  1221. function CreateVSB(R: TRect): PScrollBar;
  1222. var R2: TRect;
  1223. SB: PScrollBar;
  1224. begin
  1225. R2.Copy(R); R2.Move(1,0); R2.A.X:=R2.B.X-1;
  1226. New(SB, Init(R2)); SB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY;
  1227. CreateVSB:=SB;
  1228. end;
  1229. function CreateHSB(R: TRect): PScrollBar;
  1230. var R2: TRect;
  1231. SB: PScrollBar;
  1232. begin
  1233. R2.Copy(R); R2.Move(0,1); R2.A.Y:=R2.B.Y-1;
  1234. New(SB, Init(R2)); SB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY;
  1235. CreateHSB:=SB;
  1236. end;
  1237. begin
  1238. inherited Init(Bounds, FormatStrStr(dialog_browse,ATitle), ANumber);
  1239. HelpCtx:=hcBrowserWindow;
  1240. Sym:=ASym;
  1241. Prefix:=NewStr(APrefix);
  1242. GetExtent(R); R.Grow(-1,-1); R.B.Y:=R.A.Y+1;
  1243. {$ifndef NODEBUG}
  1244. if {assigned(Debugger) and Debugger^.IsRunning and}
  1245. assigned(Sym) and (Sym^.typ=varsym) then
  1246. begin
  1247. New(DebuggerValue,Init(ATitle,Sym));
  1248. New(ST, Init(R, ' '+DebuggerValue^.GetText));
  1249. end
  1250. else
  1251. {$endif NODEBUG}
  1252. begin
  1253. New(ST, Init(R, ' '+AName));
  1254. DebuggerValue:=nil;
  1255. end;
  1256. ST^.GrowMode:=gfGrowHiX;
  1257. Insert(ST);
  1258. GetExtent(R); R.Grow(-1,-1); Inc(R.A.Y,2);
  1259. if assigned(ASymbols) and (ASymbols^.Count>0) then
  1260. begin
  1261. HSB:=CreateHSB(R);
  1262. Insert(HSB);
  1263. VSB:=CreateVSB(R);
  1264. Insert(VSB);
  1265. New(ScopeView, Init(R, ASymbols, HSB, VSB));
  1266. ScopeView^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1267. Insert(ScopeView);
  1268. ScopeView^.MyBW:=@Self;
  1269. ScopeView^.SetGDBCol;
  1270. end;
  1271. if assigned(AReferences) and (AReferences^.Count>0) then
  1272. begin
  1273. HSB:=CreateHSB(R);
  1274. Insert(HSB);
  1275. VSB:=CreateVSB(R);
  1276. Insert(VSB);
  1277. New(ReferenceView, Init(R, AReferences, HSB, VSB));
  1278. ReferenceView^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1279. Insert(ReferenceView);
  1280. ReferenceView^.MyBW:=@Self;
  1281. end;
  1282. if assigned(AInheritance) then
  1283. begin
  1284. HSB:=CreateHSB(R);
  1285. Insert(HSB);
  1286. VSB:=CreateVSB(R);
  1287. Insert(VSB);
  1288. {$ifdef HASOUTLINE}
  1289. New(InheritanceView, Init(R, HSB,VSB, AInheritance));
  1290. InheritanceView^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1291. Insert(InheritanceView);
  1292. InheritanceView^.MyBW:=@Self;
  1293. {$endif HASOUTLINE}
  1294. end;
  1295. if assigned(AMemInfo) then
  1296. begin
  1297. New(MemInfoView, Init(R, AMemInfo));
  1298. MemInfoView^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1299. Insert(MemInfoView);
  1300. MemInfoView^.MyBW:=@Self;
  1301. end;
  1302. if Assigned(Asym) and (TypeOf(ASym^)=TypeOf(TModuleSymbol)) then
  1303. with PModuleSymbol(Sym)^ do
  1304. begin
  1305. New(UnitInfo, Init(R));
  1306. UnitInfo^.GetExtent(R3);
  1307. R2.Copy(R3);
  1308. R2.B.Y:=R2.A.Y+3;
  1309. if (Assigned(UsedUnits) or Assigned(DependentUnits))=false then
  1310. R2.B.Y:=R3.B.Y;
  1311. HSB:=CreateHSB(R2); {UnitInfo^.Insert(HSB); HSB:=nil;}
  1312. VSB:=CreateVSB(R2);
  1313. {UnitInfo^.Insert(VSB);
  1314. VSB will be owned by UnitInfoText PM }
  1315. New(UnitInfoText, Init(R2,HSB,VSB, nil));
  1316. with UnitInfoText^ do
  1317. begin
  1318. GrowMode:=gfGrowHiX;
  1319. if Assigned(LoadedFrom) then
  1320. begin
  1321. AddLine(FormatStrStr2('%s : %s',msg_usedfirstin,GetStr(LoadedFrom)));
  1322. AddLine(FormatStrStr('%s : ',msg_mainsource));
  1323. AddLine(FormatStrStr(' %s',GetStr(MainSource)));
  1324. if Assigned(SourceFiles) and (SourceFiles^.Count>1) then
  1325. begin
  1326. AddLine(FormatStrStr('%s : ',msg_sourcefiles));
  1327. for I:=0 to SourceFiles^.Count-1 do
  1328. AddLine(FormatStrStr(' %s',GetStr(SourceFiles^.At(I))));
  1329. end;
  1330. end;
  1331. end;
  1332. UnitInfo^.Insert(UnitInfoText);
  1333. if Assigned(UsedUnits) then
  1334. begin
  1335. Inc(R2.A.Y,R2.B.Y-R2.A.Y); R2.B.Y:=R2.A.Y+1;
  1336. New(CST, Init(R2,'´ Used units Ã'+CharStr('Ä',255),ColorIndex(12),false));
  1337. CST^.GrowMode:=gfGrowHiX;
  1338. UnitInfo^.Insert(CST);
  1339. Inc(R2.A.Y,R2.B.Y-R2.A.Y); R2.B.Y:=R2.A.Y+4;
  1340. if Assigned(DependentUnits)=false then R2.B.Y:=R3.B.Y;
  1341. {HSB:=CreateHSB(R2); UnitInfo^.Insert(HSB); }
  1342. HSB:=nil;
  1343. VSB:=CreateVSB(R2);
  1344. {UnitInfo^.Insert(VSB); this created crashes,
  1345. that were difficult to findout PM }
  1346. New(UnitInfoUsed, Init(R2,UsedUnits,HSB,VSB));
  1347. UnitInfoUsed^.GrowMode:=gfGrowHiY+gfGrowHiX;
  1348. UnitInfoUsed^.MyBW:=@Self;
  1349. UnitInfo^.Insert(UnitInfoUsed);
  1350. end;
  1351. if Assigned(DependentUnits) then
  1352. begin
  1353. Inc(R2.A.Y,R2.B.Y-R2.A.Y); R2.B.Y:=R2.A.Y+1;
  1354. New(CST, Init(R2,'´ Dependent units Ã'+CharStr('Ä',255),ColorIndex(12),false));
  1355. CST^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY;
  1356. UnitInfo^.Insert(CST);
  1357. Inc(R2.A.Y,R2.B.Y-R2.A.Y); R2.B.Y:=R3.B.Y;
  1358. {HSB:=CreateHSB(R2); UnitInfo^.Insert(HSB); }
  1359. HSB:=nil;
  1360. VSB:=CreateVSB(R2);
  1361. { UnitInfo^.Insert(VSB); this created crashes,
  1362. that were difficult to findout PM }
  1363. New(UnitInfoDependent, Init(R2,DependentUnits,HSB,VSB));
  1364. UnitInfoDependent^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY;
  1365. UnitInfoDependent^.MyBW:=@Self;
  1366. UnitInfo^.Insert(UnitInfoDependent);
  1367. end;
  1368. if Assigned(UnitInfoText) then
  1369. UnitInfoText^.Select;
  1370. Insert(UnitInfo);
  1371. end;
  1372. GetExtent(R); R.Grow(-1,-1); R.Move(0,1); R.B.Y:=R.A.Y+1;
  1373. New(PageTab, Init(R,
  1374. NewBrowserTabItem(label_browsertab_scope,ScopeView,
  1375. NewBrowserTabItem(label_browsertab_reference,ReferenceView,
  1376. {$ifdef HASOUTLINE}
  1377. NewBrowserTabItem(label_browsertab_inheritance,InheritanceView,
  1378. {$endif HASOUTLINE}
  1379. NewBrowserTabItem(label_browsertab_memory,MemInfoView,
  1380. NewBrowserTabItem(label_browsertab_unit,UnitInfo,
  1381. nil))
  1382. {$ifdef HASOUTLINE}
  1383. )
  1384. {$endif HASOUTLINE}
  1385. ))));
  1386. PageTab^.GrowMode:=gfGrowHiX;
  1387. Insert(PageTab);
  1388. if assigned(ScopeView) then
  1389. SelectTab(btScope)
  1390. else
  1391. if assigned(ReferenceView) then
  1392. SelectTab(btReferences)
  1393. {$ifdef HASOUTLINE}
  1394. else
  1395. if assigned(InheritanceView) then
  1396. SelectTab(btInheritance)
  1397. {$endif HASOUTLINE}
  1398. ;
  1399. end;
  1400. destructor TBrowserWindow.Done;
  1401. begin
  1402. { UnitInfoText needs to be removed first
  1403. to avoid crashes within the UnitInfo destructor PM }
  1404. if Assigned(UnitInfoText) then
  1405. begin
  1406. UnitInfo^.Delete(UnitInfoText);
  1407. Dispose(UnitInfoText,Done);
  1408. UnitInfoText:=nil;
  1409. end;
  1410. if assigned(DebuggerValue) then
  1411. begin
  1412. Dispose(DebuggerValue,Done);
  1413. DebuggerValue:=nil;
  1414. end;
  1415. if assigned(Prefix) then
  1416. begin
  1417. DisposeStr(Prefix);
  1418. Prefix:=nil;
  1419. end;
  1420. inherited Done;
  1421. end;
  1422. procedure TBrowserWindow.HandleEvent(var Event: TEvent);
  1423. var DontClear: boolean;
  1424. S: PSymbol;
  1425. Symbols: PSymbolCollection;
  1426. Anc: PObjectSymbol;
  1427. P: TPoint;
  1428. begin
  1429. case Event.What of
  1430. evBroadcast :
  1431. case Event.Command of
  1432. cmDebuggerStopped :
  1433. begin
  1434. if Assigned(DebuggerValue) and
  1435. (DebuggerValue^.GDBI<>Event.InfoLong) then
  1436. begin
  1437. If Assigned(ST^.Text) then
  1438. DisposeStr(ST^.Text);
  1439. ST^.Text:=NewStr(DebuggerValue^.GetText);
  1440. ST^.DrawView;
  1441. end;
  1442. end;
  1443. cmSearchWindow :
  1444. ClearEvent(Event);
  1445. cmListItemSelected :
  1446. begin
  1447. S:=nil;
  1448. if (Event.InfoPtr=ScopeView) then
  1449. begin
  1450. S:=ScopeView^.Symbols^.At(ScopeView^.Focused);
  1451. MakeGlobal(ScopeView^.Origin,P);
  1452. Desktop^.MakeLocal(P,P); Inc(P.Y,ScopeView^.Focused-ScopeView^.TopItem);
  1453. Inc(P.Y);
  1454. end;
  1455. if (Event.InfoPtr=UnitInfoUsed) then
  1456. begin
  1457. S:=UnitInfoUsed^.Symbols^.At(UnitInfoUsed^.Focused);
  1458. MakeGlobal(UnitInfoUsed^.Origin,P);
  1459. Desktop^.MakeLocal(P,P); Inc(P.Y,UnitInfoUsed^.Focused-UnitInfoUsed^.TopItem);
  1460. Inc(P.Y);
  1461. end;
  1462. if (Event.InfoPtr=UnitInfoDependent) then
  1463. begin
  1464. S:=UnitInfoDependent^.Symbols^.At(UnitInfoDependent^.Focused);
  1465. MakeGlobal(UnitInfoDependent^.Origin,P);
  1466. Desktop^.MakeLocal(P,P); Inc(P.Y,UnitInfoDependent^.Focused-UnitInfoDependent^.TopItem);
  1467. Inc(P.Y);
  1468. end;
  1469. if Assigned(S) then
  1470. begin
  1471. if S^.Ancestor=nil then Anc:=nil else
  1472. Anc:=SearchObjectForSymbol(S^.Ancestor);
  1473. Symbols:=S^.Items;
  1474. if (not assigned(Symbols) or (symbols^.count=0)) then
  1475. if assigned(S^.Ancestor) then
  1476. Symbols:=S^.Ancestor^.Items;
  1477. if (S^.GetReferenceCount>0) or (assigned(Symbols) and (Symbols^.Count>0)) or (Anc<>nil) then
  1478. OpenSymbolBrowser(Origin.X-1,P.Y,
  1479. S^.GetName,
  1480. ScopeView^.GetText(ScopeView^.Focused,255),
  1481. S,@self,
  1482. Symbols,S^.References,Anc,S^.MemInfo);
  1483. end;
  1484. end;
  1485. end;
  1486. { evCommand :
  1487. begin
  1488. DontClear:=false;
  1489. case Event.Command of
  1490. cmGotoSymbol :
  1491. if Event.InfoPtr=ScopeView then
  1492. if ReferenceView<>nil then
  1493. if ReferenceView^.Range>0 then
  1494. ReferenceView^.GotoItem(0);
  1495. cmTrackSymbol :
  1496. if Event.InfoPtr=ScopeView then
  1497. if (ScopeView<>nil) and (ScopeView^.Range>0) then
  1498. begin
  1499. S:=ScopeView^.At(ScopeView^.Focused);
  1500. if (S^.References<>nil) and (S^.References^.Count>0) then
  1501. TrackItem(S^.References^.At(0));
  1502. else DontClear:=true;
  1503. end;
  1504. if DontClear=false then ClearEvent(Event);
  1505. end;}
  1506. evKeyDown :
  1507. begin
  1508. DontClear:=false;
  1509. case Event.KeyCode of
  1510. kbEsc :
  1511. Close;
  1512. kbAltI :
  1513. If not Disassemble then
  1514. DontClear:=true;
  1515. else DontClear:=true;
  1516. end;
  1517. if DontClear=false then ClearEvent(Event);
  1518. end;
  1519. end;
  1520. inherited HandleEvent(Event);
  1521. end;
  1522. function TBrowserWindow.Disassemble : boolean;
  1523. begin
  1524. Disassemble:=false;
  1525. if not assigned(sym) or (sym^.typ<>procsym) then
  1526. exit;
  1527. { We need to load exefile }
  1528. {$ifndef NODEBUG}
  1529. InitGDBWindow;
  1530. if not assigned(Debugger) then
  1531. begin
  1532. new(Debugger,Init);
  1533. if assigned(Debugger) then
  1534. Debugger^.SetExe(ExeFile);
  1535. end;
  1536. if not assigned(Debugger) or not Debugger^.HasExe then
  1537. exit;
  1538. { goto source/assembly mixture }
  1539. InitDisassemblyWindow;
  1540. DisassemblyWindow^.LoadFunction(Sym^.GetName);
  1541. DisassemblyWindow^.SelectInDebugSession;
  1542. Disassemble:=true;
  1543. {$else NODEBUG}
  1544. NoDebugger;
  1545. {$endif NODEBUG}
  1546. end;
  1547. procedure TBrowserWindow.SetState(AState: Word; Enable: Boolean);
  1548. {var OldState: word;}
  1549. begin
  1550. { OldState:=State;}
  1551. inherited SetState(AState,Enable);
  1552. { if ((State xor OldState) and sfActive)<>0 then
  1553. if GetState(sfActive)=false then
  1554. Message(Desktop,evBroadcast,cmClearLineHighlights,nil);}
  1555. end;
  1556. procedure TBrowserWindow.Close;
  1557. begin
  1558. inherited Close;
  1559. end;
  1560. procedure TBrowserWindow.SelectTab(BrowserTab: Sw_integer);
  1561. var Tabs: Sw_integer;
  1562. { PB : PBreakpoint;
  1563. PS :PString;
  1564. l : longint; }
  1565. begin
  1566. (* case BrowserTab of
  1567. btScope :
  1568. if assigned(ScopeView) then
  1569. ScopeView^.Select;
  1570. btReferences :
  1571. if assigned(ReferenceView) then
  1572. ReferenceView^.Select;
  1573. btBreakWatch :
  1574. begin
  1575. if Assigned(Sym) then
  1576. begin
  1577. if Pos('proc',Sym^.GetText)>0 then
  1578. { insert function breakpoint }
  1579. begin
  1580. { make it visible }
  1581. PS:=Sym^.Name;
  1582. l:=Length(PS^);
  1583. If PS^[l]='*' then
  1584. begin
  1585. PB:=BreakpointsCollection^.GetType(bt_function,copy(GetStr(PS),1,l-1));
  1586. If Assigned(PB) then
  1587. BreakpointsCollection^.Delete(PB);
  1588. Sym^.Name:=NewStr(copy(GetStr(PS),1,l-1));
  1589. DrawView;
  1590. DisposeStr(PS);
  1591. end
  1592. else
  1593. begin
  1594. Sym^.Name:=NewStr(GetStr(PS)+'*');
  1595. DrawView;
  1596. New(PB,init_function(GetStr(PS)));
  1597. DisposeStr(PS);
  1598. BreakpointsCollection^.Insert(PB);
  1599. BreakpointsCollection^.Update;
  1600. end;
  1601. end
  1602. else if pos('var',Sym^.GetText)>0 then
  1603. { insert watch point }
  1604. begin
  1605. { make it visible }
  1606. PS:=Sym^.Name;
  1607. l:=Length(PS^);
  1608. If PS^[l]='*' then
  1609. begin
  1610. PB:=BreakpointsCollection^.GetType(bt_awatch,copy(PS^,1,l-1));
  1611. If Assigned(PB) then
  1612. BreakpointsCollection^.Delete(PB);
  1613. Sym^.Name:=NewStr(copy(PS^,1,l-1));
  1614. DrawView;
  1615. DisposeStr(PS);
  1616. end
  1617. else
  1618. begin
  1619. Sym^.Name:=NewStr(GetStr(PS)+'*');
  1620. DrawView;
  1621. New(PB,init_type(bt_awatch,GetStr(PS)));
  1622. DisposeStr(PS);
  1623. BreakpointsCollection^.Insert(PB);
  1624. BreakpointsCollection^.Update;
  1625. end;
  1626. end;
  1627. end;
  1628. end;
  1629. end;*)
  1630. Tabs:=0;
  1631. if assigned(ScopeView) then
  1632. Tabs:=Tabs or (1 shl btScope);
  1633. if assigned(ReferenceView) then
  1634. Tabs:=Tabs or (1 shl btReferences);
  1635. {$ifdef HASOUTLINE}
  1636. if assigned(InheritanceView) then
  1637. Tabs:=Tabs or (1 shl btInheritance);
  1638. {$endif HASOUTLINE}
  1639. if assigned(MemInfoView) then
  1640. Tabs:=Tabs or (1 shl btMemInfo);
  1641. if Assigned(Sym) then
  1642. if (Pos('proc',Sym^.GetText)>0) or (Pos('var',Sym^.GetText)>0) then
  1643. Tabs:=Tabs or (1 shl btBreakWatch);
  1644. if assigned(UnitInfo) then
  1645. Tabs:=Tabs or (1 shl btUnitInfo);
  1646. if PageTab<>nil then PageTab^.SetParams(Tabs,BrowserTab);
  1647. end;
  1648. function TBrowserWindow.GetPalette: PPalette;
  1649. const S: string[length(CBrowserWindow)] = CBrowserWindow;
  1650. begin
  1651. GetPalette:=@S;
  1652. end;
  1653. procedure OpenSymbolBrowser(X,Y: Sw_integer;const Name,Line: string;S : PSymbol;
  1654. ParentBrowser : PBrowserWindow;
  1655. Symbols: PSymbolCollection; References: PReferenceCollection;
  1656. Inheritance: PObjectSymbol; MemInfo: PSymbolMemInfo);
  1657. var R: TRect;
  1658. PB : PBrowserWindow;
  1659. St,st2 : string;
  1660. begin
  1661. if X=0 then X:=Desktop^.Size.X-35;
  1662. R.A.X:=X; R.A.Y:=Y;
  1663. R.B.X:=R.A.X+35; R.B.Y:=R.A.Y+15;
  1664. while (R.B.Y>Desktop^.Size.Y) do R.Move(0,-1);
  1665. if assigned(ParentBrowser) and assigned(ParentBrowser^.Prefix) and
  1666. assigned(ParentBrowser^.sym) and
  1667. (ParentBrowser^.sym^.typ<>unitsym)
  1668. then
  1669. begin
  1670. st:=GetStr(ParentBrowser^.Prefix)+' '+Name;
  1671. end
  1672. else
  1673. st:=Name;
  1674. st2:=st;
  1675. if assigned(S) and ((S^.Flags and sfPointer)<>0) then
  1676. begin
  1677. st:=st+'^';
  1678. if assigned(S^.Ancestor) and
  1679. ((S^.Ancestor^.Flags and sfRecord)<>0) then
  1680. st:=st+'.';
  1681. end
  1682. else if assigned(S) and ((S^.Flags and sfRecord)<>0) then
  1683. st:=st+'.';
  1684. PB:=New(PBrowserWindow, Init(R,
  1685. st2,SearchFreeWindowNo,S,Line,st,
  1686. Symbols,References,Inheritance,MemInfo));
  1687. if (assigned(S) and (S^.typ=varsym)) or
  1688. (assigned(ParentBrowser) and ParentBrowser^.IsValid) then
  1689. PB^.IsValid:=true;
  1690. Desktop^.Insert(PB);
  1691. end;
  1692. END.
  1693. {
  1694. $Log$
  1695. Revision 1.7 2004-11-08 20:28:26 peter
  1696. * Breakpoints are now deleted when removed from source, disabling is
  1697. still possible from the breakpoint list
  1698. * COMPILER_1_0, FVISION, GABOR defines removed, only support new
  1699. FV and 1.9.x compilers
  1700. * Run directory added to Run menu
  1701. * Useless programinfo window removed
  1702. Revision 1.6 2002/12/02 01:00:12 pierre
  1703. + Alt+I to disassemble a function from browser window
  1704. Revision 1.5 2002/09/07 15:40:45 peter
  1705. * old logs removed and tabs fixed
  1706. }