Skip to main content

Crate rustaco_view

Crate rustaco_view 

Source
Expand description

Renderer-agnostic layout for the Rustaco editor.

View turns a TextModel, one editor’s selections and a viewport into a Frame: positioned text runs, selection rectangles, carets and line numbers. A frontend only draws the frame; it never measures text or walks the rope itself. Only visible lines and visible columns are laid out, so frame cost does not grow with file size.

All coordinates are CSS pixels relative to the viewport’s top-left corner, gutter included.

A model line shows as one or more rows (word wrap) or not at all (inside a fold). Vertical geometry goes through View::line_top and View::line_at_y: a HeightMap holds every line’s own height, rows times the line height, and folds are taken out on top of it.

Modules§

markdown
The little markdown that hover cards and completion documentation show: ``` fences as code blocks, and inside text code, bold and italic. Anything else stays as written. Frontends turn the blocks into their own widgets (DOM in the browser).

Structs§

FoldMarker
A fold marker in the gutter: the line heads a region that can be folded, or is folded.
Frame
One laid-out frame. Grows with features (minimap, sticky lines, zones): read its fields, do not build it.
FrameLine
One row on screen: a whole line, or one row of a wrapped line.
Guide
A vertical indentation guide in viewport coordinates.
HeightMap
LineRows
The rows of one model line: the char column each row starts at (starts[0] is 0) and the indentation, in cells, of every row after the first.
Metrics
Font measurements supplied by the frontend. #[non_exhaustive]: measuring proportional text may add to it later, so build it with Metrics::new.
MinimapBlock
A run of non-blank chars with one style, in the minimap.
MinimapFrame
The minimap: the document at a small scale beside the text, each char a block of colour, with a slider over the part the viewport shows.
Plain
A styler that leaves everything at style 0.
Rect
StyleSpan
A styled span on one line, in char columns. Spans are sorted and do not overlap.
TextRun
Consecutive chars with one style. Tabs are already expanded to spaces.
View

Constants§

INLAY_STYLE
Style id of inlay hint runs; frontends draw them muted.

Traits§

Styler
Supplies syntax or semantic styling. Text outside every span gets style 0.

Functions§

column_at_cells
Char column whose boundary is nearest to cells (fractional) on line.
indent_fold_ranges
Foldable regions from indentation: a non-blank line followed by more deeply indented lines heads a region ending at the last of them (trailing blank lines excluded). Used when no syntax tree gives better ranges, and for languages like Python where indentation is the structure.
visual_column
Cells from line start to char column column, with tabs and wide chars expanded.
wrap_line
Breaks line into rows at most width cells wide; see wrap_slice.
wrap_slice
Breaks a line (with or without its line break) into rows at most width cells wide. Rows break after a run of spaces when the row holds one, otherwise inside the word. Spaces may hang past the edge, so a row never starts with the spaces that ended the previous one. Continuation rows are indented like the line itself, unless that indentation takes half the width or more.