unicodemonowidth

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2020 License: MIT Imports: 2 Imported by: 1

README

When creating console applications, it's important to know how many "wide" a string is. That is, assuming a monospaced font, how many visual "characters" will it use. This is complicated by combining diacritics in Unicode, which are code points that are displayed on top or below another character.

This function uses the example code for the NextBoundary function at https://godoc.org/golang.org/x/text/unicode/norm

Documentation

Overview

Copyright (c) 2019 by Gilbert Ramirez <gram@alumni.rice.edu>

Copyright (c) 2020 by Gilbert Ramirez <gram@alumni.rice.edu>

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MonoWidth

func MonoWidth(input string) int

Returns the count of one-character-wide glyphs that this string represents.

func NewNWSIterator added in v1.1.0

func NewNWSIterator(text string) *nwsIterator

Iterates over a string, returning non-whitespace spans of strings.

func Wrap added in v1.1.0

func Wrap(text string, maxWidth int) []string

func WrapPrintedWords added in v1.1.0

func WrapPrintedWords(words []*PrintedWord, maxWidth int) []string

Types

type PrintedWord added in v1.1.0

type PrintedWord struct {
	Text  string
	Width int
}

func WhitespaceSplit added in v1.1.0

func WhitespaceSplit(text string) []*PrintedWord

Jump to

Keyboard shortcuts

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