common

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RegexAnsiFormat = regexp.MustCompile(`\x1b\[[0-9;]+m`)
	RegexAnsiReset  = regexp.MustCompile(`\x1b\[[0]?m`)
)
View Source
var (
	ClearFormatRules = []FormatRule{
		func(m string) string { return regexp.MustCompile(`\x1b\[[0-9;]*m`).ReplaceAllString(m, "") },
		func(m string) string { return regexp.MustCompile(`\t`).ReplaceAllString(m, "    ") },
	}
	FormatRules = []FormatRule{
		func(m string) string { return regexp.MustCompile(`\t`).ReplaceAllString(m, "    ") },
	}
	ExtendedFormatRules = []FormatRule{
		func(m string) string { return regexp.MustCompile(`\\033`).ReplaceAllString(m, "\x1b") },
		func(m string) string { m, _ = strconv.Unquote("\"" + m + "\""); return m },
	}
)

Functions

func GetRandomFrom

func GetRandomFrom[T any](collection []T) T

func GetTermSize

func GetTermSize() (int, int)

func Say

func Say(writer io.Writer, message string, defaultMessage string, template string, padding int, formatLines int, width int, height int, escape bool) error

Types

type FormatRule

type FormatRule func(string) string

Jump to

Keyboard shortcuts

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