在 Delphi 10.3.3 中,这是循环遍历(多行)文本的每个可见Char
(即排除不可打印字符,例如 eg )的最简单、最快和最有效的方法?然后我需要根据我的计算来获取和设置每个字符的颜色。#13
TRichEdit
我试过这个:
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;
但我相信一定有更好的方法。