View Source ElementTui.Parser (ElementTui v0.4.1)
Summary
Functions
Wraps the given text
to fit within the specified max_width
and approx_height
.
Functions
Wraps the given text
to fit within the specified max_width
and approx_height
.
This function takes a string of text and wraps it to fit within the specified maximum width. The text is preferentially wrapped at word boundaries. If sentences include very long words they will be broken at the boundary instead.
If the text cannot be wrapped to fit within the specified approx_height
, it will
be truncated instead. In that case the number of lines returned will always be more
than the specified approx_height
.
Parameters
text
(binary) - The text to be wrapped.max_width
(integer) - The maximum width (in characters) for each line.approx_height
(integer) - The approximate max height (in lines) for the wrapped text.
Examples
iex> wrap_text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", 30, 3)
[["Lorem ipsum dolor sit amet,"], ["consectetur adipiscing elit."]]