Get line types in code
Posted: Thu Dec 30, 2021 11:06 pm
Hi Sergey,
I've been working on this for a long time and just can't seem to get it to work beyond a very simple setup. What I want is to be able to figure out the type of lines in my paragraphs. I'm using that to determine what I display in my line numbers gutter. I'll put an image in to illustrate:
Line 1 simple setup I can do with the following code, and this is all I'm using at the present time:
This works OK but is very basic. I either show a return symbol if the line is not a normal para, or the line number if the para is normal. This code works no matter what text format or image I have the caret on. And it works whether the line is empty or not.
How can I determine if the caret is in a line that ends with a hard return (lines 2 - 4 above), is word wrapped (lines 5 - 7), is empty (lines 8 and 10), or a line that is the last line in a word wrapped para (line 7)?
Note that I loop through visible drawitems, not regular items when I parse the text. This needs to work even if there is formatted text and/or images within the text. Those 2 things have given me a lot of trouble. I can sometimes get code to work but as soon as I select a formatted word or image, it stops working.
Thanks Sergey. Any ideas appreciated!
Stan
I've been working on this for a long time and just can't seem to get it to work beyond a very simple setup. What I want is to be able to figure out the type of lines in my paragraphs. I'm using that to determine what I display in my line numbers gutter. I'll put an image in to illustrate:
Line 1 simple setup I can do with the following code, and this is all I'm using at the present time:
Code: Select all
memo.RVData.ExpandToPara( DItem.ItemNo, DItem.ItemNo, i, X ); //i is para start item, X is para end item
if (memo.GetLineNo(i,0) <> memo.GetLineNo(DItem.ItemNo, DItem.Offs)) then //only way I can keep it from overwriting normal numbers
PBox.Canvas.TextOut( r.Left , r.Top, #$21B5) //anything other than normal para
else
PBox.Canvas.TextOut( r.Left , r.Top, IntToStr(LineNumber)); //normal para
How can I determine if the caret is in a line that ends with a hard return (lines 2 - 4 above), is word wrapped (lines 5 - 7), is empty (lines 8 and 10), or a line that is the last line in a word wrapped para (line 7)?
Note that I loop through visible drawitems, not regular items when I parse the text. This needs to work even if there is formatted text and/or images within the text. Those 2 things have given me a lot of trouble. I can sometimes get code to work but as soon as I select a formatted word or image, it stops working.
Thanks Sergey. Any ideas appreciated!
Stan