Merge branch 'alytvynov-master'

This commit is contained in:
gizak 2015-10-20 21:59:18 -04:00
commit 4d6b0249c0
2 changed files with 26 additions and 2 deletions

View File

@ -92,8 +92,12 @@ func (d *Block) Buffer() []Point {
for i := 0; i < d.innerWidth; i++ { for i := 0; i < d.innerWidth; i++ {
for j := 0; j < d.innerHeight; j++ { for j := 0; j < d.innerHeight; j++ {
p := Point{} p := Point{}
p.X = d.X + 1 + i p.X = d.X + i
p.Y = d.Y + 1 + j p.Y = d.Y + j
if d.HasBorder {
p.X++
p.Y++
}
p.Ch = ' ' p.Ch = ' '
p.Bg = d.BgColor p.Bg = d.BgColor
ps = append(ps, p) ps = append(ps, p)

20
p_test.go Normal file
View File

@ -0,0 +1,20 @@
package termui
import "testing"
func TestPar_NoBorderBackground(t *testing.T) {
par := NewPar("a")
par.HasBorder = false
par.BgColor = ColorBlue
par.TextBgColor = ColorBlue
par.Width = 2
par.Height = 2
pts := par.Buffer()
for _, p := range pts {
t.Log(p)
if p.Bg != par.BgColor {
t.Errorf("expected color to be %v but got %v", par.BgColor, p.Bg)
}
}
}