TheMathemagicians/sevenkeys/tui/home/view.go

34 lines
824 B
Go
Raw Normal View History

2024-06-08 15:32:19 +00:00
package home
2024-06-05 12:06:24 +00:00
import (
"os"
"path/filepath"
2024-06-05 13:13:29 +00:00
"strings"
2024-06-05 12:06:24 +00:00
"github.com/lukesampson/figlet/figletlib"
)
func (m Model) View() string {
var ui string
2024-06-05 13:13:29 +00:00
if m.WindowWidth <= 0 {
return ui
}
2024-06-05 12:06:24 +00:00
2024-06-05 13:13:29 +00:00
// Get fonts for figlet
cwd, _ := os.Getwd()
fontsdir := filepath.Join(cwd, "fonts")
slantFont, _ := figletlib.GetFontByName(fontsdir, "slant")
termFont, _ := figletlib.GetFontByName(fontsdir, "term")
2024-06-05 12:06:24 +00:00
2024-06-05 13:13:29 +00:00
// Display splash screen
ui += figletlib.SprintMsg("SEVENKEYS", slantFont, m.WindowWidth, slantFont.Settings(), "center")
ui += figletlib.SprintMsg("the ultimate Magic: the Gathering trading card storage system", termFont, m.WindowWidth, termFont.Settings(), "center")
// Display help
ui += strings.Repeat("\n", m.WindowHeight-8) // TODO: Avoid hardcoding height somehow
ui += m.Help.View(DefaultKeyMap)
2024-06-05 12:06:24 +00:00
return ui
}