Skip to content
Snippets Groups Projects
resultAndInputView.go 961 B
Newer Older
  • Learn to ignore specific revisions
  • package views
    
    import (
    
    	"code.fbi.h-da.de/cocsn/gosdn/cmd/gosdn-tview/app"
    
    	"github.com/rivo/tview"
    )
    
    type ResultAndInputView struct {
    
    	pages        *tview.Pages
    	resultView   *tview.TextView
    	pndInputView *AddPNDView
    
    func NewResultAndInputView(app *app.App) *ResultAndInputView {
    
    Malte Bauch's avatar
    Malte Bauch committed
    	rv := &ResultAndInputView{
    
    		pages:        tview.NewPages(),
    		pndInputView: NewAddPNDView(app),
    		resultView:   tview.NewTextView(),
    
    Malte Bauch's avatar
    Malte Bauch committed
    	}
    
    	rv.resultView.
    
    		SetDynamicColors(true).
    		SetRegions(true).
    		SetScrollable(true).
    		SetTitle("Result").
    
    		SetBorder(true)
    
    	rv.pages.
    		AddPage("result", rv.resultView, true, true).
    		AddPage("addPND", rv.pndInputView.GetContent(), true, false)
    
    
    Malte Bauch's avatar
    Malte Bauch committed
    	return rv
    
    Malte Bauch's avatar
    Malte Bauch committed
    func (rv *ResultAndInputView) GetContent() tview.Primitive {
    
    	return rv.pages
    }
    
    func (rv *ResultAndInputView) ChangeContentView(s string) {
    	rv.pages.SwitchToPage(s)
    
    Malte Bauch's avatar
    Malte Bauch committed
    func (rv *ResultAndInputView) SetContent(s string) {
    
    	rv.resultView.Clear()
    	rv.resultView.SetText(s)