Check if the line is empty
Check if the line is empty
how can I check if there are characters on a specific line? or check if a specific line is empty?
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Check if the line is empty
What's an empty line? A paragraph that contains only a single empty text item.
I am not sure if the bulleted line may be considered as empty, let say that it is not.
What line do you need? If you need a line at the caret position in RichViewEdit1, the code is:
If bulleted empty lines are considered as empty, the code is:
I am not sure if the bulleted line may be considered as empty, let say that it is not.
What line do you need? If you need a line at the caret position in RichViewEdit1, the code is:
Code: Select all
var
rve: TCustomRichViewEdit;
ItemNo: Integer;
rve := RichViewEdit1.TopLevelEditor;
ItemNo := rve.CurItemNo;
IsCurrentLineEmpty :=
// this is an empty text item
(rve.GetItemStyle(ItemNo) >= 0) and (rve.GetItemText(ItemNo) = '') and
// and it starts a paragraph section
rve.IsFromNewLine(ItemNo) and
// and it is at the end of document, or the next item starts a new paragraph section
((ItemNo + 1 = rve.ItemCount) or (rve.IsFromNewLine(ItemNo + 1));
Code: Select all
var
rve: TCustomRichViewEdit;
ItemNo: Integer;
rve := RichViewEdit1.TopLevelEditor;
ItemNo := rve.CurItemNo;
IsCurrentLineEmpty :=
// this is an empty text item
(rve.GetItemStyle(ItemNo) >= 0) and (rve.GetItemText(ItemNo) = '') and
// and it starts a paragraph section, or follows after a list marker
(rve.IsFromNewLine(ItemNo) or ((ItemNo - 1 >= 0) and (rve.GetItemStyle(ItemNo - 1) = rvsListMarker))) and
// and it is at the end of document, or the next item starts a new paragraph section
((ItemNo + 1 = rve.ItemCount) or (rve.IsFromNewLine(ItemNo + 1));