IDE: auto indent for many cases

git-svn-id: trunk@20616 -
This commit is contained in:
mattias 2009-06-13 11:22:22 +00:00
parent 282a2b206c
commit f2f207f212
2 changed files with 10 additions and 3 deletions

View File

@ -499,7 +499,7 @@ begin
p:=StartPos;
repeat
ReadRawNextPascalAtom(Src,p,AtomStart,NestedComments);
DebugLn(['TFullyAutomaticBeautifier.ParseSource Atom=',copy(Src,AtomStart,p-AtomStart)]);
//DebugLn(['TFullyAutomaticBeautifier.ParseSource Atom=',copy(Src,AtomStart,p-AtomStart)]);
if p>=EndPos then begin
if (AtomStart<=p) and (p>EndPos) then begin
LastAtomStart:=p;
@ -1026,7 +1026,7 @@ var
i: Integer;
OldLength: Integer;
begin
DebugLn(['TFABPolicies.AddIndent Typ=',FABBlockTypeNames[Typ],' SubType=',FABBlockTypeNames[SubType]]);
//DebugLn(['TFABPolicies.AddIndent Typ=',FABBlockTypeNames[Typ],' SubType=',FABBlockTypeNames[SubType]]);
OldLength:=length(Indentations);
i:=OldLength-1;
while (i>=0) and (Indentations[i].Indent<>Indent) do dec(i);

View File

@ -14000,10 +14000,13 @@ var
p: integer;
NestedComments: Boolean;
NewIndent: TFABIndentationPolicy;
EditorIndex: LongInt;
begin
{$IFNDEF EnableIndenter}
exit;
{$ENDIF}
EditorIndex:=SrcEditor.PageIndex;
SaveSourceEditorChangesToCodeCache(EditorIndex);
CodeBuf:=SrcEditor.CodeBuffer;
CodeBuf.LineColToPosition(LogCaret.Y,LogCaret.X,p);
debugln(['TMainIDE.OnSrcNoteBookGetIndent AAA1 ',dbgs(LogCaret),' p=',p,' ',CodeBuf.Filename,' ',CodeBuf.SourceLength]);
@ -14011,8 +14014,12 @@ begin
NestedComments:=CodeToolBoss.GetNestedCommentsFlagForFile(CodeBuf.Filename);
if not CodeToolBoss.Indenter.GetIndent(CodeBuf.Source,p,NestedComments,NewIndent)
then exit;
debugln(['TMainIDE.OnSrcNoteBookGetIndent AAA2 ',NewIndent.IndentValid,' ',NewIndent.Indent]);
debugln(['TMainIDE.OnSrcNoteBookGetIndent AAA2 ',NewIndent.IndentValid,' ',NewIndent.Indent,' Indent=',Indent,' BasedLine=',BasedLine,' ReplaceIndent=',ReplaceIndent]);
if not NewIndent.IndentValid then exit;
Indent:=NewIndent.Indent+1;
ReplaceIndent:=true;
BasedLine:=-1;
DebugLn(['TMainIDE.OnSrcNoteBookGetIndent END Indent=',Indent,' ReplaceIndent=',ReplaceIndent,' BasedLine=',BasedLine]);
end;
procedure TMainIDE.OnSrcNotebookMovingPage(Sender: TObject; OldPageIndex,