Discover Packages
github.com/contenox/contenox
internal
surfaces
contenoxcli
textwidth
package
Version:
v1.2.0
Opens a new window with list of versions in this module.
Published: Oct 1, 2026
License: Apache-2.0
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
Documentation
¶
Package textwidth centralizes rune-safe terminal cell-width math for beam.
Widths are terminal cells, with East-Asian wide runes counting 2.
Pad right-pads s with spaces to exactly w cells; wider input is returned
unchanged.
Truncate cuts s to at most w cells, appending tail (whose width counts toward
w) when anything was removed. It never splits a rune.
Width returns the cell width of s.
Wrap wraps s to at most w cells per line, breaking after spaces where possible
and hard-breaking only words wider than w. Every rune of s appears in the
output exactly once and in order; Wrap only ever inserts breaks. A
non-positive w still splits on newlines and does no other wrapping.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.