Made PRoject Build compile the active unit. This way we can actually play with it by compiling units.

git-svn-id: trunk@73 -
This commit is contained in:
lazarus 2000-12-20 20:04:30 +00:00
parent 90b0558cba
commit d7128b6823
4 changed files with 78 additions and 52 deletions

View File

@ -111,40 +111,6 @@ Begin
end; end;
{Function TDesigner.NewModuleSource(nmUnitName, nmForm, nmAncestor: String): Boolean;
Var
I : Integer;
Begin
FSource.Clear;
Result := True;
with FSource do
try
Add(Format('unit %s;', [nmUnitname]));
Add('');
Add('interface');
Add('');
Add('uses Classes, Graphics, Controls, Forms, Dialogs;');
Add('');
Add('type');
Add(Format(' T%s = class(T%s)', [nmForm,nmAncestor]));
Add(' private');
Add(' { private declarations}');
Add(' public');
Add(' { public declarations }');
Add(' end;');
Add('');
Add('var');
Add(Format(' %s: T%0:s;', [nmForm]));
Add('');
Add('implementation');
Add('');
Add('end.');
except
Result := False;
end;
end;
}
Procedure TDesigner.AddControlCode(Control : TComponent); Procedure TDesigner.AddControlCode(Control : TComponent);
Begin Begin

View File

@ -44,7 +44,7 @@ type
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
procedure Compile; procedure Compile(MainUnit : String);
function GetLineNumber(Value : String) : Integer; function GetLineNumber(Value : String) : Integer;
function GetColumnNumber(Value : String) : Integer; function GetColumnNumber(Value : String) : Integer;
function GetMessageType(Value : String) : TErrorType; function GetMessageType(Value : String) : TErrorType;
@ -78,7 +78,7 @@ end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TCompiler Compile } { TCompiler Compile }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
procedure TCompiler.Compile; procedure TCompiler.Compile(MainUnit : String);
const const
BufSize = 1024; BufSize = 1024;
var var
@ -91,12 +91,15 @@ var
TheProcess : TProcess; TheProcess : TProcess;
begin begin
Writeln('In Compile');
Texts := ''; Texts := '';
FOutputList.Clear; FOutputList.Clear;
TheProgram := CompilerOPts.CompilerPath; TheProgram := CompilerOPts.CompilerPath;
//TheProgram := TheProgram + ' -Ch'+inttostr(CompilerOpts.HeapSize); //TheProgram := TheProgram + ' -Ch'+inttostr(CompilerOpts.HeapSize);
TheProgram := TheProgram + ' '+ CompilerOpts.MakeOptionsString; TheProgram := TheProgram + ' '+ CompilerOpts.MakeOptionsString;
TheProgram := TheProgram + ' '+ TUnitInfo(Project1.UnitList[0]).Filename; TheProgram := TheProgram + ' '+ MainUnit;
Writeln('TheProgram = '+TheProgram);
Assert(False, 'Trace:' + TheProgram); Assert(False, 'Trace:' + TheProgram);
@ -233,6 +236,9 @@ end.
{ {
$Log$ $Log$
Revision 1.2 2000/12/20 20:04:30 lazarus
Made PRoject Build compile the active unit. This way we can actually play with it by compiling units.
Revision 1.1 2000/07/13 10:27:46 michael Revision 1.1 2000/07/13 10:27:46 michael
+ Initial import + Initial import

View File

@ -662,6 +662,7 @@ begin
itmFileSaveAs.OnClick := @SourceNotebook.SaveAsClicked; itmFileSaveAs.OnClick := @SourceNotebook.SaveAsClicked;
itmFileSaveAll.OnClick := @SourceNotebook.SaveAllClicked; itmFileSaveAll.OnClick := @SourceNotebook.SaveAllClicked;
itmFileClose.OnClick := @SourceNotebook.CloseClicked; itmFileClose.OnClick := @SourceNotebook.CloseClicked;
itmFileNew.OnClick := @SourceNotebook.NewClicked;
itmFileOpen.OnClick := @SourceNotebook.OpenClicked; itmFileOpen.OnClick := @SourceNotebook.OpenClicked;
SpeedButton4.OnClick := @SourceNotebook.OpenClicked; SpeedButton4.OnClick := @SourceNotebook.OpenClicked;
SpeedButton5.OnClick := @SourceNotebook.SaveClicked; SpeedButton5.OnClick := @SourceNotebook.SaveClicked;
@ -1549,6 +1550,22 @@ end;
Procedure TForm1.mnuBuildProjectClicked(Sender : TObject); Procedure TForm1.mnuBuildProjectClicked(Sender : TObject);
Begin Begin
//for now just compile the active unit;
SourceNotebook.SaveClicked(Sender);
if not(MessageDlg.Visible) then
Begin //display the dialog under the TSourceNotebook
MessageDlg.Show;
MessageDlg.Top := Screen.Height - 150;
MessageDlg.Height := 150;
{ if (SourceNotebook.Top+SourceNotebook.Height) > MEssageDlg.Top then
SourceNotebook.Height := SourceNotebook.Height - (ABS(MessageDlg.Top - (SourceNotebook.Top+SourceNotebook.Height)));
}
MessageDlg.Left := SourceNotebook.Left;
MessageDlg.Width := SourceNotebook.Width;
end;
MessageDlg.Clear;
Compiler1.Compile(SourceNotebook.ActiveUnitName);
end; end;
@ -1711,9 +1728,8 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.21 2000/12/20 17:35:58 lazarus Revision 1.22 2000/12/20 20:04:30 lazarus
Added GetChildren Made PRoject Build compile the active unit. This way we can actually play with it by compiling units.
Shane
Revision 1.19 2000/12/19 18:43:12 lazarus Revision 1.19 2000/12/19 18:43:12 lazarus
Removed IDEEDITOR. This causes the PROJECT class to not function. Removed IDEEDITOR. This causes the PROJECT class to not function.

View File

@ -87,6 +87,7 @@ type
Procedure SelectText(LineNum,CharStart,LineNum2,CharEnd : Integer); Procedure SelectText(LineNum,CharStart,LineNum2,CharEnd : Integer);
Procedure KeyPressed(Sender : TObject; var key: char); Procedure KeyPressed(Sender : TObject; var key: char);
Procedure CreateFormUnit(AForm : TCustomForm); Procedure CreateFormUnit(AForm : TCustomForm);
Procedure CreateNewUnit;
Function Close : Boolean; Function Close : Boolean;
Function Save : Boolean; Function Save : Boolean;
Function Open : Boolean; Function Open : Boolean;
@ -120,17 +121,18 @@ type
protected protected
Function CreateNotebook : Boolean; Function CreateNotebook : Boolean;
Function GetActiveSE : TSourceEditor; Function GetActiveSE : TSourceEditor;
Function ActiveUnitName : String;
Function ActiveFileName : String;
Function DisplayPage(SE : TSourceEditor) : Boolean; Function DisplayPage(SE : TSourceEditor) : Boolean;
Function NewSE(Pagenum : Integer) : TSourceEditor; Function NewSE(Pagenum : Integer) : TSourceEditor;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
Function ActiveUnitName : String;
Function ActiveFileName : String;
Procedure DisplayFormforActivePage; Procedure DisplayFormforActivePage;
Procedure DisplayCodeforControl(Control : TObject); Procedure DisplayCodeforControl(Control : TObject);
Function CreateUnitFromForm(AForm : TForm) : TSourceEditor; Function CreateUnitFromForm(AForm : TForm) : TSourceEditor;
procedure CloseClicked(Sender : TObject); procedure CloseClicked(Sender : TObject);
Procedure NewClicked(Sender: TObject);
procedure OpenClicked(Sender : TObject); procedure OpenClicked(Sender : TObject);
procedure SaveClicked(Sender : TObject); procedure SaveClicked(Sender : TObject);
procedure SaveAllClicked(Sender : TObject); procedure SaveAllClicked(Sender : TObject);
@ -215,6 +217,7 @@ begin
PI := _Control.ClassInfo; PI := _Control.ClassInfo;
nmControlType := PI^.Name; nmControlType := PI^.Name;
Ancestor := GetAncestor; Ancestor := GetAncestor;
//find the place in the code to add this now. //find the place in the code to add this now.
//Anyone have good method sfor parsing the source to find spots like this? //Anyone have good method sfor parsing the source to find spots like this?
//here I look for the Name of the customform, the word "Class", and it's ancestor on the same line //here I look for the Name of the customform, the word "Class", and it's ancestor on the same line
@ -248,7 +251,8 @@ end;
Procedure TSourceEditor.DisplayControl; Procedure TSourceEditor.DisplayControl;
Begin Begin
Writeln('DisplayCOntrol'); if FControl = nil then Exit;
if (FControl is TCustomForm) then TCustomForm(FControl).Show if (FControl is TCustomForm) then TCustomForm(FControl).Show
else else
if (FCOntrol is TControl) then TControl(FCOntrol).Visible := True; if (FCOntrol is TControl) then TControl(FCOntrol).Visible := True;
@ -256,9 +260,9 @@ if (FControl is TCustomForm) then TCustomForm(FControl).Show
//Bringtofront does not work yet. //Bringtofront does not work yet.
//TControl(FControl).BringToFront; //TControl(FControl).BringToFront;
//so I hide it and unhide it. //so I hide it and unhide it.
TCOntrol(FCOntrol).Visible :=False;
TCOntrol(FCOntrol).Visible := True; TControl(FCOntrol).Visible := False;
Writeln('Exit DisplayCOntrol'); TControl(FCOntrol).Visible := True;
end; end;
@ -370,6 +374,35 @@ Begin
tempSource.Free; tempSource.Free;
end; end;
Procedure TSourceEditor.CreateNewUnit;
Var
I : Integer;
TempSource : TStringList;
Begin
TempSource := TStringList.Create;
//figure out what the unit name should be...
FUnitName:='Unit1'; //just assigning it to this for now
with TempSource do
try
Add(Format('unit %s;', [FUnitName]));
Add('');
Add('interface');
Add('');
Add('implementation');
Add('');
Add('end.');
except
//raise an exception
end;
Source := TempSource;
tempSource.Free;
End;
Function TSourceEditor.Close : Boolean; Function TSourceEditor.Close : Boolean;
Begin Begin
Result := True; Result := True;
@ -616,22 +649,27 @@ Procedure TSourceNotebook.OpenClicked(Sender: TObject);
Var Var
TempEditor : TSourceEditor; TempEditor : TSourceEditor;
Begin Begin
Writeln('***********************OPENCLICKED');
FOpenDialog.Title := 'Open'; FOpenDialog.Title := 'Open';
Writeln('1');
if FOpenDialog.Execute then Begin if FOpenDialog.Execute then Begin
Writeln('2');
//create a new page //create a new page
TempEditor := NewSE(-1); TempEditor := NewSE(-1);
Writeln('3');
TempEditor.Filename := FOpenDialog.Filename; TempEditor.Filename := FOpenDialog.Filename;
TempEditor.OPen; TempEditor.OPen;
Notebook1.Pages.Strings[Notebook1.Pageindex] := TempEditor.UnitName; Notebook1.Pages.Strings[Notebook1.Pageindex] := TempEditor.UnitName;
Writeln('4');
end; end;
end; end;
Procedure TSourceNotebook.NewClicked(Sender: TObject);
Var
TempEditor : TSourceEditor;
Begin
//create a new page
TempEditor := NewSE(-1);
TempEditor.CreateNewUnit;
Notebook1.Pages.Strings[Notebook1.Pageindex] := TempEditor.UnitName;
End;
Procedure TSourceNotebook.SaveClicked(Sender: TObject); Procedure TSourceNotebook.SaveClicked(Sender: TObject);
Begin Begin
if ActiveFileName <> '' then if ActiveFileName <> '' then