Documentation ¶
Index ¶
- func Align(s string, width int, align Alignment) string
- func CountLines(s string) int
- func DisplayWidth(s string) int
- func IsMultiline(s string) bool
- func JoinLines(lines []string) string
- func MaxDisplayWidth(lines []string) (max int)
- func PadCenter(s string, width int) string
- func PadJustify(s string, width int) string
- func PadLeft(s string, width int) string
- func PadRight(s string, width int) string
- func Spaces(num int) string
- func SplitLines(s string) []string
- func Truncate(s string, width int) string
- func WrapWords(s string, width int) string
- type Alignment
- type Text
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisplayWidth ¶
DisplayWidth returns the display width of s. If s is a multiline string this returns the display width of the longest line.
func MaxDisplayWidth ¶
MaxDisplayWidth returns the display width of the longest line in the lines slice.
func PadJustify ¶
func Spaces ¶
Spaces returns a string which consist only of the specified number of spaces. Will panic is num is negative.
func SplitLines ¶
SplitLines splits s on newline characters and returns a slice of lines.
Types ¶
type Text ¶
type Text struct { // Alignment controls the alignment of the text. Default is to align left. Alignment Alignment // Style is applied to the text after alignment and word wrapping. Style *style.Style // Text contains the text that should be rendered. Can contain newlines or // even ANSI escape sequences. Text string // WordWrap controls the word wrapping behaviour. If true, words are // wrapped onto multiple lines depending on the desired render width. WordWrap bool }
Text is a console.Renderable that produces aligned and styled text.
Click to show internal directories.
Click to hide internal directories.