Create base layout for the rest page.

This commit is contained in:
2025-11-28 23:09:39 +00:00
parent f40951a601
commit f0b979708d
2 changed files with 98 additions and 20 deletions

View File

@@ -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
}