1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
|
unit compiler_parsing_options;
{$mode objfpc}{$H+}
interface
uses
SysUtils,
// LCL
ExtCtrls, StdCtrls,
// CodeTools
LinkScanner,
// IdeIntf
IDEOptionsIntf, IDEOptEditorIntf,
// IDE
CompilerOptions, PackageDefs, LazarusIDEStrConsts;
type
{ TCompilerParsingOptionsFrame }
TCompilerParsingOptionsFrame = class(TAbstractIDEOptionsEditor)
cmbSyntaxMode: TComboBox;
grpAsmStyle: TRadioGroup;
grpSyntaxMode: TGroupBox;
grpSyntaxOptions: TCheckGroup;
private
FIsPackage: boolean;
public
function GetTitle: string; override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;
implementation
{$R *.lfm}
const
// CompilerMode names to be shown after -M...
CompilerModesPretty: array[TCompilerMode] of shortstring = (
'fpc', 'Delphi', 'DelphiUnicode', 'gpc', 'tp', 'ObjFPC', 'MacPas', 'iso',
'ExtPas'
);
// CompilerMode descriptions.
CompilerModesDescr: array[TCompilerMode] of shortstring = (
'Free Pascal', 'Delphi', 'Delphi Unicode', 'GNU Pascal', 'Turbo Pascal',
'Object Pascal', 'Mac Pascal', 'ISO/IEC 7185 Pascal',
'Extended Pascal, ISO 10206'
);
function SyntaxModeToCaption(const ModeStr: string): string;
var
cm: TCompilerMode;
begin
Result := '';
for cm := Low(TCompilerMode) to High(TCompilerMode) do
if CompareText(ModeStr, CompilerModeNames[cm]) = 0 then
begin
if cm = cmOBJFPC then
Result := lisObjectPascalDefault // Is this needed?
else
Result := CompilerModesDescr[cm];
Result := Result + ' (-M' + CompilerModesPretty[cm] + ')';
Break;
end;
end;
function CaptionToSyntaxMode(const Caption: string): string;
var
cm: TCompilerMode;
begin
Result := 'ObjFPC';
// Some modes would go wrong if iterated forward, thus iterate backwards.
for cm := High(TCompilerMode) downto Low(TCompilerMode) do
if Pos('-M' + CompilerModesPretty[cm], Caption) > 0 then
begin
Result := CompilerModesPretty[cm];
Break;
end;
end;
{ TCompilerParsingOptionsFrame }
function TCompilerParsingOptionsFrame.GetTitle: string;
begin
Result := dlgCOParsing;
end;
procedure TCompilerParsingOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
var
m: TCompilerMode;
s: string;
begin
grpSyntaxMode.Caption := lisSyntaxMode + ' (-M, {$MODE})';
cmbSyntaxMode.Items.BeginUpdate;
cmbSyntaxMode.Items.Clear;
for m := Low(TCompilerMode) to High(TCompilerMode) do
begin
s := SyntaxModeToCaption(CompilerModeNames[m]);
if s <> '' then
cmbSyntaxMode.Items.Add(s);
end;
cmbSyntaxMode.Items.EndUpdate;
with grpAsmStyle do
begin
Caption := dlgCOAsmStyle + ' (-R)';
Items.BeginUpdate;
Items.Clear;
Items.Add(lisDefault);
Items.Add('Intel');
Items.Add('AT&&T');
Items.EndUpdate;
end;
with grpSyntaxOptions do
begin
AutoSize := True;
Caption := dlgSyntaxOptions;
Items.BeginUpdate;
Items.Add(dlgCOCOps + ' (-Sc, {$COPERATORS ON})');
Items.Add(dlgLabelGoto + ' (-Sg, {$GOTO ON})');
Items.Add(dlgCppInline + ' (-Si, {$INLINE ON})');
Items.Add(dlgCMacro + ' (-Sm, {$MACRO ON})');
Items.Add(dlgInitDoneOnly + ' (-Ss)');
Items.Add(dlgStaticKeyword + ' (-St)');
Items.Add(dlgCOAnsiStr + ' (-Sh, {$H+})');
Items.EndUpdate;
end;
end;
procedure TCompilerParsingOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
var
CurOptions: TBaseCompilerOptions;
begin
CurOptions := AOptions as TBaseCompilerOptions;
FIsPackage := CurOptions is TPkgCompilerOptions;
with CurOptions do
begin
cmbSyntaxMode.Text := SyntaxModeToCaption(SyntaxMode);
if (AssemblerStyle in [1,2,3]) then
grpAsmStyle.ItemIndex := AssemblerStyle
else
grpAsmStyle.ItemIndex := 0;
with grpSyntaxOptions do
begin
Checked[0] := CStyleOperators;
Checked[1] := AllowLabel;
Checked[2] := CPPInline;
Checked[3] := CStyleMacros;
Checked[4] := InitConstructor;
Checked[5] := StaticKeyword;
Checked[6] := UseAnsiStrings;
end;
end;
end;
procedure TCompilerParsingOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
begin
with AOptions as TBaseCompilerOptions do
begin
SyntaxMode := CaptionToSyntaxMode(cmbSyntaxMode.Text);
AssemblerStyle := grpAsmStyle.ItemIndex;
with grpSyntaxOptions do
begin
CStyleOperators := Checked[0];
AllowLabel := Checked[1];
CPPInline := Checked[2];
CStyleMacros := Checked[3];
InitConstructor := Checked[4];
StaticKeyword := Checked[5];
UseAnsiStrings := Checked[6];
end;
end;
end;
class function TCompilerParsingOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
begin
Result := TBaseCompilerOptions;
end;
initialization
RegisterIDEOptionsEditor(GroupCompiler, TCompilerParsingOptionsFrame,
CompilerOptionsParsing);
RegisterIDEOptionsEditor(GroupPkgCompiler, TCompilerParsingOptionsFrame,
CompilerOptionsParsing);
end.
|