Documentation ¶
Index ¶
- Variables
- func GenSpaces(l int) string
- func GenStr(l int, s string) string
- func HardWrap(input string, width int) string
- func RenderedText(str, strcolor string) string
- func Truncate(input string, width int) string
- func UtilFuncMap() template.FuncMap
- func WordWrap(input string, width int) string
- type WrapMode
Constants ¶
This section is empty.
Variables ¶
View Source
var ColorFuncMap = template.FuncMap{ "black": color.New(color.FgHiBlack).SprintFunc(), "red": color.New(color.FgHiRed).SprintFunc(), "green": color.New(color.FgHiGreen).SprintFunc(), "yellow": color.New(color.FgHiYellow).SprintFunc(), "blue": color.New(color.FgHiBlue).SprintFunc(), "magenta": color.New(color.FgHiMagenta).SprintFunc(), "cyan": color.New(color.FgHiCyan).SprintFunc(), "white": color.New(color.FgHiWhite).SprintFunc(), "bgBlack": color.New(color.BgHiBlack).SprintFunc(), "bgRed": color.New(color.BgHiRed).SprintFunc(), "bgGreen": color.New(color.BgHiGreen).SprintFunc(), "bgYellow": color.New(color.BgHiYellow).SprintFunc(), "bgBlue": color.New(color.BgHiBlue).SprintFunc(), "bgMagenta": color.New(color.BgHiMagenta).SprintFunc(), "bgCyan": color.New(color.BgHiCyan).SprintFunc(), "bgWhite": color.New(color.BgHiWhite).SprintFunc(), "bold": color.New(color.Bold).SprintFunc(), "faint": color.New(color.Faint).SprintFunc(), "italic": color.New(color.Italic).SprintFunc(), "underline": color.New(color.Underline).SprintFunc(), "reset": color.New(color.Reset).SprintFunc(), }
View Source
var ErrAborted = fmt.Errorf("prompt aborted")
ErrAborted is returned when the prompt was aborted.
Functions ¶
func GenStr ¶
GenStr generate a string of the specified length, the string is composed of the given characters
func RenderedText ¶
func UtilFuncMap ¶
UtilFuncMap returns a template.FuncMap with handy utility functions for prompt templates.
- Repeat(string, int) string: Identical to strings.Repeat.
- Len(string): reflow/ansi.PrintableRuneWidth, Len works like len but is aware of ansi codes and returns the length of the string as it appears on the screen.
- Min(int, int) int: The minimum of two ints.
- Max(int, int) int: The maximum of two ints.
- Add(int, int) int: The sum of two ints.
- Sub(int, int) int: The difference of two ints.
- Mul(int, int) int: The product of two ints.
Types ¶
Click to show internal directories.
Click to hide internal directories.