Page 1 of 1
How to determine if Cursor is in the first or last line?
Posted: Fri Dec 02, 2005 9:03 pm
by Guest
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?
Posted: Sat Dec 03, 2005 9:57 am
by Sergey Tkachenko
Line (lines depend on word wrapping, they are changed if you resize the editor)? Or paragraph?
Posted: Sun Dec 04, 2005 10:39 pm
by Guest
Sergey,
I've digged through the help file, but can't find any helpful reference to the line property (or event).
Can you please give a short expression to determin:
a.) caret is in the first line of the document
b.) caret is in the last line of the document
Thanks
Posted: Mon Dec 05, 2005 6:59 am
by Sergey Tkachenko
I am still not sure what do you mean by lines.
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));
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":
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;
Posted: Tue Dec 06, 2005 3:00 pm
by Guest
Sergey, thanks.
example 1.) is exactly what I was looking for.
Problem solved ...