Page 1 of 1

quantity of paragraphes in RichEdit

PostPosted: June 5th, 2006, 5:08 am
by N.Y.P.D.
How to get quantity of paragraphes in Delphi RichEdit. Or When I walk through the rows of RichEdit, how to detect that I jump from one paragraph to another one.
I mean:
Code: Select all
var
    s : String;
for i := 0 to ARichEdit.Lines.Count - 1 do  // walking through the rows
begin
    s := ARichEdit.Lines[i]; // Here ARichEdit.Lines[i] belongs to   
                                      //           paragraph   number 5, for exaple;
            // How to detect that ARichEdit.Lines[i + 1] will 
                                      //           belong to paragraph number 6???

 end;

PostPosted: June 5th, 2006, 10:22 am
by kokkoras
Have you tried to detect the #10#13 (or it is #13#10) combination on chars? These are the line feed and carriage return symbols uded to designate a paragraph change.

PostPosted: June 5th, 2006, 12:06 pm
by N.Y.P.D.
kokkoras wrote:Have you tried to detect the #10#13 (or it is #13#10) combination on chars? These are the line feed and carriage return symbols uded to designate a paragraph change.

There is no such
#10#13 (or it is #13#10) combination on chars in ARichEdit.Lines[row]. It does not contained even in whole paragraph and text, if text read from one row to another. In RichEdit next paragraph detected somehow magestic, but I don't know how.

PostPosted: June 5th, 2006, 4:28 pm
by Kambiz
An empty line (e.g. RichEdit.Lines[index]) indicates the paragraph boundary.

paragraph boundary

PostPosted: June 9th, 2006, 7:04 am
by N.Y.P.D.
Kambiz wrote:An empty line (e.g. RichEdit.Lines[index]) indicates the paragraph boundary.

You mean RichEdit.Lines[index]='', when you saing "empty line"? If so, then empty line doesn't indicates paragraph boundary. I checked it. A text can have a lot of boundaries and don't contain empty line.

Re: paragraph boundary

PostPosted: June 9th, 2006, 1:53 pm
by kokkoras
N.Y.P.D. wrote:
Kambiz wrote:An empty line (e.g. RichEdit.Lines[index]) indicates the paragraph boundary.

You mean RichEdit.Lines[index]='', when you saing "empty line"? If so, then empty line doesn't indicates paragraph boundary. I checked it. A text can have a lot of boundaries and don't contain empty line.


Officialy, change of paragraph is LF+CR (line feed + carriage return). If this is not the case then change of paragraph should be considered whatever you like. Usually, in plain text content, it is the empty line. In plain text there is still LF+CR but you may choose to use the empty line which is quite common. You can detect the empty line by reading the content of a line and count the mumber of chars in it.

Re: paragraph boundary

PostPosted: June 13th, 2006, 5:20 am
by N.Y.P.D.
kokkoras wrote:
N.Y.P.D. wrote:
Kambiz wrote:An empty line (e.g. RichEdit.Lines[index]) indicates the paragraph boundary.

You mean RichEdit.Lines[index]='', when you saing "empty line"? If so, then empty line doesn't indicates paragraph boundary. I checked it. A text can have a lot of boundaries and don't contain empty line.


Officialy, change of paragraph is LF+CR (line feed + carriage return). If this is not the case then change of paragraph should be considered whatever you like. Usually, in plain text content, it is the empty line. In plain text there is still LF+CR but you may choose to use the empty line which is quite common. You can detect the empty line by reading the content of a line and count the mumber of chars in it.

In my case ARichEdit.PlainText := false, because I open there RTF and DOC files. How to detect paragraph boundary here?

PostPosted: June 13th, 2006, 6:03 am
by kokkoras
Try parsing a small example of your content, char-by-char, to see the ASCII codes used at the point you asume a paragraph change.