gdamore/tcell

Excessive Ram usage for colors in direct / Tc mode

Consolatis opened this issue · 1 comments

Examples:

TERM=tmux-direct go run _demos/hello_world.go
TERM=foot-direct go run _demos/hello_world.go
TERM=vte-direct go run _demos/hello_world.go

Seems to boil down to trying to index "all the colors" which in case of the -direct variants are 16,777,216.

tcell/tscreen.go

Lines 202 to 208 in 96bb70f

t.colors = make(map[Color]Color)
t.palette = make([]Color, t.nColors())
for i := 0; i < t.nColors(); i++ {
t.palette[i] = Color(i) | ColorValid
// identity map for our builtin colors
t.colors[Color(i)|ColorValid] = Color(i) | ColorValid
}

Edit:
Removed xterm-direct and kitty-direct from the examples because at least xterm uses the builtin terminfo/x/xterm/direct.go entry that is limited to 256 colors which I guess kind of works as a work-around for known terminals but fails for all the other ones.

That would obviously be bad. I will revisit because we don't want to index more than 256 colors.