mirror of https://gitlab.com/basile.b/dexed.git
dfmt commander, adapt the options to the program version
This commit is contained in:
parent
24f612714d
commit
78544f3e3a
|
@ -57,7 +57,7 @@ type
|
||||||
property constraintsStyle: DfmtConstraint read fConstraints write setConstraintsStyle default condNewLineIndent;
|
property constraintsStyle: DfmtConstraint read fConstraints write setConstraintsStyle default condNewLineIndent;
|
||||||
public
|
public
|
||||||
constructor create(AOwner: TComponent); override;
|
constructor create(AOwner: TComponent); override;
|
||||||
procedure getParameters(str: TStrings);
|
procedure getParameters(str: TStrings; majv, minv: Byte);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCEDfmtWidget }
|
{ TCEDfmtWidget }
|
||||||
|
@ -240,7 +240,7 @@ end;
|
||||||
{$ENDREGION}
|
{$ENDREGION}
|
||||||
|
|
||||||
{$REGION Dfmt things -----------------------------------------------------------}
|
{$REGION Dfmt things -----------------------------------------------------------}
|
||||||
procedure TCEDmtWrapper.getParameters(str: TStrings);
|
procedure TCEDmtWrapper.getParameters(str: TStrings; majv, minv: Byte);
|
||||||
const
|
const
|
||||||
eol: array[DfmtEol] of string = ('cr', 'lf', 'crlf');
|
eol: array[DfmtEol] of string = ('cr', 'lf', 'crlf');
|
||||||
falsetrue: array[boolean] of string = ('false', 'true');
|
falsetrue: array[boolean] of string = ('false', 'true');
|
||||||
|
@ -260,14 +260,18 @@ begin
|
||||||
str.Add('--space_after_cast=' + falsetrue[spaceAfterCast]);
|
str.Add('--space_after_cast=' + falsetrue[spaceAfterCast]);
|
||||||
str.Add('--selective_import_space=' + falsetrue[spaceAfterImport]);
|
str.Add('--selective_import_space=' + falsetrue[spaceAfterImport]);
|
||||||
str.Add('--compact_labeled_statements=' + falsetrue[compactLabeledStatements]);
|
str.Add('--compact_labeled_statements=' + falsetrue[compactLabeledStatements]);
|
||||||
|
if (majv = 0) and (minv > 4) then
|
||||||
str.Add('--template_constraint_style=' + cts[fConstraints]);
|
str.Add('--template_constraint_style=' + cts[fConstraints]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEDfmtWidget.doApply(sender: TObject);
|
procedure TCEDfmtWidget.doApply(sender: TObject);
|
||||||
var
|
var
|
||||||
inp: string;
|
inp: string;
|
||||||
|
i: integer;
|
||||||
prc: TProcess;
|
prc: TProcess;
|
||||||
str: TStringList;
|
str: TStringList;
|
||||||
|
majv: byte = 0;
|
||||||
|
minv: byte = 4;
|
||||||
begin
|
begin
|
||||||
if fDoc.isNil then
|
if fDoc.isNil then
|
||||||
exit;
|
exit;
|
||||||
|
@ -277,9 +281,21 @@ begin
|
||||||
fBackup.Assign(fDoc.Lines);
|
fBackup.Assign(fDoc.Lines);
|
||||||
prc := TProcess.create(nil);
|
prc := TProcess.create(nil);
|
||||||
try
|
try
|
||||||
fDmtWrapper.getParameters(prc.Parameters);
|
|
||||||
prc.Options:= prc.Options + [poUsePipes, poStderrToOutPut];
|
|
||||||
prc.Executable:= exeFullName('dfmt' + exeExt);
|
prc.Executable:= exeFullName('dfmt' + exeExt);
|
||||||
|
prc.Options:= prc.Options + [poUsePipes, poStderrToOutPut];
|
||||||
|
|
||||||
|
setLength(inp, 20);
|
||||||
|
prc.Parameters.Add('--version');
|
||||||
|
prc.Execute;
|
||||||
|
i := prc.Output.Read(inp[1], 20);
|
||||||
|
if (i > 4) and (inp[2] = '.') then
|
||||||
|
begin
|
||||||
|
majv := Byte(inp[1]) - Byte('0');
|
||||||
|
minv := Byte(inp[3]) - Byte('0');
|
||||||
|
end;
|
||||||
|
|
||||||
|
prc.Parameters.Clear;
|
||||||
|
fDmtWrapper.getParameters(prc.Parameters, majv, minv);
|
||||||
prc.Execute;
|
prc.Execute;
|
||||||
inp := fDoc.Lines.Text;
|
inp := fDoc.Lines.Text;
|
||||||
prc.Input.Write(inp[1], inp.length);
|
prc.Input.Write(inp[1], inp.length);
|
||||||
|
|
Loading…
Reference in New Issue