tty ansi color, don't eat up all '^' and wrap color codes [patch]

acano acano at fastmail.fm
Thu Jun 1 10:57:27 EDT 2006


Some '^' are meant to be printed, use Q_IsColorString()
Color codes not in [0-7] still need to correspond to one of thos,
use ColorIndex()
-------------- next part --------------
diff -Naur /home/acano/svn/ioquake3/quake3/code/unix/unix_main.c quake3/code/unix/unix_main.c
--- /home/acano/svn/ioquake3/quake3/code/unix/unix_main.c	2006-05-19 23:39:43.000000000 -0400
+++ quake3/code/unix/unix_main.c	2006-06-01 10:14:15.000000000 -0400
@@ -1199,18 +1199,18 @@
 
 static struct Q3ToAnsiColorTable_s
 {
-  char Q3color;
+  byte Q3color;
   char *ANSIcolor;
 } tty_colorTable[ ] =
 {
-  { COLOR_BLACK,    "30" },
-  { COLOR_RED,      "31" },
-  { COLOR_GREEN,    "32" },
-  { COLOR_YELLOW,   "33" },
-  { COLOR_BLUE,     "34" },
-  { COLOR_CYAN,     "36" },
-  { COLOR_MAGENTA,  "35" },
-  { COLOR_WHITE,    "0" }
+  { 0, "30" },  // black
+  { 1, "31" },  // red
+  { 2, "32" },  // green
+  { 3, "33" },  // yellow
+  { 4, "34" },  // blue
+  { 5, "35" },  // cyan
+  { 6, "36" },  // magenta
+  { 7, "0"  },  // white  (use terminal foreground color)
 };
 
 static int tty_colorTableSize =
@@ -1239,7 +1239,7 @@
       strncat( buffer, tempBuffer, bufferSize );
       i++;
     }
-    else if( msg[ i ] == Q_COLOR_ESCAPE )
+    else if( Q_IsColorString(&msg[i]) )
     {
       i++;
 
@@ -1248,7 +1248,7 @@
         escapeCode = NULL;
         for( j = 0; j < tty_colorTableSize; j++ )
         {
-          if( msg[ i ] == tty_colorTable[ j ].Q3color )
+          if( ColorIndex(msg[i]) == tty_colorTable[ j ].Q3color )
           {
             escapeCode = tty_colorTable[ j ].ANSIcolor;
             break;


More information about the quake3 mailing list