Bug fix for irssi 0.8.6 -- bold attribute not unset after ANSI reset

neil klopfenstein <[email protected]> Tue, 05 Aug 2003 16:32:29 -0700
Newsgroups gmane.network.irc.irssi.devel
Message-ID <[email protected]>
 Hi there,

 I use irssi 0.8.6 for all my online chat needs, but there was a bit of an
annoying bug on a MUD I use which uses ANSI color. The problem was that when it
was displaying a 'bright' color (color codes 8-15), which is represented by one
of the basic 8 colors plus the bold attribute, and then received an ANSI code
to go back to default color (^[[m), the bold attribute would stay on and turn
the rest of the line bold. This was easily fixed and I include a patch below.

 Regards,

 --neil klopfenstein

---cut here---

--- irssi-0.8.6/src/fe-common/core/formats.c	2002-06-18 20:10:02.000000000 -0700
+++ irssi-0.8.6-mod/src/fe-common/core/formats.c	2003-08-05 16:27:15.000000000 -0700
@@ -740,6 +740,12 @@
 		case 0:
 			/* reset colors back to default */
 			fg = theme->default_color;
+			if (fg <= 7)
+				flags &= ~GUI_PRINT_FLAG_BOLD;
+			else {
+				if (fg != 8) fg -= 8;
+				flags |= GUI_PRINT_FLAG_BOLD;
+			}
 			bg = -1;
 			flags &= ~GUI_PRINT_FLAG_INDENT;
 			break;
@@ -1017,7 +1023,13 @@
 				break;
 			}
 			case FORMAT_STYLE_DEFAULTS:
-                                fgcolor = theme->default_color;
+				fgcolor = theme->default_color;
+				if (fgcolor <= 7)
+					flags &= ~GUI_PRINT_FLAG_BOLD;
+				else {
+					if (fgcolor != 8) fgcolor -= 8;
+					flags |= GUI_PRINT_FLAG_BOLD;
+				}
 				bgcolor = -1;
 				flags &= GUI_PRINT_FLAG_INDENT|GUI_PRINT_FLAG_MONOSPACE;
 				break;