From 32570bba60cf9104fba259822f540df6f6fde2f2 Mon Sep 17 00:00:00 2001 From: James Ryland Miller Date: Thu, 29 Oct 2015 21:55:30 -0500 Subject: [PATCH] few tweaks to par.go --- par.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/par.go b/par.go index 03a3c97..a60262c 100644 --- a/par.go +++ b/par.go @@ -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) {