diff options
Diffstat (limited to 'examples/apps/ide/src/unitlist.pas')
-rw-r--r-- | examples/apps/ide/src/unitlist.pas | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/examples/apps/ide/src/unitlist.pas b/examples/apps/ide/src/unitlist.pas index 827326e7..e6c09a69 100644 --- a/examples/apps/ide/src/unitlist.pas +++ b/examples/apps/ide/src/unitlist.pas @@ -1,7 +1,7 @@ { fpGUI IDE - Maximus - Copyright (C) 2012 - 2013 Graeme Geldenhuys + Copyright (C) 2012 - 2014 Graeme Geldenhuys See the file COPYING.modifiedLGPL, included in this distribution, for details about redistributing fpGUI. @@ -31,6 +31,7 @@ type function GetUnitName: TfpgString; public constructor Create; + function GetRelativePath: TfpgString; property FileName: TfpgString read FFilename write FFilename; property UnitName: TfpgString read GetUnitName; property Opened: Boolean read FOpened write FOpened; @@ -48,6 +49,8 @@ type function Count: integer; function FindByName(const AUnitName: TfpgString): TUnit; function FileExists(const AFilename: TfpgString): Boolean; + function AddFileName(const AFilename: TfpgString): TUnit; + function Remove(AUnit: TUnit): integer; procedure Add(NewUnit: TUnit); procedure Clear; procedure Delete(AIndex: integer); @@ -58,7 +61,8 @@ type implementation uses - fpg_utils; + fpg_utils, + project; { TUnitList } @@ -128,6 +132,25 @@ begin end; end; +function TUnitList.AddFileName(const AFilename: TfpgString): TUnit; +var + u: TUnit; +begin + if not FileExists(AFilename) then + begin + u := TUnit.Create; + u.FileName := AFilename; + u.Opened := True; + Add(u); + Result := u; + end; +end; + +function TUnitList.Remove(AUnit: TUnit): integer; +begin + Result := FList.Remove(AUnit); +end; + procedure TUnitList.Add(NewUnit: TUnit); var l: Integer; @@ -176,6 +199,11 @@ begin Result := fpgExtractFileName(Filename); end; +function TUnit.GetRelativePath: TfpgString; +begin + Result := fpgExtractRelativepath(GProject.ProjectDir, FileName); +end; + constructor TUnit.Create; begin inherited Create; |