1 | unit ULDModulePascal;
|
---|
2 |
|
---|
3 | {$mode delphi}{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, UModularSystem, USource, UProject;
|
---|
9 |
|
---|
10 | type
|
---|
11 | { TProjectTemplateConsoleApp }
|
---|
12 |
|
---|
13 | TProjectTemplateConsoleApp = class(TFileTemplate)
|
---|
14 | constructor Create; override;
|
---|
15 | function Execute: TSource; override;
|
---|
16 | end;
|
---|
17 |
|
---|
18 | { TProjectTemplateGUIApp }
|
---|
19 |
|
---|
20 | TProjectTemplateGUIApp = class(TFileTemplate)
|
---|
21 | constructor Create; override;
|
---|
22 | function Execute: TSource; override;
|
---|
23 | end;
|
---|
24 |
|
---|
25 | { TProjectTemplatePackage }
|
---|
26 |
|
---|
27 | TProjectTemplatePackage = class(TFileTemplate)
|
---|
28 | constructor Create; override;
|
---|
29 | function Execute: TSource; override;
|
---|
30 | end;
|
---|
31 |
|
---|
32 | { TProjectTemplateUnit }
|
---|
33 |
|
---|
34 | TProjectTemplateUnit = class(TFileTemplate)
|
---|
35 | constructor Create; override;
|
---|
36 | function Execute: TSource; override;
|
---|
37 | end;
|
---|
38 |
|
---|
39 | { TPascalSourceType }
|
---|
40 |
|
---|
41 | TPascalSourceType = class(TSourceType)
|
---|
42 | constructor Create; override;
|
---|
43 | end;
|
---|
44 |
|
---|
45 | { TLDModulePascal }
|
---|
46 |
|
---|
47 | TLDModulePascal = class(TModule)
|
---|
48 | private
|
---|
49 | PasFileType: TPascalSourceType;
|
---|
50 | ProjectTemplateConsoleApp: TProjectTemplateConsoleApp;
|
---|
51 | ProjectTemplateGUIApp: TProjectTemplateGUIApp;
|
---|
52 | ProjectTemplateUnit: TProjectTemplateUnit;
|
---|
53 | public
|
---|
54 | constructor Create(Owner: TComponent); override;
|
---|
55 | procedure Install; override;
|
---|
56 | procedure Uninstall; override;
|
---|
57 | end;
|
---|
58 |
|
---|
59 |
|
---|
60 | implementation
|
---|
61 |
|
---|
62 | uses
|
---|
63 | ULDStudioAPI, ULDModuleBasic;
|
---|
64 |
|
---|
65 | resourcestring
|
---|
66 | SPascal = 'Pascal';
|
---|
67 |
|
---|
68 | { TPascalSourceType }
|
---|
69 |
|
---|
70 | constructor TPascalSourceType.Create;
|
---|
71 | begin
|
---|
72 | inherited Create;
|
---|
73 | Extension := '.pas';
|
---|
74 | Title := 'Pascal source';
|
---|
75 | end;
|
---|
76 |
|
---|
77 | { TLDModulePascal }
|
---|
78 |
|
---|
79 | constructor TLDModulePascal.Create(Owner: TComponent);
|
---|
80 | begin
|
---|
81 | inherited;
|
---|
82 | Identification := 'Pascal';
|
---|
83 | Title := SPascal;
|
---|
84 | Version := '0.1';
|
---|
85 | License := 'GNU/LGPLv3';
|
---|
86 | end;
|
---|
87 |
|
---|
88 | procedure TLDModulePascal.Install;
|
---|
89 | begin
|
---|
90 | with TLDStudioAPI(API) do begin
|
---|
91 | PasFileType := TPascalSourceType.Create;
|
---|
92 | RegisterFileType(PasFileType);
|
---|
93 | ProjectTemplateConsoleApp := TProjectTemplateConsoleApp.Create;
|
---|
94 | RegisterFileTemplate(ProjectTemplateConsoleApp);
|
---|
95 | ProjectTemplateGUIApp := TProjectTemplateGUIApp.Create;
|
---|
96 | RegisterFileTemplate(ProjectTemplateGUIApp);
|
---|
97 | ProjectTemplateUnit := TProjectTemplateUnit.Create;
|
---|
98 | RegisterFileTemplate(ProjectTemplateUnit);
|
---|
99 | end;
|
---|
100 | inherited Install;
|
---|
101 | end;
|
---|
102 |
|
---|
103 | procedure TLDModulePascal.Uninstall;
|
---|
104 | begin
|
---|
105 | inherited Uninstall;
|
---|
106 | with TLDStudioAPI(API) do begin
|
---|
107 | RegisterFileTemplate(ProjectTemplateUnit);
|
---|
108 | FreeAndNil(ProjectTemplateUnit);
|
---|
109 | UnregisterFileTemplate(ProjectTemplateGUIApp);
|
---|
110 | FreeAndNil(ProjectTemplateGUIApp);
|
---|
111 | UnregisterFileTemplate(ProjectTemplateConsoleApp);
|
---|
112 | FreeAndNil(ProjectTemplateConsoleApp);
|
---|
113 | UnregisterFileType(PasFileType);
|
---|
114 | FreeAndNil(PasFileType);
|
---|
115 | end;
|
---|
116 | end;
|
---|
117 |
|
---|
118 | resourcestring
|
---|
119 | SConsoleApplication = 'Console application';
|
---|
120 | SUnit = 'Unit';
|
---|
121 | SPackage = 'Package';
|
---|
122 | SGUIApplication = 'GUI application';
|
---|
123 |
|
---|
124 | { TProjectTemplateUnit }
|
---|
125 |
|
---|
126 | constructor TProjectTemplateUnit.Create;
|
---|
127 | begin
|
---|
128 | inherited Create;
|
---|
129 | Name := SUnit;
|
---|
130 | //FileTypeClass := TSourceText;
|
---|
131 | end;
|
---|
132 |
|
---|
133 | function TProjectTemplateUnit.Execute: TSource;
|
---|
134 | var
|
---|
135 | NewFile: TSource;
|
---|
136 | begin
|
---|
137 | //inherited InitProject(Project);
|
---|
138 | Result := TSourceText.Create;
|
---|
139 | Result.Name := 'Unit1.pas';
|
---|
140 | with TSourceText(Result), Content do begin
|
---|
141 | Add('unit Unit1;');
|
---|
142 | Add('');
|
---|
143 | Add('interface');
|
---|
144 | Add('');
|
---|
145 | Add('implementation');
|
---|
146 | Add('');
|
---|
147 | Add('end.');
|
---|
148 | Loaded := True;
|
---|
149 | end;
|
---|
150 | end;
|
---|
151 |
|
---|
152 | { TProjectTemplatePackage }
|
---|
153 |
|
---|
154 | constructor TProjectTemplatePackage.Create;
|
---|
155 | begin
|
---|
156 | inherited Create;
|
---|
157 | Name := SPackage;
|
---|
158 | end;
|
---|
159 |
|
---|
160 | function TProjectTemplatePackage.Execute: TSource;
|
---|
161 | var
|
---|
162 | NewFile: TSourceText;
|
---|
163 | begin
|
---|
164 | { Result := TProject.Create;
|
---|
165 | Result.Name := 'Package1';
|
---|
166 | NewFile := TSourceText.Create;
|
---|
167 | NewFile.Name := 'Package1.bpl';
|
---|
168 | with NewFile.Content do begin
|
---|
169 | Add('package Package1;');
|
---|
170 | Add('');
|
---|
171 | Add('requires');
|
---|
172 | Add(' RTL;');
|
---|
173 | Add('');
|
---|
174 | Add('end.');
|
---|
175 | end;
|
---|
176 | TProject(Result).Files.Add();
|
---|
177 | TProject(Result).MainSource := NewFile;
|
---|
178 | }end;
|
---|
179 |
|
---|
180 | { TProjectTemplateGUIApp }
|
---|
181 |
|
---|
182 | constructor TProjectTemplateGUIApp.Create;
|
---|
183 | begin
|
---|
184 | inherited Create;
|
---|
185 | Name := SGUIApplication;
|
---|
186 | end;
|
---|
187 |
|
---|
188 | function TProjectTemplateGUIApp.Execute: TSource;
|
---|
189 | var
|
---|
190 | NewFile: TProjectFile;
|
---|
191 | begin
|
---|
192 | { inherited InitProject(Project);
|
---|
193 | NewFile := Project.Files.AddFile('Project1.dpr');
|
---|
194 | with NewFile.Source do begin
|
---|
195 | Add('program Project1;');
|
---|
196 | Add('');
|
---|
197 | Add('uses');
|
---|
198 | Add(' GUI;');
|
---|
199 | Add('');
|
---|
200 | Add('var');
|
---|
201 | Add(' Application: TApplication');
|
---|
202 | Add('begin');
|
---|
203 | Add(' Application := TApplication.Create;');
|
---|
204 | Add(' Application.Run;');
|
---|
205 | Add(' Application.Free;');
|
---|
206 | Add('end.');
|
---|
207 | end;
|
---|
208 | Project.MainSource := NewFile;
|
---|
209 | }end;
|
---|
210 |
|
---|
211 | { TProjectTemplateConsoleApp }
|
---|
212 |
|
---|
213 | constructor TProjectTemplateConsoleApp.Create;
|
---|
214 | begin
|
---|
215 | inherited Create;
|
---|
216 | Name := SConsoleApplication;
|
---|
217 | end;
|
---|
218 |
|
---|
219 | function TProjectTemplateConsoleApp.Execute: TSource;
|
---|
220 | var
|
---|
221 | NewFile: TProjectFile;
|
---|
222 | begin
|
---|
223 | { inherited InitProject(Project);
|
---|
224 | NewFile := Project.Files.AddFile('Project1.dpr');
|
---|
225 | with NewFile.Source do begin
|
---|
226 | Add('program Project1;');
|
---|
227 | Add('');
|
---|
228 | Add('begin');
|
---|
229 | Add('end.');
|
---|
230 | end;
|
---|
231 | Project.MainSource := NewFile;}
|
---|
232 | end;
|
---|
233 |
|
---|
234 |
|
---|
235 | end.
|
---|
236 |
|
---|