Skip to content

Commit

Permalink
Special-case color 0
Browse files Browse the repository at this point in the history
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
lilyball committed Apr 25, 2012
1 parent bd9719d commit 42a32cd
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions dcpu/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 42a32cd

Please sign in to comment.