summaryrefslogtreecommitdiffstats
path: root/tty.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2008-10-09 22:00:33 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2008-10-09 22:00:33 +0000
commit0ba0fd389c211c35958a383cbaea138f6eebea91 (patch)
treeb50b85185977a0a30d63654fb30bd389af42ebb7 /tty.c
parent185f7297e8df1399094b7e3d1314f1af1e94e633 (diff)
Translate 256 colours to 16.
Diffstat (limited to 'tty.c')
-rw-r--r--tty.c30
1 files changed, 19 insertions, 11 deletions
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 <nicm@users.sourceforge.net>
@@ -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 &&