mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 10:56:35 +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';
|
||||
dlgProjectOptionsFor = 'Options for Project: %s';
|
||||
dlgPOApplication = 'Application';
|
||||
lisApplicationAGraphicalLclFreepascalProgramTheProgra = 'Application%sA '
|
||||
+'graphical LCL/Free Pascal program. The program source is automatically '
|
||||
+'maintained by Lazarus.';
|
||||
dlgPOFroms = 'Forms';
|
||||
dlgPOMisc = 'Miscellaneous';
|
||||
dlgPOI18n = 'i18n';
|
||||
@ -4447,16 +4444,22 @@ resourcestring
|
||||
lisTabOrderConfirmSort = 'Sort tab orders of all child controls of "%s" by their positions?';
|
||||
|
||||
lisCustomProgram = 'Custom Program';
|
||||
lisSimpleProgram = 'Simple Program';
|
||||
lisProgram = 'Program';
|
||||
lisConsoleApplication = 'Console application';
|
||||
lisApplicationAGraphicalLclFreepascalProgramTheProgra = 'Application%sA '
|
||||
+'graphical LCL/Free Pascal program. The program source is automatically '
|
||||
+'maintained by Lazarus.';
|
||||
lisFreepascalProgramUsingTCustomApplicationToEasilyCh = 'Free Pascal program '
|
||||
+'using TCustomApplication to easily check command line options, handling '
|
||||
+'exceptions, etc. The program source is automatically maintained by Lazarus.';
|
||||
lisProgramAFreepascalProgramTheProgramFileIsAutomatic = 'Program%sA '
|
||||
+'Free Pascal program. The program source is automatically maintained by Lazarus.';
|
||||
lisProgramAFreepascalSimpleProgram = 'Simple Program%sA most simple Free Pascal program.'+
|
||||
' 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.';
|
||||
lisLibraryAFreepascalLibraryDllUnderWindowsSoUnderLin = 'Library%sA '
|
||||
+'Free Pascal library (.dll under Windows, .so under Linux, .dylib under '
|
||||
lisLibraryAFreepascalLibraryDllUnderWindowsSoUnderLin = 'Library%s'
|
||||
+'A Free Pascal library (.dll under Windows, .so under Linux, .dylib under '
|
||||
+'MacOS X). The library source is automatically maintained by Lazarus.';
|
||||
lisNPSelectAProjectType = 'Select a project type';
|
||||
lisNPCreateANewProject = 'Create a new project';
|
||||
|
@ -2504,6 +2504,7 @@ begin
|
||||
// project descriptors
|
||||
LazProjectDescriptors:=TLazProjectDescriptors.Create;
|
||||
RegisterProjectDescriptor(TProjectApplicationDescriptor.Create);
|
||||
RegisterProjectDescriptor(TProjectSimpleProgramDescriptor.Create);
|
||||
RegisterProjectDescriptor(TProjectProgramDescriptor.Create);
|
||||
RegisterProjectDescriptor(TProjectConsoleApplicationDescriptor.Create);
|
||||
RegisterProjectDescriptor(TProjectLibraryDescriptor.Create);
|
||||
|
@ -321,6 +321,17 @@ type
|
||||
function CreateStartFiles({%H-}AProject: TLazProject): TModalResult; override;
|
||||
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 = class(TProjectDescriptor)
|
||||
@ -1244,69 +1255,6 @@ begin
|
||||
Descriptor.Release;
|
||||
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 }
|
||||
|
||||
constructor TProjectApplicationDescriptor.Create;
|
||||
@ -1379,6 +1327,119 @@ begin
|
||||
[nfIsPartOfProject,nfOpenInEditor,nfCreateDefaultSrc]);
|
||||
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 }
|
||||
|
||||
constructor TProjectManualProgramDescriptor.Create;
|
||||
@ -1452,69 +1513,6 @@ begin
|
||||
FAddMainSource:=false;
|
||||
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 }
|
||||
|
||||
constructor TProjectConsoleApplicationDescriptor.Create;
|
||||
@ -1685,6 +1683,69 @@ begin
|
||||
[ofProjectLoading,ofRegularFile]);
|
||||
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
|
||||
LazProjectFileDescriptors:=nil;
|
||||
|
||||
|
@ -38,6 +38,7 @@ const
|
||||
|
||||
ProjDescGroupName = 'Project';
|
||||
ProjDescNameApplication = 'Application';
|
||||
ProjDescNameSimpleProgram = 'Simple Program';
|
||||
ProjDescNameProgram = 'Program';
|
||||
ProjDescNameConsoleApplication = 'Console application';
|
||||
ProjDescNameLibrary = 'Library';
|
||||
|
Loading…
Reference in New Issue
Block a user