2017-12-31 05:10:13 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-10-18 20:15:57 +08:00
|
|
|
"github.com/gdamore/tcell/v2"
|
2017-12-31 05:10:13 +08:00
|
|
|
"github.com/rivo/tview"
|
|
|
|
)
|
|
|
|
|
|
|
|
const helloWorld = `[green]package[white] main
|
|
|
|
|
|
|
|
[green]import[white] (
|
|
|
|
[red]"github.com/rivo/tview"[white]
|
|
|
|
)
|
|
|
|
|
|
|
|
[green]func[white] [yellow]main[white]() {
|
|
|
|
box := tview.[yellow]NewBox[white]().
|
|
|
|
[yellow]SetBorder[white](true).
|
|
|
|
[yellow]SetTitle[white]([red]"Hello, world!"[white])
|
|
|
|
tview.[yellow]NewApplication[white]().
|
|
|
|
[yellow]SetRoot[white](box, true).
|
|
|
|
[yellow]Run[white]()
|
|
|
|
}`
|
|
|
|
|
|
|
|
// HelloWorld shows a simple "Hello world" example.
|
|
|
|
func HelloWorld(nextSlide func()) (title string, content tview.Primitive) {
|
|
|
|
// We use a text view because we want to capture keyboard input.
|
|
|
|
textView := tview.NewTextView().SetDoneFunc(func(key tcell.Key) {
|
|
|
|
nextSlide()
|
|
|
|
})
|
|
|
|
textView.SetBorder(true).SetTitle("Hello, world!")
|
|
|
|
return "Hello, world", Code(textView, 30, 10, helloWorld)
|
|
|
|
}
|