module

Cellwrap

Cellwrap is a small, ANSI-aware word wrapping utility inspired by github.com/charmbracelet/x/cellbuf.Wrap (Go).

It treats ANSI escape sequences as zero-width and tries to wrap at word boundaries, hard-wrapping when a single word exceeds the width.

This code lives under lib/ so it can be extracted into a shard later.

Constants

BEL = 7_u8
NBSP = 160
RESET_STYLE = "\e[m"

Class methods

wrap(str : String, limit : Int32, breakpoints : String = "") : String

Wrap a string to a given cell width, preserving ANSI escape sequences.

breakpoints is a set of 1-cell characters that are valid wrap breakpoints. A hyphen (-) is always considered a breakpoint.

Source