IDE: code templates: fixed auto indent for middle space

git-svn-id: trunk@28970 -
This commit is contained in:
mattias 2011-01-12 12:21:41 +00:00
parent 2b72e682a8
commit f4ecc0e4f7
3 changed files with 12 additions and 3 deletions

View File

@ -296,6 +296,7 @@ const
); );
function ProcHeadAttributesToStr(Attr: TProcHeadAttributes): string; function ProcHeadAttributesToStr(Attr: TProcHeadAttributes): string;
function dbgs(Attr: TProcHeadAttributes): string; overload;
implementation implementation
@ -318,6 +319,11 @@ begin
end; end;
end; end;
function dbgs(Attr: TProcHeadAttributes): string;
begin
Result:=ProcHeadAttributesToStr(Attr);
end;
{ TPascalParserTool } { TPascalParserTool }
constructor TPascalParserTool.Create; constructor TPascalParserTool.Create;

View File

@ -212,6 +212,7 @@ const
var var
IndentLevel: Integer; IndentLevel: Integer;
LastLineIndent: Integer; LastLineIndent: Integer;
IsLineStart: boolean;
procedure AppentToDest(S: String); procedure AppentToDest(S: String);
var var
@ -232,14 +233,14 @@ var
FDestTemplate := FDestTemplate + copy(s, LastCopy, i - LastCopy) + FIndent; FDestTemplate := FDestTemplate + copy(s, LastCopy, i - LastCopy) + FIndent;
LastCopy := i; LastCopy := i;
FDestPosX := 1 + length(FIndent); FDestPosX := 1 + length(FIndent);
IsLineStart:=true;
inc(FDestPosY); inc(FDestPosY);
end; end;
else // case else else // case else
begin begin
if (s[i] in [' ',#9]) if (s[i] in [' ',#9])
and (not KeepSubIndent) and (not KeepSubIndent)
and (FDestTemplate<>'') and ((FDestTemplate<>'') and IsLineStart)
and ((i=1) or (S[i-1] in [#10,#13]))
then begin then begin
// space at start of template line (not first line) // space at start of template line (not first line)
FDestTemplate:=FDestTemplate+copy(S,LastCopy,i-LastCopy); FDestTemplate:=FDestTemplate+copy(S,LastCopy,i-LastCopy);
@ -270,6 +271,7 @@ var
inc(i); inc(i);
inc(FDestPosX); inc(FDestPosX);
end; end;
IsLineStart:=false;
end; end;
end; end;
end; end;
@ -303,6 +305,7 @@ begin
len:=length(Template); len:=length(Template);
IndentLevel:=0; IndentLevel:=0;
LastLineIndent:=0; LastLineIndent:=0;
IsLineStart:=false;
while p <= len do begin while p <= len do begin
case Template[p] of case Template[p] of
'$': '$':

View File

@ -363,7 +363,7 @@ begin
end; end;
end; end;
//debugln('CodeMacroProcedureHead B '); //debugln('CodeMacroProcedureHead B ',dbgs(Attributes));
if not CodeToolBoss.ExtractProcedureHeader( if not CodeToolBoss.ExtractProcedureHeader(
SrcEdit.CodeToolsBuffer as TCodeBuffer, SrcEdit.CodeToolsBuffer as TCodeBuffer,
SrcEdit.CursorTextXY.X,SrcEdit.CursorTextXY.Y,Attributes,Value) then SrcEdit.CursorTextXY.X,SrcEdit.CursorTextXY.Y,Attributes,Value) then