Newer
Older
"code.fbi.h-da.de/cocsn/gosdn/cmd/gosdn-tview/app"
"google.golang.org/grpc"
//ResultAndInputView is an application view to display different other views.
//Depending on the required features the views are changed.
pages *tview.Pages
resultView *tview.TextView
pndInputView *AddPNDView
consoleLogView *ConsoleLogView
//NewResultAndInputView creates a new ResultAndInputView
func NewResultAndInputView(title string, app *app.App, commandListView tview.Primitive, conn *grpc.ClientConn) *ResultAndInputView {
pndInputView: NewAddPNDView("add PND", app),
consoleLogView: NewConsoleLogView("logs", app, conn),
SetDynamicColors(true).
SetRegions(true).
SetScrollable(true).
AddPage(rv.title, rv.resultView, true, true).
AddPage(rv.pndInputView.GetTitle(), rv.pndInputView.GetContent(), true, false).
AddPage(rv.consoleLogView.GetTitle(), rv.consoleLogView.GetContent(), true, false)
rv.pages.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
k := event.Key()
if k == tcell.KeyESC {
app.SetFocus(commandListView)
}
return event
})
//GetContent returns the tview.Primitive belonging to the ResultAndInputView
func (rv *ResultAndInputView) GetContent() tview.Primitive {
//ChangeContentView changes the current content (tview.Primitive) that is visible
//inside this view
func (rv *ResultAndInputView) ChangeContentView(s string) {
rv.pages.SwitchToPage(s)
//SetContent sets new string content for the ResultAndInputView
rv.resultView.Clear()
rv.resultView.SetText(s)
//GetTitle returns the title of the specific view
func (rv *ResultAndInputView) GetTitle() string {
return rv.title
}