Wrap termenv altscreen functions to make things simpler for the end user

This commit is contained in:
Christian Rocha
2020-02-01 21:02:12 -05:00
parent f94701aff3
commit 5383f5a61e
2 changed files with 14 additions and 3 deletions

View File

@@ -8,7 +8,6 @@ import (
"time"
"github.com/charmbracelet/tea"
"github.com/muesli/termenv"
)
type model int
@@ -16,8 +15,8 @@ type model int
type tickMsg struct{}
func main() {
termenv.AltScreen()
defer termenv.ExitAltScreen()
tea.AltScreen()
defer tea.ExitAltScreen()
err := tea.NewProgram(initialize, update, view, subscriptions).Start()
if err != nil {
log.Fatal(err)

12
tea.go
View File

@@ -269,3 +269,15 @@ func (p *Program) processSubs(msgs chan Msg, activeSubs subManager) subManager {
return activeSubs
}
// AltScreen exits the altscreen. Just is just a wrapper around the termenv
// function
func AltScreen() {
termenv.AltScreen()
}
// ExitAltScreen exits the altscreen. Just is just a wrapper around the termenv
// function
func ExitAltScreen() {
termenv.ExitAltScreen()
}