3
3
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
4
4
* obtain one at https://mozilla.org/MPL/2.0/
5
5
*
6
- * Copyright (C) 2005-2021 , Peter Johnson (gravatar.com/delphidabbler).
6
+ * Copyright (C) 2005-2022 , Peter Johnson (gravatar.com/delphidabbler).
7
7
*
8
8
* Implements a dialogue box where the user can configure the Pascal compilers
9
9
* that are to be used by CodeSnip.
@@ -122,7 +122,12 @@ implementation
122
122
123
123
uses
124
124
// Project
125
- Compilers.UCompilers, IntfCommon, UCtrlArranger, UExeFileType, UFontHelper,
125
+ Compilers.UAutoDetect,
126
+ Compilers.UCompilers,
127
+ IntfCommon,
128
+ UCtrlArranger,
129
+ UExeFileType,
130
+ UFontHelper,
126
131
UMessageBox;
127
132
128
133
@@ -148,8 +153,6 @@ procedure TCompilersDlg.ArrangeForm;
148
153
end ;
149
154
150
155
procedure TCompilersDlg.btnDetectClick (Sender: TObject);
151
- var
152
- Compiler: ICompiler; // refers to each compiler
153
156
resourcestring
154
157
// Text displayed in confirmation box
155
158
sOKToDetect = ' Detected compiler file names will overwrite any existing '
@@ -159,19 +162,14 @@ procedure TCompilersDlg.btnDetectClick(Sender: TObject);
159
162
Exit;
160
163
// Record any changes to current compiler
161
164
UpdateCurrentCompiler;
162
- // Loop thru all compilers attempting to detect exe files
163
- for Compiler in fLocalCompilers do
164
- begin
165
- if Supports(Compiler, ICompilerAutoDetect) then
165
+ // Register any available compilers
166
+ TCompilerAutoDetect.RegisterCompilers(fLocalCompilers,
167
+ procedure (RegisteredCompiler: ICompiler)
166
168
begin
167
- if (Compiler as ICompilerAutoDetect).DetectExeFile then
168
- begin
169
- // Update currently displayed compiler details
170
- if Compiler.GetID = fCurCompiler.GetID then
171
- UpdateEditFrames;
172
- end ;
173
- end ;
174
- end ;
169
+ if RegisteredCompiler.GetID = fCurCompiler.GetID then
170
+ UpdateEditFrames;
171
+ end
172
+ );
175
173
// Redisplay compiler list and current compiler title to reflect any changes
176
174
fCompListMgr.Refresh;
177
175
fBannerMgr.Refresh;
@@ -234,20 +232,21 @@ class function TCompilersDlg.Execute(AOwner: TComponent;
234
232
const ACompilers: ICompilers): Boolean;
235
233
var
236
234
Persister: IPersistCompilers; // object used to save object to storage
235
+ Dlg: TCompilersDlg; // dialogue box instance
237
236
begin
238
- with InternalCreate(AOwner) do
239
- try
240
- (fLocalCompilers as IAssignable).Assign(ACompilers);
241
- Result := ShowModal = mrOK;
242
- if Result then
243
- begin
244
- (ACompilers as IAssignable).Assign(fLocalCompilers);
245
- Persister := TPersistCompilers.Create;
246
- Persister.Save(ACompilers);
247
- end ;
248
- finally
249
- Free;
237
+ Dlg := InternalCreate(AOwner);
238
+ try
239
+ (Dlg.fLocalCompilers as IAssignable).Assign(ACompilers);
240
+ Result := Dlg.ShowModal = mrOK;
241
+ if Result then
242
+ begin
243
+ (ACompilers as IAssignable).Assign(Dlg.fLocalCompilers);
244
+ Persister := TPersistCompilers.Create;
245
+ Persister.Save(ACompilers);
250
246
end ;
247
+ finally
248
+ Dlg.Free;
249
+ end ;
251
250
end ;
252
251
253
252
procedure TCompilersDlg.FormCreate (Sender: TObject);
0 commit comments