2021-01-10 21:52:29 +01:00
|
|
|
package tui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
2022-04-01 20:10:51 +02:00
|
|
|
"git.tordarus.net/Tordarus/tui"
|
|
|
|
"git.tordarus.net/Tordarus/tui/views"
|
2021-01-10 21:52:29 +01:00
|
|
|
"github.com/gdamore/tcell"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestScreen(t *testing.T) {
|
2022-04-01 20:10:51 +02:00
|
|
|
textView := views.NewTextView("hello world")
|
|
|
|
eventView := views.NewEventView(textView)
|
2021-01-10 21:52:29 +01:00
|
|
|
screen, err := tui.NewScreen(eventView)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-04-01 20:10:51 +02:00
|
|
|
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
|
2021-01-10 21:52:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
err = screen.Start()
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|