tview
tview copied to clipboard
Special character rendered incorrect in Table
Special characters such as / do not get rendered in the Table Cell if font color is set to light. However, if I set the font color to be black, it gets rendered.
The 1st image is the one that the whole table cell does not get rendered, the 2nd image is the one that table cell gets rendered if I set the font color to be black.
The issue seems only on Table component. I do not see the same issue with TextView at least
Please include a brief code snippet that allows me to reproduce this issue.
Please see blow example. I found out the issue is probably more leaning towards [ and ] instead of previous special character /.
package main
import (
"github.com/rivo/tview"
"github.com/gdamore/tcell/v2"
)
func main() {
app := tview.NewApplication()
table := tview.NewTable().
SetBorders(true)
content := []string{"Name", "[WEB][ABC][SINGLE][Tom & Bob][123][SAMPLE]"}
for r := 0; r < len(content); r++ {
table.SetCellSimple(r, 0, content[r])
}
table.Select(0, 0).SetDoneFunc(func(key tcell.Key) {
if key == tcell.KeyEscape {
app.Stop()
}
if key == tcell.KeyEnter {
table.SetSelectable(true, true)
}
}).SetSelectedFunc(func(row int, column int) {
table.GetCell(row, column).SetTextColor(tcell.ColorRed)
table.SetSelectable(false, false)
})
if err := app.SetRoot(table, true).SetFocus(table).Run(); err != nil {
panic(err)
}
}