In Delphi 10.3.3, which is the most simple and fastest and most efficient way to loop through each visible Char
(i.e. excluding non-printable characters such as e.g. #13
) of a (multiline) TRichEdit
text? I then need to get and set the color of each char according to my calculations.
I have tried this one:
function GetCharByIndex(Index: Integer): Char;
begin
RichEdit1.SelStart := Index;
RichEdit1.SelLength := 1;
Result := RichEdit1.SelText[1];
end;
RichLen := RichEdit1.GetTextLen - RichEdit1.Lines.Count;
for i := 0 to RichLen - 1 do
begin
c := GetCharByIndex(i);
if c = #13 then CONTINUE;
// ... do my stuff here
end;
But I am sure there must be a better way.