GetVisualCaretOrder
Forms, interaction, Unicode
Description
Returns every caret position for the active edit in physical left-to-right order after resolving bidirectional runs
Each line is resolved independently and every returned position is aligned to an extended grapheme-cluster boundary
The same logical index can appear in more than one non-adjacent slot at a mixed-direction boundary because the two visual caret positions are physically distinct
The requested index unit changes only the reported logical indexes and does not change visual ordering
Declaration
function GetVisualCaretOrder(
IndexUnit: TPDFlibFormSelectionUnit;
out CaretIndices: TPDFlibFormCaretIndices): Integer;
Parameters
| IndexUnit | fsuUTF16CodeUnit, fsuUnicodeCodePoint or fsuGraphemeCluster |
|---|---|
| CaretIndices | Receives logical caret indexes ordered from the left edge of the visual text to the right edge |
Return value
Returns the number of visual caret slots, or zero when no edit is active or the index unit is invalid
Performance
Grapheme boundaries and resolved visual order are cached for the current edit value and direction, with binary searches used to map run boundaries
Example
var
Carets: TPDFlibFormCaretIndices;
begin
if Session.GetVisualCaretOrder(fsuGraphemeCluster, Carets) > 0 then
FirstVisualCaret := Carets[0];
end;
See also
MoveVisualCaret, SetTextDirection, GetSelectionRange, TPDFlibFormSession