summaryrefslogtreecommitdiffstats
path: root/sys/teken/teken_subr.h
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-09-26 15:26:32 +0000
committered <ed@FreeBSD.org>2009-09-26 15:26:32 +0000
commitb69a48a63f54bfcc1c9b1bf8a8828fbaf25e004b (patch)
tree33e925a77e9fa035d0525a951f7a87e23f46271e /sys/teken/teken_subr.h
parentba94d1a005032941ea59b2f361257e1cbd4fa6bd (diff)
downloadFreeBSD-src-b69a48a63f54bfcc1c9b1bf8a8828fbaf25e004b.zip
FreeBSD-src-b69a48a63f54bfcc1c9b1bf8a8828fbaf25e004b.tar.gz
Add 256 color support.
It is quite inconvenient that if an application for xterm uses 256 color mode, text suddenly starts to blink (because of ;5; in the middle). We'd better just implement 256 color mode and add a conversion routine from 256 to 8 color mode, which doesn't seem to be too bad in practice. Remapping colors is done quite simple. If one of the channels is most actively represented, primary colors are used. If two channels are most actively represented, secondary colors are used. If all three channels are equal (gray), it picks between black and white. Reported by: Paul B. Mahol <onemda gmail com>
Diffstat (limited to 'sys/teken/teken_subr.h')
-rw-r--r--sys/teken/teken_subr.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/sys/teken/teken_subr.h b/sys/teken/teken_subr.h
index 4c31065..32cae4d 100644
--- a/sys/teken/teken_subr.h
+++ b/sys/teken/teken_subr.h
@@ -1150,6 +1150,12 @@ teken_subr_set_graphic_rendition(teken_t *t, unsigned int ncmds,
case 37: /* Set foreground color: white */
t->t_curattr.ta_fgcolor = n - 30;
break;
+ case 38: /* Set foreground color: 256 color mode */
+ if (i + 2 >= ncmds || cmds[i + 1] != 5)
+ continue;
+ t->t_curattr.ta_fgcolor = cmds[i + 2];
+ i += 2;
+ break;
case 39: /* Set default foreground color. */
t->t_curattr.ta_fgcolor = t->t_defattr.ta_fgcolor;
break;
@@ -1163,9 +1169,35 @@ teken_subr_set_graphic_rendition(teken_t *t, unsigned int ncmds,
case 47: /* Set background color: white */
t->t_curattr.ta_bgcolor = n - 40;
break;
+ case 48: /* Set background color: 256 color mode */
+ if (i + 2 >= ncmds || cmds[i + 1] != 5)
+ continue;
+ t->t_curattr.ta_bgcolor = cmds[i + 2];
+ i += 2;
+ break;
case 49: /* Set default background color. */
t->t_curattr.ta_bgcolor = t->t_defattr.ta_bgcolor;
break;
+ case 90: /* Set bright foreground color: black */
+ case 91: /* Set bright foreground color: red */
+ case 92: /* Set bright foreground color: green */
+ case 93: /* Set bright foreground color: brown */
+ case 94: /* Set bright foreground color: blue */
+ case 95: /* Set bright foreground color: magenta */
+ case 96: /* Set bright foreground color: cyan */
+ case 97: /* Set bright foreground color: white */
+ t->t_curattr.ta_fgcolor = n - 90 + 8;
+ break;
+ case 100: /* Set bright background color: black */
+ case 101: /* Set bright background color: red */
+ case 102: /* Set bright background color: green */
+ case 103: /* Set bright background color: brown */
+ case 104: /* Set bright background color: blue */
+ case 105: /* Set bright background color: magenta */
+ case 106: /* Set bright background color: cyan */
+ case 107: /* Set bright background color: white */
+ t->t_curattr.ta_bgcolor = n - 100 + 8;
+ break;
default:
teken_printf("unsupported attribute %u\n", n);
}
OpenPOWER on IntegriCloud