Setup.
This commit is contained in:
15
tui/rest/init.go
Normal file
15
tui/rest/init.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package rest
|
||||
|
||||
import "github.com/rivo/tview"
|
||||
|
||||
type Rest struct{}
|
||||
|
||||
func New() Rest {
|
||||
return Rest{}
|
||||
}
|
||||
|
||||
func (r Rest) Root() *tview.Box {
|
||||
return tview.NewBox().
|
||||
SetBorder(true).
|
||||
SetTitle("Hello Rest")
|
||||
}
|
||||
33
tui/tui.go
Normal file
33
tui/tui.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user