From 3eaafc770691cae9ae8a53846876cd9c9ca5d164 Mon Sep 17 00:00:00 2001 From: Ryan Lewis Date: Fri, 1 Feb 2019 18:24:46 +0000 Subject: [PATCH] Tweaked background colour rendering on seperators when using row fill --- _examples/table.go | 2 +- widgets/table.go | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/_examples/table.go b/_examples/table.go index 3fda66b..ee42212 100644 --- a/_examples/table.go +++ b/_examples/table.go @@ -56,7 +56,7 @@ func main() { table3.SetRect(0, 30, 70, 20) table3.FillRow = true table3.RowStyles[0] = ui.NewStyle(ui.ColorWhite, ui.ColorBlack, ui.ModifierBold) - table3.RowStyles[2] = ui.NewStyle(ui.ColorRed) + table3.RowStyles[2] = ui.NewStyle(ui.ColorWhite, ui.ColorRed, ui.ModifierBold) table3.RowStyles[3] = ui.NewStyle(ui.ColorYellow) ui.Render(table3) diff --git a/widgets/table.go b/widgets/table.go index b6a2f62..14f58ef 100644 --- a/widgets/table.go +++ b/widgets/table.go @@ -100,13 +100,16 @@ func (self *Table) Draw(buf *Buffer) { // draw vertical separators separatorStyle := self.Block.BorderStyle - if self.FillRow { - separatorStyle.Bg = rowStyle.Bg - } separatorXCoordinate := self.Inner.Min.X verticalCell := NewCell(VERTICAL_LINE, separatorStyle) - for _, width := range columnWidths { + for i, width := range columnWidths { + if self.FillRow && i < len(columnWidths)-1 { + verticalCell.Style.Bg = rowStyle.Bg + } else { + verticalCell.Style.Bg = self.Block.BorderStyle.Bg + } + separatorXCoordinate += width buf.SetCell(verticalCell, image.Pt(separatorXCoordinate, yCoordinate)) separatorXCoordinate++