mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 22:19:18 +02:00
IDE: add a "Simple Program" descriptor/template. Requested by Jeff Duntemann for his book "FreePascal From Square One"
git-svn-id: trunk@38632 -
This commit is contained in:
parent
3688f42e45
commit
5b6cb21f1c
@ -2172,9 +2172,6 @@ resourcestring
|
|||||||
dlgProjectOptions = 'Project Options';
|
dlgProjectOptions = 'Project Options';
|
||||||
dlgProjectOptionsFor = 'Options for Project: %s';
|
dlgProjectOptionsFor = 'Options for Project: %s';
|
||||||
dlgPOApplication = 'Application';
|
dlgPOApplication = 'Application';
|
||||||
lisApplicationAGraphicalLclFreepascalProgramTheProgra = 'Application%sA '
|
|
||||||
+'graphical LCL/Free Pascal program. The program source is automatically '
|
|
||||||
+'maintained by Lazarus.';
|
|
||||||
dlgPOFroms = 'Forms';
|
dlgPOFroms = 'Forms';
|
||||||
dlgPOMisc = 'Miscellaneous';
|
dlgPOMisc = 'Miscellaneous';
|
||||||
dlgPOI18n = 'i18n';
|
dlgPOI18n = 'i18n';
|
||||||
@ -4447,16 +4444,22 @@ resourcestring
|
|||||||
lisTabOrderConfirmSort = 'Sort tab orders of all child controls of "%s" by their positions?';
|
lisTabOrderConfirmSort = 'Sort tab orders of all child controls of "%s" by their positions?';
|
||||||
|
|
||||||
lisCustomProgram = 'Custom Program';
|
lisCustomProgram = 'Custom Program';
|
||||||
|
lisSimpleProgram = 'Simple Program';
|
||||||
lisProgram = 'Program';
|
lisProgram = 'Program';
|
||||||
lisConsoleApplication = 'Console application';
|
lisConsoleApplication = 'Console application';
|
||||||
|
lisApplicationAGraphicalLclFreepascalProgramTheProgra = 'Application%sA '
|
||||||
|
+'graphical LCL/Free Pascal program. The program source is automatically '
|
||||||
|
+'maintained by Lazarus.';
|
||||||
lisFreepascalProgramUsingTCustomApplicationToEasilyCh = 'Free Pascal program '
|
lisFreepascalProgramUsingTCustomApplicationToEasilyCh = 'Free Pascal program '
|
||||||
+'using TCustomApplication to easily check command line options, handling '
|
+'using TCustomApplication to easily check command line options, handling '
|
||||||
+'exceptions, etc. The program source is automatically maintained by Lazarus.';
|
+'exceptions, etc. The program source is automatically maintained by Lazarus.';
|
||||||
lisProgramAFreepascalProgramTheProgramFileIsAutomatic = 'Program%sA '
|
lisProgramAFreepascalSimpleProgram = 'Simple Program%sA most simple Free Pascal program.'+
|
||||||
+'Free Pascal program. The program source is automatically maintained by Lazarus.';
|
' The program source is automatically maintained by Lazarus.';
|
||||||
|
lisProgramAFreepascalProgramTheProgramFileIsAutomatic = 'Program%sA Free Pascal program.'+
|
||||||
|
' The program source is automatically maintained by Lazarus.';
|
||||||
lisCustomProgramAFreepascalProgram = 'Custom Program%sA Free Pascal program.';
|
lisCustomProgramAFreepascalProgram = 'Custom Program%sA Free Pascal program.';
|
||||||
lisLibraryAFreepascalLibraryDllUnderWindowsSoUnderLin = 'Library%sA '
|
lisLibraryAFreepascalLibraryDllUnderWindowsSoUnderLin = 'Library%s'
|
||||||
+'Free Pascal library (.dll under Windows, .so under Linux, .dylib under '
|
+'A Free Pascal library (.dll under Windows, .so under Linux, .dylib under '
|
||||||
+'MacOS X). The library source is automatically maintained by Lazarus.';
|
+'MacOS X). The library source is automatically maintained by Lazarus.';
|
||||||
lisNPSelectAProjectType = 'Select a project type';
|
lisNPSelectAProjectType = 'Select a project type';
|
||||||
lisNPCreateANewProject = 'Create a new project';
|
lisNPCreateANewProject = 'Create a new project';
|
||||||
|
@ -2504,6 +2504,7 @@ begin
|
|||||||
// project descriptors
|
// project descriptors
|
||||||
LazProjectDescriptors:=TLazProjectDescriptors.Create;
|
LazProjectDescriptors:=TLazProjectDescriptors.Create;
|
||||||
RegisterProjectDescriptor(TProjectApplicationDescriptor.Create);
|
RegisterProjectDescriptor(TProjectApplicationDescriptor.Create);
|
||||||
|
RegisterProjectDescriptor(TProjectSimpleProgramDescriptor.Create);
|
||||||
RegisterProjectDescriptor(TProjectProgramDescriptor.Create);
|
RegisterProjectDescriptor(TProjectProgramDescriptor.Create);
|
||||||
RegisterProjectDescriptor(TProjectConsoleApplicationDescriptor.Create);
|
RegisterProjectDescriptor(TProjectConsoleApplicationDescriptor.Create);
|
||||||
RegisterProjectDescriptor(TProjectLibraryDescriptor.Create);
|
RegisterProjectDescriptor(TProjectLibraryDescriptor.Create);
|
||||||
|
@ -321,6 +321,17 @@ type
|
|||||||
function CreateStartFiles({%H-}AProject: TLazProject): TModalResult; override;
|
function CreateStartFiles({%H-}AProject: TLazProject): TModalResult; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TProjectSimpleProgramDescriptor }
|
||||||
|
|
||||||
|
TProjectSimpleProgramDescriptor = class(TProjectDescriptor)
|
||||||
|
public
|
||||||
|
constructor Create; override;
|
||||||
|
function GetLocalizedName: string; override;
|
||||||
|
function GetLocalizedDescription: string; override;
|
||||||
|
function InitProject(AProject: TLazProject): TModalResult; override;
|
||||||
|
function CreateStartFiles(AProject: TLazProject): TModalResult; override;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TProjectProgramDescriptor }
|
{ TProjectProgramDescriptor }
|
||||||
|
|
||||||
TProjectProgramDescriptor = class(TProjectDescriptor)
|
TProjectProgramDescriptor = class(TProjectDescriptor)
|
||||||
@ -1244,69 +1255,6 @@ begin
|
|||||||
Descriptor.Release;
|
Descriptor.Release;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TProjectProgramDescriptor }
|
|
||||||
|
|
||||||
constructor TProjectProgramDescriptor.Create;
|
|
||||||
begin
|
|
||||||
inherited Create;
|
|
||||||
Name:=ProjDescNameProgram;
|
|
||||||
Flags:=Flags-[pfMainUnitHasCreateFormStatements,pfMainUnitHasTitleStatement]
|
|
||||||
+[pfUseDefaultCompilerOptions];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TProjectProgramDescriptor.GetLocalizedName: string;
|
|
||||||
begin
|
|
||||||
Result:=lisProgram;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TProjectProgramDescriptor.GetLocalizedDescription: string;
|
|
||||||
begin
|
|
||||||
Result:=Format(lisProgramAFreepascalProgramTheProgramFileIsAutomatic, [#13]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TProjectProgramDescriptor.InitProject(AProject: TLazProject
|
|
||||||
): TModalResult;
|
|
||||||
var
|
|
||||||
le: String;
|
|
||||||
NewSource: String;
|
|
||||||
MainFile: TLazProjectFile;
|
|
||||||
begin
|
|
||||||
Result:=inherited InitProject(AProject);
|
|
||||||
|
|
||||||
MainFile:=AProject.CreateProjectFile('project1.lpr');
|
|
||||||
MainFile.IsPartOfProject:=true;
|
|
||||||
AProject.AddFile(MainFile,false);
|
|
||||||
AProject.MainFileID:=0;
|
|
||||||
|
|
||||||
// create program source
|
|
||||||
le:=LineEnding;
|
|
||||||
NewSource:='program Project1;'+le
|
|
||||||
+le
|
|
||||||
+'{$mode objfpc}{$H+}'+le
|
|
||||||
+le
|
|
||||||
+'uses'+le
|
|
||||||
+' {$IFDEF UNIX}{$IFDEF UseCThreads}'+le
|
|
||||||
+' cthreads,'+le
|
|
||||||
+' {$ENDIF}{$ENDIF}'+le
|
|
||||||
+' Classes'+le
|
|
||||||
+' { you can add units after this };'+le
|
|
||||||
+le
|
|
||||||
+'begin'+le
|
|
||||||
+'end.'+le
|
|
||||||
+le;
|
|
||||||
AProject.MainFile.SetSourceText(NewSource);
|
|
||||||
|
|
||||||
AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
|
|
||||||
AProject.LazCompilerOptions.TargetFilename:='project1';
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TProjectProgramDescriptor.CreateStartFiles(AProject: TLazProject
|
|
||||||
): TModalResult;
|
|
||||||
begin
|
|
||||||
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
|
|
||||||
[ofProjectLoading,ofRegularFile]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TProjectApplicationDescriptor }
|
{ TProjectApplicationDescriptor }
|
||||||
|
|
||||||
constructor TProjectApplicationDescriptor.Create;
|
constructor TProjectApplicationDescriptor.Create;
|
||||||
@ -1379,6 +1327,119 @@ begin
|
|||||||
[nfIsPartOfProject,nfOpenInEditor,nfCreateDefaultSrc]);
|
[nfIsPartOfProject,nfOpenInEditor,nfCreateDefaultSrc]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TProjectSimpleProgramDescriptor }
|
||||||
|
|
||||||
|
constructor TProjectSimpleProgramDescriptor.Create;
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
Name:=ProjDescNameSimpleProgram;
|
||||||
|
Flags:=Flags-[pfMainUnitHasCreateFormStatements,pfMainUnitHasTitleStatement]
|
||||||
|
+[pfUseDefaultCompilerOptions];
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProjectSimpleProgramDescriptor.GetLocalizedName: string;
|
||||||
|
begin
|
||||||
|
Result:=lisSimpleProgram;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProjectSimpleProgramDescriptor.GetLocalizedDescription: string;
|
||||||
|
begin
|
||||||
|
Result:=Format(lisProgramAFreepascalSimpleProgram, [#13]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProjectSimpleProgramDescriptor.InitProject(AProject: TLazProject): TModalResult;
|
||||||
|
var
|
||||||
|
le: String;
|
||||||
|
NewSource: String;
|
||||||
|
MainFile: TLazProjectFile;
|
||||||
|
begin
|
||||||
|
Result:=inherited InitProject(AProject);
|
||||||
|
|
||||||
|
MainFile:=AProject.CreateProjectFile('project1.lpr');
|
||||||
|
MainFile.IsPartOfProject:=true;
|
||||||
|
AProject.AddFile(MainFile,false);
|
||||||
|
AProject.MainFileID:=0;
|
||||||
|
|
||||||
|
// create program source
|
||||||
|
le:=LineEnding;
|
||||||
|
NewSource:='program Project1;'+le
|
||||||
|
+le
|
||||||
|
+'begin'+le
|
||||||
|
+'end.'+le
|
||||||
|
+le;
|
||||||
|
AProject.MainFile.SetSourceText(NewSource);
|
||||||
|
|
||||||
|
AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
|
||||||
|
AProject.LazCompilerOptions.TargetFilename:='project1';
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProjectSimpleProgramDescriptor.CreateStartFiles(AProject: TLazProject): TModalResult;
|
||||||
|
begin
|
||||||
|
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
|
||||||
|
[ofProjectLoading,ofRegularFile]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TProjectProgramDescriptor }
|
||||||
|
|
||||||
|
constructor TProjectProgramDescriptor.Create;
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
Name:=ProjDescNameProgram;
|
||||||
|
Flags:=Flags-[pfMainUnitHasCreateFormStatements,pfMainUnitHasTitleStatement]
|
||||||
|
+[pfUseDefaultCompilerOptions];
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProjectProgramDescriptor.GetLocalizedName: string;
|
||||||
|
begin
|
||||||
|
Result:=lisProgram;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProjectProgramDescriptor.GetLocalizedDescription: string;
|
||||||
|
begin
|
||||||
|
Result:=Format(lisProgramAFreepascalProgramTheProgramFileIsAutomatic, [#13]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProjectProgramDescriptor.InitProject(AProject: TLazProject): TModalResult;
|
||||||
|
var
|
||||||
|
le: String;
|
||||||
|
NewSource: String;
|
||||||
|
MainFile: TLazProjectFile;
|
||||||
|
begin
|
||||||
|
Result:=inherited InitProject(AProject);
|
||||||
|
|
||||||
|
MainFile:=AProject.CreateProjectFile('project1.lpr');
|
||||||
|
MainFile.IsPartOfProject:=true;
|
||||||
|
AProject.AddFile(MainFile,false);
|
||||||
|
AProject.MainFileID:=0;
|
||||||
|
|
||||||
|
// create program source
|
||||||
|
le:=LineEnding;
|
||||||
|
NewSource:='program Project1;'+le
|
||||||
|
+le
|
||||||
|
+'{$mode objfpc}{$H+}'+le
|
||||||
|
+le
|
||||||
|
+'uses'+le
|
||||||
|
+' {$IFDEF UNIX}{$IFDEF UseCThreads}'+le
|
||||||
|
+' cthreads,'+le
|
||||||
|
+' {$ENDIF}{$ENDIF}'+le
|
||||||
|
+' Classes'+le
|
||||||
|
+' { you can add units after this };'+le
|
||||||
|
+le
|
||||||
|
+'begin'+le
|
||||||
|
+'end.'+le
|
||||||
|
+le;
|
||||||
|
AProject.MainFile.SetSourceText(NewSource);
|
||||||
|
|
||||||
|
AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
|
||||||
|
AProject.LazCompilerOptions.TargetFilename:='project1';
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProjectProgramDescriptor.CreateStartFiles(AProject: TLazProject): TModalResult;
|
||||||
|
begin
|
||||||
|
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
|
||||||
|
[ofProjectLoading,ofRegularFile]);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TProjectManualProgramDescriptor }
|
{ TProjectManualProgramDescriptor }
|
||||||
|
|
||||||
constructor TProjectManualProgramDescriptor.Create;
|
constructor TProjectManualProgramDescriptor.Create;
|
||||||
@ -1452,69 +1513,6 @@ begin
|
|||||||
FAddMainSource:=false;
|
FAddMainSource:=false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TProjectLibraryDescriptor }
|
|
||||||
|
|
||||||
constructor TProjectLibraryDescriptor.Create;
|
|
||||||
begin
|
|
||||||
inherited Create;
|
|
||||||
Name:=ProjDescNameLibrary;
|
|
||||||
Flags:=Flags-[pfMainUnitHasCreateFormStatements,pfMainUnitHasTitleStatement]
|
|
||||||
+[pfUseDefaultCompilerOptions];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TProjectLibraryDescriptor.GetLocalizedName: string;
|
|
||||||
begin
|
|
||||||
Result:=lisPckOptsLibrary;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TProjectLibraryDescriptor.GetLocalizedDescription: string;
|
|
||||||
begin
|
|
||||||
Result:= Format(lisLibraryAFreepascalLibraryDllUnderWindowsSoUnderLin, [#13]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TProjectLibraryDescriptor.InitProject(AProject: TLazProject
|
|
||||||
): TModalResult;
|
|
||||||
var
|
|
||||||
le: String;
|
|
||||||
NewSource: String;
|
|
||||||
MainFile: TLazProjectFile;
|
|
||||||
begin
|
|
||||||
Result:=inherited InitProject(AProject);
|
|
||||||
|
|
||||||
MainFile:=AProject.CreateProjectFile('project1.lpr');
|
|
||||||
MainFile.IsPartOfProject:=true;
|
|
||||||
AProject.AddFile(MainFile,false);
|
|
||||||
AProject.MainFileID:=0;
|
|
||||||
AProject.LazCompilerOptions.ExecutableType:=cetLibrary;
|
|
||||||
|
|
||||||
// create program source
|
|
||||||
le:=LineEnding;
|
|
||||||
NewSource:='library Project1;'+le
|
|
||||||
+le
|
|
||||||
+'{$mode objfpc}{$H+}'+le
|
|
||||||
+le
|
|
||||||
+'uses'+le
|
|
||||||
+' Classes'+le
|
|
||||||
+' { you can add units after this };'+le
|
|
||||||
+le
|
|
||||||
+'begin'+le
|
|
||||||
+'end.'+le
|
|
||||||
+le;
|
|
||||||
AProject.MainFile.SetSourceText(NewSource);
|
|
||||||
|
|
||||||
AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
|
|
||||||
AProject.LazCompilerOptions.TargetFilename:='project1';
|
|
||||||
AProject.LazCompilerOptions.Win32GraphicApp:=false;
|
|
||||||
AProject.LazCompilerOptions.RelocatableUnit:=true;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TProjectLibraryDescriptor.CreateStartFiles(AProject: TLazProject
|
|
||||||
): TModalResult;
|
|
||||||
begin
|
|
||||||
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
|
|
||||||
[ofProjectLoading,ofRegularFile]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TProjectConsoleApplicationDescriptor }
|
{ TProjectConsoleApplicationDescriptor }
|
||||||
|
|
||||||
constructor TProjectConsoleApplicationDescriptor.Create;
|
constructor TProjectConsoleApplicationDescriptor.Create;
|
||||||
@ -1685,6 +1683,69 @@ begin
|
|||||||
[ofProjectLoading,ofRegularFile]);
|
[ofProjectLoading,ofRegularFile]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TProjectLibraryDescriptor }
|
||||||
|
|
||||||
|
constructor TProjectLibraryDescriptor.Create;
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
Name:=ProjDescNameLibrary;
|
||||||
|
Flags:=Flags-[pfMainUnitHasCreateFormStatements,pfMainUnitHasTitleStatement]
|
||||||
|
+[pfUseDefaultCompilerOptions];
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProjectLibraryDescriptor.GetLocalizedName: string;
|
||||||
|
begin
|
||||||
|
Result:=lisPckOptsLibrary;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProjectLibraryDescriptor.GetLocalizedDescription: string;
|
||||||
|
begin
|
||||||
|
Result:= Format(lisLibraryAFreepascalLibraryDllUnderWindowsSoUnderLin, [#13]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProjectLibraryDescriptor.InitProject(AProject: TLazProject
|
||||||
|
): TModalResult;
|
||||||
|
var
|
||||||
|
le: String;
|
||||||
|
NewSource: String;
|
||||||
|
MainFile: TLazProjectFile;
|
||||||
|
begin
|
||||||
|
Result:=inherited InitProject(AProject);
|
||||||
|
|
||||||
|
MainFile:=AProject.CreateProjectFile('project1.lpr');
|
||||||
|
MainFile.IsPartOfProject:=true;
|
||||||
|
AProject.AddFile(MainFile,false);
|
||||||
|
AProject.MainFileID:=0;
|
||||||
|
AProject.LazCompilerOptions.ExecutableType:=cetLibrary;
|
||||||
|
|
||||||
|
// create program source
|
||||||
|
le:=LineEnding;
|
||||||
|
NewSource:='library Project1;'+le
|
||||||
|
+le
|
||||||
|
+'{$mode objfpc}{$H+}'+le
|
||||||
|
+le
|
||||||
|
+'uses'+le
|
||||||
|
+' Classes'+le
|
||||||
|
+' { you can add units after this };'+le
|
||||||
|
+le
|
||||||
|
+'begin'+le
|
||||||
|
+'end.'+le
|
||||||
|
+le;
|
||||||
|
AProject.MainFile.SetSourceText(NewSource);
|
||||||
|
|
||||||
|
AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
|
||||||
|
AProject.LazCompilerOptions.TargetFilename:='project1';
|
||||||
|
AProject.LazCompilerOptions.Win32GraphicApp:=false;
|
||||||
|
AProject.LazCompilerOptions.RelocatableUnit:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProjectLibraryDescriptor.CreateStartFiles(AProject: TLazProject
|
||||||
|
): TModalResult;
|
||||||
|
begin
|
||||||
|
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
|
||||||
|
[ofProjectLoading,ofRegularFile]);
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
LazProjectFileDescriptors:=nil;
|
LazProjectFileDescriptors:=nil;
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ const
|
|||||||
|
|
||||||
ProjDescGroupName = 'Project';
|
ProjDescGroupName = 'Project';
|
||||||
ProjDescNameApplication = 'Application';
|
ProjDescNameApplication = 'Application';
|
||||||
|
ProjDescNameSimpleProgram = 'Simple Program';
|
||||||
ProjDescNameProgram = 'Program';
|
ProjDescNameProgram = 'Program';
|
||||||
ProjDescNameConsoleApplication = 'Console application';
|
ProjDescNameConsoleApplication = 'Console application';
|
||||||
ProjDescNameLibrary = 'Library';
|
ProjDescNameLibrary = 'Library';
|
||||||
|
Loading…
Reference in New Issue
Block a user