forked from tslocum/cview
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
769 B
35 lines
769 B
// Demo code for the Pages primitive. |
|
package main |
|
|
|
import ( |
|
"fmt" |
|
|
|
"git.sr.ht/~tslocum/cview" |
|
) |
|
|
|
const pageCount = 5 |
|
|
|
func main() { |
|
app := cview.NewApplication() |
|
pages := cview.NewPages() |
|
for page := 0; page < pageCount; page++ { |
|
func(page int) { |
|
pages.AddPage(fmt.Sprintf("page-%d", page), |
|
cview.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() |
|
} |
|
}), |
|
false, |
|
page == 0) |
|
}(page) |
|
} |
|
if err := app.SetRoot(pages, true).Run(); err != nil { |
|
panic(err) |
|
} |
|
}
|
|
|