This commit is contained in:
Saeed Afzal
2025-11-28 14:32:44 +00:00
committed by Saeed Afzal
parent 6a7524befb
commit 9569b401ba
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
}