limn
    ↑↓ ChooseEnter OpenEsc Close
    GitHub

    Components/Data

    OutputBlock

    Read-only monospaced output of a command or a tool, bounded however much text it is given.

    Native componentGuide source

    Preview

    CodeSource
    fn view(state: &State, palette: ComponentPalette) -> Element {
        OutputBlock::new("test-output", &state.output, palette).render()
    }

    Examples

    Each one is the library drawing it. Press, type and hover.

    Output block2 / 3
    CodeSource
    OutputBlock::new(
        "blocks-output-short",
        "error[E0308]: mismatched types\n\n  expected `u32`, found `&str` in a line that runs well past the right edge of the block and is clipped there",
        palette,
    )
    .ink(palette.muted)
    .width(width)
    .render()
    Output block3 / 3
    CodeSource
    OutputBlock::new("blocks-output-empty", "", palette).width(width).render()

    OutputBlock

    Read-only monospaced output of a command or a tool, bounded however much text it is given.

    Import

    use limn::{Component, OutputBlock};

    Usage

    An output block needs an ID, the text and the palette. The ID names its scroll area and must be unique in the window. It reports no actions.

    fn view(state: &State, palette: ComponentPalette) -> Element {
        OutputBlock::new("test-output", &state.output, palette).render()
    }

    Each line of the text is one clipped row, in a scroll area that builds only the rows in view. The fill is the palette’s surface, so pass a palette whose surface is the host’s code well.

    Limits

    The text is cut to 48 KiB, 600 lines and 500 characters per line before any of it is shaped. A line that was cut ends with an ellipsis.

    OutputBlock::new("test-output", &state.output, palette)
        .truncation_note("Partial view: the output is too long")
        .render()

    truncation_note adds a muted line under the output, shown only when lines or bytes were cut.

    Height

    OutputBlock::new("test-output", &state.output, palette).max_height(136.0).render()

    The block is as tall as its lines up to max_height, then it scrolls. The default is 200, and the least is one line. Values that are not finite are ignored.

    Ink

    OutputBlock::new("stderr", &state.errors, palette).ink(error_color).render()

    ink paints the lines in a color that carries meaning the host owns, such as an error stream, in place of the palette’s text.

    Width

    OutputBlock::new("test-output", &state.output, palette).width(520.0).render()

    width fixes the width. Without it the block fills the width it is given. Values that are negative or not finite are ignored.

    API reference

    The guide covers composition, options and actions. Generate the complete Rust type and builder reference from the checkout:

    cargo doc -p limn --open

    Component API overview · State and actions

    The example is drawn by crates/limn-gallery/src/pages/blocks.rs.