Skip to main content

Crate urushi

Crate urushi 

Source
Expand description

Composable styling, layout, and rendering for terminal applications.

urushi separates logical View construction, layout resolution, ANSI serialization, and output. resolve turns a view into a ResolvedView under an Available area. render then serializes that rectangle using explicit RenderSettings. render_text bypasses layout for a StyledText, preserving source tabs and line boundaries. print(), println(), eprint(), and eprintln() are the convenient text path for the process standard streams; their *_view peers resolve layout first.

§Example

use urushi::{Available, BlockStyle, Border, RenderSettings, TextStyle, View, render, resolve};

let style = BlockStyle::new().border(Border::ROUNDED).padding((0, 1));
let view = View::block(style, View::text("こんにちは, urushi!", TextStyle::new()));
let resolved = resolve(&view, Available::NONE).unwrap();

assert_eq!(render(&resolved, &RenderSettings::default()).lines().count(), 3);

Width calculations are aware of East Asian wide characters. Terminal contracts and inspection live in the workspace-independent urushi-terminal crate; arbitrary writers combine its detection with resolve, render, and std::io::Write.

Structs§

AnchoredRect
One anchor’s complete logical rectangle and its visible intersection.
Available
The area a view may occupy: an input to layout, not an afterthought.
BlockStyle
A rectangle: padding, margin, border, dimensions, alignment, and the TextStyle that fills the geometry they create.
BlockTitle
One styled line embedded in a block’s top border.
Border
The characters used to draw a box border.
Canvas
A finite drawing surface and its ordered, owned frame items.
CanvasCell
Complete content of one Canvas cell.
CanvasContext
Frame-scoped command recorder passed to super::CanvasItem::draw.
CanvasSizing
The sizing policy of one Canvas.
CellContribution
A sparse contribution; absent fields are transparent under Composition::Overlay.
ComponentTheme
Theme-derived presentations and shared role styles for common components.
Grapheme
One grapheme cluster: the smallest run of text a cell boundary may fall on.
GridStyle
A grid’s geometry: an optional Length per column and the padding its cells take.
Hyperlink
A terminal hyperlink attached to one run of text.
InvalidFillWeight
A fill weight was zero.
Key
The identity of something an application names, built from any hashable value.
LayoutError
A layout request that cannot produce finite geometry.
LineContinuations
Incidence that continues beyond a line segment’s inclusive range.
LineGlyphs
Glyphs selected by the incident directions of one line-network cell.
LineNetwork
One connected drawing whose horizontal and vertical segments form junctions.
List
Owned typed list data independent of presentation policy.
ListItem
One owned typed value and its recursive nested list items.
ListItemPresentation
Typed formatting and optional role-style overrides for List items.
ListPosition
A list item’s position among its visible siblings.
ListPresentation
Presentation policy used to compose a List into a View.
Position
A signed cell position relative to a Canvas’s top-left corner.
PositionedCell
Sparse positioned cell input.
PrintableLines
Several lines of plain text, separated by \n.
PrintableText
One line of plain text: a row of cells, every character printable.
Projection
One projected axis of a Viewport.
RenderSettings
The output features selected for one render operation.
ResolvedView
A view resolved to one rectangle of styled graphemes.
Resolver
An opt-in evaluator that reuses unchanged View evaluation across frames.
Scrollbar
Immutable semantic input for one finite-viewport position indicator.
ScrollbarGlyphs
The four glyphs used along one scrollbar orientation.
ScrollbarPresentation
Selectable visual and geometric policy for a Scrollbar.
SemanticTokens
Colors named for their display meaning rather than a rendering technology.
Sides
Spacing values for the four sides of a box.
Size
The size of a resolved rectangle, in terminal cells.
StyledGrapheme
One grapheme, the width it occupies, and its logical style.
StyledText
One text flow carrying any number of styles.
StyledTextError
A grapheme boundary between two input spans was invalid.
TabPolicy
A fixed-width replacement for one tab during text layout.
Table
Owned table data independent of presentation policy.
TableBorder
Line model used by a TablePresentation.
TableCell
Identifies one cell while a TableRowPresentation resolves its style.
TablePresentation
Presentation policy used to compose a Table into a View.
TableRowCells
A short-lived destination for the formatted cells of one row.
TableRowPosition
The visible position of one typed body row during composition.
TableRowPresentation
Typed row formatting and optional complete cell-style replacements.
TerminalBackground
An RGB background color reported by a terminal.
TerminalCapabilities
Rendering features positively confirmed by a terminal query or supplied by an explicitly configured backend.
TerminalStyle
The complete physical text style applied to terminal output.
TerminalTextStyle
A text style lowered to the terminal representation without discarding its hyperlink.
TextAttributes
A set of terminal text attributes with no duplicates or ordering.
TextSpan
One caller-authored piece of text carrying one complete style.
TextStyle
A reusable set of text styling rules.
TextTable
A direct-text Table builder that normalizes every row into owned strings.
TextTableRow
One normalized row used by Table::text for direct plain-text input.
Theme
A theme with common semantic tokens and canonical component presentations.
ThemePreset
One named built-in terminal theme.
ThemeSet
A matched light and dark theme.
Tree
Owned tree data independent of presentation policy.
TreeNode
One owned value and its recursive child nodes.
TreeNodePresentation
Typed formatting and optional text-style overrides for Tree values.
TreePresentation
Presentation policy used to compose a Tree into a View.
Underline
An underline and its optional color independent of the foreground.
UnderlineStyleSet
A set of underline shapes supported by a terminal.
Viewport
The axes one child view projects into its finite layout allocation.
VisibleRect
The part of an anchor rectangle that survived every enclosing clip.

Enums§

Align
Horizontal alignment of content within a styled block.
Axis
An axis for which a finite Canvas extent was required.
Color
A color addressable by terminal text commands.
ColorLevel
The color fidelity a terminal can display.
ColorScheme
An explicit choice between a light and dark theme.
ComponentRole
A reusable text component understood by all urushi consumers.
Composition
How one command combines its contributions with preceding commands.
InvalidTabMarker
Why a visible tab marker cannot participate in layout.
LayoutErrorKind
The input whose finite extent is missing.
Length
A box dimension: an absolute size, or a share of the remaining area.
ListRole
A semantic style role used by the List component.
Overflow
How content that does not fit its box is absorbed.
PanelRole
A framed surface: a rectangle, not a run of text.
ProjectionBoundary
How a requested projection origin behaves at a content boundary.
ScrollbarOrientation
The axis along which a Scrollbar describes a viewport.
ScrollbarRole
A semantic style role used by the Scrollbar component.
ScrollbarThumbSizing
How a ScrollbarPresentation represents the visible viewport on its track.
TableRole
A semantic cell role used by the Table component.
TextAttribute
One independently selectable terminal text attribute.
ThemeMode
The caller’s policy for selecting a light or dark theme.
TreePosition
A visible value’s position in a Tree.
TreeRole
A semantic style role used by the Tree component.
UnderlineStyle
The shape of an underline drawn by the terminal.
VerticalAlign
Vertical alignment of content within a styled block or of blocks joined side by side.
View
A fully composed, renderer-neutral terminal view.

Traits§

BlockThemeRole
A typed role that resolves a BlockStyle from a Theme.
CanvasItem
Immutable frame data that records drawing commands after Canvas size is known.
TableRow
Canonically formats one typed value as a table row.
TextThemeRole
A typed role that resolves a TextStyle from a Theme.

Functions§

alphabet_enumerator
Draws an uppercase alphabetic marker (A through Z, then AA, …).
arabic_enumerator
Draws a one-based Arabic numeral marker.
asterisk_enumerator
Draws an asterisk marker.
bullet_enumerator
Draws the default bullet marker.
dash_enumerator
Draws a dash marker.
eprint
Writes styled text to stderr without resolving layout or adding a newline.
eprint_view
Resolves view for stderr and writes it without a trailing newline.
eprintln
Writes styled text to stderr without resolving layout, then adds a newline.
eprintln_view
Resolves view for stderr and writes it with a trailing newline.
measure
Returns the intrinsic rectangle view occupies: its size when no area bounds it.
print
Writes styled text to stdout without resolving layout or adding a newline.
print_view
Resolves view for stdout and writes it without a trailing newline.
println
Writes styled text to stdout without resolving layout, then adds a newline.
println_view
Resolves view for stdout and writes it with a trailing newline.
render
Serializes view using the selected output features.
render_text
Serializes styled source text without resolving terminal-cell layout.
resolve
Resolves view into one rectangle sized under available.
roman_enumerator
Draws an uppercase Roman numeral marker through 3999.
try_measure
Tries to measure a view, reporting any required finite extent that is not established within the tree.

Type Aliases§

ListEnumerator
Produces the single-line marker drawn before one visible list item.

Derive Macros§

TableRow
Derives urushi’s canonical row formatter for a struct.