TRichViewEdit - Getting at the text

General TRichView support forum. Please post your questions here
Post Reply
Graham
Posts: 64
Joined: Sun Jan 27, 2013 7:51 pm
Location: Berkshire U.K.

TRichViewEdit - Getting at the text

Post by Graham »

I have typed some text into the RichEdit component. The text is of various styles. Now I need to get at the text and process it.
I see that I can use GetItem GetItemText, GetItemStyle GetItemTag etc. to get at each portion of text.

But how do I know if a particular item has a "Hard Carriage Return" at the end of it?
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

If rv.IsFromNewLine(i)=True, the i-th item starts a new line (so, it i>0, there is a "carriage return" before it.

PS: there are two kinds of line breaks: starting a new paragraph (IsParaStart(i)=True, and IsFromNewLine(i)=True), and starting a line inside a paragraph (IsParaStart(i)=False, but IsFromNewLine(i)=True). But for working with a plain text distinguishing these line breaks is not necessary, so you can use IsFromNewLine only

PPS: There are functions returning all text.
1) GetAllText from RVGetTextW.pas (Unicode version) and RVGetText.pas (non-Unicode version). See http://www.trichview.com/help/idh_rvgettext.html
2) RVGetTextRange(rv, 0, RVGetTextLength(rv)) from RVLinear.pas . http://www.trichview.com/help/idh_rvlinear.html This function returns a text string having 1:1 corresponsence to the original document (knowing the character index, you can find the position in the document, and vice versa).
Post Reply