Skip to content

Commit

Permalink
fixes #564 Excessive Ram usage for colors in direct / Tc mode
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamore committed Oct 17, 2022
1 parent 178ac43 commit 7557ac2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tscreen.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,13 @@ func (t *tScreen) Init() error {
if os.Getenv("TCELL_TRUECOLOR") == "disable" {
t.truecolor = false
}
t.colors = make(map[Color]Color)
t.palette = make([]Color, t.nColors())
for i := 0; i < t.nColors(); i++ {
nColors := t.nColors()
if nColors > 256 {
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
// identity map for our builtin colors
t.colors[Color(i)|ColorValid] = Color(i) | ColorValid
Expand Down

0 comments on commit 7557ac2

Please sign in to comment.