HideBorder flag for BorderView

This commit is contained in:
Timon Ringwald 2022-05-03 17:49:25 +02:00
parent 7a1a6503e8
commit bb68797b02

View File

@ -8,6 +8,7 @@ import "git.tordarus.net/Tordarus/tui"
type BorderView struct {
tui.WrapperTmpl
Border BorderBox
HideBorder bool
}
var _ tui.Wrapper = &BorderView{}
@ -20,6 +21,11 @@ func NewBorderView(view tui.View) *BorderView {
}
func (g *BorderView) Draw(buf *tui.ViewBuffer) {
if g.HideBorder {
g.View().Draw(buf)
return
}
g.View().Draw(buf.Sub(1, 1, buf.Width()-2, buf.Height()-2))
buf.Set(0, 0, tui.Rune{Rn: g.Border.TopLeft, Style: g.Style()})