etui/span
Types
A single terminal row composed of styled spans.
pub type Line {
Line(spans: List(Span), alignment: text.Alignment)
}
Constructors
-
Line(spans: List(Span), alignment: text.Alignment)
A styled text fragment: string content + display style + optional hyperlink.
pub type Span {
Span(
content: String,
fg: style.Color,
bg: style.Color,
modifier: style.Modifier,
link: String,
)
}
Constructors
-
Span( content: String, fg: style.Color, bg: style.Color, modifier: style.Modifier, link: String, )Arguments
- link
-
OSC 8 hyperlink URI. Empty string = no link.
Values
pub fn line_aligned(
spans: List(Span),
alignment: text.Alignment,
) -> Line
Line from spans with explicit alignment.
pub fn line_plain(content: String) -> Line
Line with a single unstyled string, left-aligned.
pub fn render_line(
buf: buffer.Buffer,
pos: geometry.Position,
l: Line,
max_width: Int,
) -> buffer.Buffer
Render a line into the buffer at pos, clipped to max_width cells.
Each span is drawn with its own fg/bg/modifier. Spans beyond max_width
are silently dropped; a span that straddles the boundary is truncated.
The line’s alignment field shifts the start position within the available width.
pub fn span_italic(content: String) -> Span
Italic span (default colors + italic modifier).
pub fn span_link(content: String, uri: String) -> Span
Span with an OSC 8 clickable hyperlink. Terminals that support OSC 8 (iTerm2, Kitty, VTE, Windows Terminal) will render the text as a clickable link. Others display it as plain text.
span.span_link("docs.gleam.run", "https://docs.gleam.run")
pub fn span_modifier(sp: Span, modifier: style.Modifier) -> Span
Add a modifier to a span.
pub fn span_plain(content: String) -> Span
Span with default terminal colors and no modifier.
pub fn span_styled(content: String, s: style.Style) -> Span
Span with explicit style applied.
pub fn span_underline(content: String) -> Span
Underline span (default colors + underline modifier).