CursorCalculator class
Cursor position calculator.
Converts source code offset (cursorOffset) to pixel coordinates on the canvas, based on the node position information recorded in LayoutMap.
Algorithm:
- Find the deepest node in LayoutMap containing cursorOffset.
- For leaf nodes: calculate the exact X position within the node by character ratio interpolation.
- For compound nodes (Fraction/Script/Root etc.): locate the sourceRange of the substructure, and use the visual area of the substructure within the compound node for more precise positioning.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
calculate(
{required int cursorOffset, required LayoutMap layoutMap, required double horizontalPadding, required double verticalPadding}) → CursorPosition? - Calculates the pixel position of the cursor.
-
hitTestToOffset(
{required double px, required double py, required LayoutMap layoutMap, required double horizontalPadding, required double verticalPadding, required int textLength}) → int - Hit-test: Converts canvas coordinates to a source code offset.