This commit is contained in:
2025-11-28 16:54:57 +00:00
parent 57c947df05
commit f40951a601
8 changed files with 135 additions and 3 deletions

33
tui/tui.go Normal file
View File

@@ -0,0 +1,33 @@
package tui
import (
"git.embergate.com/saeedafzal/restui/tui/rest"
"github.com/rivo/tview"
"github.com/gdamore/tcell/v2"
)
type Tui struct {
app *tview.Application
pages *tview.Pages
}
func New(app *tview.Application) Tui {
return Tui{app, tview.NewPages()}
}
func (t Tui) Root() *tview.Pages {
rest := rest.New()
t.pages.AddPage("rest", rest.Root(), true, true)
t.pages.SetInputCapture(t.rootInputCapture)
return t.pages
}
func (t Tui) rootInputCapture(event *tcell.EventKey) *tcell.EventKey {
if event.Rune() == 'q' {
t.app.Stop()
return nil
}
return event
}