Expand description
Viewport geometry calculations for editor rendering.
Pure geometry: converts between byte offsets, logical/visual lines, and pixel coordinates. No DOM or Canvas dependency.
Structs§
- Rect
- Axis-aligned rectangle in pixel coordinates.
- Viewport
Layout - Computed layout measurements.
- Viewport
Metrics - Host-injected font metrics. Plain struct (parameter bag).
- Visual
Line Frame
Enums§
- Viewport
Error - Errors returned by viewport operations.
Functions§
- caret_
rect - Compute the pixel rectangle for the caret at
offset. - caret_
rect_ with_ width_ policy - gutter_
width - Compute the line-number gutter width for
total_lineslines. - hit_
test - Convert a click at pixel
(x, y)to a byte offset intext. - hit_
test_ with_ width_ policy - line_
top - Return the Y pixel coordinate for the top of
visual_line. - scroll_
to_ reveal - Compute a new
scroll_topthat reveals the caret atoffset, orNoneif already visible. - selection_
rects - Compute the pixel rectangles that cover
selection. - selection_
rects_ with_ width_ policy - visible_
line_ range - Returns
(first_visual_line, last_visual_line)visible in the viewport. - visual_
line_ frame