Skip to main content

wrap_plain

Function wrap_plain 

Source
pub fn wrap_plain(text: &str, width: usize) -> Vec<String>
Expand description

Wraps plain text to width columns without interpreting it in any way.

Meant for hints and messages, which must be printed exactly as written: [ab]*.txt, backticks and asterisks are ordinary characters here. Explicit newlines start a new line, blank lines are kept, runs of spaces inside a line are kept, and lines break only at spaces (a word longer than width is split between characters). The leading indentation of a line is repeated on its continuation rows. Trailing spaces are removed, control characters are replaced (see sanitize) and tabs expanded.

use shellgame::ui::text::wrap_plain;

assert_eq!(
    wrap_plain("použijte `ls [ab]*.txt` zde", 14),
    ["použijte `ls", "[ab]*.txt` zde"],
);