mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 15:10:16 +02:00
IDE: Link GUI changes back to all compiler options.
git-svn-id: trunk@42182 -
This commit is contained in:
parent
3c057df946
commit
dacab2e94f
@ -31,6 +31,9 @@ type
|
||||
FEffectiveFilter: string;
|
||||
procedure SetIdleConnected(AValue: Boolean);
|
||||
procedure OnIdle(Sender: TObject; var Done: Boolean);
|
||||
procedure CheckBoxClick(Sender: TObject);
|
||||
procedure EditChange(Sender: TObject);
|
||||
procedure ComboChange(Sender: TObject);
|
||||
procedure RenderAndFilterOptions;
|
||||
private
|
||||
property IdleConnected: Boolean read FIdleConnected write SetIdleConnected;
|
||||
@ -76,9 +79,6 @@ begin
|
||||
btnResetOptionsFilter.Hint := 'Clear the filter for options';
|
||||
FEffectiveFilter:=#1; // Set an impossible value first, makes sure options are filtered.
|
||||
IdleConnected := True;
|
||||
//btnGetAllOptions.Caption := 'Get all options';
|
||||
//btnGetAllOptions.Hint := 'Read available options using "fpc -i" and "fpc -h"';
|
||||
//lblStatus.Caption := '';
|
||||
end;
|
||||
|
||||
procedure TfrmAllCompilerOptions.edOptionsFilterChange(Sender: TObject);
|
||||
@ -119,8 +119,44 @@ begin
|
||||
finally
|
||||
Screen.Cursor:=crDefault;
|
||||
end;
|
||||
//sbAllOptions.Anchors := [];
|
||||
//sbAllOptions.Anchors := [akLeft,akTop, akRight, akBottom];
|
||||
end;
|
||||
|
||||
procedure TfrmAllCompilerOptions.CheckBoxClick(Sender: TObject);
|
||||
var
|
||||
cb: TCheckBox;
|
||||
Opt: TCompilerOpt;
|
||||
begin
|
||||
cb := Sender as TCheckBox;
|
||||
Opt := FOptionsReader.FindOptionById(cb.Tag);
|
||||
if Assigned(Opt) then
|
||||
begin
|
||||
if cb.Checked then
|
||||
Opt.Value := 'True'
|
||||
else
|
||||
Opt.Value := '';
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmAllCompilerOptions.EditChange(Sender: TObject);
|
||||
var
|
||||
ed: TEdit;
|
||||
Opt: TCompilerOpt;
|
||||
begin
|
||||
ed := Sender as TEdit;
|
||||
Opt := FOptionsReader.FindOptionById(ed.Tag);
|
||||
if Assigned(Opt) then
|
||||
Opt.Value := ed.Text;
|
||||
end;
|
||||
|
||||
procedure TfrmAllCompilerOptions.ComboChange(Sender: TObject);
|
||||
var
|
||||
cb: TComboBox;
|
||||
Opt: TCompilerOpt;
|
||||
begin
|
||||
cb := Sender as TComboBox;
|
||||
Opt := FOptionsReader.FindOptionById(cb.Tag);
|
||||
if Assigned(Opt) then
|
||||
Opt.Value := cb.Text;
|
||||
end;
|
||||
|
||||
procedure TfrmAllCompilerOptions.RenderAndFilterOptions;
|
||||
@ -141,6 +177,7 @@ var
|
||||
Result.Top := yLoc+aTopOffs;
|
||||
Result.Left := Opt.Indentation*4;
|
||||
Result.Caption := aCaption;
|
||||
Result.Tag := Opt.Id;
|
||||
FGeneratedControls.Add(Result);
|
||||
end;
|
||||
|
||||
@ -153,6 +190,7 @@ var
|
||||
Result.AnchorSide[akTop].Side := asrCenter;
|
||||
Result.Left := LeftEdit; // Now use Left instead of anchors
|
||||
Result.Anchors := [akLeft,akTop];
|
||||
Result.Tag := Opt.Id;
|
||||
FGeneratedControls.Add(Result);
|
||||
end;
|
||||
|
||||
@ -205,17 +243,20 @@ var
|
||||
NewLeft := LeftDescrBoolean + (Length(Opt.Option)-10)*8
|
||||
else
|
||||
NewLeft := LeftDescrBoolean;
|
||||
Cntrl.OnClick := @CheckBoxClick;
|
||||
MakeDescrLabel(Cntrl, NewLeft);
|
||||
end;
|
||||
oeSetElem: begin // Sub-item for set, CheckBox
|
||||
Cntrl := MakeOptionCntrl(TCheckBox, Opt.Option+Opt.Description);
|
||||
Assert((Opt.Value='') or (Opt.Value='True'), 'Wrong value in Boolean option '+Opt.Option);
|
||||
TCheckBox(Cntrl).Checked := Opt.Value<>'';
|
||||
Cntrl.OnClick := @CheckBoxClick;
|
||||
end;
|
||||
oeNumber, oeText, oeSetNumber: begin // Edit
|
||||
Lbl := MakeOptionCntrl(TLabel, Opt.Option+Opt.Suffix, 3);
|
||||
Cntrl := MakeEditCntrl(Lbl, TEdit);
|
||||
TEdit(Cntrl).Text := Opt.Value;
|
||||
TEdit(Cntrl).OnChange := @EditChange;
|
||||
MakeDescrLabel(Cntrl, LeftDescrEdit);
|
||||
end;
|
||||
oeList: begin // ComboBox
|
||||
@ -236,6 +277,7 @@ var
|
||||
raise Exception.Create('AddChoices: Unknown option ' + Opt.Option);
|
||||
end;
|
||||
cb.Text := Opt.Value;
|
||||
cb.OnChange := @ComboChange;
|
||||
MakeDescrLabel(Cntrl, LeftDescrEdit);
|
||||
end
|
||||
else
|
||||
|
@ -113,7 +113,8 @@ type
|
||||
|
||||
TCompilerOpt = class
|
||||
private
|
||||
fOption: string; // Option without the leading '-'
|
||||
fId: integer; // Identification.
|
||||
fOption: string; // Option without the leading '-'.
|
||||
fSuffix: string; // <x> or similar suffix of option.
|
||||
fValue: string; // Data entered by user, 'True' for Boolean.
|
||||
fEditKind: TCompilerOptEditKind;
|
||||
@ -128,6 +129,7 @@ type
|
||||
constructor Create(aOwnerGroup: TCompilerOptGroup);
|
||||
destructor Destroy; override;
|
||||
public
|
||||
property Id: integer read fId;
|
||||
property Option: string read fOption;
|
||||
property Suffix: string read fSuffix;
|
||||
property Value: string read fValue write fValue;
|
||||
@ -153,6 +155,7 @@ type
|
||||
constructor Create(aOwnerGroup: TCompilerOptGroup);
|
||||
destructor Destroy; override;
|
||||
function FindOption(aOptStr: string): TCompilerOpt;
|
||||
function FindOptionById(aId: integer): TCompilerOpt;
|
||||
function SelectOption(aOptAndValue: string): Boolean;
|
||||
public
|
||||
property CompilerOpts: TCompilerOptList read fCompilerOpts;
|
||||
@ -194,6 +197,7 @@ type
|
||||
destructor Destroy; override;
|
||||
function ReadAndParseOptions: TModalResult;
|
||||
function FilterOptions(aFilter: string): Boolean;
|
||||
function FindOptionById(aId: integer): TCompilerOpt;
|
||||
function FromCustomOptions(aStrings: TStrings): TModalResult;
|
||||
function ToCustomOptions(aStrings: TStrings): TModalResult;
|
||||
public
|
||||
@ -383,6 +387,15 @@ end;
|
||||
|
||||
// Compiler options parsed from "fpc -h" and "fpc -i".
|
||||
|
||||
var
|
||||
OptionIdCounter: integer;
|
||||
|
||||
function NextOptionId: integer;
|
||||
begin
|
||||
Result := OptionIdCounter;
|
||||
Inc(OptionIdCounter);
|
||||
end;
|
||||
|
||||
function CalcIndentation(s: string): integer;
|
||||
begin
|
||||
Result := 0;
|
||||
@ -395,7 +408,6 @@ begin
|
||||
Result := aOpt = '-F'; // Ignore all file names and paths
|
||||
end;
|
||||
|
||||
|
||||
{ TCompilerOpt }
|
||||
|
||||
constructor TCompilerOpt.Create(aOwnerGroup: TCompilerOptGroup);
|
||||
@ -404,6 +416,7 @@ begin
|
||||
fOwnerGroup := aOwnerGroup;
|
||||
if Assigned(aOwnerGroup) then
|
||||
aOwnerGroup.fCompilerOpts.Add(Self);
|
||||
fId := NextOptionId;
|
||||
end;
|
||||
|
||||
destructor TCompilerOpt.Destroy;
|
||||
@ -498,6 +511,33 @@ begin
|
||||
Result := FindOptionSub(Self);
|
||||
end;
|
||||
|
||||
function TCompilerOptGroup.FindOptionById(aId: integer): TCompilerOpt;
|
||||
|
||||
function FindOptionSub(aRoot: TCompilerOpt): TCompilerOpt;
|
||||
var
|
||||
Children: TCompilerOptList;
|
||||
i: Integer;
|
||||
begin
|
||||
Result := Nil;
|
||||
if aRoot is TCompilerOptGroup then
|
||||
begin
|
||||
Children := TCompilerOptGroup(aRoot).CompilerOpts;
|
||||
for i := 0 to Children.Count-1 do // Recursive call for children.
|
||||
begin
|
||||
Result := FindOptionSub(TCompilerOpt(Children[i]));
|
||||
if Assigned(Result) then Break;
|
||||
end;
|
||||
end
|
||||
else begin // TCompilerOpt
|
||||
if aRoot.fId = aId then
|
||||
Result := aRoot;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
Result := FindOptionSub(Self);
|
||||
end;
|
||||
|
||||
function TCompilerOptGroup.SelectOption(aOptAndValue: string): Boolean;
|
||||
var
|
||||
Opt: TCompilerOpt;
|
||||
@ -843,6 +883,7 @@ function TCompilerOptReader.ReadAndParseOptions: TModalResult;
|
||||
var
|
||||
Lines: TStringList;
|
||||
begin
|
||||
OptionIdCounter := 0;
|
||||
Lines := TStringList.Create;
|
||||
try
|
||||
// FPC with option -i
|
||||
@ -892,6 +933,11 @@ begin
|
||||
Result := FilterOptionsSub(fRootOptGroup);
|
||||
end;
|
||||
|
||||
function TCompilerOptReader.FindOptionById(aId: integer): TCompilerOpt;
|
||||
begin
|
||||
Result := fRootOptGroup.FindOptionById(aId);
|
||||
end;
|
||||
|
||||
function TCompilerOptReader.FromCustomOptions(aStrings: TStrings): TModalResult;
|
||||
var
|
||||
i, CommentPos: Integer;
|
||||
|
Loading…
Reference in New Issue
Block a user