fpsymbol.pas 50 KB

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