Page 1 of 1

InsertStringTag with RC

Posted: Wed Jul 25, 2007 8:11 am
by Yann
Hello,

I use the method "InsertStringTag" to insert fields. It works great.

Is there a method to insert strings with RC (#13#10) ?

Thanks
Yann

Posted: Wed Jul 25, 2007 12:06 pm
by Sergey Tkachenko
InsertText, but it inserts text with empty (zero) tags.

Posted: Wed Jul 25, 2007 12:34 pm
by Yann
will you implement this functionality ?
(an InsertText method with Tag<>0)

Posted: Thu Jul 26, 2007 6:09 pm
by Sergey Tkachenko
No, sorry. Because it's rarely needed.

You can use this procedure (assuming that rvoTagsArePChars in rve.Options):

Code: Select all

procedure InsertTextTag(rve: TCustomRichViewEdit; const Text,  Tag: String);
var SL: TStringList;
  i: Integer;
begin
  SL := TStringList.Create;
  SL.Text := Text;
  rve.BeginUpdate;
  for i := 0 to SL.ItemCount-1 do
     rve.InsertStringTag(SL[i], Tag);
    // for older versions of TRichView: rve.InsertStringTag(SL[i], Integer(StrNew(PChar(Tag))));
  rve.EndUpdate;
  SL.Free;
end;
If you use TRichView version older than 1.9.22, remove calls to BeginUpdate and EndUpdate.

---

Update 2011-Oct-22: changed for compatibility with TRichView 13.3+