diff options
author | james <> | 2008-02-07 12:16:04 +0000 |
---|---|---|
committer | james <> | 2008-02-07 12:16:04 +0000 |
commit | ab5452e7390705d3b46ca29e900d2c5ec9faf555 (patch) | |
tree | f1dfb6e48f4d180866420bae638368772d49fca9 /src/ansi.c | |
parent | b7dab6019f661c3ef5d19f8faeacfec3a927f727 (diff) | |
download | sympathy-ab5452e7390705d3b46ca29e900d2c5ec9faf555.tar.gz sympathy-ab5452e7390705d3b46ca29e900d2c5ec9faf555.tar.bz2 sympathy-ab5452e7390705d3b46ca29e900d2c5ec9faf555.zip |
*** empty log message ***
Diffstat (limited to 'src/ansi.c')
-rw-r--r-- | src/ansi.c | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.13 2008/02/07 12:16:04 james + * *** empty log message *** + * * Revision 1.12 2008/02/07 11:32:41 james * *** empty log message *** * @@ -226,6 +229,39 @@ ansi_force_attr_normal (ANSI * a) { ansi_write (a, "\033[0m", 4); a->attr = CRT_ATTR_NORMAL; + a->color = ANSI_INVAL; +} + +void +ansi_set_color (ANSI * a, int color) +{ + int dif; + char buf[16]; + int i; + int fg,bg; + + if ((a->color == ANSI_INVAL) || (color!=a->color)) { + fg=CRT_COLOR_FG(color); + bg=CRT_COLOR_BG(color); + + if (fg & CRT_COLOR_INTENSITY) { + fg+=90; + } else { + fg+=30; + } + + if (bg & CRT_COLOR_INTENSITY) { + bg+=100; + } else { + bg+=40; + } + + i=sprintf(buf,"\033[%d;%dm",fg,bg); + fprintf(stderr,"Color set to %d %d %x\n",fg,bg,color); + + ansi_write (a,buf,i); + a->color=color; + } } void @@ -240,11 +276,13 @@ ansi_set_attr (ANSI * a, int attr) a->attr = attr; +#if 0 if (attr == CRT_ATTR_NORMAL) { ansi_force_attr_normal (a); return; } +#endif if (dif & CRT_ATTR_UNDERLINE) { @@ -295,6 +333,7 @@ ansi_render (ANSI * a, CRT_CA ca) ca.chr = ' '; ansi_set_attr (a, ca.attr); + ansi_set_color(a,ca.color); ansi_write (a, &ca.chr, 1); @@ -316,6 +355,7 @@ ansi_cls (ANSI * a) crt_cls (&a->crt); ansi_force_attr_normal (a); + ansi_set_color(a,CRT_COLOR_NORMAL); ansi_move (a, p); ansi_write (a, "\033[2J", 4); /*different emulators leave cursor in different places after cls differently*/ @@ -359,6 +399,7 @@ ansi_draw (ANSI * a, CRT * c) ansi_showhide_cursor (a, 1); ansi_set_attr (a, CRT_ATTR_REVERSE); + ansi_set_color(a,CRT_MAKE_COLOR(CRT_COLOR_WHITE,CRT_COLOR_RED)); ansi_move (a, p); ansi_write (a, msg, sizeof (msg)); |