etui/widgets/paragraph

Types

Word-wrapping text block with alignment and styling.

pub type Paragraph {
  Paragraph(
    text: String,
    alignment: text.Alignment,
    fg: style.Color,
    bg: style.Color,
    modifier: style.Modifier,
  )
}

Constructors

Paragraph backed by styled span lines rather than a plain string. Use paragraph_new_lines to construct, render_lines_styled to render.

pub type SpanParagraph {
  SpanParagraph(lines: List(span.Line))
}

Constructors

Values

pub fn paragraph_new(text: String) -> Paragraph

New paragraph with left-aligned text and default colors.

pub fn paragraph_new_lines(
  lines: List(span.Line),
) -> SpanParagraph

Build a SpanParagraph from a list of span.Line values.

paragraph.paragraph_new_lines([
  span.line_new([span.span_plain("normal "), span.span_styled("bold", style.bold_style())]),
  span.line_plain("second line"),
])
|> paragraph.render_lines_styled(buf, area, _)
pub fn render(
  buf: buffer.Buffer,
  area: geometry.Rect,
  para: Paragraph,
) -> buffer.Buffer

Render paragraph into buffer at area. Word-wraps to area width. Rows beyond area height are clipped. Short lines are padded to area width.

pub fn render_lines_styled(
  buf: buffer.Buffer,
  area: geometry.Rect,
  para: SpanParagraph,
) -> buffer.Buffer

Render a SpanParagraph into area. Lines beyond area height are clipped.

pub fn render_styled(
  buf: buffer.Buffer,
  area: geometry.Rect,
  lines: List(span.Line),
) -> buffer.Buffer

Render a list of span.Line values, one per row, into area. Each Line is drawn with per-span styles. Lines beyond area height are clipped; the list may be shorter than the area (remaining rows unchanged).

pub fn with_alignment(
  p: Paragraph,
  alignment: text.Alignment,
) -> Paragraph

Set text alignment (Left, Center, Right).

pub fn with_style(p: Paragraph, s: style.Style) -> Paragraph

Apply a style (colors + modifier) to the paragraph text.

Search Document