summaryrefslogtreecommitdiffstats
path: root/colour.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-03-07 10:29:06 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-03-07 10:29:06 +0000
commite6d35b6aa49ca708f62a289bc7c44ad09f5a393f (patch)
tree2ada93cebada7d5bee775832411894ddad6b1680 /colour.c
parent521fa7d6409da23ff3f9f357dc8244374ef01a9e (diff)
Support for 88 colour terminals.
Diffstat (limited to 'colour.c')
-rw-r--r--colour.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/colour.c b/colour.c
index 497f157b..f825c4a9 100644
--- a/colour.c
+++ b/colour.c
@@ -1,4 +1,4 @@
-/* $Id: colour.c,v 1.4 2009-01-27 20:22:33 nicm Exp $ */
+/* $Id: colour.c,v 1.5 2009-03-07 10:29:06 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -74,9 +74,9 @@ colour_fromstring(const char *s)
}
u_char
-colour_translate256(u_char c)
+colour_256to16(u_char c)
{
- static const u_char table[] = {
+ static const u_char table[256] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
0, 4, 4, 4, 12, 12, 2, 6, 4, 4, 12, 12, 2, 2, 6, 4,
12, 12, 2, 2, 2, 6, 12, 12, 10, 10, 10, 10, 14, 12, 10, 10,
@@ -97,3 +97,28 @@ colour_translate256(u_char c)
return (table[c]);
}
+
+u_char
+colour_256to88(u_char c)
+{
+ static const u_char table[256] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 17, 18, 18, 19, 20, 21, 21, 22, 22, 23, 20, 21, 21, 22,
+ 22, 23, 24, 25, 25, 26, 26, 27, 24, 25, 25, 26, 26, 27, 28, 29,
+ 29, 30, 30, 31, 32, 33, 33, 34, 34, 35, 36, 37, 37, 38, 38, 39,
+ 36, 37, 37, 38, 38, 39, 40, 41, 41, 42, 42, 43, 40, 41, 41, 42,
+ 42, 43, 44, 45, 45, 46, 46, 47, 32, 33, 33, 34, 34, 35, 36, 37,
+ 37, 38, 38, 39, 36, 37, 37, 38, 38, 39, 40, 41, 41, 42, 42, 43,
+ 40, 41, 41, 42, 42, 43, 44, 45, 45, 46, 46, 47, 48, 49, 49, 50,
+ 50, 51, 52, 53, 53, 54, 54, 55, 52, 53, 53, 54, 54, 55, 56, 57,
+ 57, 58, 58, 59, 56, 57, 57, 58, 58, 59, 60, 61, 61, 62, 62, 63,
+ 48, 49, 49, 50, 50, 51, 52, 53, 53, 54, 54, 55, 52, 53, 53, 54,
+ 54, 55, 56, 57, 57, 58, 58, 59, 56, 57, 57, 58, 58, 59, 60, 61,
+ 61, 62, 62, 63, 64, 65, 65, 66, 66, 67, 68, 69, 69, 70, 70, 71,
+ 68, 69, 69, 70, 70, 71, 72, 73, 73, 74, 74, 75, 72, 73, 73, 74,
+ 74, 75, 76, 77, 77, 78, 78, 79, 0, 0, 80, 80, 80, 81, 81, 81,
+ 82, 82, 82, 83, 83, 83, 84, 84, 84, 85, 85, 85, 86, 86, 86, 87
+ };
+
+ return (table[c]);
+}