few tweaks to par.go

This commit is contained in:
James Ryland Miller 2015-10-29 21:55:30 -05:00
parent 16d4dfecd0
commit 32570bba60

9
par.go
View File

@ -16,6 +16,7 @@ type Par struct {
Text string
TextFgColor Attribute
TextBgColor Attribute
WrapLength uint
}
// NewPar returns a new *Par with given text as its content.
@ -25,6 +26,7 @@ func NewPar(s string) *Par {
Text: s,
TextFgColor: ThemeAttr("par.text.fg"),
TextBgColor: ThemeAttr("par.text.bg"),
WrapLength: 0,
}
}
@ -33,7 +35,12 @@ func (p *Par) Buffer() Buffer {
buf := p.Block.Buffer()
fg, bg := p.TextFgColor, p.TextBgColor
cs := DefaultTxBuilder.Build(p.Text, fg, bg)
cs := []Cell{}
if p.WrapLength < 1 {
cs = DefaultTxBuilder.Build(p.Text, fg, bg)
} else {
cs = DefaultTxBuilder.BuildWrap(p.Text, fg, bg, p.WrapLength)
}
y, x, n := 0, 0, 0
for y < p.innerArea.Dy() && n < len(cs) {