Documentation
¶
Overview ¶
Package text provides a few basic text alignment and utility functions.
Index ¶
- func AlignBottom(str string, width, height int) string
- func AlignCenter(str string, width int) string
- func AlignLeft(str string) string
- func AlignMiddle(str string, width, height int) string
- func AlignRight(str string, width int) string
- func AlignTop(str string, width, height int) string
- func CenterText(str string, width int) string
- func Chunks(s string, length int) (res []string)
- func ClearCode(str string) string
- func JoinLines(lines []*Line) string
- func LineCount(s ...interface{}) int
- func Lines(s string) iter.Seq2[int, *Line]
- func OddLength(s ...interface{}) bool
- func OddVisibleLength(s ...interface{}) bool
- func SplitLines(s ...interface{}) []string
- func VisibleLength(s ...interface{}) int
- type Line
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlignBottom ¶
AlignBottom aligns the text to the bottom.
func AlignCenter ¶
AlignCenter centers str. It trims and then centers all the lines in the text with space.
func AlignMiddle ¶
AlignMiddle aligns the text to the middle.
func AlignRight ¶
AlignRight aligns string to the right.
func CenterText ¶
CenterText centers the text by adding spaces to the left and right. It assumes the text is one line. For multiple lines use AlignCenter.
func LineCount ¶
func LineCount(s ...interface{}) int
LineCount returns the number of lines in the string.
func OddLength ¶
func OddLength(s ...interface{}) bool
OddLength returns true if the length of the string is odd.
func OddVisibleLength ¶
func OddVisibleLength(s ...interface{}) bool
OddVisibleLength returns true if the visible length of the string is odd.
func SplitLines ¶
func SplitLines(s ...interface{}) []string
SplitLines splits the string by new line character ("\n")
func VisibleLength ¶
func VisibleLength(s ...interface{}) int
VisibleLength returns the length of the string as seen by a human. It removes all ANSI sequences from the string.