runewidth

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package runewidth is a wrapper over github.com/mattn/go-runewidth which gives different treatment to certain runes with ambiguous width.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RuneWidth

func RuneWidth(r rune, opts ...Option) int

RuneWidth returns the number of cells needed to draw r. Background in http://www.unicode.org/reports/tr11/.

Treats runes used internally by termdash as single-cell (half-width) runes regardless of the locale. I.e. runes that are used to draw lines, boxes, indicate resize or text trimming was needed and runes used by the braille canvas.

This should be safe, since even in locales where these runes have ambiguous width, we still place all the character content around them so they should have be half-width.

func StringWidth

func StringWidth(s string, opts ...Option) int

StringWidth is like RuneWidth, but returns the number of cells occupied by all the runes in the string.

Types

type Option added in v0.16.0

type Option interface {
	// contains filtered or unexported methods
}

Option is used to provide options.

func CountAsWidth added in v0.16.0

func CountAsWidth(r rune, width int) Option

CountAsWidth overrides the default behavior, counting the specified runes as the specified width. Can be provided multiple times to specify an override for multiple runes.

Jump to

Keyboard shortcuts

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