ide: load default indentation resource from FPC resource

git-svn-id: trunk@43012 -
This commit is contained in:
paul 2013-09-28 15:16:27 +00:00
parent 87c32c3dd4
commit 28a7e9342f
4 changed files with 16 additions and 37 deletions

2
.gitattributes vendored
View File

@ -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

View File

@ -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.

View File

@ -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
]);

BIN
ide/lazarus_indentation.res Normal file

Binary file not shown.