## quantity of paragraphes in RichEdit

Please discuss general Delphi programming topics here.

### quantity of paragraphes in RichEdit

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 rowsbegin    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;
N.Y.P.D.
N.Y.P.D.
Active Member

Posts: 13
Joined: May 15th, 2006, 1:14 pm
Location: Russia Tver

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.
Fotis

kokkoras
Moderator

Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

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.
N.Y.P.D.
N.Y.P.D.
Active Member

Posts: 13
Joined: May 15th, 2006, 1:14 pm
Location: Russia Tver

An empty line (e.g. RichEdit.Lines[index]) indicates the paragraph boundary.
Kambiz

Kambiz

Posts: 2428
Joined: March 7th, 2003, 7:10 pm

### paragraph boundary

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.
N.Y.P.D.
N.Y.P.D.
Active Member

Posts: 13
Joined: May 15th, 2006, 1:14 pm
Location: Russia Tver

### Re: paragraph boundary

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.
Fotis

kokkoras
Moderator

Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

### Re: paragraph boundary

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?
N.Y.P.D.
N.Y.P.D.
Active Member

Posts: 13
Joined: May 15th, 2006, 1:14 pm
Location: Russia Tver

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.
Fotis

kokkoras
Moderator

Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece