Description
Description
When changing the fore/background colors of rows in a table, the bottom line in the box enclosing the table takes that FG+BG value
To Reproduce
See code way below, with explanations
Expected behavior
Bottom border should be the same as the rest of the borders
Software (please complete the following information):
- OS: Linux (Ubuntu 22.04.01, fully updated)
- GoLang Version 1.19 (manual install, not taking the .deb package from distro)
Additional context
A simple libvirtd client; a port of my Python3 current client. I want the "Running" VMs to be displayed in green, at the bottom of the list, but the bottom border keeps the last line's colors.
Here's my function that displays the VMs with their various states. The struct vmspecs holds all of the various VMs stats (I've snipped part of the code where not pertinent to issue)
func VM_List() {
var vmspecs = collectInfo()
t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.AppendHeader((table.Row{"ID", "VM name", "State", "vMemory", "vCPUs", "Snapshots", "Curr snapshot", "iface name", "IP address"}))
for _, vmspec := range vmspecs {
sID := ""
if vmspec.viId > 0 && vmspec.viId < 10 {
sID = fmt.Sprintf("000%d", vmspec.viId)
<SNIP>
t.AppendRow([]interface{}{sID, vmspec.viName, vmspec.viState, vmspec.viMem, vmspec.viCpu, vmspec.viSnapshot, vmspec.viCurrentSnapshot, vmspec.viInterfaceName, vmspec.viIPaddress})
}
t.SortBy([]table.SortBy{
{Name: "ID", Mode: table.Asc},
{Name: "VM name", Mode: table.Asc},
})
t.SetStyle(table.StyleBold)
//t.Style().Options.DrawBorder = false
//t.Style().Options.SeparateColumns = false
t.Style().Format.Header = text.FormatDefault
t.SetRowPainter(table.RowPainter(func(row table.Row) text.Colors {
switch row[2] {
case "Running":
return text.Colors{text.BgBlack, text.FgHiGreen}
case "Crashed":
return text.Colors{text.BgBlack, text.FgHiRed}
case "Blocked":
case "Suspended":
case "Paused":
return text.Colors{text.BgHiBlack, text.FgHiYellow}
}
return nil
}))
t.Render()
}
This is my very first Go software; to learn a language you need your own project, right, so I'm porting my Python3 tool to Go, so bear with me if you see glaring coding errors.
For all I know, I might be missing something obvious in your package usage.