Create base layout for the rest page.
This commit is contained in:
23
tui/tui.go
23
tui/tui.go
@@ -2,12 +2,12 @@ package tui
|
||||
|
||||
import (
|
||||
"git.embergate.com/saeedafzal/restui/tui/rest"
|
||||
"github.com/rivo/tview"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
type Tui struct {
|
||||
app *tview.Application
|
||||
app *tview.Application
|
||||
pages *tview.Pages
|
||||
}
|
||||
|
||||
@@ -16,18 +16,17 @@ func New(app *tview.Application) Tui {
|
||||
}
|
||||
|
||||
func (t Tui) Root() *tview.Pages {
|
||||
rest := rest.New()
|
||||
rest := rest.New(t.app)
|
||||
|
||||
t.pages.AddPage("rest", rest.Root(), true, true)
|
||||
t.pages.SetInputCapture(t.rootInputCapture)
|
||||
|
||||
t.pages.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
||||
if event.Rune() == 'q' {
|
||||
t.app.Stop()
|
||||
return nil
|
||||
}
|
||||
return event
|
||||
})
|
||||
|
||||
return t.pages
|
||||
}
|
||||
|
||||
func (t Tui) rootInputCapture(event *tcell.EventKey) *tcell.EventKey {
|
||||
if event.Rune() == 'q' {
|
||||
t.app.Stop()
|
||||
return nil
|
||||
}
|
||||
return event
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user