fpsymbol.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  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. unit FPSymbol;
  13. interface
  14. uses Objects,Drivers,Views,Dialogs,
  15. BrowCol,
  16. FPViews;
  17. const
  18. { Browser tab constants }
  19. btScope = 1;
  20. btReferences = 2;
  21. btInheritance = 4;
  22. btBreakWatch = 8;
  23. type
  24. PSymbolView = ^TSymbolView;
  25. TSymbolView = object(TListBox)
  26. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  27. procedure HandleEvent(var Event: TEvent); virtual;
  28. procedure GotoItem(Item: sw_integer); virtual;
  29. function GetPalette: PPalette; virtual;
  30. end;
  31. PSymbolScopeView = ^TSymbolScopeView;
  32. TSymbolScopeView = object(TSymbolView)
  33. constructor Init(var Bounds: TRect; ASymbols: PSymbolCollection; AHScrollBar, AVScrollBar: PScrollBar);
  34. function GetText(Item,MaxLen: Sw_Integer): String; virtual;
  35. procedure HandleEvent(var Event: TEvent); virtual;
  36. procedure Draw; virtual;
  37. procedure LookUp(S: string); virtual;
  38. private
  39. Symbols: PSymbolCollection;
  40. LookupStr: string;
  41. end;
  42. PSymbolReferenceView = ^TSymbolReferenceView;
  43. TSymbolReferenceView = object(TSymbolView)
  44. constructor Init(var Bounds: TRect; AReferences: PReferenceCollection; AHScrollBar, AVScrollBar: PScrollBar);
  45. procedure HandleEvent(var Event: TEvent); virtual;
  46. function GetText(Item,MaxLen: Sw_Integer): String; virtual;
  47. procedure SelectItem(Item: Sw_Integer); virtual;
  48. procedure GotoItem(Item: sw_integer); virtual;
  49. procedure GotoSource; virtual;
  50. procedure TrackSource; virtual;
  51. private
  52. References: PReferenceCollection;
  53. end;
  54. PBrowserTab = ^TBrowserTab;
  55. TBrowserTab = object(TView)
  56. constructor Init(var Bounds: TRect);
  57. procedure SetParams(AFlags: word; ACurrent: Sw_integer); virtual;
  58. procedure Draw; virtual;
  59. function GetPalette: PPalette; virtual;
  60. private
  61. Flags : word;
  62. Current : Sw_integer;
  63. end;
  64. PBrowserWindow = ^TBrowserWindow;
  65. TBrowserWindow = object(TFPWindow)
  66. constructor Init(var Bounds: TRect; ATitle: TTitleStr; ANumber: Sw_Integer;ASym : PSymbol;
  67. const AName: string; ASymbols: PSymbolCollection; AReferences: PReferenceCollection);
  68. procedure HandleEvent(var Event: TEvent); virtual;
  69. procedure SetState(AState: Word; Enable: Boolean); virtual;
  70. procedure Close; virtual;
  71. procedure SelectTab(BrowserTab: Sw_integer); virtual;
  72. function GetPalette: PPalette; virtual;
  73. private
  74. PageTab : PBrowserTab;
  75. Sym : PSymbol;
  76. ScopeView : PSymbolScopeView;
  77. ReferenceView : PSymbolReferenceView;
  78. end;
  79. procedure OpenSymbolBrowser(X,Y: Sw_integer;const Name,Line: string;S : PSymbol;
  80. Symbols: PSymbolCollection; References: PReferenceCollection);
  81. function IsSymbolInfoAvailable: boolean;
  82. procedure OpenOneSymbolBrowser(Name : String);
  83. implementation
  84. uses Commands,App,
  85. WEditor,FPDebug,
  86. FPConst,FPUtils,FPVars;
  87. function IsSymbolInfoAvailable: boolean;
  88. begin
  89. IsSymbolInfoAvailable:=BrowCol.Modules<>nil;
  90. end;
  91. procedure OpenOneSymbolBrowser(Name : String);
  92. var Index : sw_integer;
  93. PS : PSymbol;
  94. P : Pstring;
  95. function Search(P : PSymbol) : boolean;
  96. begin
  97. Search:=UpcaseStr(P^.Items^.LookUp(Name,Index))=Name;
  98. end;
  99. begin
  100. Name:=UpcaseStr(Name);
  101. If BrowCol.Modules<>nil then
  102. begin
  103. PS:=BrowCol.Modules^.FirstThat(@Search);
  104. If assigned(PS) then
  105. OpenSymbolBrowser(0,20,
  106. PS^.Items^.At(Index)^.GetName,'',PS^.Items^.At(Index),
  107. PS^.Items^.At(Index)^.Items,PS^.Items^.At(Index)^.References)
  108. else
  109. begin
  110. P:=@Name;
  111. ErrorBox(#3'Symbol %s not found',@P);
  112. end;
  113. end
  114. else
  115. ErrorBox('No Browser info available',nil);
  116. end;
  117. (*procedure ReadBrowseLog(FileName: string);
  118. var f: text;
  119. IOOK,EndOfFile: boolean;
  120. Line: string;
  121. procedure NextLine;
  122. begin
  123. readln(f,Line);
  124. EndOfFile:=Eof(f);
  125. end;
  126. var Level: integer;
  127. procedure ProcessSymTable(Indent: integer; Owner: PSymbolCollection);
  128. var IndentS,S,Source: string;
  129. Sym: PSymbol;
  130. Ref: PSymbolReference;
  131. P: byte;
  132. PX: TPoint;
  133. PS: PString;
  134. PCount: integer;
  135. Params: array[0..30] of PString;
  136. Typ: tsymtyp;
  137. ExitBack: boolean;
  138. begin
  139. Inc(Level);
  140. IndentS:=CharStr(' ',Indent); ExitBack:=false;
  141. Sym:=nil;
  142. repeat
  143. if copy(Line,1,length(IndentS))<>IndentS then ExitBack:=true else
  144. if copy(Line,Indent+1,3)='***' then
  145. { new symbol }
  146. begin
  147. S:=copy(Line,Indent+1+3,255);
  148. P:=Pos('***',S); if P=0 then P:=length(S)+1;
  149. S:=Trim(copy(S,1,P-1));
  150. if (copy(S,1,1)='_') and (Pos('$$',S)>0) then
  151. begin
  152. repeat
  153. P:=Pos('$$',S);
  154. if P>0 then Delete(S,1,P+1);
  155. until P=0;
  156. P:=Pos('$',S);
  157. Delete(S,1,P);
  158. PCount:=0;
  159. repeat
  160. P:=Pos('$',S); if P=0 then P:=length(S)+1;
  161. Params[PCount]:=TypeNames^.Add(copy(S,1,P-1));
  162. Inc(PCount);
  163. Delete(S,1,P);
  164. until S='';
  165. Sym^.Typ:=procsym;
  166. Sym^.SetParams(PCount,@Params);
  167. end
  168. else
  169. New(Sym, Init(S, varsym, 0, nil));
  170. Owner^.Insert(Sym);
  171. NextLine;
  172. end else
  173. if copy(Line,Indent+1,3)='---' then
  174. { child symtable }
  175. begin
  176. S:=Trim(copy(Line,Indent+1+12,255));
  177. if Level=1 then Typ:=unitsym else
  178. Typ:=typesym;
  179. if (Sym<>nil) and (Sym^.GetName=S) then
  180. else
  181. begin
  182. New(Sym, Init(S, Typ, 0, nil));
  183. Owner^.Insert(Sym);
  184. end;
  185. Sym^.Typ:=Typ;
  186. NextLine;
  187. New(Sym^.Items, Init(0,50));
  188. ProcessSymTable(Indent+2,Sym^.Items);
  189. end else
  190. { if Sym<>nil then}
  191. if copy(Line,Indent+1,1)=' ' then
  192. { reference }
  193. begin
  194. S:=copy(Line,Indent+1+2,255);
  195. P:=Pos('(',S); if P=0 then P:=length(S)+1;
  196. Source:=Trim(copy(S,1,P-1)); Delete(S,1,P);
  197. P:=Pos(',',S); if P=0 then P:=length(S)+1;
  198. PX.Y:=StrToInt(copy(S,1,P-1)); Delete(S,1,P);
  199. P:=Pos(')',S); if P=0 then P:=length(S)+1;
  200. PX.X:=StrToInt(copy(S,1,P-1)); Delete(S,1,P);
  201. PS:=ModuleNames^.Add(Source);
  202. New(Ref, Init(PS, PX));
  203. if Sym^.References=nil then
  204. New(Sym^.References, Init(10,50));
  205. Sym^.References^.Insert(Ref);
  206. end;
  207. if ExitBack=false then
  208. NextLine;
  209. until EndOfFile or ExitBack;
  210. Dec(Level);
  211. end;
  212. begin
  213. DoneSymbolBrowser;
  214. InitSymbolBrowser;
  215. {$I-}
  216. Assign(f,FileName);
  217. Reset(f);
  218. Level:=0;
  219. NextLine;
  220. while (IOResult=0) and (EndOfFile=false) do
  221. ProcessSymTable(0,Modules);
  222. Close(f);
  223. EatIO;
  224. {$I+}
  225. end;*)
  226. {****************************************************************************
  227. TSymbolView
  228. ****************************************************************************}
  229. constructor TSymbolView.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  230. begin
  231. inherited Init(Bounds,1,AVScrollBar);
  232. HScrollBar:=AHScrollBar;
  233. if assigned(HScrollBar) then
  234. HScrollBar^.SetRange(1,80);
  235. Options:=Options or (ofSelectable+ofTopSelect);
  236. end;
  237. procedure TSymbolView.HandleEvent(var Event: TEvent);
  238. var DontClear: boolean;
  239. begin
  240. case Event.What of
  241. evKeyDown :
  242. begin
  243. DontClear:=false;
  244. case Event.KeyCode of
  245. kbEnter :
  246. GotoItem(Focused);
  247. kbRight,kbLeft :
  248. if HScrollBar<>nil then
  249. HScrollBar^.HandleEvent(Event);
  250. else DontClear:=true;
  251. end;
  252. if DontClear=false then ClearEvent(Event);
  253. end;
  254. evMouse :
  255. if Event.double then
  256. GotoItem(Focused);
  257. end;
  258. inherited HandleEvent(Event);
  259. end;
  260. function TSymbolView.GetPalette: PPalette;
  261. const
  262. P: string[length(CBrowserListBox)] = CBrowserListBox;
  263. begin
  264. GetPalette:=@P;
  265. end;
  266. procedure TSymbolView.GotoItem(Item: sw_integer);
  267. begin
  268. SelectItem(Item);
  269. end;
  270. {****************************************************************************
  271. TSymbolScopeView
  272. ****************************************************************************}
  273. constructor TSymbolScopeView.Init(var Bounds: TRect; ASymbols: PSymbolCollection; AHScrollBar, AVScrollBar: PScrollBar);
  274. begin
  275. inherited Init(Bounds,AHScrollBar, AVScrollBar);
  276. Symbols:=ASymbols;
  277. NewList(ASymbols);
  278. SetRange(Symbols^.Count);
  279. end;
  280. procedure TSymbolScopeView.HandleEvent(var Event: TEvent);
  281. var OldFocus: sw_integer;
  282. begin
  283. case Event.What of
  284. evKeyDown :
  285. case Event.KeyCode of
  286. kbBack :
  287. begin
  288. LookUp(copy(LookUpStr,1,length(LookUpStr)-1));
  289. ClearEvent(Event);
  290. end;
  291. else
  292. if Event.CharCode in[#32..#255] then
  293. begin
  294. LookUp(LookUpStr+Event.CharCode);
  295. ClearEvent(Event);
  296. end;
  297. end;
  298. end;
  299. OldFocus:=Focused;
  300. inherited HandleEvent(Event);
  301. if OldFocus<>Focused then
  302. Lookup('');
  303. end;
  304. procedure TSymbolScopeView.Draw;
  305. begin
  306. inherited Draw;
  307. SetCursor(2+SymbolTypLen+length(LookUpStr),Focused-TopItem);
  308. end;
  309. procedure TSymbolScopeView.LookUp(S: string);
  310. var Idx: Sw_integer;
  311. NS: string;
  312. begin
  313. NS:=LookUpStr;
  314. if (Symbols=nil) or (S='') then NS:='' else
  315. begin
  316. S:=Symbols^.LookUp(S,Idx);
  317. if Idx<>-1 then
  318. begin
  319. NS:=S;
  320. FocusItem(Idx);
  321. end;
  322. end;
  323. LookUpStr:=NS;
  324. SetState(sfCursorVis,LookUpStr<>'');
  325. DrawView;
  326. end;
  327. function TSymbolScopeView.GetText(Item,MaxLen: Sw_Integer): String;
  328. var S: string;
  329. begin
  330. S:=Symbols^.At(Item)^.GetText;
  331. GetText:=copy(S,1,MaxLen);
  332. end;
  333. {****************************************************************************
  334. TSymbolReferenceView
  335. ****************************************************************************}
  336. constructor TSymbolReferenceView.Init(var Bounds: TRect; AReferences: PReferenceCollection;
  337. AHScrollBar, AVScrollBar: PScrollBar);
  338. begin
  339. inherited Init(Bounds,AHScrollBar, AVScrollBar);
  340. References:=AReferences;
  341. NewList(AReferences);
  342. SetRange(References^.Count);
  343. end;
  344. procedure TSymbolReferenceView.HandleEvent(var Event: TEvent);
  345. var OldFocus: sw_integer;
  346. begin
  347. OldFocus:=Focused;
  348. inherited HandleEvent(Event);
  349. if OldFocus<>Focused then
  350. Message(Desktop,evBroadcast,cmClearLineHighlights,nil);
  351. end;
  352. function TSymbolReferenceView.GetText(Item,MaxLen: Sw_Integer): String;
  353. var S: string;
  354. P: PReference;
  355. begin
  356. P:=References^.At(Item);
  357. S:=P^.GetFileName+'('+IntToStr(P^.Position.Y)+','+IntToStr(P^.Position.X)+')';
  358. GetText:=copy(S,1,MaxLen);
  359. end;
  360. procedure TSymbolReferenceView.GotoSource;
  361. var R: PReference;
  362. W: PSourceWindow;
  363. begin
  364. if Range=0 then Exit;
  365. R:=References^.At(Focused);
  366. Desktop^.Lock;
  367. W:=TryToOpenFile(nil,R^.GetFileName,R^.Position.X-1,R^.Position.Y-1);
  368. if W<>nil then W^.Select;
  369. Desktop^.UnLock;
  370. end;
  371. function LastBrowserWindow: PBrowserWindow;
  372. var BW: PBrowserWindow;
  373. procedure IsBW(P: PView); {$ifndef FPC}far;{$endif}
  374. begin
  375. if (P^.HelpCtx=hcBrowserWindow) then
  376. BW:=pointer(P);
  377. end;
  378. begin
  379. BW:=nil;
  380. Desktop^.ForEach(@IsBW);
  381. LastBrowserWindow:=BW;
  382. end;
  383. procedure TSymbolReferenceView.TrackSource;
  384. var R: PReference;
  385. W: PSourceWindow;
  386. BW: PBrowserWindow;
  387. P: TPoint;
  388. begin
  389. Message(Desktop,evBroadcast,cmClearLineHighlights,nil);
  390. if Range=0 then Exit;
  391. R:=References^.At(Focused);
  392. Desktop^.Lock;
  393. P.X:=R^.Position.X-1; P.Y:=R^.Position.Y-1;
  394. W:=TryToOpenFile(nil,R^.GetFileName,P.X,P.Y);
  395. if W<>nil then
  396. begin
  397. BW:=LastBrowserWindow;
  398. if BW=nil then
  399. W^.Select
  400. else
  401. begin
  402. Desktop^.Delete(W);
  403. Desktop^.InsertBefore(W,BW^.NextView);
  404. end;
  405. W^.Editor^.SetHighlightRow(P.Y);
  406. end;
  407. Desktop^.UnLock;
  408. end;
  409. procedure TSymbolReferenceView.GotoItem(Item: sw_integer);
  410. begin
  411. GotoSource;
  412. end;
  413. procedure TSymbolReferenceView.SelectItem(Item: Sw_Integer);
  414. begin
  415. TrackSource;
  416. end;
  417. {****************************************************************************
  418. TBrowserTab
  419. ****************************************************************************}
  420. constructor TBrowserTab.Init(var Bounds: TRect);
  421. begin
  422. inherited Init(Bounds);
  423. SetParams(0,0);
  424. end;
  425. procedure TBrowserTab.SetParams(AFlags: word; ACurrent: Sw_integer);
  426. begin
  427. Flags:=AFlags; Current:=ACurrent;
  428. DrawView;
  429. end;
  430. procedure TBrowserTab.Draw;
  431. var B: TDrawBuffer;
  432. SelColor, NormColor, C: word;
  433. I,CurX,Count: Sw_integer;
  434. const
  435. Names: string[4] = 'SRIB';
  436. begin
  437. NormColor:=GetColor(1); SelColor:=GetColor(2);
  438. MoveChar(B,'Ä',SelColor,Size.X);
  439. CurX:=0; Count:=0;
  440. for I:=0 to 3 do
  441. if (Flags and (1 shl I))<>0 then
  442. begin
  443. Inc(Count);
  444. if Current=(1 shl I) then C:=SelColor
  445. else C:=NormColor;
  446. if Count=1 then MoveChar(B[CurX],'´',SelColor,1)
  447. else MoveChar(B[CurX],'³',SelColor,1);
  448. MoveCStr(B[CurX+1],' '+Names[I+1]+' ',C);
  449. Inc(CurX,4);
  450. end;
  451. if Count>0 then
  452. MoveChar(B[CurX],'Ã',SelColor,1);
  453. WriteLine(0,0,Size.X,Size.Y,B);
  454. end;
  455. function TBrowserTab.GetPalette: PPalette;
  456. const P: string[length(CBrowserTab)] = CBrowserTab;
  457. begin
  458. GetPalette:=@P;
  459. end;
  460. constructor TBrowserWindow.Init(var Bounds: TRect; ATitle: TTitleStr; ANumber: Sw_Integer;ASym : PSymbol;
  461. const AName: string; ASymbols: PSymbolCollection; AReferences: PReferenceCollection);
  462. var R: TRect;
  463. ST: PStaticText;
  464. HSB,VSB: PScrollBar;
  465. function CreateVSB(R: TRect): PScrollBar;
  466. var R2: TRect;
  467. SB: PScrollBar;
  468. begin
  469. Sym:=ASym;
  470. R2.Copy(R); R2.Move(1,0); R2.A.X:=R2.B.X-1;
  471. New(SB, Init(R2)); SB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY;
  472. CreateVSB:=SB;
  473. end;
  474. function CreateHSB(R: TRect): PScrollBar;
  475. var R2: TRect;
  476. SB: PScrollBar;
  477. begin
  478. R2.Copy(R); R2.Move(0,1); R2.A.Y:=R2.B.Y-1;
  479. New(SB, Init(R2)); SB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY;
  480. CreateHSB:=SB;
  481. end;
  482. begin
  483. inherited Init(Bounds, ATitle, ANumber);
  484. HelpCtx:=hcBrowserWindow;
  485. GetExtent(R); R.Grow(-1,-1); R.B.Y:=R.A.Y+1;
  486. New(ST, Init(R, ' '+AName)); ST^.GrowMode:=gfGrowHiX;
  487. Insert(ST);
  488. GetExtent(R); R.Grow(-1,-1); R.Move(0,1); R.B.Y:=R.A.Y+1;
  489. New(PageTab, Init(R));
  490. PageTab^.GrowMode:=gfGrowHiX;
  491. Insert(PageTab);
  492. GetExtent(R); R.Grow(-1,-1); Inc(R.A.Y,2);
  493. if assigned(ASymbols) and (ASymbols^.Count>0) then
  494. begin
  495. HSB:=CreateHSB(R); Insert(HSB);
  496. VSB:=CreateVSB(R); Insert(VSB);
  497. New(ScopeView, Init(R, ASymbols, HSB, VSB));
  498. ScopeView^.GrowMode:=gfGrowHiX+gfGrowHiY;
  499. Insert(ScopeView);
  500. end;
  501. if assigned(AReferences) and (AReferences^.Count>0) then
  502. begin
  503. HSB:=CreateHSB(R); Insert(HSB);
  504. VSB:=CreateVSB(R); Insert(VSB);
  505. New(ReferenceView, Init(R, AReferences, HSB, VSB));
  506. ReferenceView^.GrowMode:=gfGrowHiX+gfGrowHiY;
  507. Insert(ReferenceView);
  508. end;
  509. if assigned(ScopeView) then
  510. SelectTab(btScope)
  511. else
  512. if assigned(ReferenceView) then
  513. SelectTab(btReferences);
  514. end;
  515. procedure TBrowserWindow.HandleEvent(var Event: TEvent);
  516. var DontClear: boolean;
  517. S: PSymbol;
  518. P: TPoint;
  519. begin
  520. case Event.What of
  521. evBroadcast :
  522. case Event.Command of
  523. cmSearchWindow :
  524. ClearEvent(Event);
  525. cmListItemSelected :
  526. if Event.InfoPtr=ScopeView then
  527. begin
  528. S:=ScopeView^.Symbols^.At(ScopeView^.Focused);
  529. MakeGlobal(ScopeView^.Origin,P);
  530. Desktop^.MakeLocal(P,P); Inc(P.Y,ScopeView^.Focused-ScopeView^.TopItem);
  531. Inc(P.Y);
  532. if (S^.GetReferenceCount>0) or (S^.GetItemCount>0) then
  533. OpenSymbolBrowser(Origin.X-1,P.Y,
  534. S^.GetName,
  535. ScopeView^.GetText(ScopeView^.Focused,255),S,
  536. S^.Items,S^.References);
  537. end;
  538. end;
  539. evKeyDown :
  540. begin
  541. DontClear:=false;
  542. case Event.KeyCode of
  543. kbEsc :
  544. Close;
  545. kbCtrlB :
  546. SelectTab(btBreakWatch);
  547. kbCtrlS :
  548. SelectTab(btScope);
  549. kbCtrlR :
  550. SelectTab(btReferences);
  551. else DontClear:=true;
  552. end;
  553. if DontClear=false then ClearEvent(Event);
  554. end;
  555. end;
  556. inherited HandleEvent(Event);
  557. end;
  558. procedure TBrowserWindow.SetState(AState: Word; Enable: Boolean);
  559. var OldState: word;
  560. begin
  561. OldState:=State;
  562. inherited SetState(AState,Enable);
  563. if ((State xor OldState) and sfActive)<>0 then
  564. if GetState(sfActive)=false then
  565. Message(Desktop,evBroadcast,cmClearLineHighlights,nil);
  566. end;
  567. procedure TBrowserWindow.Close;
  568. begin
  569. Message(Desktop,evBroadcast,cmClearLineHighlights,nil);
  570. inherited Close;
  571. end;
  572. procedure TBrowserWindow.SelectTab(BrowserTab: Sw_integer);
  573. var Tabs: Sw_integer;
  574. PB : PBreakpoint;
  575. PS :PString;
  576. l : longint;
  577. begin
  578. case BrowserTab of
  579. btScope :
  580. if assigned(ScopeView) then
  581. ScopeView^.Select;
  582. btReferences :
  583. if assigned(ReferenceView) then
  584. ReferenceView^.Select;
  585. btBreakWatch :
  586. begin
  587. if Assigned(Sym) then
  588. begin
  589. if Pos('proc',Sym^.GetText)>0 then
  590. { insert function breakpoint }
  591. begin
  592. { make it visible }
  593. PS:=Sym^.Name;
  594. l:=Length(PS^);
  595. If PS^[l]='*' then
  596. begin
  597. PB:=BreakpointCollection^.GetType(bt_function,copy(GetStr(PS),1,l-1));
  598. If Assigned(PB) then
  599. BreakpointCollection^.Delete(PB);
  600. Sym^.Name:=NewStr(copy(GetStr(PS),1,l-1));
  601. DrawView;
  602. DisposeStr(PS);
  603. end
  604. else
  605. begin
  606. Sym^.Name:=NewStr(GetStr(PS)+'*');
  607. DrawView;
  608. New(PB,init_function(GetStr(PS)));
  609. DisposeStr(PS);
  610. BreakpointCollection^.Insert(PB);
  611. BreakpointCollection^.Update;
  612. end;
  613. end
  614. else if pos('var',Sym^.GetText)>0 then
  615. { insert watch point }
  616. begin
  617. { make it visible }
  618. PS:=Sym^.Name;
  619. l:=Length(PS^);
  620. If PS^[l]='*' then
  621. begin
  622. PB:=BreakpointCollection^.GetType(bt_awatch,copy(PS^,1,l-1));
  623. If Assigned(PB) then
  624. BreakpointCollection^.Delete(PB);
  625. Sym^.Name:=NewStr(copy(PS^,1,l-1));
  626. DrawView;
  627. DisposeStr(PS);
  628. end
  629. else
  630. begin
  631. Sym^.Name:=NewStr(GetStr(PS)+'*');
  632. DrawView;
  633. New(PB,init_type(bt_awatch,GetStr(PS)));
  634. DisposeStr(PS);
  635. BreakpointCollection^.Insert(PB);
  636. BreakpointCollection^.Update;
  637. end;
  638. end;
  639. end;
  640. end;
  641. end;
  642. Tabs:=0;
  643. if assigned(ScopeView) then
  644. Tabs:=Tabs or btScope;
  645. if assigned(ReferenceView) then
  646. Tabs:=Tabs or btReferences;
  647. if Assigned(Sym) then
  648. if (Pos('proc',Sym^.GetText)>0) or (Pos('var',Sym^.GetText)>0) then
  649. Tabs:=Tabs or btBreakWatch;
  650. if (Tabs and BrowserTab)=0 then
  651. if (Tabs and btScope)<>0 then BrowserTab:=btScope else
  652. if (Tabs and btReferences)<>0 then BrowserTab:=btReferences else
  653. if (Tabs and btInheritance)<>0 then BrowserTab:=btInheritance else
  654. BrowserTab:=btBreakWatch;
  655. if PageTab<>nil then PageTab^.SetParams(Tabs,BrowserTab);
  656. end;
  657. function TBrowserWindow.GetPalette: PPalette;
  658. const S: string[length(CBrowserWindow)] = CBrowserWindow;
  659. begin
  660. GetPalette:=@S;
  661. end;
  662. procedure OpenSymbolBrowser(X,Y: Sw_integer;const Name,Line: string;S : PSymbol;
  663. Symbols: PSymbolCollection; References: PReferenceCollection);
  664. var R: TRect;
  665. begin
  666. if X=0 then X:=Desktop^.Size.X-35;
  667. R.A.X:=X; R.A.Y:=Y;
  668. R.B.X:=R.A.X+35; R.B.Y:=R.A.Y+15;
  669. while (R.B.Y>Desktop^.Size.Y) do R.Move(0,-1);
  670. Desktop^.Insert(New(PBrowserWindow, Init(R,
  671. 'Browse: '+Name,SearchFreeWindowNo,S,Line,Symbols,References)));
  672. end;
  673. END.
  674. {
  675. $Log$
  676. Revision 1.6 1999-02-10 09:44:59 pierre
  677. + added B tab for functions and vars for break/watch
  678. TBrowserWindow also stores the symbol itself for break/watchpoints
  679. Revision 1.5 1999/02/04 17:53:47 pierre
  680. + OpenOneSymbolBrowser
  681. Revision 1.4 1999/02/04 13:16:14 pierre
  682. + column info added
  683. Revision 1.3 1999/01/21 11:54:23 peter
  684. + tools menu
  685. + speedsearch in symbolbrowser
  686. * working run command
  687. Revision 1.2 1999/01/14 21:42:24 peter
  688. * source tracking from Gabor
  689. Revision 1.1 1999/01/12 14:29:40 peter
  690. + Implemented still missing 'switch' entries in Options menu
  691. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  692. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  693. ASCII chars and inserted directly in the text.
  694. + Added symbol browser
  695. * splitted fp.pas to fpide.pas
  696. Revision 1.0 1999/01/09 11:49:41 gabor
  697. Original implementation
  698. }