bugfixes for ide project code

git-svn-id: trunk@212 -
This commit is contained in:
lazarus 2001-03-05 14:24:52 +00:00
parent ab68959328
commit 45af56fc7b
4 changed files with 87 additions and 35 deletions

View File

@ -143,7 +143,7 @@ begin
while (EndPos<DirEnd) and (Directive[EndPos] in IdentifierChar) do
inc(EndPos);
DirectiveName:=lowercase(copy(Directive,DirStart,EndPos-DirStart));
Parameters:=copy(Directive,EndPos+1,DirEnd-EndPos+1);
Parameters:=copy(Directive,EndPos+1,DirEnd-EndPos-1);
Result:=true;
end else
Result:=false;

View File

@ -980,18 +980,33 @@ end;
{------------------------------------------------------------------------------}
Procedure TMainIDE.UpdateViewDialogs;
var a:integer;
var a,ProgramNameStart,ProgramNameEnd:integer;
s,SrcTxt:string;
Begin
ViewUnits1.Listbox1.Items.BeginUpdate;
ViewUnits1.Listbox1.Items.Clear;
ViewForms1.Listbox1.Items.BeginUpdate;
ViewForms1.Listbox1.Items.Clear;
// ViewForms1.Listbox1.Items.BeginUpdate;
// ViewForms1.Listbox1.Items.Clear;
for a:=0 to Project.UnitCount-1 do begin
ViewUnits1.Listbox1.Items.Add(Project.Units[a].Unitname);
// ToDo: forms
if Project.Units[a].IsPartOfProject then begin
if (Project.Units[a].Unitname<>'') then begin
ViewUnits1.Listbox1.Items.Add(Project.Units[a].Unitname);
// if Project.Units[a].FormName<>'' then
// ViewForms1.Listbox1.Items.Add(Project.Units[a].Unitname);
end else if (Project.MainUnit=a)
and (Project.ProjectType in [ptProgram,ptApplication]) then begin
s:=ExtractFilename(Project.Units[a].Filename);
if s='' then begin
SrcTxt:=Project.Units[a].Source.Text;
s:=FindProgramNameInSource(SrcTxt,ProgramNameStart,ProgramnameEnd);
end;
if s<>'' then
ViewUnits1.Listbox1.Items.Add(s);
end;
end;
end;
ViewUnits1.Listbox1.Items.EndUpdate;
ViewForms1.Listbox1.Items.EndUpdate;
// ViewForms1.Listbox1.Items.EndUpdate;
End;
{------------------------------------------------------------------------------}
@ -1004,7 +1019,7 @@ Begin
writeln('Toggle form clicked');
if FCodeLastActivated then
SourceNotebook.DisplayFormforActivePage
SourceNotebook.DisplayFormForActivePage
else
SourceNotebook.DisplayCodeforControl(FControlLastActivated);
end;
@ -1326,13 +1341,17 @@ end;
Procedure TMainIDE.mnuViewUnitsClicked(Sender : TObject);
Begin
Writeln('View Units Clicked');
UpdateViewDialogs;
ViewUnits1.ShowModal;
Writeln('Done with ViewUnits Clicked');
end;
Procedure TMainIDE.mnuViewFormsClicked(Sender : TObject);
Begin
Writeln('View Forms Clicked');
UpdateViewDialogs;
ViewForms1.ShowModal;
Writeln('Done with ViewForms Clicked');
end;
Procedure TMainIDE.mnuViewCodeExplorerClick(Sender : TObject);
@ -2172,23 +2191,25 @@ end;
function TMainIDE.DoCloseProject:TModalResult;
begin
writeln('TMainIDE.DoCloseProject');
writeln('TMainIDE.DoCloseProject 1');
// close all loaded files
while SourceNotebook.NoteBook<>nil do begin
Result:=DoCloseEditorUnit(SourceNotebook.Notebook.Pages.Count-1,false);
if Result=mrAbort then exit;
end;
writeln('TMainIDE.DoCloseProject 2');
// close Project
Project.Free;
Project:=nil;
Result:=mrOk;
writeln('TMainIDE.DoCloseProject end');
end;
function TMainIDE.DoOpenProjectFile(AFileName:string):TModalResult;
var Ext,AText,ACaption,LPIFilename:string;
LowestEditorIndex,LowestUnitIndex,LastEditorIndex,i:integer;
begin
writeln('TMainIDE.DoOpenProjectFile');
writeln('TMainIDE.DoOpenProjectFile 1');
Result:=mrCancel;
if AFileName='' then exit;
AFilename:=ExpandFileName(AFilename);
@ -2211,10 +2232,13 @@ writeln('TMainIDE.DoOpenProjectFile');
// close the old project
Result:=DoCloseProject;
if Result=mrAbort then exit;
writeln('TMainIDE.DoOpenProjectFile 2');
// create a new one
LPIFilename:=ChangeFileExt(AFilename,'.lpi');
Project:=TProject.Create(ptProgram);
writeln('TMainIDE.DoOpenProjectFile 3');
Project.ReadProject(LPIFilename);
writeln('TMainIDE.DoOpenProjectFile 4');
UpdateCaption;
// restore files
LastEditorIndex:=-1;
@ -2241,10 +2265,12 @@ writeln('TMainIDE.DoOpenProjectFile');
LastEditorIndex:=LowestEditorIndex;
end;
until LowestEditorIndex<0;
writeln('TMainIDE.DoOpenProjectFile 5');
// set active editor source editor
if (SourceNoteBook.NoteBook<>nil) and (Project.ActiveEditorIndexAtStart>=0)
and (Project.ActiveEditorIndexAtStart<SourceNoteBook.NoteBook.Pages.Count) then
SourceNoteBook.Notebook.PageIndex:=Project.ActiveEditorIndexAtStart;
writeln('TMainIDE.DoOpenProjectFile end');
end;
function TMainIDE.DoSaveAll: TModalResult;
@ -2420,6 +2446,9 @@ end.
{ =============================================================================
$Log$
Revision 1.69 2001/03/05 14:24:52 lazarus
bugfixes for ide project code
Revision 1.68 2001/03/03 11:06:15 lazarus
added project support, codetools

View File

@ -33,7 +33,7 @@ interface
uses
Classes, SysUtils, LCLLinux, XMLCfg, LazConf, CompilerOptions, FileCtrl,
CodeTools, Forms, Controls, EditorOptions;
CodeTools, Forms, Controls, EditorOptions, Dialogs;
type
//---------------------------------------------------------------------------
@ -212,7 +212,7 @@ type
IsPartOfProject:boolean):TModalResult;
function GetProjectInfoFile:string;
procedure SetProjectInfoFile(NewFilename:string);
procedure OnLoadSaveFilename(var Filename:string; Load:boolean);
procedure OnLoadSaveFilename(var AFilename:string; Load:boolean);
procedure OnUnitNameChange(AnUnitInfo: TUnitInfo;
OldUnitName, NewUnitName: string; var Allowed: boolean);
public
@ -245,7 +245,8 @@ type
property ActiveEditorIndexAtStart: integer
read fActiveEditorIndexAtStart write fActiveEditorIndexAtStart;
property Bookmarks: TProjectBookmarkList read fBookmarks write fBookmarks;
property CompilerOptions: TCompilerOptions read fCompilerOptions write fCompilerOptions;
property CompilerOptions: TCompilerOptions
read fCompilerOptions write fCompilerOptions;
property IconPath: String read fIconPath write fIconPath;
property MainUnit: Integer // the MainUnit is the unit index of the program file
read fMainUnit write fMainUnit;
@ -257,7 +258,8 @@ type
property ProjectType: TProjectType read fProjectType write fProjectType;
property TargetFileExt: String read fTargetFileExt write fTargetFileExt;
property Title: String read fTitle write fTitle;
property UnitOutputDirectory: String read fUnitOutputDirectory write fUnitOutputDirectory;
property UnitOutputDirectory: String
read fUnitOutputDirectory write fUnitOutputDirectory;
end;
const
@ -627,6 +629,7 @@ begin
AFilename:=XMLConfig.GetValue(Path+'Filename/Value','');
if Assigned(fOnLoadSaveFilename) then
fOnLoadSaveFilename(AFilename,true);
writeln('TUnitInfo.LoadFromXMLConfig ',AFilename);
fFilename:=AFilename;
fFormName:=XMLConfig.GetValue(Path+'FormName/Value','');
HasResources:=XMLConfig.GetValue(Path+'HasResources/Value',false);
@ -873,12 +876,22 @@ var
NewUnitInfo: TUnitInfo;
NewUnitCount,i: integer;
begin
writeln('TProject.ReadProject 1');
Result := mrCancel;
Clear;
ProjectInfoFile:=LPIFilename;
xmlcfg := TXMLConfig.Create(ProjectInfoFile);
writeln('TProject.ReadProject 2 ',LPIFilename);
try
xmlcfg := TXMLConfig.Create(ProjectInfoFile);
except
MessageDlg('Unable to read the project info file "'+ProjectInfoFile+'".'
,mtError,[mbOk],0);
Result:=mrCancel;
exit;
end;
writeln('TProject.ReadProject 3');
try
MainUnit := xmlcfg.GetValue('ProjectOptions/General/MainUnit/Value', -1);
ActiveEditorIndexAtStart := xmlcfg.GetValue(
@ -893,25 +906,29 @@ begin
'ProjectOptions/General/UnitOutputDirectory/Value', '.');
fBookmarks.LoadFromXMLConfig(xmlcfg,'ProjectOptions/');
writeln('TProject.ReadProject 4');
NewUnitCount:=xmlcfg.GetValue('ProjectOptions/Units/Count',0);
for i := 0 to NewUnitCount - 1 do begin
NewUnitInfo:=TUnitInfo.Create;
AddUnit(NewUnitInfo,false);
NewUnitInfo.LoadFromXMLConfig(
xmlcfg,'ProjectOptions/Units/Unit'+IntToStr(i)+'/');
AddUnit(NewUnitInfo,false);
end;
writeln('TProject.ReadProject 5');
// Load the compiler options
CompilerOptions.XMLConfigFile := xmlcfg;
CompilerOptions.ProjectFile := ProjectFile;
CompilerOptions.LoadCompilerOptions(true);
writeln('TProject.ReadProject 6');
finally
xmlcfg.Free;
xmlcfg:=nil;
end;
Result := mrOk;
writeln('TProject.ReadProject end');
end;
{------------------------------------------------------------------------------
@ -1250,10 +1267,12 @@ begin
// change programname in source
NewProgramName:=ExtractFilename(NewProjectFilename);
NewProgramName:=copy(NewProgramName,1,length(NewProgramName)-length(Ext));
SrcTxt:=Units[MainUnit].Source.Text;
SrcChanged:=RenameProgramInSource(SrcTxt,NewProgramName);
if SrcChanged then
Units[MainUnit].Source.Text:=SrcTxt;
if MainUnit>=0 then begin
SrcTxt:=Units[MainUnit].Source.Text;
SrcChanged:=RenameProgramInSource(SrcTxt,NewProgramName);
if SrcChanged then
Units[MainUnit].Source.Text:=SrcTxt;
end;
end;
if MainUnit>=0 then begin
Units[MainUnit].Filename:=ChangeFileExt(NewProjectFilename
@ -1286,17 +1305,17 @@ begin
ProjectFile:=NewFilename;
end;
procedure TProject.OnLoadSaveFilename(var Filename:string; Load:boolean);
procedure TProject.OnLoadSaveFilename(var AFilename:string; Load:boolean);
function FilenameIsAbsolute(AFilename: string):boolean;
function FilenameIsAbsolute(TheFilename: string):boolean;
begin
DoDirSeparators(AFilename);
DoDirSeparators(TheFilename);
{$IFDEF linux}
Result:=(AFilename='') or (AFilename[1]='/');
Result:=(TheFilename='') or (TheFilename[1]='/');
{$ELSE}
// windows
Result:=(length(AFilename)<3) or (copy(AFilename,1,2)='\\')
or ((upcase(AFilename[1]) in ['A'..'Z']) and (copy(AFilename,2,2)=':\');
Result:=(length(TheFilename)<3) or (copy(TheFilename,1,2)='\\')
or ((upcase(TheFilename[1]) in ['A'..'Z']) and (copy(TheFilename,2,2)=':\');
{$ENDIF}
end;
@ -1304,17 +1323,18 @@ procedure TProject.OnLoadSaveFilename(var Filename:string; Load:boolean);
var ProjectPath:string;
begin
ProjectPath:=ExtractFilePath(ProjectFile);
DoDirSeparators(Filename);
if ProjectPath='' then ProjectPath:=GetCurrentDir;
DoDirSeparators(AFilename);
if Load then begin
// make filename absolute
if not FilenameIsAbsolute(Filename) then
Filename:=ProjectPath+Filename;
if not FilenameIsAbsolute(AFilename) then
AFilename:=ProjectPath+AFilename;
end else begin
// try making filename relative to project file
if FilenameIsAbsolute(Filename)
and (copy(Filename,1,length(ProjectPath))=ProjectPath) then
Filename:=copy(Filename,length(ProjectPath)+1,
length(Filename)-length(ProjectPath));
if FilenameIsAbsolute(AFilename)
and (copy(AFilename,1,length(ProjectPath))=ProjectPath) then
AFilename:=copy(AFilename,length(ProjectPath)+1,
length(AFilename)-length(ProjectPath));
end;
end;
@ -1348,6 +1368,9 @@ end.
{
$Log$
Revision 1.11 2001/03/05 14:24:52 lazarus
bugfixes for ide project code
Revision 1.10 2001/03/03 11:06:15 lazarus
added project support, codetools

View File

@ -2066,7 +2066,7 @@ begin
Result := nil;
if (FSourceEditorList=nil)
or (Notebook=nil)
or (PageIndex<0) or (PageIndex>Notebook.Pages.Count) then exit;
or (PageIndex<0) or (PageIndex>=Notebook.Pages.Count) then exit;
TempEditor:=nil;
with Notebook.Page[PageIndex] do
for I := 0 to ControlCount-1 do