Documentation ¶
Index ¶
- Constants
- Variables
- func Ask(prompt string, store *string)
- func AskSecret(prompt string, store *string)
- func BackUp()
- func Background(str string, code int) string
- func Banner(message string) (banner string)
- func Bell()
- func BigBanner(message string) (banner string)
- func ClearDisplay()
- func ClearLine()
- func Cursor(row int, col int)
- func CursorBack(columns int)
- func CursorFwd(columns int)
- func CursorHide()
- func CursorShow()
- func CursorStart()
- func Fail(message string)
- func FailErr(label string, err error)
- func Failf(message string, v ...any)
- func File(path string)
- func Foreground(str string, code int) string
- func Grid(rows []Row) (grid string)
- func Info(message string)
- func Infof(message string, v ...any)
- func LineDown(lines int)
- func LineFeed()
- func LineNext(lines int)
- func LinePrev(lines int)
- func LineUp(lines int)
- func Menu(title string, options []Option)
- func Painter(callback Template)
- func ProgressBar(status int)
- func Prompt(prompt string) (proceed bool)
- func ScrollDown(lines int)
- func ScrollUp(lines int)
- func Segmented(n string) string
- func Spinner(status string, style SpinnerStyle)
- func StopPainting()
- func StopSpinner()
- func Style(str string, styles ...SGR) string
- func StylePersist(styles ...SGR) string
- func Success(message string)
- func Successf(message string, v ...any)
- func Table(headers []string, rows []Row)
- func Typewriter(message string)
- func TypewriterTimed(message string, duration time.Duration)
- func Viewport(content string)
- func Warn(message string)
- func Warnf(message string, v ...any)
- func YesNo(prompt string) (proceed bool)
- type Option
- type Row
- type SGR
- type SpinnerStyle
- type Template
Constants ¶
const CSI = "\033["
const Reset = CSI + "0m"
Variables ¶
var BlackBg = bg + black
var BlackText = fg + black
var BlueBg = bg + blue
var BlueText = fg + blue
var BrightBlueBg = bg + brightBlue
var BrightBlueText = fg + brightBlue
var BrightCyanBg = bg + brightCyan
var BrightCyanText = fg + brightCyan
var BrightGreenBg = bg + brightGreen
var BrightGreenText = fg + brightGreen
var BrightMagentaBg = bg + brightMagenta
var BrightMagentaText = fg + brightMagenta
var BrightRedBg = bg + brightRed
var BrightRedText = fg + brightRed
var BrightYellowBg = bg + brightYellow
var BrightYellowText = fg + brightYellow
var CyanBg = bg + cyan
var CyanText = fg + cyan
var GrayBg = bg + gray
var GrayText = fg + gray
var GreenBg = bg + green
var GreenText = fg + green
var MagentaBg = bg + magenta
var MagentaText = fg + magenta
var RedBg = bg + red
var RedText = fg + red
var WhiteBg = bg + white
var WhiteText = fg + white
var YellowBg = bg + yellow
var YellowText = fg + yellow
Functions ¶
func AskSecret ¶
AskSecret prints your prompt and feeds input from os.Stdin into store but hides the input
func BackUp ¶
func BackUp()
BackUp passes `currentLine` to LinePrev to go to the previous line `currentLine` number of times. It then resets `currentLine` to 0.
func BigBanner ¶
BigBanner returns a box around `message` made of # signs. ########### # EXAMPLE # ###########
func Cursor ¶
Cursor moves the cursor to a specific position on the screen. `row` sets the cursors Y position `col` sets the cursors X position
func CursorBack ¶
func CursorBack(columns int)
CursorBack moves the cursor back `columns` number of times
func CursorFwd ¶
func CursorFwd(columns int)
CursorFwd moves the cursor forward `columns` number of times
func LineFeed ¶
func LineFeed()
LineFeed simulates a line feed by going to the next line and scrolling up once
func LineNext ¶
func LineNext(lines int)
LineNext moves the cursor to the next line, `lines` number of times
func LinePrev ¶
func LinePrev(lines int)
LinePrev moves the cursor to the previous line, `lines` number of times
func Menu ¶
Menu displays a menu of options and triggers the callback corresponding to the option chosen
func Painter ¶
func Painter(callback Template)
Painter prints and updates content received from Template Learn more: https://github.com/electrikmilk/ttuy/wiki/Painter()
func Prompt ¶
Prompt prints a prompt for the user to choose yes or no using the arrow keys then returns a boolean based on the option chosen
func ScrollDown ¶
func ScrollDown(lines int)
ScrollDown scrolls the whole page down by `lines` lines
func Segmented ¶
Segmented transforms n into a series of characters resembling a segmented display. It accepts numbers 0-9 and colons. Example: "20:00"
func Spinner ¶
func Spinner(status string, style SpinnerStyle)
Spinner prints a progress indicator in style until StopSpinner() is called You must use a goroutine when running this function (e.g. go Spinner(...))
func StylePersist ¶
StylePersist outputs SGR sequences with no reset Anything after will be formatted using styles until the Reset constant is used
func Typewriter ¶
func Typewriter(message string)
Typewriter prints characters in message out one at a time
func TypewriterTimed ¶
TypewriterTimed prints characters in message out one at a time at duration
Types ¶
type SGR ¶
type SGR string
const Blink SGR = "5"
const BlinkFast SGR = "6"
const Bold SGR = "1"
const Crossed SGR = "9"
const Dim SGR = "2"
const Hidden SGR = "8"
const Inverted SGR = "7"
const Italic SGR = "3"
const Underlined SGR = "4"
type SpinnerStyle ¶
type SpinnerStyle string
const Blinker SpinnerStyle = "blinker"
const DotDotDot SpinnerStyle = "dotdotdot"
const Throbber SpinnerStyle = "throbber"
const Ticker SpinnerStyle = "ticker"