29 lines
499 B
Go
29 lines
499 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) {
|
|
v.ViewTmpl.Draw(buf)
|
|
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)
|
|
}
|