package text

Import Path
	github.com/jedib0t/go-pretty/v6/text (on go.dev)

Dependency Relation
	imports 11 packages, and imported by one package


Package-Level Type Names (total 7, all are exported)
/* sort exporteds by: | */
Align denotes how text is to be aligned horizontally. Apply aligns the text as directed. For ex.: * AlignDefault.Apply("Jon Snow", 12) returns "Jon Snow " * AlignLeft.Apply("Jon Snow", 12) returns "Jon Snow " * AlignCenter.Apply("Jon Snow", 12) returns " Jon Snow " * AlignJustify.Apply("Jon Snow", 12) returns "Jon Snow" * AlignRight.Apply("Jon Snow", 12) returns " Jon Snow" HTMLProperty returns the equivalent HTML horizontal-align tag property. MarkdownProperty returns the equivalent Markdown horizontal-align separator. const AlignCenter const AlignDefault const AlignJustify const AlignLeft const AlignRight
Color represents a single color to render with. EscapeSeq returns the ANSI escape sequence for the color. HTMLProperty returns the "class" attribute for the color. Sprint colorizes and prints the given string(s). Sprintf formats and colorizes and prints the given string(s). const BgBlack const BgBlue const BgCyan const BgGreen const BgHiBlack const BgHiBlue const BgHiCyan const BgHiGreen const BgHiMagenta const BgHiRed const BgHiWhite const BgHiYellow const BgMagenta const BgRed const BgWhite const BgYellow const BlinkRapid const BlinkSlow const Bold const Concealed const CrossedOut const Faint const FgBlack const FgBlue const FgCyan const FgGreen const FgHiBlack const FgHiBlue const FgHiCyan const FgHiGreen const FgHiMagenta const FgHiRed const FgHiWhite const FgHiYellow const FgMagenta const FgRed const FgWhite const FgYellow const Italic const Reset const ReverseVideo const Underline
Colors represents an array of Color objects to render with. Example: Colors{FgCyan, BgBlack} EscapeSeq returns the ANSI escape sequence for the colors set. HTMLProperty returns the "class" attribute for the colors. Sprint colorizes and prints the given string(s). Sprintf formats and colorizes and prints the given string(s).
Cursor helps move the cursor on the console in multiple directions. Sprint prints the Escape Sequence to move the Cursor once. Sprintn prints the Escape Sequence to move the Cursor "n" times. const CursorDown const CursorLeft const CursorRight const CursorUp const EraseLine
Format lets you transform the text in supported methods while keeping escape sequences in the string intact and untouched. Apply converts the text as directed. const FormatDefault const FormatLower const FormatTitle const FormatUpper
Transformer helps format the contents of an object to the user's liking. func NewJSONTransformer(prefix string, indent string) Transformer func NewNumberTransformer(format string) Transformer func NewTimeTransformer(layout string, location *time.Location) Transformer func NewUnixTimeTransformer(layout string, location *time.Location) Transformer func NewURLTransformer() Transformer
VAlign denotes how text is to be aligned vertically. Apply aligns the lines vertically. For ex.: * VAlignTop.Apply({"Game", "Of", "Thrones"}, 5) returns {"Game", "Of", "Thrones", "", ""} * VAlignMiddle.Apply({"Game", "Of", "Thrones"}, 5) returns {"", "Game", "Of", "Thrones", ""} * VAlignBottom.Apply({"Game", "Of", "Thrones"}, 5) returns {"", "", "Game", "Of", "Thrones"} ApplyStr aligns the string (of 1 or more lines) vertically. For ex.: * VAlignTop.ApplyStr("Game\nOf\nThrones", 5) returns {"Game", "Of", "Thrones", "", ""} * VAlignMiddle.ApplyStr("Game\nOf\nThrones", 5) returns {"", "Game", "Of", "Thrones", ""} * VAlignBottom.ApplyStr("Game\nOf\nThrones", 5) returns {"", "", "Game", "Of", "Thrones"} HTMLProperty returns the equivalent HTML vertical-align tag property. const VAlignBottom const VAlignDefault const VAlignMiddle const VAlignTop
Package-Level Functions (total 36, in which 21 are exported)
DisableColors (forcefully) disables color coding globally.
EnableColors (forcefully) enables color coding globally.
Escape encodes the string with the ANSI Escape Sequence. For ex.: Escape("Ghost", "") == "Ghost" Escape("Ghost", "\x1b[91m") == "\x1b[91mGhost\x1b[0m" Escape("\x1b[94mGhost\x1b[0mLady", "\x1b[91m") == "\x1b[94mGhost\x1b[0m\x1b[91mLady\x1b[0m" Escape("Nymeria\x1b[94mGhost\x1b[0mLady", "\x1b[91m") == "\x1b[91mNymeria\x1b[94mGhost\x1b[0m\x1b[91mLady\x1b[0m" Escape("Nymeria \x1b[94mGhost\x1b[0m Lady", "\x1b[91m") == "\x1b[91mNymeria \x1b[94mGhost\x1b[0m\x1b[91m Lady\x1b[0m"
Filter filters the slice 's' to items which return truth when passed to 'f'.
InsertEveryN inserts the rune every N characters in the string. For ex.: InsertEveryN("Ghost", '-', 1) == "G-h-o-s-t" InsertEveryN("Ghost", '-', 2) == "Gh-os-t" InsertEveryN("Ghost", '-', 3) == "Gho-st" InsertEveryN("Ghost", '-', 4) == "Ghos-t" InsertEveryN("Ghost", '-', 5) == "Ghost"
LongestLineLen returns the length of the longest "line" within the argument string. For ex.: LongestLineLen("Ghost!\nCome back here!\nRight now!") == 15
NewJSONTransformer returns a Transformer that can format a JSON string or an object into pretty-indented JSON-strings.
NewNumberTransformer returns a number Transformer that: * transforms the number as directed by 'format' (ex.: %.2f) * colors negative values Red * colors positive values Green
NewTimeTransformer returns a Transformer that can format a timestamp (a time.Time) into a well-defined time format defined using the provided layout (ex.: time.RFC3339). If a non-nil location value is provided, the time will be localized to that location (use time.Local to get localized timestamps).
NewUnixTimeTransformer returns a Transformer that can format a unix-timestamp into a well-defined time format as defined by 'layout'. This can handle unix-time in Seconds, MilliSeconds, Microseconds and Nanoseconds. If a non-nil location value is provided, the time will be localized to that location (use time.Local to get localized timestamps).
NewURLTransformer returns a Transformer that can format and pretty print a string that contains an URL (the text is underlined and colored Blue).
Pad pads the given string with as many characters as needed to make it as long as specified (maxLen). This function does not count escape sequences while calculating length of the string. Ex.: Pad("Ghost", 0, ' ') == "Ghost" Pad("Ghost", 3, ' ') == "Ghost" Pad("Ghost", 5, ' ') == "Ghost" Pad("Ghost", 7, ' ') == "Ghost " Pad("Ghost", 10, '.') == "Ghost....."
RepeatAndTrim repeats the given string until it is as long as maxRunes. For ex.: RepeatAndTrim("", 5) == "" RepeatAndTrim("Ghost", 0) == "" RepeatAndTrim("Ghost", 5) == "Ghost" RepeatAndTrim("Ghost", 7) == "GhostGh" RepeatAndTrim("Ghost", 10) == "GhostGhost"
RuneCount is similar to utf8.RuneCountInString, except for the fact that it ignores escape sequences while counting. For ex.: RuneCount("") == 0 RuneCount("Ghost") == 5 RuneCount("\x1b[33mGhost\x1b[0m") == 5 RuneCount("\x1b[33mGhost\x1b[0") == 5
RuneWidth returns the mostly accurate character-width of the rune. This is not 100% accurate as the character width is usually dependant on the typeface (font) used in the console/terminal. For ex.: RuneWidth('A') == 1 RuneWidth('ツ') == 2 RuneWidth('⊙') == 1 RuneWidth('︿') == 2 RuneWidth(0x27) == 0
Snip returns the given string with a fixed length. For ex.: Snip("Ghost", 0, "~") == "Ghost" Snip("Ghost", 1, "~") == "~" Snip("Ghost", 3, "~") == "Gh~" Snip("Ghost", 5, "~") == "Ghost" Snip("Ghost", 7, "~") == "Ghost " Snip("\x1b[33mGhost\x1b[0m", 7, "~") == "\x1b[33mGhost\x1b[0m "
StripEscape strips all ANSI Escape Sequence from the string. For ex.: StripEscape("Ghost") == "Ghost" StripEscape("\x1b[91mGhost\x1b[0m") == "Ghost" StripEscape("\x1b[94mGhost\x1b[0m\x1b[91mLady\x1b[0m") == "GhostLady" StripEscape("\x1b[91mNymeria\x1b[94mGhost\x1b[0m\x1b[91mLady\x1b[0m") == "NymeriaGhostLady" StripEscape("\x1b[91mNymeria \x1b[94mGhost\x1b[0m\x1b[91m Lady\x1b[0m") == "Nymeria Ghost Lady"
Trim trims a string to the given length while ignoring escape sequences. For ex.: Trim("Ghost", 3) == "Gho" Trim("Ghost", 6) == "Ghost" Trim("\x1b[33mGhost\x1b[0m", 3) == "\x1b[33mGho\x1b[0m" Trim("\x1b[33mGhost\x1b[0m", 6) == "\x1b[33mGhost\x1b[0m"
WrapHard wraps a string to the given length using a newline. Handles strings with ANSI escape sequences (such as text color) without breaking the text formatting. Breaks all words that go beyond the line boundary. For examples, refer to the unit-tests or GoDoc examples.
WrapSoft wraps a string to the given length using a newline. Handles strings with ANSI escape sequences (such as text color) without breaking the text formatting. Tries to move words that go beyond the line boundary to the next line. For examples, refer to the unit-tests or GoDoc examples.
WrapText is very similar to WrapHard except for one minor difference. Unlike WrapHard which discards line-breaks and respects only paragraph-breaks, this function respects line-breaks too. For examples, refer to the unit-tests or GoDoc examples.
Package-Level Variables (total 11, in which 1 are exported)
ANSICodesSupported will be true on consoles where ANSI Escape Codes/Sequences are supported.
Package-Level Constants (total 68, in which 65 are exported)
Align enumerations
Align enumerations
Align enumerations
Align enumerations
Align enumerations
Background colors
Background colors
Background colors
Background colors
Background Hi-Intensity colors
Background Hi-Intensity colors
Background Hi-Intensity colors
Background Hi-Intensity colors
Background Hi-Intensity colors
Background Hi-Intensity colors
Background Hi-Intensity colors
Background Hi-Intensity colors
Background colors
Background colors
Background colors
Background colors
Base colors -- attributes in reality
Base colors -- attributes in reality
Base colors -- attributes in reality
Base colors -- attributes in reality
Base colors -- attributes in reality
CursorDown helps move the Cursor Down X lines
CursorLeft helps move the Cursor Left X characters
CursorRight helps move the Cursor Right X characters
CursorUp helps move the Cursor Up X lines
EraseLine helps erase all characters to the Right of the Cursor in the current line
Constants
Constants
Constants
Constants
Constants
Base colors -- attributes in reality
Foreground colors
Foreground colors
Foreground colors
Foreground colors
Foreground Hi-Intensity colors
Foreground Hi-Intensity colors
Foreground Hi-Intensity colors
Foreground Hi-Intensity colors
Foreground Hi-Intensity colors
Foreground Hi-Intensity colors
Foreground Hi-Intensity colors
Foreground Hi-Intensity colors
Foreground colors
Foreground colors
Foreground colors
Foreground colors
Format enumerations
Format enumerations
Format enumerations
Format enumerations
Base colors -- attributes in reality
Base colors -- attributes in reality
Base colors -- attributes in reality
Base colors -- attributes in reality
VAlign enumerations
VAlign enumerations
VAlign enumerations
VAlign enumerations