tui/views/textview.go
Timon Ringwald dfa00f5fe3 more views
2022-04-02 13:01:41 +02:00

28 lines
477 B
Go

package views
import (
"git.tordarus.net/Tordarus/tui"
)
// TextView is a tui.View which prints text
type TextView struct {
tui.ViewTmpl
Text string
}
var _ tui.View = &TextView{}
func (v *TextView) Draw(buf *tui.ViewBuffer) {
tui.WriteMultiLineString(buf, v.Text, v.Style(), 0, 0)
}
func NewTextView(text string) *TextView {
return &TextView{
Text: text,
}
}
func (v *TextView) Layout() (prefWidth, prefHeight int) {
return tui.MeasureMultiLineString(v.Text)
}