print_columns
Get the number of occupied columns of a character string on a terminal.
The string passed to this function is a decoded string, free of control characters, non-characters, and
surrogates.
$print_width = print_columns( $string );
line_fold
Fold a string.
This function accepts a decoded string. Control characters (excluding vertical spaces), non-characters,
and surrogates are removed before the string is folded. Changes are applied to a copy; the passed string
is unchanged.
$folded_string = line_fold( $string );
$folded_string = line_fold( $string, { width => 120, color => 1 } );
Options
width
If not set, defaults to the terminal width.
width is 1 or greater.
init_tab
Sets the initial tab inserted at the beginning of paragraphs. If a value consisting of "/^[0-9]+$/"
is provided, the tab will be that number of spaces. Otherwise, the provided value is used directly as
the tab. By default, no initial tab is inserted. If the initial tab is longer than half the available
width, it will be cut to half the available width.
subseq_tab
Sets the subsequent tab inserted at the beginning of all broken lines (excluding paragraph
beginnings). If a value consisting of "/^[0-9]+$/" is provided, the tab will be that number of
spaces. Otherwise, the provided value is used directly as the tab. By default, no subsequent tab is
inserted. If the subsequent tab is longer than half the available width, it will be cut to half the
available width.
color
Enables support for ANSI SGR escape sequences. If enabled, all zero-width no-break spaces (0xfeff)
are removed.
color is 0 or 1.