Source File
graphemes.go
Belonging Package
github.com/clipperhouse/displaywidth
package displaywidthimport ()// Graphemes is an iterator over grapheme clusters.//// Iterate using the Next method, and get the width of the current grapheme// using the Width method.type Graphemes[ ~string | []byte] struct {iter *graphemes.Iterator[]options Options}// Next advances the iterator to the next grapheme cluster.func ( *Graphemes[]) () bool {return .iter.Next()}// Value returns the current grapheme cluster.func ( *Graphemes[]) () {return .iter.Value()}// Width returns the display width of the current grapheme cluster.func ( *Graphemes[]) () int {return graphemeWidth(.Value(), .options)}// StringGraphemes returns an iterator over grapheme clusters for the given// string.//// Iterate using the Next method, and get the width of the current grapheme// using the Width method.func ( string) Graphemes[string] {return DefaultOptions.StringGraphemes()}// StringGraphemes returns an iterator over grapheme clusters for the given// string, with the given options.//// Iterate using the Next method, and get the width of the current grapheme// using the Width method.func ( Options) ( string) Graphemes[string] {:= graphemes.FromString().AnsiEscapeSequences = .ControlSequences.AnsiEscapeSequences8Bit = .ControlSequences8Bitreturn Graphemes[string]{iter: , options: }}// BytesGraphemes returns an iterator over grapheme clusters for the given// []byte.//// Iterate using the Next method, and get the width of the current grapheme// using the Width method.func ( []byte) Graphemes[[]byte] {return DefaultOptions.BytesGraphemes()}// BytesGraphemes returns an iterator over grapheme clusters for the given// []byte, with the given options.//// Iterate using the Next method, and get the width of the current grapheme// using the Width method.func ( Options) ( []byte) Graphemes[[]byte] {:= graphemes.FromBytes().AnsiEscapeSequences = .ControlSequences.AnsiEscapeSequences8Bit = .ControlSequences8Bitreturn Graphemes[[]byte]{iter: , options: }}
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64)