Menu

#2 Add function to keep commented scripts in proper hierarchy.

open
nobody
None
5
2012-09-14
2004-03-24
Anonymous
No

IN FILE formatter.pas

  1. Modify uses

uses
DomCore, Classes;
(Not required if you can do this better without
TStringList).

  1. Add new function after TrimLeftSpaces. // I use tabs,
    so this must be modified to use (FIndent * FDepth).

function IndentText(S: TDomString; Depth: Integer):
TDomString;
var
Str: string;
TmpStr: TStringList;
I, J: Integer;
begin
TmpStr := TStringList.Create;
try
TmpStr.Text := S;
for I := 1 to TmpStr.Count - 1 do
// Start at 1, don't indent first line with <!--
begin
Str := TrimLeftSpaces
(TmpStr[I]);
SetLength(Str, Length(Str)
+ Depth);
for J := Length(Str) downto
Depth + 1 do
Str[J] := Str[J -
Depth]
;
for J := Depth downto 1 do
Str[J] := #9;
TmpStr[I] := Str;
end;
Result := TmpStr.Text;
SetLength(Result, Length(Result) -
2); // Remove trailing #D#A added by TStringList
finally
TmpStr.Free;
end;
end;


  1. Modify class method

procedure TBaseFormatter.ProcessComment(Comment:
TComment);
begin
AppendText('')
end;

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.