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§
- Anchored
Rect - One anchor’s complete logical rectangle and its visible intersection.
- Available
- The area a view may occupy: an input to layout, not an afterthought.
- Block
Style - A rectangle: padding, margin, border, dimensions, alignment, and the
TextStylethat fills the geometry they create. - Block
Title - 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.
- Canvas
Cell - Complete content of one Canvas cell.
- Canvas
Context - Frame-scoped command recorder passed to
super::CanvasItem::draw. - Canvas
Sizing - The sizing policy of one Canvas.
- Cell
Contribution - A sparse contribution; absent fields are transparent under
Composition::Overlay. - Component
Theme - 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.
- Grid
Style - A grid’s geometry: an optional
Lengthper column and the padding its cells take. - Hyperlink
- A terminal hyperlink attached to one run of text.
- Invalid
Fill Weight - A fill weight was zero.
- Key
- The identity of something an application names, built from any hashable value.
- Layout
Error - A layout request that cannot produce finite geometry.
- Line
Continuations - Incidence that continues beyond a line segment’s inclusive range.
- Line
Glyphs - Glyphs selected by the incident directions of one line-network cell.
- Line
Network - One connected drawing whose horizontal and vertical segments form junctions.
- List
- Owned typed list data independent of presentation policy.
- List
Item - One owned typed value and its recursive nested list items.
- List
Item Presentation - Typed formatting and optional role-style overrides for List items.
- List
Position - A list item’s position among its visible siblings.
- List
Presentation - Presentation policy used to compose a
Listinto aView. - Position
- A signed cell position relative to a Canvas’s top-left corner.
- Positioned
Cell - Sparse positioned cell input.
- Printable
Lines - Several lines of plain text, separated by
\n. - Printable
Text - One line of plain text: a row of cells, every character printable.
- Projection
- One projected axis of a
Viewport. - Render
Settings - The output features selected for one render operation.
- Resolved
View - 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.
- Scrollbar
Glyphs - The four glyphs used along one scrollbar orientation.
- Scrollbar
Presentation - Selectable visual and geometric policy for a
Scrollbar. - Semantic
Tokens - 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.
- Styled
Grapheme - One grapheme, the width it occupies, and its logical style.
- Styled
Text - One text flow carrying any number of styles.
- Styled
Text Error - 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.
- Table
Border - Line model used by a
TablePresentation. - Table
Cell - Identifies one cell while a
TableRowPresentationresolves its style. - Table
Presentation - Presentation policy used to compose a
Tableinto aView. - Table
RowCells - A short-lived destination for the formatted cells of one row.
- Table
RowPosition - The visible position of one typed body row during composition.
- Table
RowPresentation - Typed row formatting and optional complete cell-style replacements.
- Terminal
Background - An RGB background color reported by a terminal.
- Terminal
Capabilities - Rendering features positively confirmed by a terminal query or supplied by an explicitly configured backend.
- Terminal
Style - The complete physical text style applied to terminal output.
- Terminal
Text Style - A text style lowered to the terminal representation without discarding its hyperlink.
- Text
Attributes - A set of terminal text attributes with no duplicates or ordering.
- Text
Span - One caller-authored piece of text carrying one complete style.
- Text
Style - A reusable set of text styling rules.
- Text
Table - A direct-text Table builder that normalizes every row into owned strings.
- Text
Table Row - One normalized row used by
Table::textfor direct plain-text input. - Theme
- A theme with common semantic tokens and canonical component presentations.
- Theme
Preset - One named built-in terminal theme.
- Theme
Set - A matched light and dark theme.
- Tree
- Owned tree data independent of presentation policy.
- Tree
Node - One owned value and its recursive child nodes.
- Tree
Node Presentation - Typed formatting and optional text-style overrides for Tree values.
- Tree
Presentation - Presentation policy used to compose a
Treeinto aView. - Underline
- An underline and its optional color independent of the foreground.
- Underline
Style Set - A set of underline shapes supported by a terminal.
- Viewport
- The axes one child view projects into its finite layout allocation.
- Visible
Rect - 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.
- Color
Level - The color fidelity a terminal can display.
- Color
Scheme - An explicit choice between a light and dark theme.
- Component
Role - A reusable text component understood by all urushi consumers.
- Composition
- How one command combines its contributions with preceding commands.
- Invalid
TabMarker - Why a visible tab marker cannot participate in layout.
- Layout
Error Kind - The input whose finite extent is missing.
- Length
- A box dimension: an absolute size, or a share of the remaining area.
- List
Role - A semantic style role used by the List component.
- Overflow
- How content that does not fit its box is absorbed.
- Panel
Role - A framed surface: a rectangle, not a run of text.
- Projection
Boundary - How a requested projection origin behaves at a content boundary.
- Scrollbar
Orientation - The axis along which a
Scrollbardescribes a viewport. - Scrollbar
Role - A semantic style role used by the Scrollbar component.
- Scrollbar
Thumb Sizing - How a
ScrollbarPresentationrepresents the visible viewport on its track. - Table
Role - A semantic cell role used by the Table component.
- Text
Attribute - One independently selectable terminal text attribute.
- Theme
Mode - The caller’s policy for selecting a light or dark theme.
- Tree
Position - A visible value’s position in a Tree.
- Tree
Role - A semantic style role used by the Tree component.
- Underline
Style - The shape of an underline drawn by the terminal.
- Vertical
Align - Vertical alignment of content within a styled block or of blocks joined side by side.
- View
- A fully composed, renderer-neutral terminal view.
Traits§
- Block
Theme Role - A typed role that resolves a
BlockStylefrom aTheme. - Canvas
Item - Immutable frame data that records drawing commands after Canvas size is known.
- Table
Row - Canonically formats one typed value as a table row.
- Text
Theme Role - A typed role that resolves a
TextStylefrom aTheme.
Functions§
- alphabet_
enumerator - Draws an uppercase alphabetic marker (
AthroughZ, thenAA, …). - 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
viewfor stderr and writes it without a trailing newline. - eprintln
- Writes styled text to stderr without resolving layout, then adds a newline.
- eprintln_
view - Resolves
viewfor stderr and writes it with a trailing newline. - measure
- Returns the intrinsic rectangle
viewoccupies: its size when no area bounds it. - Writes styled text to stdout without resolving layout or adding a newline.
- print_
view - Resolves
viewfor stdout and writes it without a trailing newline. - println
- Writes styled text to stdout without resolving layout, then adds a newline.
- println_
view - Resolves
viewfor stdout and writes it with a trailing newline. - render
- Serializes
viewusing the selected output features. - render_
text - Serializes styled source text without resolving terminal-cell layout.
- resolve
- Resolves
viewinto one rectangle sized underavailable. - 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§
- List
Enumerator - Produces the single-line marker drawn before one visible list item.
Derive Macros§
- Table
Row - Derives urushi’s canonical row formatter for a struct.