Import std.text.layout
String
extend
Extend String
Wrapping, dedenting, and indenting a String's lines.
-
Its lines filled with words up to
widthcolumns each, as a terminal shows them, with DisplayWidth and a tab going on to the next multiple of 8 columns: each line breaks before the word that would go past it, at the spaces before that word, which go, while the spaces between words that stay on a line stay as they are. A no-break space, U+00A0, U+2007, or U+202F, is part of its word, not a place to break. A line's leading whitespace starts each line it becomes, and a word wider than the rest of thewidthis broken between its grapheme clusters. Panics whenwidthis below 1.Examples
Expect("the quick brown fox".WordWrap(10) == "the quick\nbrown fox") Expect("a\nb".Indent("> ") == "> a\n> b") -
A copy without the leading spaces and tabs that each line that isn't blank starts with, all alike, as when text is written indented in code. A blank line becomes empty.
-
A copy with
prefixbefore each line that isn't blank.
Report an issue with this page or with FutureBlitz on GitHub.