few tweaks to par.go
This commit is contained in:
parent
16d4dfecd0
commit
32570bba60
9
par.go
9
par.go
@ -16,6 +16,7 @@ type Par struct {
|
|||||||
Text string
|
Text string
|
||||||
TextFgColor Attribute
|
TextFgColor Attribute
|
||||||
TextBgColor Attribute
|
TextBgColor Attribute
|
||||||
|
WrapLength uint
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPar returns a new *Par with given text as its content.
|
// NewPar returns a new *Par with given text as its content.
|
||||||
@ -25,6 +26,7 @@ func NewPar(s string) *Par {
|
|||||||
Text: s,
|
Text: s,
|
||||||
TextFgColor: ThemeAttr("par.text.fg"),
|
TextFgColor: ThemeAttr("par.text.fg"),
|
||||||
TextBgColor: ThemeAttr("par.text.bg"),
|
TextBgColor: ThemeAttr("par.text.bg"),
|
||||||
|
WrapLength: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +35,12 @@ func (p *Par) Buffer() Buffer {
|
|||||||
buf := p.Block.Buffer()
|
buf := p.Block.Buffer()
|
||||||
|
|
||||||
fg, bg := p.TextFgColor, p.TextBgColor
|
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
|
y, x, n := 0, 0, 0
|
||||||
for y < p.innerArea.Dy() && n < len(cs) {
|
for y < p.innerArea.Dy() && n < len(cs) {
|
||||||
|
Loading…
Reference in New Issue
Block a user