2017-12-30 21:10:13 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
2020-10-18 12:15:57 +00:00
|
|
|
"github.com/gdamore/tcell/v2"
|
2017-12-30 21:10:13 +00:00
|
|
|
"github.com/rivo/tview"
|
|
|
|
)
|
|
|
|
|
|
|
|
const logo = `
|
|
|
|
__ _
|
|
|
|
/ /__ __(_)__ _ __
|
|
|
|
/ __/ | / / / _ \ | /| / /
|
|
|
|
/ /_ | |/ / / __/ |/ |/ /
|
|
|
|
\__/ |___/_/\___/|__/|__/
|
|
|
|
|
|
|
|
`
|
|
|
|
|
2018-01-12 07:19:32 +00:00
|
|
|
const (
|
|
|
|
subtitle = `tview - Rich Widgets for Terminal UIs`
|
2023-08-26 14:19:31 +00:00
|
|
|
navigation = `[yellow]Ctrl-N[-]: Next slide [yellow]Ctrl-P[-]: Previous slide [yellow]Ctrl-C[-]: Exit`
|
2020-03-29 18:53:28 +00:00
|
|
|
mouse = `(or use your mouse)`
|
2018-01-12 07:19:32 +00:00
|
|
|
)
|
2017-12-30 21:10:13 +00:00
|
|
|
|
|
|
|
// Cover returns the cover page.
|
|
|
|
func Cover(nextSlide func()) (title string, content tview.Primitive) {
|
|
|
|
// What's the size of the logo?
|
|
|
|
lines := strings.Split(logo, "\n")
|
|
|
|
logoWidth := 0
|
|
|
|
logoHeight := len(lines)
|
|
|
|
for _, line := range lines {
|
|
|
|
if len(line) > logoWidth {
|
|
|
|
logoWidth = len(line)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
logoBox := tview.NewTextView().
|
|
|
|
SetTextColor(tcell.ColorGreen).
|
|
|
|
SetDoneFunc(func(key tcell.Key) {
|
|
|
|
nextSlide()
|
|
|
|
})
|
|
|
|
fmt.Fprint(logoBox, logo)
|
|
|
|
|
2018-01-12 07:19:32 +00:00
|
|
|
// Create a frame for the subtitle and navigation infos.
|
2017-12-30 21:10:13 +00:00
|
|
|
frame := tview.NewFrame(tview.NewBox()).
|
|
|
|
SetBorders(0, 0, 0, 0, 0, 0).
|
2018-01-12 07:19:32 +00:00
|
|
|
AddText(subtitle, true, tview.AlignCenter, tcell.ColorWhite).
|
|
|
|
AddText("", true, tview.AlignCenter, tcell.ColorWhite).
|
2020-03-29 18:53:28 +00:00
|
|
|
AddText(navigation, true, tview.AlignCenter, tcell.ColorDarkMagenta).
|
|
|
|
AddText(mouse, true, tview.AlignCenter, tcell.ColorDarkMagenta)
|
2017-12-30 21:10:13 +00:00
|
|
|
|
|
|
|
// Create a Flex layout that centers the logo and subtitle.
|
|
|
|
flex := tview.NewFlex().
|
|
|
|
SetDirection(tview.FlexRow).
|
|
|
|
AddItem(tview.NewBox(), 0, 7, false).
|
|
|
|
AddItem(tview.NewFlex().
|
|
|
|
AddItem(tview.NewBox(), 0, 1, false).
|
|
|
|
AddItem(logoBox, logoWidth, 1, true).
|
|
|
|
AddItem(tview.NewBox(), 0, 1, false), logoHeight, 1, true).
|
|
|
|
AddItem(frame, 0, 10, false)
|
|
|
|
|
|
|
|
return "Start", flex
|
|
|
|
}
|