mirror of https://github.com/rivo/tview
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
733 B
Go
34 lines
733 B
Go
7 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"github.com/rivo/tview"
|
||
|
)
|
||
|
|
||
|
const pageCount = 5
|
||
|
|
||
|
func main() {
|
||
|
app := tview.NewApplication()
|
||
|
pages := tview.NewPages()
|
||
|
for page := 0; page < pageCount; page++ {
|
||
|
func(page int) {
|
||
|
pages.AddPage(fmt.Sprintf("page-%d", page),
|
||
|
tview.NewModal().
|
||
|
SetText(fmt.Sprintf("This is page %d. Choose where to go next.", page+1)).
|
||
|
AddButtons([]string{"Next", "Quit"}).
|
||
|
SetDoneFunc(func(buttonIndex int, buttonLabel string) {
|
||
|
if buttonIndex == 0 {
|
||
|
pages.SwitchToPage(fmt.Sprintf("page-%d", (page+1)%pageCount))
|
||
|
} else {
|
||
|
app.Stop()
|
||
|
}
|
||
|
}),
|
||
|
page == 0)
|
||
|
}(page)
|
||
|
}
|
||
|
if err := app.SetRoot(pages, true).SetFocus(pages).Run(); err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
}
|