fpsymbol.pas 50 KB

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