Extract block text and put it back

General TRichView support forum. Please post your questions here
Post Reply
AutoCorect
Posts: 84
Joined: Sun Dec 16, 2007 7:15 pm

Extract block text and put it back

Post by AutoCorect »

Sorry for my english...

I want to extract a text-only fragment from a certain position in a RTF (any number of items), change this text, and put it back.
2 questions:

1. How can I know that in TRichViewEdit it's a difference between:

Text1 [Objects] Text2

and

Text1 [Objects]
Text2

In a normal text the difference is #13#10 in Windows and #13 in Linux.
I ask because the final text will be in the first case "Text1 Text2" and in the second case "Text1#13#10Text2".

2. What function could I use to keep the format of the text in sync with my modifications?
Example:

"Hello [bold]world[nobold]" >> "Hi [bold]world[nobold]".


Thanks for your reply...
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

In TRichView, document consists of items (text items, pictures, etc.). Items are indexed from 0 to rv.ItemCount-1.
If the i-th item starts a new line, rv.IsFromNewLine(i) returns True.

To keep text attributes, copy fragment either in RTF or (better) in RVF format. Other objects in the fragment (such as pictures) will be copied too.
(SaveRVFToStream(..., True), LoadRVFFromStream in another RichView, modify, copy it back).
But may be you can modify text directly in the source control (using SetItemTextEd or SetItemText)
Post Reply