text

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package text makes text from GitHub fit to draw. Anyone can write a starred gist or a comment, and an escape sequence reaching the terminal could move the cursor or change the title.

This is for what is drawn only, which is why just the TUI and the Markdown renderer may import it. Anywhere on the way to editing or printing it would change a gist's content without showing in a diff.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Breaks

func Breaks(s string, width int) []int

Breaks are the byte offsets the rows of s start at when it is wrapped to width cells, the first being 0. A word of narrow letters moves to the next row whole. Wide letters are not words, as Japanese has no spaces: going back to a space over them would leave a row mostly empty.

func Clean

func Clean(s string) string

Clean removes escape sequences and control characters from s, and writes a tab as four spaces. Newlines stay.

func Line

func Line(s string) string

Line is Clean for what is drawn on one line.

func Width

func Width(s string) int

Width is how many cells s takes. A variation selector or a zero-width joiner takes none.

Types

This section is empty.

Jump to

Keyboard shortcuts

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