Documentation ¶
Index ¶
- Constants
- func AddPadding(content string, width int) string
- func ColorF(color, format string, a ...interface{}) string
- func Errorf(format string, a ...interface{}) error
- func FormatRoundedBox(content string) string
- func GetCursorPos() string
- func GetWidth(content string) int
- func HexBgAndFg(hexFg, hexBg, msg string) (string, error)
- func HexColor256(r, g, b int, msg string) string
- func HexToBg(hex string) (string, error)
- func HexToRGB(hex string) (int, int, int, error)
- func ItalicF(format string, a ...interface{}) string
- func PrintBold(msg string)
- func PrintColor(color, msg string)
- func PrintColorAndBg(color, bg, msg string)
- func PrintColorAndBgBold(color, bg, msg string)
- func PrintColorBold(color, msg string)
- func PrintColorUnderline(color, msg string)
- func PrintColorf(color, format string, a ...interface{})
- func PrintDebug(msg string)
- func PrintError(msg string)
- func PrintErrorf(format string, a ...interface{})
- func PrintInfo(msg string)
- func PrintInverse(msg string)
- func PrintItalic(msg string)
- func PrintRoundedBottom(width int)
- func PrintRoundedTop(width int)
- func PrintSuccess(msg string)
- func PrintUnderline(msg string)
- func PrintWarning(msg string)
- func RGBToColor256(r, g, b int) int
- func SPrintRoundedBottom(width int) string
- func SPrintRoundedTop(width int) string
- func SetCursorPos(x, y int)
- func SprintHexf(hex string, msg string) (string, error)
- type U8Color
Constants ¶
const ( Reset = "\033[0m" // Reset the escape sequence Red = "\033[31m" Green = "\033[32m" Yellow = "\033[33m" Blue = "\033[34m" Purple = "\033[35m" Cyan = "\033[36m" Gray = "\033[37m" White = "\033[97m" )
Ansi colors
const ( Bold = "\033[1m" Underline = "\033[4m" Inverse = "\033[7m" )
Ansi styles
const ( LightRed = "\033[91m" LightGreen = "\033[92m" LightYellow = "\033[93m" LightBlue = "\033[94m" LightPurple = "\033[95m" LightCyan = "\033[96m" )
Ansi 256 light colors
const ( DarkRed = "\033[31m" DarkGreen = "\033[32m" DarkYellow = "\033[33m" DarkBlue = "\033[34m" DarkPurple = "\033[35m" DarkCyan = "\033[36m" )
Ansi 256 dark colors
const ( BgRed = "\033[41m" BgGreen = "\033[42m" BgYellow = "\033[43m" BgBlue = "\033[44m" BgPurple = "\033[45m" BgCyan = "\033[46m" BgGray = "\033[47m" )
Background colors
const ( CursorUp = "\033[A" // Move the cursor up CursorDown = "\033[B" // Move the cursor down CursorRight = "\033[C" // Move the cursor right CursorLeft = "\033[D" // Move the cursor left )
Cursor movement
const ( ClearScreen = "\033[2J" // Clear the screen ClearLine = "\033[K" // Clear the current line Backspace = "\b" // Backspace key Delete = "\033[3~" // Delete key Enter = "\r" // Return carriage Tab = "\t" // Tab // Cursor positioning Home = "\033[H" Position = "\033[%d;%dH" GetPos = "\033[6n" // Save and restore cursor position SaveCursor = "\033[s" RestoreCursor = "\033[u" // Hide and show cursor HideCursor = "\033[?25l" ShowCursor = "\033[?25h" // Overwrite the current line Overwrite = "\033[1A\033[2K" )
Terminal control
const ( RoundedTopLeft = "╭" // Top left corner of a rounded box RoundedTopRight = "╮" // Top right corner of a rounded box RoundedBottomLeft = "╰" // Bottom left corner of a rounded box RoundedBottomRight = "╯" // Bottom right corner of a rounded box RoundedHoriz = "─" // Horizontal line of a rounded box RoundedVert = "│" // Vertical line of a rounded box )
Rounded box characters
Variables ¶
This section is empty.
Functions ¶
func AddPadding ¶
AddPadding adds padding to a string to make it a certain width
func FormatRoundedBox ¶
FormatRoundedBox formats a string into a rounded box with proper padding
func GetCursorPos ¶
func GetCursorPos() string
func HexBgAndFg ¶
HexBgAndFg returns a string with a background and foreground color
func HexColor256 ¶
HexColor256 converts RGB values to an ANSI 256 color escape sequence and applies it to a message
func HexToRGB ¶
HexToRGB converts a hex color string to an RGB string
Example:
U8color.HexColor256("#3498db") or U8Color.HexToColor("3498d")
HexToRGB converts a hex color string to an RGB string
func PrintColor ¶
func PrintColor(color, msg string)
PrintColor prints a colored message to the console
func PrintColorAndBg ¶
func PrintColorAndBg(color, bg, msg string)
PrintColorAndBg prints a colored message with a background to the console
func PrintColorAndBgBold ¶
func PrintColorAndBgBold(color, bg, msg string)
PrintColorAndBgBold prints a colored bold message with a background to the console
func PrintColorBold ¶
func PrintColorBold(color, msg string)
PrintColorBold prints a colored bold message to the console
func PrintColorUnderline ¶
func PrintColorUnderline(color, msg string)
PrintColorUnderline prints a colored underlined message to the console
func PrintColorf ¶
func PrintColorf(color, format string, a ...interface{})
PrintColorf prints a colored formatted message to the console
func PrintErrorf ¶
func PrintErrorf(format string, a ...interface{})
PrintErrorf prints a formatted error message to the console
func PrintInverse ¶
func PrintInverse(msg string)
PrintInverse prints an inverted message to the console
func PrintRoundedBottom ¶
func PrintRoundedBottom(width int)
PrintRoundedBottom prints a rounded bottom
func PrintSuccess ¶
func PrintSuccess(msg string)
PrintSuccess prints a success message to the console
func PrintUnderline ¶
func PrintUnderline(msg string)
PrintUnderline prints an underlined message to the console
func PrintWarning ¶
func PrintWarning(msg string)
PrintWarning prints a warning message to the console
func RGBToColor256 ¶
RGBToColor256 converts RGB values to the nearest xterm 256 color code
func SPrintRoundedBottom ¶
SPrintRoundedBottom returns a string with a rounded bottom
func SPrintRoundedTop ¶
SPrintRoundedTop returns a string with a rounded top