From 0ba0fd389c211c35958a383cbaea138f6eebea91 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 9 Oct 2008 22:00:33 +0000 Subject: Translate 256 colours to 16. --- tty.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'tty.c') diff --git a/tty.c b/tty.c index 2df880af..6477cbde 100644 --- a/tty.c +++ b/tty.c @@ -1,4 +1,4 @@ -/* $Id: tty.c,v 1.45 2008-09-26 07:23:21 nicm Exp $ */ +/* $Id: tty.c,v 1.46 2008-10-09 22:00:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -980,11 +980,14 @@ tty_attributes_fg(struct tty *tty, const struct grid_cell *gc) tty_puts(tty, s); return; } - - if (fg > 15) - fg = 8; - else if (fg > 7) - fg -= 8; + fg = colour_translate256(fg); + if (fg & 8) { + fg &= 7; + if (enter_bold_mode != NULL) + tty_puts(tty, enter_bold_mode); + tty->cell.attr |= GRID_ATTR_BRIGHT; + } else if (tty->cell.attr & GRID_ATTR_BRIGHT) + tty_reset(tty); } if (fg == 8 && @@ -1010,11 +1013,16 @@ tty_attributes_bg(struct tty *tty, const struct grid_cell *gc) tty_puts(tty, s); return; } - - if (bg > 15) - bg = 8; - else if (bg > 7) - bg -= 8; + bg = colour_translate256(bg); + if (bg & 8) { + /* + * Bold background; not sure how widely this is + * supported... + */ + xsnprintf(s, sizeof s, "\033[%hhum", 92 + bg); + tty_puts(tty, s); + return; + } } if (bg == 8 && -- cgit