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
14 files
+ 569
7
Compare changes
  • Side-by-side
  • Inline
Files
14
+ 50
0
package app
import "github.com/rivo/tview"
type view interface {
GetContent() tview.Primitive
}
type App struct {
app *tview.Application
pages *tview.Pages
}
func NewApp() *App {
a := &App{
app: tview.NewApplication(),
}
return a
}
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 {
return a.app.Run()
}
func (a *App) Stop() {
a.app.Stop()
}
func (a *App) Draw() {
a.app.Draw()
}
func (a *App) SetFocus(v tview.Primitive) {
a.app.SetFocus(v)
}
Loading