Skip to content
Browse files

Special-case color 0

When rendering color 0, use the ANSI system color 0 instead of the
xterm-256 color 16. In theory they're the same, but in practice
Terminal.app treats them differently for text color purposes.
  • Loading branch information...
1 parent bd9719d commit 42a32cd3330b22ea2d1e900e88e404ad8b336223 @kballard committed Apr 24, 2012
Showing with 13 additions and 5 deletions.
  1. +13 −5 dcpu/video.go
View
18 dcpu/video.go
@@ -124,11 +124,19 @@ var glyphMap = map[rune]rune{
func colorToAttr(color byte) termbox.Attribute {
var attr termbox.Attribute
if supportsXterm256 {
- // We need to use xterm-256 colors to work properly here.
- // Luckily, we built a table!
- attr = termbox.ColorXterm256
- ansi := colorToAnsi[color]
- attr |= termbox.Attribute(ansi) << termbox.XtermColorShift
+ // special-case 0 for Terminal.app.
+ // Terminal.app adjusts the foreground colors a bit so text can be distinguished
+ // from a same-colored background. We don't want this. It doesn't appear to perform
+ // this adjustment for ANSI color 0 (but it does for xterm-256 color 16).
+ if color == 0 {
+ attr = termbox.ColorBlack
+ } else {
+ // We need to use xterm-256 colors to work properly here.
+ // Luckily, we built a table!
+ attr = termbox.ColorXterm256
+ ansi := colorToAnsi[color]
+ attr |= termbox.Attribute(ansi) << termbox.XtermColorShift
+ }
} else {
// We don't seem to support xterm-256 colors, so fall back on
// trying to use the normal ANSI colors

0 comments on commit 42a32cd

Please sign in to comment.
Something went wrong with that request. Please try again.