Enum TextAffinity
Which side of a position a caret belongs to where one index has two places: at a line wrap or a bidi boundary.
public enum TextAffinity
Fields
Downstream = 0With the character after the index: the start of the next line at a wrap.
Upstream = 1With the character before the index: the end of the previous line at a wrap.
Examples
// A click: the nearest caret position, then where to draw the caret.
TextPosition position = layout.HitTest(new System.Numerics.Vector2(40, 30));
Caret caret = layout.GetCaret(position);
CaretLine bar = caret.Primary; // x, top and bottom; Secondary at a bidi boundary
// Arrow keys: logical moves, and line moves that keep the column.
TextPosition right = layout.MoveCaret(position, CaretMove.NextGrapheme);
TextPosition down = layout.MoveCaret(position, CaretMove.LineDown, preferredX: bar.X);
// A selection: rectangles to fill, one per visually contiguous piece on each line.
IReadOnlyList<TextBounds> highlight = layout.GetSelectionRects(position.Index, down.Index);
Egami.Fonts.Unicode.TextSegment word = layout.GetWordBoundary(position.Index); // double-click