File: ctrlfilebrowser.pas

package info (click to toggle)
lazarus 4.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 275,760 kB
  • sloc: pascal: 2,341,904; xml: 509,420; makefile: 348,726; cpp: 93,608; sh: 3,387; java: 609; perl: 297; sql: 222; ansic: 137
file content (614 lines) | stat: -rw-r--r-- 18,352 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
unit ctrlfilebrowser;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, contnrs, frmFileBrowser, forms, filebrowsertypes, SrcEditorIntf, Masks,
  LazIDEIntf, MenuIntf, IDECommands, ProjectIntf, IDEOptEditorIntf, IDEWindowIntf, BaseIDEIntf;

Type
    TFileSearchOption = (fsoMatchOnlyFileName,fsoAbsolutePaths,fsoUseLetters);
    TFileSearchOptions = Set of TFileSearchOption;

    TFilenameMatchOption = (fmoFileNameOnly,fmoLetters);
    TFilenameMatchOptions = set of TFilenameMatchOption;

    TMatchPosition = record
      pos,len : Integer;
    end;
    TMatchPositionArray = Array of TMatchPosition;

    { TFileSearchMatch }

    TFileSearchMatch = Class(TObject)
    Private
      FEntry : TFileEntry;
      FFileName: string;
      FMatchPositions : TMatchPositionArray;
    Public
      Constructor create(const aFileName : string; aEntry : TFileEntry; const aPositions : TMatchPositionArray);
      Property FileName : string Read FFileName;
      Property Entry : TFileEntry Read FEntry;
      Property MatchPositions : TMatchPositionArray Read FMatchPositions;
    end;

    { TFileSearchResults }

    TFileSearchResults = Class(TFPObjectList)
    private
      function GetMatch(aIndex : Integer): TFileSearchMatch;
    Public
      Constructor Create;
      function Add(aMatch : TFileSearchMatch) : Integer;
      Property Match [aIndex : Integer] : TFileSearchMatch Read GetMatch; default;
    end;

   { TFileBrowserController }
    TFileBrowserController = class(TComponent)
    private
      FConfigFrame: TAbstractIDEOptionsEditorClass;
      FCustomStartDir: string;
      FDirectoriesBeforeFiles: Boolean;
      FLastOpenedDir: string;
      FRoot: TFileSystemEntry;
      FSearchOptions: TFileSearchOptions;
      FStartDir: TStartDir;
      FRootDir : TRootDir;
      FFilesInTree : Boolean;
      FCustomRootDir : string;
      FNeedSave: Boolean;
      FSplitterPos: integer;
      FCurrentEditorFile : String;
      FSyncCurrentEditor: Boolean;
      FTreeFiller : TTreeCreatorThread;
      FFileList : TStrings;
      procedure ActiveEditorChanged(Sender: TObject);
      procedure AddFileNodes(List: TStrings; aNode: TFileSystemEntry; aDir: String);
      procedure CreateFileList(aUseAbsolutePaths: boolean);
      function DoProjectChanged(Sender: TObject; AProject: TLazProject): TModalResult;
      procedure DoSelectDir(Sender: TObject);
      function GetProjectDir: String;
      function GetResolvedStartDir: String;
      procedure SetCustomRootDir(AValue: string);
      procedure SetCustomStartDir(AValue: string);
      procedure SetDirectoriesBeforeFiles(AValue: Boolean);
      procedure SetFilesInTree(AValue: Boolean);
      procedure SetLastOpenedDir(AValue: string);
      procedure SetRootDir(AValue: TRootDir);
      procedure SetSearchOptions(AValue: TFileSearchOptions);
      procedure SetSplitterPos(AValue: integer);
      procedure SetStartDir(AValue: TStartDir);
      procedure SetSyncCurrentEditor(AValue: Boolean);
      procedure OnFormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
      procedure TreeFillDone(Sender: TThread; aTree: TDirectoryEntry);
      procedure TreeFillError(Sender: TThread; const aError: String);
    protected
      { Called by file browser window }
      procedure DoOpenFile(Sender: TObject; const AFileName: string); virtual;
      { Called by file browser window }
      procedure DoConfig(Sender: TObject);
      procedure SyncCurrentFile;
      function FillingTree: boolean;
    public
      constructor Create(AOwner: TComponent); override;
      destructor Destroy; override;
      procedure ConfigWindow(AForm: TFileBrowserForm); virtual;
      procedure OpenFiles(aEntries : TFileEntryArray);
      function GetResolvedRootDir : String;
      function ShowConfig: Boolean;
      procedure WriteConfig; virtual;
      procedure ReadConfig; virtual;
      procedure IndexRootDir;
      function FindFiles(aPattern: String; aOutFileList: TFileSearchResults; aMatchOptions : TFilenameMatchOptions; aExtMask : TMaskList): Integer;
      procedure Notification(AComponent: TComponent; Operation: TOperation); override;
      Property Root : TFileSystemEntry Read FRoot;
      property StartDir: TStartDir read FStartDir write SetStartDir;
      property RootDir: TRootDir read FRootDir write SetRootDir;
      property CustomStartDir: string read FCustomStartDir write SetCustomStartDir;
      property CustomRootDir: string read FCustomRootDir write SetCustomRootDir;
      property LastOpenedDir: string read FLastOpenedDir write SetLastOpenedDir;
      property SyncCurrentEditor : Boolean Read FSyncCurrentEditor Write SetSyncCurrentEditor;
      property SplitterPos: integer read FSplitterPos write SetSplitterPos;
      Property FilesInTree : Boolean Read FFilesInTree Write SetFilesInTree;
      Property DirectoriesBeforeFiles : Boolean Read FDirectoriesBeforeFiles Write SetDirectoriesBeforeFiles;
      Property ConfigFrame : TAbstractIDEOptionsEditorClass Read FConfigFrame Write FConfigFrame;
      property SearchOptions : TFileSearchOptions Read FSearchOptions Write SetSearchOptions;
    end;


implementation

uses Controls, StrUtils, IDEMsgIntf, IDEExternToolIntf, LazConfigStorage;

{ TFileSearchMatch }

constructor TFileSearchMatch.create(const aFileName: string;
  aEntry: TFileEntry; const aPositions: TMatchPositionArray);
begin
  FFileName:=aFileName;
  FEntry:=aEntry;
  FMatchPositions:=aPositions;
end;

{ TFileSearchResults }

function TFileSearchResults.GetMatch(aIndex : Integer): TFileSearchMatch;
begin
  Result:=TFileSearchMatch(Items[aIndex]);
end;

constructor TFileSearchResults.Create;
begin
  Inherited Create(True);
end;

function TFileSearchResults.Add(aMatch: TFileSearchMatch): Integer;
begin
  Result:=Inherited Add(aMatch);
end;

{ TFileBrowserController }


procedure TFileBrowserController.TreeFillError(Sender: TThread; const aError : String);

begin
  AddIDEMessage(mluError,Format(SErrSearching,[GetResolvedRootDir,aError]),'',0,0,SViewFilebrowser);
end;

procedure TFileBrowserController.TreeFillDone(Sender: TThread; aTree: TDirectoryEntry);

begin
  if (FTreeFiller<>Sender) then exit;
  FTreeFiller:=Nil;
  FreeAndNil(FRoot);
  FRoot:=aTree;
  CreateFileList(fsoAbsolutePaths in SearchOptions);
  AddIDEMessage(mluProgress,Format(SFilesFound,[FFileList.Count,GetResolvedRootDir]),'',0,0,SViewFilebrowser);
end;

procedure TFileBrowserController.AddFileNodes(List : TStrings; aNode : TFileSystemEntry; aDir : String);

var
  FN : String;
  i : Integer;

begin
  FN:=aDir;
  if FN<>'' then
     FN:=IncludeTrailingPathDelimiter(FN);
  FN:=FN+aNode.Name;
  case aNode.EntryType of
  etFile,
  etSymlink:
    List.AddObject(FN,aNode);
  etDirectory:
    For I:=0 to ANode.EntryCount-1 do
      AddFileNodes(List,ANode.Entries[I],FN);
  end;
end;

procedure TFileBrowserController.CreateFileList(aUseAbsolutePaths : boolean);

var
  lList,l2 : TStrings;
  lDir : String;
begin
  l2:=Nil;
  lList:=TStringList.Create;
  try
    if aUseAbsolutePaths then
      lDir:=GetResolvedRootDir
    else
      lDir:='';
    AddFileNodes(lList,FRoot,lDir);
    l2:=FFileList;
    FFileList:=lList;
  except
    lList.Free;
    Raise;
  end;
  FreeAndNil(L2);
end;

procedure TFileBrowserController.ReadConfig;
var
  Storage : TConfigStorage;
  Opts : TFileSearchOptions;


begin
  Opts:=[];
  Storage:=GetIDEConfigStorage(SConfigFile, True);
  with Storage do
    try
      FStartDir  := TStartDir(GetValue(KeyStartDir, Ord(DefaultStartDir)));
      FRootDir  := TRootDir(GetValue(KeyRootDir, Ord(DefaultRootDir)));
      FCustomStartDir := GetValue(KeyCustomStartDir, '');
      FCustomRootDir := GetValue(KeyCustomRootDir, '');
      FSplitterPos:=GetValue(KeySplitterPos, DefaultSplitterPos);
      FFilesInTree:=GetValue(KeyFilesInTree, DefaultFilesInTree);
      FDirectoriesBeforeFiles:=GetValue(KeyDirectoriesBeforeFiles,DefaultDirectoriesBeforeFiles);
      FSyncCurrentEditor:=GetValue(KeySyncCurrentEditor,DefaultSyncCurrentEditor);
      if GetValue(KeySearchMatchOnlyFilename,False) then
        Include(Opts,fsoMatchOnlyFileName);
      if GetValue(KeySearchAbsoluteFilenames,False) then
        Include(Opts,fsoAbsolutePaths);
      if GetValue(KeySearchLetters,False) then
        Include(Opts,fsoUseLetters);
      SearchOptions:=Opts;
    finally
      Free;
    end;
end;


procedure TFileBrowserController.SetCustomRootDir(AValue: string);
begin
  if FCustomRootDir=AValue then Exit;
  FCustomRootDir:=AValue;
  FNeedSave:=true;
end;

procedure TFileBrowserController.SetCustomStartDir(AValue: string);
begin
  if FCustomStartDir=AValue then Exit;
  FCustomStartDir:=AValue;
  FNeedSave:=true;
end;

procedure TFileBrowserController.SetDirectoriesBeforeFiles(AValue: Boolean);
begin
  if FDirectoriesBeforeFiles=AValue then Exit;
  FDirectoriesBeforeFiles:=AValue;
  FNeedSave:=true;
end;

procedure TFileBrowserController.SetFilesInTree(AValue: Boolean);
begin
  if FFilesInTree=AValue then Exit;
  FFilesInTree:=AValue;
  FNeedSave:=true;
end;

procedure TFileBrowserController.SetLastOpenedDir(AValue: string);
begin
  if FLastOpenedDir=AValue then Exit;
  FLastOpenedDir:=AValue;
  FNeedSave:=True;
end;

procedure TFileBrowserController.SetRootDir(AValue: TRootDir);
begin
  if FRootDir=AValue then Exit;
  FRootDir:=AValue;
  FNeedSave:=True;
end;

procedure TFileBrowserController.SetSearchOptions(AValue: TFileSearchOptions);
begin
  if FSearchOptions=AValue then Exit;
  FSearchOptions:=AValue;
  FNeedSave:=True;
end;

procedure TFileBrowserController.SetSplitterPos(AValue: integer);
begin
  if FSplitterPos=AValue then Exit;
  FSplitterPos:=AValue;
  FNeedSave:=true;
end;

procedure TFileBrowserController.SetStartDir(AValue: TStartDir);
begin
  if FStartDir=AValue then Exit;
  FStartDir:=AValue;
  FNeedSave:=True;
end;

procedure TFileBrowserController.SetSyncCurrentEditor(AValue: Boolean);
begin
  if FSyncCurrentEditor=AValue then Exit;
  FSyncCurrentEditor:=AValue;
  FNeedSave:=True;
  if aValue and (FCurrentEditorFile<>'') then
    SyncCurrentFile;
end;

procedure TFileBrowserController.WriteConfig;
var
  Storage : TConfigStorage;
begin
  Storage:=GetIDEConfigStorage(SConfigFile, True);
  with Storage do
    try
      SetDeleteValue(KeyStartDir, Ord(FStartDir), Ord(DefaultStartDir));
      SetDeleteValue(KeyRootDir, Ord(FRootDir), Ord(DefaultRootDir));
      SetDeleteValue(KeyCustomStartDir, CustomStartDir, '');
      SetDeleteValue(KeyCustomRootDir, CustomRootDir, '');
      SetDeleteValue(KeySplitterPos, FSplitterPos, DefaultSplitterPos);
      SetDeleteValue(KeyFilesInTree, FFilesInTree, DefaultFilesInTree);
      SetDeleteValue(KeyDirectoriesBeforeFiles, FDirectoriesBeforeFiles, DefaultDirectoriesBeforeFiles);
      SetDeleteValue(KeySyncCurrentEditor,FSyncCurrentEditor, DefaultSyncCurrentEditor);
      SetDeleteValue(KeySearchMatchOnlyFilename,fsoMatchOnlyFileName in SearchOptions,False);
      SetDeleteValue(KeySearchAbsoluteFilenames,fsoAbsolutePaths in SearchOptions,False);
      SetDeleteValue(KeySearchLetters,fsoUseLetters in SearchOptions,False);
      FNeedSave := False;
    finally
      Free;
    end;
end;

function TFileBrowserController.FillingTree : boolean;

begin
  Result:=Assigned(FTreeFiller);
end;

procedure TFileBrowserController.IndexRootDir;

var
  lDir : String;
begin
  if FillingTree then
    Exit;
  lDir:=GetResolvedRootDir;
  // Do not recurse, thread handles it, it needs to react to terminate...
  FTreeFiller:=TTreeCreatorThread.Create(lDir,[],@TreeFillDone,@TreeFillError);
  AddIDEMessage(mluVerbose,Format(SSearchingFiles,[lDir]),'',0,0,SViewFilebrowser);
end;

function TFileBrowserController.FindFiles(aPattern: String;
  aOutFileList: TFileSearchResults; aMatchOptions: TFilenameMatchOptions;
  aExtMask: TMaskList): Integer;
  
  function MatchesPattern(const aName: string; aStartPos: Integer; const aPtrn: string; var aPositions : TMatchPositionArray): Integer;
  var
    wasMatch : boolean;
    lPtrnLen,lNameLen,lPtrnPos, lNamePos: Integer;
  begin
    Result:=0;
    lPtrnPos := 1;
    lPtrnLen := Length(aPtrn);
    lNameLen := Length(aName);
    lNamePos := aStartPos;
    wasMatch := false;

    while (lPtrnPos <= lPtrnLen) and (lNamePos <= lNameLen) do
    begin
      if aName[lNamePos] = aPtrn[lPtrnPos] then
        begin
        if WasMatch then
          Inc(aPositions[Result].Len)
        else
          begin
          aPositions[Result].Pos:=lNamePos;
          aPositions[Result].Len:=1;
          Inc(Result);
          end;
        Inc(lPtrnPos);
        end;
      Inc(lNamePos);
    end;
    if (lPtrnPos < lPtrnLen) then
      Result := 0;
  end;

var
  lPtrn, lFilename : String;
  lMatchLen,lStartPos,lFileIdx: Integer;
  isMatch : Boolean;
  Match : TFileSearchMatch;
  lPositions : TMatchPositionArray;

begin
  Result:=0;
  if (FFileList=Nil) or (Length(aPattern)<2) then exit;

  lPtrn := Lowercase(aPattern);

  For lFileIdx:=0 to FFileList.Count-1 do
  begin
    // Reset positions array.
    lPositions:=[];
    if fmoLetters in aMatchOptions then
      SetLength(lPositions,Length(lPtrn))
    else
      SetLength(lPositions,1);
    // Determine Start position
    lFilename := Lowercase(FFileList[lFileIdx]);
    if fmoFileNameOnly in aMatchOptions then
      lStartPos:=rpos(PathDelim,lFileName)+1
    else
      lStartPos:=1;

    if (aExtMask=Nil) or (aExtMask.Matches(lFilename)) then
    begin
      if fmoLetters in aMatchOptions then
        begin
        lMatchLen:=MatchesPattern(lFilename, lStartPos, lPtrn, lPositions);
        isMatch:=lMatchLen>0;
        if IsMatch then
          SetLength(lPositions,lMatchLen);
        end
      else
        begin
        lPositions[0].Pos:=Pos(lPtrn,lFileName,lStartPos);
        lPositions[0].Len:=Length(lPtrn);
        IsMatch:=(lPositions[0].Pos>0);
        end;
      if IsMatch then
        begin
        Match:=TFileSearchMatch.Create(FFileList[lFileIdx],TFileEntry(FFileList.Objects[lFileIdx]),lPositions);
        aOutFileList.Add(Match);
        end;
    end;
  end;
end;

procedure TFileBrowserController.ConfigWindow(AForm: TFileBrowserForm);

begin
  aForm.Caption:=SFileBrowserIDEMenuCaption;
  aForm.FreeNotification(Self);
  aForm.OnOpenFile := @DoOpenFile;
  aForm.OnConfigure := @DoConfig;
  aForm.OnSelectDir := @DoSelectDir;
  aForm.AddHandlerClose(@OnFormClose);
  aForm.TV.Height:=FSplitterPos;

  aForm.RootDirectory:=GetResolvedRootDir;
  aForm.CurrentDirectory := GetResolvedStartDir;
  aForm.FilesInTree:=FilesInTree;
  aForm.DirectoriesBeforeFiles:=DirectoriesBeforeFiles;
  if FCurrentEditorFile<>'' then
    SyncCurrentFile;
end;

procedure TFileBrowserController.OpenFiles(aEntries: TFileEntryArray);

var
  E : TFileEntry;

begin
  for E in aEntries do
    DoOpenFile(Self,E.AbsolutePath);
end;

function TFileBrowserController.GetProjectDir : String;

begin
  if Assigned(LazarusIDE.ActiveProject) then
    Result:=ExtractFilePath(LazarusIDE.ActiveProject.ProjectInfoFile)
  else
    Result:=GetTempDir(False);
end;

function TFileBrowserController.GetResolvedStartDir: String;

begin
  Case StartDir of
    sdProjectDir : Result:=GetProjectDir;
    sdCustomDir : Result:=IncludeTrailingPathDelimiter(CustomStartDir);
    sdLastOpened : Result:=IncludeTrailingPathDelimiter(LastOpenedDir);
  end;
end;

function TFileBrowserController.GetResolvedRootDir: String;
begin
  Case RootDir of
    rdProjectDir : Result:=GetProjectDir;
    rdRootDir : Result:='/';
    rdCustomDir : Result:=IncludeTrailingPathDelimiter(CustomRootDir);
    rdUserDir : Result:=IncludeTrailingPathDelimiter(GetUserDir);
  end;
end;

procedure TFileBrowserController.DoOpenFile(Sender: TObject; const AFileName: string);
var
  Flags: TOpenFlags;
begin
  // Set up as desired. Maybe create config settings;
  Flags := [ofOnlyIfExists, ofAddToRecent, ofUseCache];
  LazarusIDE.DoOpenEditorFile(AFileName, 0, 0, Flags);
end;


procedure TFileBrowserController.OnFormClose(Sender: TObject;
  var CloseAction: TCloseAction);
begin
  SplitterPos:=FileBrowserForm.Splitter1.Top;
end;

procedure TFileBrowserController.DoSelectDir(Sender: TObject);
begin
  if StartDir = sdLastOpened then
    LastOpenedDir := FileBrowserForm.CurrentDirectory;
end;

function TFileBrowserController.DoProjectChanged(Sender: TObject; AProject: TLazProject): TModalResult;

var
  aPath : String;

begin
  Result:=mrOK;
  if Assigned(FileBrowserForm) then
    begin
    APath:=ExcludeTrailingPathDelimiter(ExtractFilePath(aProject.ProjectInfoFile));
    if RootDir=rdProjectDir then
      FileBrowserForm.RootDirectory:=aPath;
    if StartDir=sdProjectDir then
      FileBrowserForm.CurrentDirectory:=aPath;
    end;

end;

procedure TFileBrowserController.ActiveEditorChanged(Sender: TObject);


begin
  if not Assigned(SourceEditorManagerIntf.ActiveEditor) then
    exit;
  FCurrentEditorFile:=SourceEditorManagerIntf.ActiveEditor.FileName;
  SyncCurrentFile;
end;

procedure TFileBrowserController.SyncCurrentFile;

begin
  if Not (Assigned(FileBrowserForm) and SyncCurrentEditor) then
    exit;
  FileBrowserForm.CurrentFile:=FCurrentEditorFile
end;

procedure TFileBrowserController.DoConfig(Sender: TObject);
begin
  // Maybe later some reconfiguration of FWindow is needed after ShowConfig ?
  if ShowConfig then
    WriteConfig;
end;

constructor TFileBrowserController.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  LazarusIDE.AddHandlerOnProjectOpened(@DoProjectChanged);
  if SourceEditorManagerIntf <> nil then
    SourceEditorManagerIntf.RegisterChangeEvent(semEditorActivate,@ActiveEditorChanged);
  FDirectoriesBeforeFiles:=DefaultDirectoriesBeforeFiles;
  FFilesInTree:=DefaultFilesInTree;
  ReadConfig;
end;

destructor TFileBrowserController.Destroy;
begin
  if Assigned(FTreeFiller) then
    FTreeFiller.Terminate;
  FreeAndNil(FFileList);
  FreeAndNil(FRoot);
  if SourceEditorManagerIntf <> nil then
    SourceEditorManagerIntf.UnRegisterChangeEvent(semEditorActivate,@ActiveEditorChanged);
  if FNeedSave then
    WriteConfig;
  inherited;
end;

function TFileBrowserController.ShowConfig: Boolean;

begin
  Result:=LazarusIDE.DoOpenIDEOptions(ConfigFrame);
end;

procedure TFileBrowserController.Notification(AComponent: TComponent; Operation: TOperation);
begin
  inherited;
  if (AComponent = FileBrowserForm) and (opRemove = Operation) then
    FileBrowserForm := nil;
end;



end.