Skip to main content

Module style

Module style 

Source
Expand description

A toolkit-neutral text style — the seam that lets one document model drive any frontend.

The WYSIWYG builder (crate::wysiwyg) tags each rendered glyph with one of these instead of a ratatui::Style or a gpui::TextStyle, so the caret model and the AST→glyph layout stay free of any GUI/TUI dependency.

What core records is what a glyph is, never what color to paint it: a Role (heading, code, link, a list bullet, …) plus the portable emphasis the author actually wrote (**bold**, *em*, {+ins+}, {-del-}). Palette is presentation, and presentation belongs to the frontend — a terminal tells a heading from body text by color because color is all it can vary, while a GUI varies size and font instead. So each frontend maps a Role to its own look: leaf-tui turns it into terminal colors, leaf-gpui into an Hsla plus a font size and family. Core stays out of that argument.

The one place core does carry a paint value is the presentation vocabulary the author writes by hand: a data-size is a name (SizeStep) where a name will do and a measurement (FontSize::Points) where the author needed exactness, and the open type beside each closed enum — FontSize, LineHeight, TextColor, FontFace — is where the two meet. A name outlives a theme change and a value does not, which is the trade the author makes knowingly; see docs/proposals/exact-presentation-values.md.

Structs§

FaceId
A named family’s id on a glyph — what FaceRef::Named carries and FaceTable::name reads back.
FaceTable
Every named family a crate::wysiwyg::VisualMap draws, by the id its glyphs carry — the side table that lets Style stay Copy while a face name stays a String.
Hundredths
A number a presentation value carries, in hundredths — 14 points is 1400, a ratio of 1.3 is 130.
Style
A glyph’s style: a typographic Role plus the compositional emphasis flags the author wrote. Deliberately no color — that is a frontend’s call, keyed on the Role. Builder methods (.bold, .italic, …) mirror the shape of ratatui’s Style so the WYSIWYG builder reads the same as it did before the split.

Enums§

Align
How a block’s lines are set across the measure — the one presentation property an author reaches for before any other, and the only one of the six whose vocabulary is a class rather than a data- key.
Baseline
Which line a glyph sits on relative to the text around it.
FaceRef
The face a glyph is set in — FontFace’s Copy half, so that a Style stays Copy and Eq and can be stamped on every glyph and compared for run-merging.
FontFace
The face a run is set in: one of CSS’s four generics, or the family the author named.
FontFamily
The face a run is set in — CSS’s generic families, less fantasy and system-ui, neither of which an author asks for.
FontSize
How large a run is set: a SizeStep relative to the text around it, or the point size the author asked for.
LineHeight
How far apart a block’s lines are set: a LineSpacing from the menu’s three, or the ratio the author asked for. FontSize’s peer, one property along, and with no unit at all — a line height is a multiple.
LineSpacing
How far apart a block’s lines are set, as a multiple of the theme’s own line height — the spacing menu every word processor has, less the single spacing that is absence.
MarkColor
The colour an author named on a highlight — the closed vocabulary twig records as a mark node’s data-color, one variant per circle emoji the ==🔴 text== spelling recognises.
Role
What a glyph is, typographically — the semantic role a frontend maps to its own presentation. Mutually exclusive per glyph (a glyph is a heading, or a link, or body text — not two at once); the compositional emphasis a run can also carry lives in Style’s bold/italic/underline/strikethrough flags alongside this.
SizeStep
How large a run is set relative to the text around it — CSS’s <absolute-size> keyword set with medium removed, because medium is absence.
TextColor
A run’s foreground colour: one of the seven MarkColor names, or the RGB triple the author asked for.
Token
What a glyph in a fenced code block is to the language it is written in — the syntax-highlighting vocabulary, one level down from Role.