Hi
Can somebody help me?
How can you detect that the cursor is positioned on the first character of a line (with or without a bullet)?
Thanks in advance
TdbRichViewEdit cursor position
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: TdbRichViewEdit cursor position
Do you mean paragraph?
If yes, the code is
If you want to check not only beginnings of paragraphs, but also breaks added by Shift+Enter, change IsParaStart to IsFromNewLine.
If you want to check a screen line (that depends on word wrapping), I can post a code, but it requires using undocumented methods.
If yes, the code is
Code: Select all
function IsAtTheBeginningOfParagraph(rve: TCustomRichViewEdit): Boolean;
var
ItemNo, Offs: Integer;
begin
rve := rve.TopLevelEditor;
// caret position
ItemNo := rve.CurItemNo;
Offs := rve.OffsetInCurItem;
// is it at the beginning of an item?
Result := Offs = rve.GetOffsBeforeItem(ItemNo);
if not Result then
exit;
// is this item at the beginning of paragraph?
Result := rve.IsParaStart(ItemNo);
if Result then
exit;
// this is definitely not the first item. maybe it is after a list marker?
Result := rve.GetItemStyle(ItemNo-1) = rvsListMarker;
end;
If you want to check a screen line (that depends on word wrapping), I can post a code, but it requires using undocumented methods.