beamtea_util (beamtea v0.1.0)
View SourceSmall shared helpers for beamtea bubbles.
Summary
Functions
Format milliseconds as MM:SS (or HH:MM:SS past an hour).
Format milliseconds as MM:SS.CS (centiseconds) — for stopwatches.
Right-pad an iodata string with spaces to Width code points (never truncates).
Right-pad to Width *visible* columns, ignoring ANSI escapes in the width calculation (so coloured text lines up correctly).
Remove ANSI escape sequences (SGR colours, cursor moves, …) from a string, leaving only the visible characters.
Truncate an iodata string to at most Max code points, adding an ellipsis when cut.
The number of visible columns in a string, ignoring ANSI escapes. (Counts code points; wide characters are treated as width 1.)
Functions
Format milliseconds as MM:SS (or HH:MM:SS past an hour).
Format milliseconds as MM:SS.CS (centiseconds) — for stopwatches.
-spec pad_right(iodata(), non_neg_integer()) -> iodata().
Right-pad an iodata string with spaces to Width code points (never truncates).
-spec pad_visible(unicode:chardata(), non_neg_integer()) -> iodata().
Right-pad to Width *visible* columns, ignoring ANSI escapes in the width calculation (so coloured text lines up correctly).
-spec strip_ansi(unicode:chardata()) -> binary().
Remove ANSI escape sequences (SGR colours, cursor moves, …) from a string, leaving only the visible characters.
-spec truncate(iodata(), non_neg_integer()) -> binary().
Truncate an iodata string to at most Max code points, adding an ellipsis when cut.
-spec visible_width(unicode:chardata()) -> non_neg_integer().
The number of visible columns in a string, ignoring ANSI escapes. (Counts code points; wide characters are treated as width 1.)