Skip to main content

build_string

Function build_string 

Source
pub fn build_string<'a>(
    input: &'a str,
    hspace: usize,
    vspace: usize,
    overflow: &Overflow,
) -> Vec<AnsiString<'a>>
Expand description

Processes input text with ANSI codes into formatted lines that fit within specified dimensions.

Takes raw text containing ANSI escape sequences and breaks it into lines that respect both horizontal (character) and vertical (line) constraints while preserving ANSI formatting.

§Arguments

  • input - Raw input text that may contain ANSI escape sequences
  • hspace - Maximum characters per line (excluding ANSI codes)
  • vspace - Maximum number of lines to generate
  • overflow - Strategy for handling text that exceeds horizontal space

§Returns

Vector of AnsiString objects, each representing a formatted line with:

  • Original text slice (may include ANSI codes)
  • Continuation codes needed to maintain formatting across line breaks
  • Actual display length (excluding ANSI codes)
  • Whether the line needs a reset code for proper formatting