codetools: auto indent: added parameter UseLineStart

git-svn-id: trunk@22333 -
This commit is contained in:
mattias 2009-10-29 11:08:38 +00:00
parent 1a34693b34
commit fbac1ba4b8
2 changed files with 9 additions and 7 deletions

View File

@ -298,17 +298,13 @@ type
destructor Destroy; override;
procedure Clear;
function GetIndent(const Source: string; CleanPos: integer;
NewNestedComments: boolean;
NewNestedComments: boolean; UseLineStart: boolean;
out Indent: TFABIndentationPolicy): boolean;
procedure GetDefaultSrcIndent(const Source: string; CleanPos: integer;
NewNestedComments: boolean;
out Indent: TFABIndentationPolicy);
procedure GetDefaultIndentPolicy(Typ, SubTyp: TFABBlockType;
out Indent: TFABIndentationPolicy);
{ ToDo:
- indent on paste (position + new source)
- indent auto generated code (several snippets)
}
property OnGetExamples: TOnGetFABExamples read FOnGetExamples
write FOnGetExamples;
property OnGetNestedComments: TOnGetFABNestedComments
@ -1040,7 +1036,7 @@ end;
function TFullyAutomaticBeautifier.GetIndent(const Source: string;
CleanPos: integer; NewNestedComments: boolean;
out Indent: TFABIndentationPolicy): boolean;
UseLineStart: boolean; out Indent: TFABIndentationPolicy): boolean;
var
Block: TBlock;
@ -1075,6 +1071,11 @@ begin
CleanPos:=FindStartOfAtom(Source,CleanPos);
if CleanPos<1 then exit;
if UseLineStart then begin
while (CleanPos<=length(Source)) and (Source[CleanPos] in [' ',#9]) do
inc(CleanPos);
end;
Block:=CleanBlock;
ParentBlock:=CleanBlock;
Policies:=TFABPolicies.Create;

View File

@ -14455,7 +14455,8 @@ begin
if FirstLinePos<SrcEditor.LineCount then
DebugLn(['TMainIDE.OnSrcNoteBookGetIndent Firstline+1=',SrcEditor.Lines[FirstLinePos+1]]);
NestedComments:=CodeToolBoss.GetNestedCommentsFlagForFile(CodeBuf.Filename);
if not CodeToolBoss.Indenter.GetIndent(CodeBuf.Source,p,NestedComments,NewIndent)
if not CodeToolBoss.Indenter.GetIndent(CodeBuf.Source,p,NestedComments,
true,NewIndent)
then exit;
if not NewIndent.IndentValid then exit;
Indent:=NewIndent.Indent;