allow_ansi fix
Hi,
mutt-1.5.11 doesn't correctly work with allow_ansi option: codes "[39m"
(set foreground to defaut) and "[49m" (set background to default) ignore
terminal settings and always use white and black colors respecitvely.
Also, if only foreground color is set, background color stays
initialized with 0 instead of default color. The same happens if only
background color is specified, foreground stays 0. It isn't noticable
when using default white-on-black terminal, but doesn't look too nice in
a different color scheme.
Here's my attempt to fix the problem:
--- pager.c.orig 2006-02-26 15:54:33.000000000 +0300
+++ pager.c 2006-02-26 15:54:36.000000000 +0300
@@ -908,6 +908,8 @@
a->attr = ANSI_OFF;
a->pair = -1;
}
+ a->bg = -2;
+ a->fg = -2;
while (pos < x)
{
if (buf[pos] == '1' && (pos+1 == x || buf[pos+1] == ';'))
@@ -948,7 +950,8 @@
#endif
a->pair = -1;
a->attr |= ANSI_COLOR;
- a->fg = buf[pos+1] - '0';
+ if (buf[pos + 1] != '9')
+ a->fg = buf[pos+1] - '0';
pos += 3;
}
else if (buf[pos] == '4' && isdigit(buf[pos+1]))
@@ -959,7 +962,8 @@
#endif
a->pair = -1;
a->attr |= ANSI_COLOR;
- a->bg = buf[pos+1] - '0';
+ if (buf[pos + 1] != '9')
+ a->bg = buf[pos+1] - '0';
pos += 3;
}
else
brief comments: fg and bg colors are initialized with -2 from the very
beginning. -2 is COLOR_DEFAULT from color.c (should be probably moved to
color.h) When back- or foreground colorcode is spotted, we check if it
is an attempt to set a default color and change bg/fg value only when
needed.
Here's sample screenshot before the patch:
ftp://80.70.228.198/misc/mutt1.png
and after the patch:
ftp://80.70.228.198/misc/mutt2.png
--
/KoS
* C is for Bangers.