Skip to content
pixi-silk
GitHub repository
Function

caretVisual

import { caretVisual } from 'pixi-silk/text';
function caretVisual(
   layout: TextLayout, 
   index: number, 
   dir: number, 
   upstream?: boolean, 
   isStop?: (index: number) => boolean, 
   leading?: boolean
): CaretStop | null;

The caret stop one step left (dir -1) or right (1) on screen from index, on the same line. In a line that mixes directions this follows what the eye sees, not the order of the text. The arrow keys then move the way they point, and a caret can reach both places an offset has where the direction changes. Returns null on a line that runs left to right only, or at the line’s edge: step through the text instead there. isStop filters the stops, for example to grapheme or word boundaries.

Parameters#

ParameterTypeDefault value
layoutTextLayoutundefined
indexnumberundefined
dirnumberundefined
upstreambooleanfalse
isStop?(index: number) => booleanundefined
leading?booleanfalse

Returns#

CaretStop | null