i've tried curitemno=0 and curitemno=itemcount-1, but this is not working, if there are fonts changed or other formattings in that line.
I'd like to detect the presence of the cursor in the first or last line of the formatted document.
How can that be done?
How to determine if Cursor is in the first or last line?
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I am still not sure what do you mean by lines.
So I am giving two answers.
1) If you really mean "lines":
Lines depend on word wrapping, so when user resizes the editor window, results will be different. The method above is simple, but not very efficient. If you need to call this code often, I can give alternative version.
2) If you mean "paragraphs":
So I am giving two answers.
1) If you really mean "lines":
Code: Select all
rve.GetCurrentLineCol(Line, Col);
InTheFirstLine := (rve.InplaceEditor=nil) and (Line=1);
InTheLastLine := (rve.InplaceEditor=nil) and (Line=rve.GetLineNo(rve.ItemCount-1, rve.GetOffsAfterItem(rve.ItemCount-1));
2) If you mean "paragraphs":
Code: Select all
if rve.TopLevelEditor<>nil then
InTheFirstPara := False;
InTheLastPara := False;
exit;
end;
ItemNo := rve.CurItemNo;
while (ItemNo>0) and not rve.IsParaStart(ItemNo) do
dec(ItemNo);
InTheFirstPara := ItemNo=0;
ItemNo := rve.CurItemNo+1;
while (ItemNo<rve.ItemCount) and not rve.IsParaStart(ItemNo) do
inc(ItemNo);
InTheLastPara := ItemNo=rve.ItemCount;