lineWrap

Same thing as asLineWrapped, except it is eagerly evaluated.

@trusted pure
string
lineWrap
(
const(char)[] text
,)

Parameters

text const(char)[]

The text to line wrap.

options LineWrapOptions

The options to line wrap with.

Performance: With character-based wrapping, this function can calculate the entire amount of space needed for the resulting string, resulting in only a single GC allocation.

Return Value

Type: string

A newly allocated string containing the eagerly-evaluated results of asLineWrapped(text, options).

Throws

Exception if the char limit is too small to show any text.

Examples

const options = LineWrapOptions(8, "\t", "-");
const text    = "Hello world".lineWrap(options);
assert(text == "\tHello-\n\tworld-", text);

See Also

LineWrapRange for full documentation.

asLineWrapped for a lazily evaluated version.

Meta