Package: pango

Function pango:layout-move-cursor-visually

Lambda List

pango:layout-move-cursor-visually (layout strong index trailing direction)

Syntax

(pango:layout-move-cursor-visually layout strong index trailing direction) => new-index, new-trailing

Arguments

layout -- a pango:layout object
strong -- a boolean whether the moving cursor is the strong cursor or the weak cursor, the strong cursor is the cursor corresponding to text insertion in the base direction for the layout
index -- an integer for the byte index of the grapheme for the old index
trailing -- an integer, if 0, the cursor was at the trailing edge of the grapheme indicated by index, if > 0, the cursor was at the leading edge
direction -- an integer for the direction to move cursor, a negative value indicates motion to the left
new-index -- an integer for the new cursor byte index, a value of -1 indicates that the cursor has been moved off the beginning of the Pango layout, a value of G_MAXINT indicates that the cursor has been moved off the end of the Pango layout
new-trailing -- an integer for the number of characters to move forward from the location returned for new-index to get the position where the cursor should be displayed, this allows distinguishing the position at the beginning of one line from the position at the end of the preceding line, new-index is always on the line where the cursor should be displayed

Details

Computes a new cursor position from an old position and a count of positions to move visually. If direction is positive, then the new strong cursor position will be one position to the right of the old cursor position. If direction is negative, then the new strong cursor position will be one position to the left of the old cursor position.

In the presence of bidirectional text, the correspondence between logical and visual order will depend on the direction of the current run, and there may be jumps when the cursor is moved off of the end of a run.

Motion here is in cursor positions, not in characters, so a single call to the pango:layout-move-cursor-visually function may move the cursor over multiple characters when multiple characters combine to form a single grapheme.
 

See also

2025-2-15