class function TStringManipulation.SyntaxHighlighting(Edit: TRichEdit; Progressbar: TProgressbar): Bool;
var AResultList : TStringList;
var Linelength : Integer;
var Linemax : Integer;
var Offset : Integer;
var Count : Integer;
var i : Integer;
begin
try
Offset := 9;
// später aus XML
Count := 5;
// später aus XML
LineLength := 0;
AResultList := TStringList.Create;
AResultList.Assign(Edit.Lines);
Linemax := Edit.Lines.Count-1;
ProgressBar.Position := 0;
ProgressBar.Max := Linemax;
Edit.Lines.Clear;
Edit.SelStart := Offset-1;
for i := 0
to Linemax
do
begin
with Edit
do
begin
SelText := AResultList.Strings[i]+sLineBreak;
SelStart := Edit.SelStart + Linelength;
SelLength := Count;
SelAttributes.Color := clBlue;
SelAttributes.Style := [fsBold];
end;
Linelength := Length(Edit.Lines[i])+2;
//+2 wegen Zeilenumbruch!
ProgressBar.Position := Progressbar.Position + 1;
end;
FreeAndNil(AResultList);
result := true;
except
FreeAndNil(AResultList);
result := false;
end;
end;