Repository navigation
Widgets
Brandon Jordan edited this page Apr 15, 2023
·
23 revisions
var name string
ttuy.Ask("Enter your name", &name)
if ttuy.Prompt("Install Program? This will take up 586kb.") {
fmt.Println("Installing...")
} else {
fmt.Println("Installation Canceled.")
}
if ttuy.YesNo("Are you sure?") {
fmt.Println("Installing...")
} else {
fmt.Println("Installation Canceled.")
}
ttuy.Menu("Title", []ttuy.Option{
{
Label: "Option 1",
Callback: func() {
// ...
},
},
{
Label: "Option 2",
Callback: func() {
// ...
},
Disabled: true,
},
// ...
})
var headers = []string{"Header 1", "Header 2", "Header 3", "Header 4"}
var rows []ttuy.Row
for i := 0; i < 5; i++ {
var rowRows = []string{"Cell 1", "Cell 2", "Cell 3", "Cell 4"}
rows = append(rows, ttuy.Row{columns: rowRows})
}
ttuy.Table(headers, rows)
var alphabet = strings.Split("abcdefghijklmnopqrstuvwxyz", "")
var rows []ttuy.Row
for i := 0; i < 10; i++ {
var rowRows []string
for c := 1; c < 5; c++ {
var cellContent string
for w := 0; w < 26; w++ {
cellContent += alphabet[w]
}
rowRows = append(rowRows, cellContent)
}
rows = append(rows, ttuy.Row{columns: rowRows})
}
fmt.Println(ttuy.Grid(rows))
ttuy.Viewport(fileContents)
for i := 0; i <= 100; i++ {
ttuy.ProgressBar(i)
time.Sleep(100 * time.Millisecond)
}
Displays numbers like a segmented display, takes a string. Allows for numbers 0-9 and colons.
ttuy.Segmented("20:00")go ttuy.Spinner("Indeterminate Progress", ttuy.Ticker | ttuy.DotDotDot | ttuy.Throbber | ttuy.Blinker)
for i := 0; i < 50; i++ {
time.Sleep(30 * time.Millisecond)
}
ttuy.StopSpinner()
ttuy.Typewriter("Typed out one character at a time")
Or time it specifically...
ttuy.TypewriterTimed("Typed out at duration...", 1000)
