diff --git a/.gitattributes b/.gitattributes index c0d4f51171..cd4458b201 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5209,7 +5209,7 @@ ide/lazarus.ico -text svneol=unset#image/ico ide/lazarus.lpi svneol=native#text/plain ide/lazarus.pp svneol=native#text/pascal ide/lazarus.res -text -ide/lazarus_indentation.lrs svneol=native#text/plain +ide/lazarus_indentation.res -text ide/lazarusidestrconsts.pas svneol=native#text/pascal ide/lazarusmanager.pas svneol=native#text/pascal ide/lazbuild.lpi svneol=native#text/plain diff --git a/ide/codetoolsoptions.pas b/ide/codetoolsoptions.pas index 250e28e3e1..8d93bbe478 100644 --- a/ide/codetoolsoptions.pas +++ b/ide/codetoolsoptions.pas @@ -36,7 +36,7 @@ interface uses Classes, SysUtils, LazConf, FileUtil, Laz2_XMLCfg, lazutf8classes, - LResources, Forms, Controls, Buttons, LclProc, ExtCtrls, + LResources, Forms, Controls, Buttons, LclProc, LCLType, ExtCtrls, Dialogs, CodeToolManager, DefineTemplates, SourceChanger, SynEdit, IDEOptionsIntf, MacroIntf, IDEOptionDefs, LazarusIDEStrConsts, IDEProcs; @@ -243,6 +243,7 @@ function ReadIdentifier(const s, DefaultIdent: string): string; implementation +{$R lazarus_indentation.res} const CodeToolsOptionsVersion = 1; @@ -891,27 +892,27 @@ end; procedure TCodeToolsOptions.CreateDefaultIndentationFile; var - res: TLResource; + res: TResourceStream; fs: TFileStreamUTF8; begin // indentations (laz_indentation.pas) CopySecondaryConfigFile(DefaultIndentationFilename); if not FileExistsUTF8(IndentationFilename) then begin - res := LazarusResources.Find('indentation'); - if (res <> Nil) and (res.Value <> '') and (res.ValueType = 'PAS') then + res := TResourceStream.Create(HInstance, PChar('indentation'), PChar(RT_RCDATA)); + try + InvalidateFileStateCache; + fs := TFileStreamUTF8.Create(IndentationFilename, fmCreate); try - InvalidateFileStateCache; - fs := TFileStreamUTF8.Create(IndentationFilename, fmCreate); - try - fs.Write(res.Value[1], length(res.Value)); - finally - fs.Free; - end; - except - DebugLn('WARNING: unable to write indentation file "', - IndentationFilename, '"'); + fs.CopyFrom(res, res.Size); + finally + fs.Free; end; + except + DebugLn('WARNING: unable to write indentation file "', + IndentationFilename, '"'); + end; + res.Free; end; end; @@ -984,6 +985,5 @@ end; initialization RegisterIDEOptionsGroup(GroupCodetools, TCodeToolsOptions); - {$I lazarus_indentation.lrs} end. diff --git a/ide/lazarus_indentation.lrs b/ide/lazarus_indentation.lrs deleted file mode 100644 index a0d3c85818..0000000000 --- a/ide/lazarus_indentation.lrs +++ /dev/null @@ -1,21 +0,0 @@ -LazarusResources.Add('indentation','PAS',[ - 'unit Indentation;'#10#10'{$mode objfpc}{$H+}'#10#10'interface'#10#10'uses'#10 - +' Classes, SysUtils;'#10#10'type'#10' TEnums = ('#10' enum1,'#10' en' - +'um2,'#10' enum3'#10' );'#10#10' TMyRecord = record'#10' i: intege' - +'r;'#10' end;'#10' PMyRecord = ^TMyRecord;'#10#10' { TMyClass }'#10#10' ' - +'TMyClass = class(TObject)'#10' public'#10' procedure DoSomething1(a, b,' - +' c: integer);'#10' procedure Code;'#10' end;'#10#10'implementation'#10 - +#10'{ TMyClass }'#10#10'procedure TMyClass.DoSomething1(a, b, c: integer;'#10 - +' LongParameter1: TSomeLongParameter);'#10'var'#10' i: integer;'#10'begin' - +#10' if i=0 then'#10' begin'#10' repeat'#10' if a=2 then'#10' ' - +' ;'#10' until b=3;'#10' try'#10' Code;'#10' finally'#10' ' - +' Code;'#10' end;'#10' try'#10' Code;'#10' except'#10' ' - +'on e: exception do'#10' ;'#10' end;'#10' end'#10' else'#10' be' - +'gin'#10' case c of'#10' 1:'#10' Code;'#10' 2:'#10' begin' - +#10' code;'#10' end;'#10' else'#10' code;'#10' end;' - +#10' end;'#10'end;'#10#10'procedure TMyClass.Code;'#10#10' procedure SubPr' - +'oc;'#10' begin'#10#10' end;'#10#10'var'#10' i: Integer;'#10'begin'#10' ' - +'writeln(''TMyClass.Code '');'#10' repeat'#10#10' until ;'#10' for i:=1 t' - +'o 3 do'#10' Code;'#10' for i:=1 to 3 do'#10' begin'#10' Code;'#10' ' - +' end;'#10'end;'#10#10'end.'#10#10 -]); diff --git a/ide/lazarus_indentation.res b/ide/lazarus_indentation.res new file mode 100644 index 0000000000..8b1ed6cf44 Binary files /dev/null and b/ide/lazarus_indentation.res differ