Ilya Zakharevich on Wed, 27 Jan 1999 04:10:12 -0500 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
[PATCH 2.0.12] Colors in ANSI console |
This enables colors in an ANSI console. Colors 0..7 are bright ones, 8..15 are dimmer ones. To change background to color 3, add 300 (decimal) to the color id. The patch is wrt 2.0.12. Enjoy, Ilya P.S. I did it only if __EMX__ is defined, probably it is wise to create a new define (USE_ANSI_COLORS) and set it from Configure. Btw, ANSI colors should be supported by color xterms and linux consoles too, thus I do not know why not use them by default. Just in case I disable ANSI colors if term name starts with x, but since color xterm supports them, maybe it is not that wise. --- ./src/language/init.c~ Sun Nov 8 21:26:30 1998 +++ ./src/language/init.c Wed Jan 27 03:57:32 1999 @@ -23,7 +23,7 @@ GEN gpi=NULL, geuler=NULL, bernzone= GEN primetab; /* private primetable */ byteptr diffptr; char *current_logfile, *current_psfile; -char gp_colors[c_LAST]; +int gp_colors[c_LAST]; int disable_color = 1, added_newline = 1, under_emacs = 0; int functions_tblsz = 135; /* size of functions_hash */ --- ./src/language/es.c~ Wed Jan 27 03:03:14 1999 +++ ./src/language/es.c Wed Jan 27 03:53:12 1999 @@ -249,13 +249,27 @@ char * term_get_color(int c) { static char s[16]; + int c0 = 0, c2 = 107; + static char *t = (char *)1; if (disable_color) return ""; if (c == c_NONE) return "\033[0m"; /* reset */ c = gp_colors[c]; +#ifdef __EMX__ + if (t == (char *)1) { + t = getenv("TERM"); + } + if (!t || *t != 'x') { + c2 = 40 + c/100; + c = c % 100; + c0 = c/8; + c0 = !c0; /* Default is to use bright colors */ + c = 30 + c % 8; + } else +#endif if (c<8) c += 30; else c += 82; - sprintf(s, "\033[0;%d;%dm", c, 107); + sprintf(s, "\033[%d;%d;%dm", c0, c, c2); return s; } --- ./src/language/anal.h~ Wed Jan 27 03:56:16 1999 +++ ./src/language/anal.h Wed Jan 27 03:56:32 1999 @@ -55,7 +55,7 @@ extern entree functions_gp[]; extern entree gp_member_list[]; extern char *helpmessages_highlevel[]; extern entree functions_highlevel[]; -extern char gp_colors[]; +extern int gp_colors[]; extern int disable_color,added_newline; /* Variables containing the list of old PARI fonctions (up to 1.39.15) */