var
i: Integer;
c: Char;
cord: Integer;
...
i := -1;
for c in RichEdit1.Text do
begin
Inc(i);
cord := ord(c);
if (cord = 13) then
Dec(i);
if (cord >= 32) and (not ((cord > 126) and (cord < 161))) then
begin
// do your stuff here, for example exchanging red and green colors:
RichEdit1.SelStart := i;
RichEdit1.SelLength := 1;
if RichEdit1.SelAttributes.Color = clGreen then
RichEdit1.SelAttributes.Color := clRed
else if RichEdit1.SelAttributes.Color = clRed then
RichEdit1.SelAttributes.Color := clGreen;
end;
end;
|