fixes #564 Excessive Ram usage for colors in direct / Tc mode

This commit is contained in:
Garrett D'Amore 2022-10-16 22:39:04 -07:00
parent 178ac4393a
commit 7557ac2a6c
1 changed files with 7 additions and 3 deletions

View File

@ -199,9 +199,13 @@ func (t *tScreen) Init() error {
if os.Getenv("TCELL_TRUECOLOR") == "disable" { if os.Getenv("TCELL_TRUECOLOR") == "disable" {
t.truecolor = false t.truecolor = false
} }
t.colors = make(map[Color]Color) nColors := t.nColors()
t.palette = make([]Color, t.nColors()) if nColors > 256 {
for i := 0; i < t.nColors(); i++ { nColors = 256 // clip to reasonable limits
}
t.colors = make(map[Color]Color, nColors)
t.palette = make([]Color, nColors)
for i := 0; i < nColors; i++ {
t.palette[i] = Color(i) | ColorValid t.palette[i] = Color(i) | ColorValid
// identity map for our builtin colors // identity map for our builtin colors
t.colors[Color(i)|ColorValid] = Color(i) | ColorValid t.colors[Color(i)|ColorValid] = Color(i) | ColorValid