mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 16:00:16 +02:00
Created new TProjectUnitInfo class.
Created new TProject class. Saves to XML config file. Moved compiler options to write to the project file. CAW git-svn-id: trunk@144 -
This commit is contained in:
parent
5db12a2d5c
commit
061fa9525a
546
ide/project.pp
546
ide/project.pp
@ -2,8 +2,7 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
project.pp - project utility class file
|
project.pp - project utility class file
|
||||||
-------------------
|
-------------------
|
||||||
TCompiler is responsible for configuration and running
|
TProject is responsible for managing a complete project.
|
||||||
the PPC386 compiler.
|
|
||||||
|
|
||||||
|
|
||||||
Initial Revision : Sun Mar 28 23:15:32 CST 1999
|
Initial Revision : Sun Mar 28 23:15:32 CST 1999
|
||||||
@ -20,279 +19,400 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
}
|
}
|
||||||
|
{$H+}
|
||||||
unit project;
|
unit project;
|
||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
|
|
||||||
|
{$ifdef Trace}
|
||||||
|
{$ASSERTIONS ON}
|
||||||
|
{$endif}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, Global, SysUtils, IniFiles,mwCustomEdit, FORMS,dlgMessage;
|
Classes, Global, SysUtils, xmlcfg, lazconf, compileroptions, filectrl;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
TProjectUnitInfo = class(TObject)
|
||||||
|
private
|
||||||
|
{ Variables }
|
||||||
|
fAutoCreate: Boolean;
|
||||||
|
fBookmarks: TList;
|
||||||
|
fBreakpoints: TList;
|
||||||
|
fCursorPos: LongInt;
|
||||||
|
fFilename: String;
|
||||||
|
fUnitName: String;
|
||||||
|
fReadOnly: Boolean;
|
||||||
|
fSyntaxHighlighter: String;
|
||||||
|
public
|
||||||
|
constructor Create;
|
||||||
|
|
||||||
|
{ Properties }
|
||||||
|
property AutoCreate: Boolean read fAutoCreate write fAutoCreate;
|
||||||
|
property Bookmarks: TList read fBookmarks write fBookmarks;
|
||||||
|
property Breakpoints: TList read fBreakpoints write fBreakpoints;
|
||||||
|
property CursorPos: LongInt read fCursorPos write fCursorPos;
|
||||||
|
property Filename: String read fFilename write fFilename;
|
||||||
|
property UnitName: String read fUnitName write fUnitName;
|
||||||
|
property ReadOnly: Boolean read fReadOnly write fReadOnly;
|
||||||
|
property SyntaxHighlighter: String read fSyntaxHighlighter write fSyntaxHighlighter;
|
||||||
|
end;
|
||||||
|
|
||||||
TProject = class(TObject)
|
TProject = class(TObject)
|
||||||
private
|
private
|
||||||
FUnits: TList;
|
xmlcfg: TXMLConfig;
|
||||||
FLibrary: TStrings;
|
|
||||||
FName: String;
|
{ Variables }
|
||||||
|
fAliases: String;
|
||||||
|
fCompilerOptions: TCompilerOptions;
|
||||||
|
fIconPath: String;
|
||||||
|
fMainUnit: String;
|
||||||
|
fOutputDirectory: String;
|
||||||
|
fProjectFile: String;
|
||||||
|
fProjectInfoFile: String;
|
||||||
|
fTargetFileExt: String;
|
||||||
|
fTitle: String;
|
||||||
|
fUnitList: TList;
|
||||||
|
fUnitNameList: String;
|
||||||
|
fUnitOutputDirectory: String;
|
||||||
|
|
||||||
|
{ Functions }
|
||||||
|
function GetUnitList: TList;
|
||||||
|
function GetXMLConfigPath: String;
|
||||||
|
|
||||||
|
{ Procedures }
|
||||||
|
procedure SetUnitList(AList: TList);
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
function SaveProject(const SaveName: string) : Boolean;
|
destructor Destroy;
|
||||||
function OpenProject(const OpenName: string) : Boolean;
|
|
||||||
procedure AddUnit(AUnit: TUnitInfo);
|
{ Functions }
|
||||||
procedure AddLibraryPath(const LibPath: String);
|
function ReadProject: Boolean;
|
||||||
function GetLibraryPaths: TStrings;
|
function WriteProject: Boolean;
|
||||||
function GetUnits: TList;
|
|
||||||
property UnitList: TList read FUnits write FUnits;
|
{ Procedures }
|
||||||
property Name: String read FName write FName;
|
procedure AddUnit(AUnit: TProjectUnitInfo);
|
||||||
|
procedure RemoveUnit(AUnitName: String);
|
||||||
|
|
||||||
|
{ Properties }
|
||||||
|
property Aliases: String read fAliases write fAliases;
|
||||||
|
property CompilerOptions: TCompilerOptions read fCompilerOptions write fCompilerOptions;
|
||||||
|
property IconPath: String read fIconPath write fIconPath;
|
||||||
|
property MainUnit: String read fMainUnit write fMainUnit;
|
||||||
|
property OutputDirectory: String read fOutputDirectory write fOutputDirectory;
|
||||||
|
property ProjectFile: String read fProjectFile write fProjectFile;
|
||||||
|
property ProjectInfoFile: String read fProjectInfoFile write fProjectInfoFile;
|
||||||
|
property TargetFileExt: String read fTargetFileExt write fTargetFileExt;
|
||||||
|
property Title: String read fTitle write fTitle;
|
||||||
|
property UnitList: TList read GetUnitList write SetUnitList;
|
||||||
|
property UnitNameList: String read fUnitNameList write fUnitNameList;
|
||||||
|
property UnitOutputDirectory: String read fUnitOutputDirectory write fUnitOutputDirectory;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
Project1 : TProject;
|
Project1 : TProject;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Main;
|
Main;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
TProjectUnitInfo Class
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------
|
||||||
|
TProjectUnitInfo Constructor
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
constructor TProjectUnitInfo.Create;
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
Assert(False, 'Project Unit Info Class Created');
|
||||||
|
|
||||||
|
fAutoCreate := true;
|
||||||
|
fBookmarks := TList.Create;
|
||||||
|
fBreakpoints := TList.Create;
|
||||||
|
fCursorPos := 0;
|
||||||
|
fFilename := '';
|
||||||
|
fUnitName := '';
|
||||||
|
fReadOnly := false;
|
||||||
|
fSyntaxHighlighter := 'freepascal';
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
TProject Class
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
TProject Constructor
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
constructor TProject.Create;
|
constructor TProject.Create;
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FUnits := TList.Create;
|
Assert(False, 'Trace:Project Class Created');
|
||||||
FLibrary := TStringList.Create;
|
|
||||||
|
xmlcfg := nil;
|
||||||
|
|
||||||
|
fAliases := '';
|
||||||
|
fCompilerOptions := TCompilerOptions.Create;
|
||||||
|
fIconPath := '';
|
||||||
|
fMainUnit := '';
|
||||||
|
fOutputDirectory := '';
|
||||||
|
fProjectFile := '';
|
||||||
|
fProjectInfoFile := '';
|
||||||
|
fTargetFileExt := '';
|
||||||
|
fTitle := '';
|
||||||
|
fUnitList := TList.Create;
|
||||||
|
fUnitNameList := '';
|
||||||
|
fUnitOutputDirectory := '';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------
|
||||||
function TProject.SaveProject(const SaveName: String) : Boolean;
|
TProject Destructor
|
||||||
var
|
------------------------------------------------------------------------------}
|
||||||
iniFile : TIniFile;
|
destructor TProject.Destroy;
|
||||||
Texts : String;
|
|
||||||
TempName : String;
|
|
||||||
I,X : Integer;
|
|
||||||
TempEditor : TmwCustomEdit;
|
|
||||||
begin
|
begin
|
||||||
Result := True;
|
if (xmlcfg <> nil) then xmlcfg.Free;
|
||||||
if SaveName = '' then Exit;
|
fUnitList.Free;
|
||||||
|
fCompilerOptions.Free;
|
||||||
|
|
||||||
//create the .dsk file based on the project name
|
inherited Destroy;
|
||||||
Assert(False, 'Trace:INIFILE CREATE');
|
|
||||||
if FileExists(SaveName + '.dsk') then
|
|
||||||
begin
|
|
||||||
TempName := SaveName + '.~dsk';
|
|
||||||
RenameFile(SaveName + '.dsk', TempName);
|
|
||||||
end;
|
|
||||||
|
|
||||||
INiFile := TiniFile.Create(Savename+'.dsk');
|
|
||||||
Assert(False, 'Trace:INIFILE CREATE');
|
|
||||||
|
|
||||||
for i := 0 to FUnits.Count -1 do
|
|
||||||
begin
|
|
||||||
INIFIle.WriteString('Modules','Module'+inttostr(I),TUnitInfo(FUnits.items[i]).Filename);
|
|
||||||
INIFile.WriteString(TUnitInfo(FUnits.items[i]).Filename,'ModuleType','SourceModule');
|
|
||||||
INIFile.WriteString(TUnitInfo(FUnits.items[i]).Filename,'FormState','0');
|
|
||||||
INIFile.WriteString(TUnitInfo(FUnits.items[i]).Filename,'FormOnTop','0');
|
|
||||||
end;
|
|
||||||
|
|
||||||
INIFIle.WriteInteger('Modules','Count',FUnits.Count);
|
|
||||||
|
|
||||||
//have to check this later
|
|
||||||
INIFIle.WriteString('Modules','EditWindowCount','1');
|
|
||||||
|
|
||||||
// INIFile.WriteInteger('EditWindow0','ViewCount',IdeEditor1.Notebook1.Pages.Count);
|
|
||||||
// INIFile.WriteInteger('EditWindow0','CurrentView',IdeEditor1.Notebook1.PageIndex);
|
|
||||||
{ for I := 0 to ideEditor1.Notebook1.Pages.Count-1 do
|
|
||||||
begin
|
|
||||||
|
|
||||||
//Determine what entry each notebook is displaying.
|
|
||||||
Assert(False, 'Trace:*******************');
|
|
||||||
Assert(False, 'Trace:*******************');
|
|
||||||
Assert(False, 'Trace:***I := '+Inttostr(i));
|
|
||||||
Assert(False, 'Trace:*******************');
|
|
||||||
Assert(False, 'Trace:*******************');
|
|
||||||
for X := 0 to FUnits.Count-1 do
|
|
||||||
begin
|
|
||||||
Assert(False, 'Trace:X = '+Inttostr(x));
|
|
||||||
Assert(False, 'Trace:Page = '+inttostr(TUnitInfo(FUnits.Items[x]).Page));
|
|
||||||
if TUnitInfo(FUnits.Items[x]).Page = I
|
|
||||||
then begin
|
|
||||||
INIFile.WriteInteger('EditWindow0','View'+Inttostr(I),X);
|
|
||||||
//write out the View section while here.
|
|
||||||
IniFile.WriteString('View'+Inttostr(I),'Module',TUnitInfo(FUnits.Items[x]).Filename);
|
|
||||||
TempEditor := ideEditor1.GetEditorfromPage(i);
|
|
||||||
if TempEditor = nil then Break;
|
|
||||||
IniFile.WriteInteger('View'+Inttostr(I),'CursorX',TempEditor.CaretX);
|
|
||||||
IniFile.WriteInteger('View'+Inttostr(I),'CursorY',TempEditor.CaretY);
|
|
||||||
IniFile.WriteInteger('View'+Inttostr(I),'TopLine',TempEditor.TopLine);
|
|
||||||
IniFile.WriteInteger('View'+Inttostr(I),'LeftCol',tempEditor.LeftChar);
|
|
||||||
Break;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
if IdeEditor1.Visible
|
|
||||||
then INIFile.WriteInteger('EditWindow0','Visible',1)
|
|
||||||
else INIFile.WriteInteger('EditWindow0','Visible',0);
|
|
||||||
}
|
|
||||||
//Write out screen coords
|
|
||||||
{ INIFile.WriteInteger('EditWindow0','Left',ideEditor1.Left);
|
|
||||||
INIFile.WriteInteger('EditWindow0','Top',ideEditor1.Top);
|
|
||||||
INIFile.WriteInteger('EditWindow0','Height',ideEditor1.Height);
|
|
||||||
INIFile.WriteInteger('EditWindow0','Width',ideEditor1.Width);
|
|
||||||
INIFile.WriteInteger('EditWindow0','CurrentView',ideEditor1.Notebook1.Pageindex);
|
|
||||||
}
|
|
||||||
INIFile.WriteInteger('Main Window','Create',1);
|
|
||||||
INIFile.WriteInteger('Main Window','Visible',1);
|
|
||||||
INIFile.WriteInteger('Main Window','State',0); //0 = normal?
|
|
||||||
INIFile.WriteInteger('Main Window','Left',MainIDE.Left);
|
|
||||||
INIFile.WriteInteger('Main Window','Top',MainIDE.Top);
|
|
||||||
INIFile.WriteInteger('Main Window','Width',MainIDE.Width);
|
|
||||||
INIFile.WriteInteger('Main Window','Height',MainIDE.Height);
|
|
||||||
|
|
||||||
INIFile.WriteInteger('Message Window','Create',1);
|
|
||||||
if Messagedlg.Visible
|
|
||||||
then INIFile.WriteInteger('Message WIndow','Visible',1)
|
|
||||||
else INIFile.WriteInteger('Message WIndow','Visible',0);
|
|
||||||
|
|
||||||
INIFile.WriteInteger('Message Window','State',0); //0 = normal?
|
|
||||||
INIFile.WriteInteger('Message Window','Left',MainIDE.Left);
|
|
||||||
INIFile.WriteInteger('Message Window','Top',MainIDE.Top);
|
|
||||||
INIFile.WriteInteger('Message Window','Width',MainIDE.Width);
|
|
||||||
INIFile.WriteInteger('Message Window','Height',MainIDE.Height);
|
|
||||||
|
|
||||||
|
|
||||||
IniFile.Free;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------
|
||||||
function TProject.OpenProject(const OpenName: String) : Boolean;
|
TProject WriteProject
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function TProject.WriteProject: Boolean;
|
||||||
var
|
var
|
||||||
tempInt: Integer;
|
confPath: String;
|
||||||
tempStr: String;
|
i: Integer;
|
||||||
Count : Integer;
|
|
||||||
EditCount : Integer;
|
|
||||||
ViewCount : Integer;
|
|
||||||
tempEditor : TmwCustomEdit;
|
|
||||||
SList : TUnitInfo;
|
|
||||||
INIFile : TIniFile;
|
|
||||||
I,X : Integer;
|
|
||||||
begin
|
begin
|
||||||
Result := True;
|
Result := false;
|
||||||
//open the .dsk file based on the project name
|
|
||||||
Assert(False, 'Trace:INIFILE CREATE '+Openname+'.dsk');
|
|
||||||
INiFile := TiniFile.Create(OpenName+'.dsk');
|
|
||||||
Assert(False, 'Trace:INIFILE CREATE');
|
|
||||||
|
|
||||||
Assert(False, 'Trace:Read count');
|
|
||||||
count := INIFIle.ReadInteger('Modules','Count',0);
|
|
||||||
Assert(False, 'Trace:Count = '+Inttostr(count));
|
|
||||||
|
|
||||||
for i := 0 to Count - 1 do
|
|
||||||
begin
|
|
||||||
tempStr := INIFIle.ReadString('Modules','Module'+inttostr(I),'');
|
|
||||||
if TempStr <> ''
|
|
||||||
then Begin //a name exists
|
|
||||||
Assert(False, 'Trace:TempStr = '+TempStr);
|
|
||||||
SList := TUnitInfo.Create;
|
|
||||||
SList.Source := TStringList.Create;
|
|
||||||
SList.Filename := TempStr;
|
|
||||||
SList.Source.LoadFromFile(SList.Filename);
|
|
||||||
SList.Page := -1;
|
|
||||||
MainIDE.SetFlags(SList);
|
|
||||||
MainIDE.SetName_Form(SList);
|
|
||||||
FUnits.Add(SList);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Assert(False, 'Trace:Read EditCount');
|
confPath := GetXMLConfigPath;
|
||||||
EditCount := INIFile.ReadInteger('Modules','EditWindowCount',0);
|
if (confPath = '') then exit;
|
||||||
|
|
||||||
for I := 0 to EditCount -1 do
|
xmlcfg := TXMLConfig.Create(SetDirSeparators(confPath));
|
||||||
begin
|
|
||||||
Assert(False, 'Trace:Read ViewCount');
|
try
|
||||||
|
xmlcfg.SetValue('ProjectOptions/General/ProjectFile/Value', ProjectFile);
|
||||||
ViewCount := INIFIle.ReadInteger('EditWindow'+inttostr(i),'ViewCount',0);
|
xmlcfg.SetValue('ProjectOptions/General/MainUnit/Value', MainUnit);
|
||||||
if ViewCount > 0
|
xmlcfg.SetValue('ProjectOptions/General/Aliases/Value', Aliases);
|
||||||
then begin
|
xmlcfg.SetValue('ProjectOptions/General/IconPath/Value', IconPath);
|
||||||
for x := 0 to ViewCount-1 do
|
xmlcfg.SetValue('ProjectOptions/General/TargetFileExt/Value', TargetFileExt);
|
||||||
|
xmlcfg.SetValue('ProjectOptions/General/Title/Value', Title);
|
||||||
|
xmlcfg.SetValue('ProjectOptions/General/OutputDirectory/Value', OutputDirectory);
|
||||||
|
xmlcfg.SetValue('ProjectOptions/General/UnitOutputDirectory/Value', UnitOutputDirectory);
|
||||||
|
|
||||||
|
// Set options for each Unit
|
||||||
|
if (UnitList <> nil) then
|
||||||
|
begin
|
||||||
|
for i := 0 to UnitList.Count - 1 do
|
||||||
begin
|
begin
|
||||||
Assert(False, 'Trace:Read View'+inttostr(x));
|
xmlcfg.SetValue('ProjectOptions/UnitInfo/' + TProjectUnitInfo(UnitList.Items[i]).UnitName + '/UnitName/Value', TProjectUnitInfo(UnitList.Items[i]).UnitName);
|
||||||
TempInt := INIFIle.ReadInteger('EditWindow'+inttostr(i),'View'+InttoStr(x),0);
|
xmlcfg.SetValue('ProjectOptions/UnitInfo/' + TProjectUnitInfo(UnitList.Items[i]).UnitName + '/Filename/Value', TProjectUnitInfo(UnitList.Items[i]).Filename);
|
||||||
TUnitInfo(FUnits.Items[TempInt]).Page := x;
|
xmlcfg.SetValue('ProjectOptions/UnitInfo/' + TProjectUnitInfo(UnitList.Items[i]).UnitName + '/CursorPos/Value', TProjectUnitInfo(UnitList.Items[i]).CursorPos);
|
||||||
//add the page here
|
xmlcfg.SetValue('ProjectOptions/UnitInfo/' + TProjectUnitInfo(UnitList.Items[i]).UnitName + '/AutoCreate/Value', TProjectUnitInfo(UnitList.Items[i]).AutoCreate);
|
||||||
{debug}
|
xmlcfg.SetValue('ProjectOptions/UnitInfo/' + TProjectUnitInfo(UnitList.Items[i]).UnitName + '/ReadOnly/Value', TProjectUnitInfo(UnitList.Items[i]).ReadOnly);
|
||||||
Assert(False, 'Trace:NAME = '+TUnitInfo(FUnits.Items[TempInt]).Name);
|
xmlcfg.SetValue('ProjectOptions/UnitInfo/' + TProjectUnitInfo(UnitList.Items[i]).UnitName + '/SyntaxHighlighter/Value', TProjectUnitInfo(UnitList.Items[i]).SyntaxHighlighter);
|
||||||
|
|
||||||
// ideEditor1.AddPage(TUnitInfo(FUnits.Items[TempInt]).Name,TUnitInfo(FUnits.Items[TempInt]).Source);
|
{ TODO:
|
||||||
|
Depending on how Bookmarks and Breakpoints work, save them out. They are setup as a TList.
|
||||||
|
This may change if they are done in some other manner. Need to uncomment them and implement
|
||||||
|
them once this it is known how they are going to work (depends on editor being used).
|
||||||
|
}
|
||||||
|
// xmlcfg.SetValue('ProjectOptions/UnitInfo/' + TProjectUnitInfo(UnitList.Items[i]).UnitName + '/Bookmarks/Value', TProjectUnitInfo(UnitList.Items[i]).Bookmarks);
|
||||||
|
// xmlcfg.SetValue('ProjectOptions/UnitInfo/' + TProjectUnitInfo(UnitList.Items[i]).UnitName + '/Breakpoints/Value', TProjectUnitInfo(UnitList.Items[i]).Breakpoints);
|
||||||
end;
|
end;
|
||||||
TempInt := INIFIle.ReadInteger('EditWindow'+inttostr(i),'CurrentView',0);
|
|
||||||
// ideEditor1.Notebook1.Pageindex := tempint;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Assert(False, 'Trace:Read Visible');
|
|
||||||
Assert(False, 'Trace:I = '+Inttostr(i));
|
|
||||||
|
|
||||||
{ ideEditor1.Visible := (INIFile.ReadInteger('EditWindow'+inttostr(i),'Visible',0) = 1);
|
// Save the compiler options
|
||||||
ideEditor1.Left := INIFIle.ReadInteger('EditWindow'+inttostr(i),'Left',0);
|
CompilerOptions.XMLConfigFile := xmlcfg;
|
||||||
ideEditor1.Top := INIFIle.ReadInteger('EditWindow'+inttostr(i),'Top',0);
|
CompilerOptions.ProjectFile := confPath;
|
||||||
ideEditor1.Width := INIFIle.ReadInteger('EditWindow'+inttostr(i),'Width',300);
|
CompilerOptions.SaveCompilerOptions(true);
|
||||||
ideEditor1.Height := INIFIle.ReadInteger('EditWindow'+inttostr(i),'Height',400);
|
|
||||||
}
|
xmlcfg.Flush;
|
||||||
|
finally
|
||||||
|
xmlcfg.Free;
|
||||||
|
end;
|
||||||
|
Result := true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
TProject ReadProject
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function TProject.ReadProject: Boolean;
|
||||||
|
var
|
||||||
|
confPath: String;
|
||||||
|
curUnitName: String;
|
||||||
|
workUnitList: String;
|
||||||
|
pui: TProjectUnitInfo;
|
||||||
|
begin
|
||||||
|
Result := false;
|
||||||
|
|
||||||
|
confPath := GetXMLConfigPath;
|
||||||
|
if (confPath = '') then exit;
|
||||||
|
|
||||||
|
xmlcfg := TXMLConfig.Create(SetDirSeparators(confPath));
|
||||||
|
|
||||||
|
try
|
||||||
|
ProjectFile := xmlcfg.GetValue('ProjectOptions/General/ProjectFile/Value', '');
|
||||||
|
MainUnit := xmlcfg.GetValue('ProjectOptions/General/MainUnit/Value', '');
|
||||||
|
UnitNameList := xmlcfg.GetValue('ProjectOptions/General/UnitNameList/Value', '');
|
||||||
|
Aliases := xmlcfg.GetValue('ProjectOptions/General/Aliases/Value', '');
|
||||||
|
IconPath := xmlcfg.GetValue('ProjectOptions/General/IconPath/Value', './');
|
||||||
|
TargetFileExt := xmlcfg.GetValue('ProjectOptions/General/TargetFileExt/Value', '');
|
||||||
|
Title := xmlcfg.GetValue('ProjectOptions/General/Title/Value', '');
|
||||||
|
OutputDirectory := xmlcfg.GetValue('ProjectOptions/General/OutputDirectory/Value', './');
|
||||||
|
UnitOutputDirectory := xmlcfg.GetValue('ProjectOptions/General/UnitOutputDirectory/Value', './');
|
||||||
|
|
||||||
|
pui := TProjectUnitInfo.Create;
|
||||||
|
try
|
||||||
|
// Get first name
|
||||||
|
curUnitName := Copy(UnitNameList, 0, Pos(UnitNameList, '|') - 1);
|
||||||
|
workUnitList := Copy(UnitNameList, Pos(UnitNameList, '|') - 1, Length(UnitNameList));
|
||||||
|
|
||||||
|
// Make sure we have a starting unit
|
||||||
|
if (curUnitName <> '') then
|
||||||
|
begin
|
||||||
|
// Get all the info for each unit
|
||||||
|
while (curUnitName <> '') do
|
||||||
|
begin
|
||||||
|
pui.UnitName := xmlcfg.GetValue('ProjectOptions/UnitInfo/' + curUnitName + '/UnitName/Value', '');
|
||||||
|
pui.Filename := xmlcfg.GetValue('ProjectOptions/UnitInfo/' + curUnitName + '/Filename/Value', '');
|
||||||
|
pui.CursorPos := xmlcfg.GetValue('ProjectOptions/UnitInfo/' + curUnitName + '/CursorPos/Value', 0);
|
||||||
|
pui.AutoCreate := xmlcfg.GetValue('ProjectOptions/UnitInfo/' + curUnitName + '/AutoCreate/Value', true);
|
||||||
|
pui.ReadOnly := xmlcfg.GetValue('ProjectOptions/UnitInfo/' + curUnitName + '/ReadOnly/Value', false);
|
||||||
|
pui.SyntaxHighlighter := xmlcfg.GetValue('ProjectOptions/UnitInfo/' + curUnitName + '/SyntaxHighlighter/Value', 'freepascal');
|
||||||
|
|
||||||
|
{ TODO:
|
||||||
|
Depending on how Bookmarks and Breakpoints work, save them out. They are setup as a TList.
|
||||||
|
This may change if they are done in some other manner. Need to uncomment them and implement
|
||||||
|
them once this it is known how they are going to work (depends on editor being used).
|
||||||
|
}
|
||||||
|
// pui.Bookmarks := xmlcfg.GetValue('ProjectOptions/UnitInfo/' + curUnitName + '/Bookmarks/Value', '');
|
||||||
|
// pui.Breakpoints := xmlcfg.GetValue('ProjectOptions/UnitInfo/' + curUnitName + '/Breakpoints/Value', '');
|
||||||
|
|
||||||
|
// Add the unit to the project
|
||||||
|
AddUnit(pui);
|
||||||
|
|
||||||
|
// Get the next unit name
|
||||||
|
curUnitName := Copy(workUnitList, 0, Pos(workUnitList, '|') - 1);
|
||||||
|
workUnitList := Copy(workUnitList, Pos(workUnitList, '|') - 1, Length(workUnitList));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
pui.free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// Load the compiler options
|
||||||
|
CompilerOptions.XMLConfigFile := xmlcfg;
|
||||||
|
CompilerOptions.ProjectFile := confPath;
|
||||||
|
CompilerOptions.LoadCompilerOptions(true);
|
||||||
|
finally
|
||||||
|
xmlcfg.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Assert(False, 'Trace:For loop : ViewCount = '+Inttostr(ViewCount));
|
Result := true;
|
||||||
|
end;
|
||||||
|
|
||||||
for i := 0 to ViewCount - 1 do
|
{------------------------------------------------------------------------------
|
||||||
|
TProject AddUnit
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TProject.AddUnit(AUnit: TProjectUnitInfo);
|
||||||
|
begin
|
||||||
|
if (AUnit <> nil) then UnitList.Add(AUnit);
|
||||||
|
{ TODO:
|
||||||
|
Add the unit to the .lpr file.
|
||||||
|
Add an AutoCreate method call to the .lpr file for the unit.
|
||||||
|
}
|
||||||
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
TProject RemoveUnit
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TProject.RemoveUnit(AUnitName: String);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
if (AUnitName <> '') then
|
||||||
begin
|
begin
|
||||||
// TempEditor := ideEditor1.GetEditorfromPage(i);
|
for i := 0 to fUnitList.Count - 1 do
|
||||||
tempEditor.CaretX := INIFIle.ReadInteger('View'+inttostr(i),'CursorX',0);
|
begin
|
||||||
tempEditor.CaretY := INIFIle.ReadInteger('View'+inttostr(i),'CursorY',0);
|
if (TProjectUnitInfo(UnitList.Items[i]).UnitName = AUnitName) then
|
||||||
tempEditor.TopLine := INIFIle.ReadInteger('View'+inttostr(i),'TopLine',0);
|
UnitList.Remove(UnitList.Items[i]);
|
||||||
tempEditor.LeftChar := INIFIle.ReadInteger('View'+inttostr(i),'LeftCol',0);
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
MainIDE.Visible := (INIFile.ReadInteger('Main Window','Visible',1) = 1);
|
{ TODO:
|
||||||
MainIDE.Left := INIFile.ReadInteger('Main Window','Left',0);
|
Remove the unit from the .lpr file.
|
||||||
MainIDE.Top := INIFile.ReadInteger('Main Window','Top',0);
|
Remove the AutoCreate method call from the .lpr file for the unit.
|
||||||
MainIDE.Height := INIFile.ReadInteger('Main Window','Height',100);
|
}
|
||||||
MainIDE.Width := INIFile.ReadInteger('Main Window','Width',800);
|
|
||||||
|
|
||||||
Messagedlg.Visible := (INIFile.ReadInteger('Message WIndow','Visible',1) = 1);
|
|
||||||
Messagedlg.Left := INIFile.ReadInteger('Message Window','Left',0);
|
|
||||||
Messagedlg.Top := INIFile.ReadInteger('Message Window','Top',0);
|
|
||||||
Messagedlg.Width := InIfile.ReadInteger('Message Window','Width',(Screen.Width div 2));
|
|
||||||
Messagedlg.Height := INIFile.ReadInteger('Message Window','Height',100);
|
|
||||||
|
|
||||||
INiFile.Free;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------
|
||||||
procedure TProject.AddUnit(AUnit: TUnitInfo);
|
TProject GetUnitList
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function TProject.GetUnitList: TList;
|
||||||
begin
|
begin
|
||||||
if (AUnit <> nil) then FUnits.Add(AUnit);
|
Result := fUnitList;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------
|
||||||
function TProject.GetUnits: TList;
|
TProject SetUnitList
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TProject.SetUnitList(AList: TList);
|
||||||
begin
|
begin
|
||||||
Result := FUnits;
|
fUnitList := AList;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------
|
||||||
procedure TProject.AddLibraryPath(const LibPath: String);
|
TProject GetXMLConfigPath
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function TProject.GetXMLConfigPath: String;
|
||||||
|
var
|
||||||
|
confPath: String;
|
||||||
begin
|
begin
|
||||||
FLibrary.Add(LibPath);
|
Result := '';
|
||||||
|
|
||||||
|
if (ProjectInfoFile = '') then exit;
|
||||||
|
|
||||||
|
confPath := GetPrimaryConfigPath + '/' + ProjectInfoFile;
|
||||||
|
|
||||||
|
// See if config path exists and if not create it
|
||||||
|
if (not DirectoryExists(GetPrimaryConfigPath)) then
|
||||||
|
begin
|
||||||
|
try
|
||||||
|
// Create the directory
|
||||||
|
CreatePrimaryConfigPath;
|
||||||
|
|
||||||
|
{ TODO:
|
||||||
|
Try to read the configuration from the current path
|
||||||
|
If successful, then read it in and write it to the primary path
|
||||||
|
If unsuccessful, then just use defaults
|
||||||
|
}
|
||||||
|
except
|
||||||
|
Assert(False, 'Trace:There was a problem creating the config directory. Using defaults.');
|
||||||
|
Assert(False, 'Trace:File = ' + GetPrimaryConfigPath);
|
||||||
|
confPath := './' + ProjectInfoFile;
|
||||||
|
Result := confPath;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Result := confPath;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------}
|
|
||||||
function TProject.GetLibraryPaths: TStrings;
|
|
||||||
begin
|
|
||||||
GetLibraryPaths := FLibrary;
|
|
||||||
end;
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.4 2001/01/29 05:42:41 lazarus
|
||||||
|
Created new TProjectUnitInfo class.
|
||||||
|
Created new TProject class. Saves to XML config file.
|
||||||
|
Moved compiler options to write to the project file. CAW
|
||||||
|
|
||||||
Revision 1.3 2001/01/04 20:33:53 lazarus
|
Revision 1.3 2001/01/04 20:33:53 lazarus
|
||||||
Moved lresources.
|
Moved lresources.
|
||||||
Moved CreateLFM to Main.pp
|
Moved CreateLFM to Main.pp
|
||||||
|
Loading…
Reference in New Issue
Block a user