IDE: Harmonize the style of spaces with ":=". Issue #27441, patch from Alexey Torgashin.

git-svn-id: trunk@48140 -
This commit is contained in:
juha 2015-03-05 17:39:32 +00:00
parent b03737cc9e
commit 09bbaa4174
2 changed files with 27 additions and 8 deletions

View File

@ -247,6 +247,9 @@ function GetTranslatedAtomTypes(a: TAtomType): string;
function TranslatedAtomToType(const s: string): TAtomType; function TranslatedAtomToType(const s: string): TAtomType;
function ReadIdentifier(const s, DefaultIdent: string): string; function ReadIdentifier(const s, DefaultIdent: string): string;
function SpaceCharBeforeSymbols: string;
function SpaceCharAfterSymbols: string;
implementation implementation
{$R lazarus_indentation.res} {$R lazarus_indentation.res}
@ -329,6 +332,22 @@ begin
Result:=DefaultIdent; Result:=DefaultIdent;
end; end;
function SpaceCharBeforeSymbols: string;
begin
if atSymbol in CodeToolsOpts.DoInsertSpaceInFront then
Result:= ' '
else
Result:= '';
end;
function SpaceCharAfterSymbols: string;
begin
if atSymbol in CodeToolsOpts.DoInsertSpaceAfter then
Result:= ' '
else
Result:= '';
end;
{ TCodeToolsOptions } { TCodeToolsOptions }
constructor TCodeToolsOptions.Create; constructor TCodeToolsOptions.Create;

View File

@ -41,7 +41,8 @@ uses
Controls, Forms, SynRegExpr, FileProcs, Laz2_XMLCfg, LazUTF8, Controls, Forms, SynRegExpr, FileProcs, Laz2_XMLCfg, LazUTF8,
CompOptsIntf, ProjectIntf, LazIDEIntf, CompOptsIntf, ProjectIntf, LazIDEIntf,
ProjectResourcesIntf, ProjectResourcesIntf,
frmCustomApplicationOptions, PublishModule, IDEProcs, LazarusIDEStrConsts; frmCustomApplicationOptions, PublishModule, IDEProcs, LazarusIDEStrConsts,
CodeToolsOptions;
type type
TOnLoadSaveFilename = procedure(var Filename:string; Load:boolean) of object; TOnLoadSaveFilename = procedure(var Filename:string; Load:boolean) of object;
@ -383,7 +384,6 @@ type
implementation implementation
{ TProjectBookmark } { TProjectBookmark }
constructor TProjectBookmark.Create(X, Y, AnID: integer; AUnitInfo: TObject); constructor TProjectBookmark.Create(X, Y, AnID: integer; AUnitInfo: TObject);
@ -1291,7 +1291,7 @@ begin
+' { you can add units after this };'+LineEnding +' { you can add units after this };'+LineEnding
+LineEnding +LineEnding
+'begin'+LineEnding +'begin'+LineEnding
+' RequireDerivedFormResource:=True;'+LineEnding +' RequireDerivedFormResource'+SpaceCharBeforeSymbols+':='+SpaceCharAfterSymbols+'True;'+LineEnding
+' Application.Initialize;'+LineEnding +' Application.Initialize;'+LineEnding
+' Application.Run;'+LineEnding +' Application.Run;'+LineEnding
+'end.'+LineEnding +'end.'+LineEnding
@ -1586,7 +1586,7 @@ begin
if CO then if CO then
begin begin
NewSource.Add(' // quick check parameters'); NewSource.Add(' // quick check parameters');
NewSource.Add(' ErrorMsg:=CheckOptions(''h'',''help'');'); NewSource.Add(' ErrorMsg'+SpaceCharBeforeSymbols+':='+SpaceCharAfterSymbols+'CheckOptions(''h'',''help'');');
NewSource.Add(' if ErrorMsg<>'''' then begin'); NewSource.Add(' if ErrorMsg<>'''' then begin');
NewSource.Add(' ShowException(Exception.Create(ErrorMsg));'); NewSource.Add(' ShowException(Exception.Create(ErrorMsg));');
NewSource.Add(' Terminate;'); NewSource.Add(' Terminate;');
@ -1616,7 +1616,7 @@ begin
NewSource.Add('begin'); NewSource.Add('begin');
NewSource.Add(' inherited Create(TheOwner);'); NewSource.Add(' inherited Create(TheOwner);');
If CS then If CS then
NewSource.Add(' StopOnException:=True;'); NewSource.Add(' StopOnException'+SpaceCharBeforeSymbols+':='+SpaceCharAfterSymbols+'True;');
NewSource.Add('end;'); NewSource.Add('end;');
NewSource.Add(''); NewSource.Add('');
end; end;
@ -1633,19 +1633,19 @@ begin
NewSource.Add('procedure '+C+'.WriteHelp;'); NewSource.Add('procedure '+C+'.WriteHelp;');
NewSource.Add('begin'); NewSource.Add('begin');
NewSource.Add(' { add your help code here }'); NewSource.Add(' { add your help code here }');
NewSource.Add(' writeln(''Usage: '',ExeName,'' -h'');'); NewSource.Add(' Writeln(''Usage: '',ExeName,'' -h'');');
NewSource.Add('end;'); NewSource.Add('end;');
NewSource.Add(''); NewSource.Add('');
end; end;
NewSource.Add('var'); NewSource.Add('var');
NewSource.Add(' Application: '+C+';'); NewSource.Add(' Application: '+C+';');
NewSource.Add('begin'); NewSource.Add('begin');
NewSource.Add(' Application:='+C+'.Create(nil);'); NewSource.Add(' Application'+SpaceCharBeforeSymbols+':='+SpaceCharAfterSymbols+C+'.Create(nil);');
If (T<>'') then If (T<>'') then
begin begin
AProject.Flags:=AProject.Flags+[pfMainUnitHasTitleStatement]; AProject.Flags:=AProject.Flags+[pfMainUnitHasTitleStatement];
AProject.Title:=T; AProject.Title:=T;
NewSource.Add(' Application.Title:='''+T+''';'); NewSource.Add(' Application.Title'+SpaceCharBeforeSymbols+':='+SpaceCharBeforeSymbols+''''+T+''';');
end; end;
NewSource.Add(' Application.Run;'); NewSource.Add(' Application.Run;');
NewSource.Add(' Application.Free;'); NewSource.Add(' Application.Free;');