Skip to main content

wrap_indent

Function wrap_indent 

Source
pub fn wrap_indent(s: &str, width: usize, indent: usize) -> Vec<String>
Expand description

Wraps text with a continuation indent on subsequent lines.

The first line uses the full width. Subsequent lines are indented by the specified amount, reducing their effective width.

ANSI escape codes are preserved and don’t count toward width calculations.

§Arguments

  • s - The string to wrap
  • width - Maximum display width for each line
  • indent - Number of spaces to indent continuation lines

§Example

use standout_render::tabular::wrap_indent;

let lines = wrap_indent("hello world foo bar", 12, 2);
assert_eq!(lines, vec!["hello world", "  foo bar"]);