cmn

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChopLineFunc

func ChopLineFunc(line string, maxWidth int, fnWidth WidthFunc) string

func ChopMarkLine

func ChopMarkLine(line string, maxWidth int, chopMark string) string

func ChopMarkLineFunc

func ChopMarkLineFunc(line string, maxWidth int, chopMark string, fnWidth WidthFunc) string

func Max

func Max(x, y int) int

func Min

func Min(x, y int) int

func PadLeft

func PadLeft(s string, padWith rune, maxRunes int) string

func PadLeftFunc

func PadLeftFunc(s string, padWith rune, maxWidth int, fnWidth WidthFunc) string

func PadRight

func PadRight(s string, padWith rune, maxRunes int) string

func PadRightFunc

func PadRightFunc(s string, padWith rune, maxWidth int, fnWidth WidthFunc) string

func VcsRevision

func VcsRevision() (rev string, ok bool)

func WidthBytes

func WidthBytes(s string) int

WidthBytes returns the number of bytes in s

Equivalent to len(s)

func WidthMonospace

func WidthMonospace(s string) int

WidthMonospace returns the monospace width for the given string, that is, the number of same-size cells to be occupied by the string.

Equivalent to uniseg.StringWidth(s)

func WidthRunes

func WidthRunes(s string) int

WidthRunes returns the number of runes in s

Equivalent to utf8.RuneCountInString(s)

func WillUseVar

func WillUseVar(v ...any)

Types

type BoxChars

type BoxChars struct {
	CornerTL string
	CornerTR string
	CornerBL string
	CornerBR string
	Left     string
	Right    string
	Top      string
	Bottom   string
	Cross    string
	Hor      string
	Ver      string
}

func BoxCharsAscii

func BoxCharsAscii() BoxChars

func BoxCharsDos

func BoxCharsDos() BoxChars

type BytesWidther

type BytesWidther struct{}

func (BytesWidther) String

func (bw BytesWidther) String() string

func (BytesWidther) Width

func (bw BytesWidther) Width(s string) int

type FnChopMarkLine

type FnChopMarkLine func(line string, maxWidth int, chopMark string) string

func ChopMarkLineSelector

func ChopMarkLineSelector(w Widther) (fn FnChopMarkLine)

type LineBuilder

type LineBuilder struct {
	strings.Builder
	EoL eol.EndOfLine
}

func (*LineBuilder) WriteLine

func (lb *LineBuilder) WriteLine(value string) (int, error)

type LineWriter

type LineWriter interface {
	WriteLine(value string) (int, error)
}

type MonospaceWidther

type MonospaceWidther struct{}

func (MonospaceWidther) String

func (mw MonospaceWidther) String() string

func (MonospaceWidther) Width

func (mw MonospaceWidther) Width(s string) int

type RunesWidther

type RunesWidther struct{}

func (RunesWidther) String

func (rw RunesWidther) String() string

func (RunesWidther) Width

func (rw RunesWidther) Width(s string) int

type WidthFunc

type WidthFunc func(string) int

type Widther

type Widther interface {
	Width(s string) int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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