tui/tests/screen_test.go
2022-04-01 20:10:51 +02:00

34 lines
680 B
Go

package tui
import (
"errors"
"fmt"
"testing"
"git.tordarus.net/Tordarus/tui"
"git.tordarus.net/Tordarus/tui/views"
"github.com/gdamore/tcell"
)
func TestScreen(t *testing.T) {
textView := views.NewTextView("hello world")
eventView := views.NewEventView(textView)
screen, err := tui.NewScreen(eventView)
if err != nil {
t.Error(err)
return
}
eventView.KeyPressed = func(event *tui.KeyEvent) (consumed bool) {
if event.Key() == tcell.KeyCtrlC {
screen.StopWithError(errors.New(fmt.Sprintf("key: %#v | rune: %s", event.Key(), string(event.Rune()))))
}
//textView.Text = event.When().String()
return true
}
err = screen.Start()
fmt.Println(err)
}