From 5eb15bb51790821b6ecdd2cbefb7b0fe807ff8d8 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 15 Oct 2021 23:17:39 -0700 Subject: [PATCH] termbox missed the color refactoring memo --- termbox/compat.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/termbox/compat.go b/termbox/compat.go index e1bc4c6..7baf4d2 100644 --- a/termbox/compat.go +++ b/termbox/compat.go @@ -94,15 +94,13 @@ func fixColor(c tcell.Color) tcell.Color { } switch outMode { case OutputNormal: - c %= tcell.Color(16) + c = tcell.PaletteColor(int(c) & 0xf) case Output256: - c %= tcell.Color(256) + c = tcell.PaletteColor(int(c) & 0xff) case Output216: - c %= tcell.Color(216) - c += tcell.Color(16) + c = tcell.PaletteColor(int(c) % 216 + 16) case OutputGrayscale: - c %= tcell.Color(24) - c += tcell.Color(232) + c %= tcell.PaletteColor(int(c) % 24 + 232) default: c = tcell.ColorDefault } @@ -112,8 +110,8 @@ func fixColor(c tcell.Color) tcell.Color { func mkStyle(fg, bg Attribute) tcell.Style { st := tcell.StyleDefault - f := tcell.Color(int(fg)&0x1ff) - 1 - b := tcell.Color(int(bg)&0x1ff) - 1 + f := tcell.PaletteColor(int(fg)&0x1ff-1) + b := tcell.PaletteColor(int(bg)&0x1ff-1) f = fixColor(f) b = fixColor(b)