textwidth

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package textwidth centralizes rune-safe terminal cell-width math for beam. Widths are terminal cells, with East-Asian wide runes counting 2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pad

func Pad(s string, w int) string

Pad right-pads s with spaces to exactly w cells; wider input is returned unchanged.

func Truncate

func Truncate(s string, w int, tail string) string

Truncate cuts s to at most w cells, appending tail (whose width counts toward w) when anything was removed. It never splits a rune.

func Width

func Width(s string) int

Width returns the cell width of s.

func Wrap

func Wrap(s string, w int) []string

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL