Skip to content
Snippets Groups Projects

V.0.1.0 Codename Threadbare

Closed Ghost User requested to merge v.0.1.0-codename-threadbare into master
4 files
+ 61
4
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 16
3
@@ -5,8 +5,10 @@ import "github.com/rivo/tview"
type view interface {
GetContent() tview.Primitive
}
type App struct {
app *tview.Application
app *tview.Application
pages *tview.Pages
}
func NewApp() *App {
@@ -16,8 +18,19 @@ func NewApp() *App {
return a
}
func (a *App) SetView(v view) {
a.app.SetRoot(v.GetContent(), true)
func (a *App) SetRoot(v view) {
a.pages = v.GetContent().(*tview.Pages)
a.app.SetRoot(a.pages, true)
}
func (a *App) SwitchPage(s string) {
if a.pages.HasPage(s) {
a.pages.SwitchToPage(s)
}
}
func (a *App) AddPage(name string, p view) {
a.pages.AddPage(name, p.GetContent(), true, false)
}
func (a *App) Run() error {
Loading