Delphi-Quellcode:
{
Text in RichEdit formatieren
}
procedure TForm1.RichEdit1Change(Sender: TObject);
var
i : LongInt;
p : DWord;
begin
p := 0;
for i := 0 to RichEdit1.Lines.Count-1 do
begin
if (pos('//',RichEdit1.Lines[i]) = 1) or
(pos('{' ,RichEdit1.Lines[i]) = 1) or
(pos('}', RichEdit1.Lines[i]) = 1) or
(pos('(*',RichEdit1.Lines[i]) = 1) or
(pos('*)',RichEdit1.Lines[i]) = 1) then
begin
RichEdit1.SelStart := p;
RichEdit1.SelLength := Length(RichEdit1.Lines[i]);
RichEdit1.SelAttributes.Color := clgray;
RichEdit1.SelLength := 0;
end;
inc(p,Length(RichEdit1.Lines[i])+2);
end;
end;
Ich weiß nicht(habe nicht getestet) ob dir das jetzt weiter helfen könnte...