It seems that SelStart and SelLength can be set but when text is assigned to SelText its causes:
QTextCursor::setPosition: Position '11' out of range
Tried with different order of those 3 , but SelText assign causes the error.
procedure AddColorStr(s: string; const col: TColor = clBlack; const NewLine: boolean = true);
begin
with WsjtxMemo do
begin
if NewLine then
begin
writeln('---------------------print NL-----------------');
Lines.Add('');
Lines.Delete(Lines.Count - 1); // avoid double line spacing
end;
writeln('---------------------print text-----------------');
writeln('textlen',Length(s));
SelStart := length(Text);
writeln('selstart ',SelStart);
SelLength := length(s);
writeln('sellen ',SelLength);
SelText := s;
writeln('seltext ',s);
SetRangeColor(SelStart, SelLength, col);
end;
end;
I wonder why there is not a function that you could add one char (or string) to existing text without CR+NL.
And if that exist why just change first FontParameters to desired color and then just add wanted char(s) to end of the existing text (that then appeared with new selected color)
Why this coloring has to go via add text, select it, color it like in wiki's example.