Page 1 of 1

Stripping unwanted returns

Posted: Thu May 31, 2007 12:35 pm
by martindholmes
Hi there,

I'm trying to code a routine which will deal with the extra return characters in text which is copy/pasted from an email. Email programs usually hard-wrap text at about 80 characters. I can assume that a single return which is not followed by whitespace or another return is a hardwrap that should be removed, so that in this text:

This is
a paragraph.
This is a
second paragraph.

This is a third paragraph.

The first and third linebreaks can be removed.

This is easy to do with plain text, but I'm not sure how to approach it in the context of a TRichViewEdit, since each line will be a "paragraph"; I guess what I need to do is to find any paragraph which:

-is not empty
-does not start with whitespace, and
-is not preceded by an empty paragraph

and then "merge" it with the preceding paragraph. Has anyone done anything like this before with TRichViewEdit, and if so, can you suggest an approach?

All help appreciated,
Martin

Posted: Thu May 31, 2007 1:11 pm
by Sergey Tkachenko
I hope these code samples will be useful for you
http://www.trichview.com/forums/viewtop ... =6701#6701

Posted: Thu May 31, 2007 2:47 pm
by martindholmes
That's great! Exactly what I need.

All the best,
Martin

Posted: Mon Jun 04, 2007 12:58 pm
by martindholmes
None of those functions does exactly what I need to do, so I have to write my own based on them. To do that, I need to understand a couple of undocumented things. Could you help with these?

SaveAsPrev

rvbpFullWidth

In my case, the linebreaks I want to remove are those which are not preceded by an empty line, and do not start with whitespace (indicating a paragraph indent). In other words:

This line break should
be removed.

However, the preceding ones shouldn't.
And the one at the beginning of this line shouldn't.

Cheers,
Martin

Posted: Mon Jun 04, 2007 6:10 pm
by Sergey Tkachenko
rbpfullwidth is a bool property of item. it is true for breaks and tables. this item must start a new line, and the item after it too.

sameasprev is a bool property too, it is true if this item continues the paragraph.