width

package
v0.1.1-beta Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package width provides visual width calculations for text, accounting for tabs and multi-byte characters.

Index

Constants

View Source
const DefaultTabStop = 8

DefaultTabStop is the default tab width (8 spaces).

Variables

This section is empty.

Functions

func AdvanceColsWithTab

func AdvanceColsWithTab(startCol int, s string, tabStop int) int

AdvanceColsWithTab returns the column after writing s starting from startCol, with a custom tab stop.

func FirstLineLenWithTab

func FirstLineLenWithTab(s string, tabStop int) int

FirstLineLenWithTab returns the visual width of the first line with custom tab stop.

func LastLineLenWithTab

func LastLineLenWithTab(s string, tabStop int) int

LastLineLenWithTab returns the visual width of the last line with custom tab stop.

func RuneWidth

func RuneWidth(r rune) int

RuneWidth returns the display width of a rune. Most runes are width 1, but wide CJK characters and some emoji are width 2. Zero-width characters (combining marks, control chars, etc.) return 0.

func VisualLenWithTab

func VisualLenWithTab(s string, tabStop int) int

VisualLenWithTab returns the visual column width of s with a custom tab stop.

Types

This section is empty.

Jump to

Keyboard shortcuts

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