2017-12-30 21:10:13 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
2020-08-30 15:36:03 +00:00
|
|
|
"github.com/gdamore/tcell/v2"
|
2020-01-22 23:28:19 +00:00
|
|
|
"gitlab.com/tslocum/cview"
|
2017-12-30 21:10:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const logo = `
|
2020-01-04 02:46:23 +00:00
|
|
|
======= === === === ======== === === ===
|
|
|
|
=== === === === === === === ===
|
|
|
|
=== === === === ====== === === ===
|
2020-01-07 00:59:59 +00:00
|
|
|
=== ====== === === ===========
|
2020-01-04 02:46:23 +00:00
|
|
|
======= == === ======== ==== ====
|
2017-12-30 21:10:13 +00:00
|
|
|
`
|
|
|
|
|
2018-01-12 07:19:32 +00:00
|
|
|
const (
|
2020-01-07 00:59:59 +00:00
|
|
|
subtitle = `Terminal-based user interface toolkit`
|
2020-04-01 15:42:30 +00:00
|
|
|
mouse = `Navigate with your keyboard or mouse.`
|
|
|
|
navigation = `Next slide: Ctrl-N Previous: Ctrl-P Exit: Ctrl-C`
|
2018-01-12 07:19:32 +00:00
|
|
|
)
|
2017-12-30 21:10:13 +00:00
|
|
|
|
|
|
|
// Cover returns the cover page.
|
2019-12-30 23:12:17 +00:00
|
|
|
func Cover(nextSlide func()) (title string, content cview.Primitive) {
|
2017-12-30 21:10:13 +00:00
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
}
|
2019-12-30 23:12:17 +00:00
|
|
|
logoBox := cview.NewTextView().
|
2020-08-30 15:36:03 +00:00
|
|
|
SetTextColor(tcell.ColorGreen.TrueColor()).
|
2017-12-30 21:10:13 +00:00
|
|
|
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.
|
2019-12-30 23:12:17 +00:00
|
|
|
frame := cview.NewFrame(cview.NewBox()).
|
2017-12-30 21:10:13 +00:00
|
|
|
SetBorders(0, 0, 0, 0, 0, 0).
|
2020-08-30 15:36:03 +00:00
|
|
|
AddText(subtitle, true, cview.AlignCenter, tcell.ColorWhite.TrueColor()).
|
|
|
|
AddText("", true, cview.AlignCenter, tcell.ColorWhite.TrueColor()).
|
|
|
|
AddText(mouse, true, cview.AlignCenter, tcell.ColorDarkMagenta.TrueColor()).
|
|
|
|
AddText(navigation, true, cview.AlignCenter, tcell.ColorDarkMagenta.TrueColor())
|
2017-12-30 21:10:13 +00:00
|
|
|
|
|
|
|
// Create a Flex layout that centers the logo and subtitle.
|
2019-12-30 23:12:17 +00:00
|
|
|
flex := cview.NewFlex().
|
|
|
|
SetDirection(cview.FlexRow).
|
|
|
|
AddItem(cview.NewBox(), 0, 7, false).
|
|
|
|
AddItem(cview.NewFlex().
|
|
|
|
AddItem(cview.NewBox(), 0, 1, false).
|
2017-12-30 21:10:13 +00:00
|
|
|
AddItem(logoBox, logoWidth, 1, true).
|
2019-12-30 23:12:17 +00:00
|
|
|
AddItem(cview.NewBox(), 0, 1, false), logoHeight, 1, true).
|
2017-12-30 21:10:13 +00:00
|
|
|
AddItem(frame, 0, 10, false)
|
|
|
|
|
|
|
|
return "Start", flex
|
|
|
|
}
|