diff -ur vte-0.17.4.orig/src/vte.c vte-0.17.4/src/vte.c
--- vte-0.17.4.orig/src/vte.c	2008-09-08 21:48:31.000000000 +0200
+++ vte-0.17.4/src/vte.c	2010-04-27 18:53:28.597802000 +0200
@@ -249,10 +249,6 @@
 #endif
 
 
-/* Indexes in the "palette" color array for the dim colors.
- * Only the first VTE_LEGACY_COLOR_SET_SIZE colors have dim versions.  */
-static const guchar corresponding_dim_index[] = {16,88,28,100,18,90,30,102};
-
 /* Free a no-longer-used row data array. */
 void
 _vte_free_row_data(VteRowData *row)
@@ -355,6 +351,8 @@
 	screen->basic_defaults = screen->defaults;
 	screen->color_defaults = screen->defaults;
 	screen->fill_defaults = screen->defaults;
+	screen->fg_256 = FALSE;
+	screen->bg_256 = FALSE;
 }
 
 /* Cause certain cells to be repainted. */
@@ -8502,32 +8500,9 @@
 		*back = cell ? cell->attr.back : VTE_DEF_BG;
 	}
 
-	/* Handle invisible, bold, and standout text by adjusting colors. */
-	if (cell) {
-		if (cell->attr.invisible) {
-			*fore = *back;
-		}
-		if (cell->attr.bold) {
-			if (*fore == VTE_DEF_FG) {
-				*fore = VTE_BOLD_FG;
-			} else
-			if ((*fore != VTE_DEF_BG) && (*fore < VTE_LEGACY_COLOR_SET_SIZE)) {
-				*fore += VTE_COLOR_BRIGHT_OFFSET;
-			}
-		}
-		if (cell->attr.half) {
-			if (*fore == VTE_DEF_FG) {
-				*fore = VTE_DIM_FG;
-			} else
-			if ((*fore < VTE_LEGACY_COLOR_SET_SIZE)) {
-				*fore = corresponding_dim_index[*fore];;
-			}
-		}
-		if (cell->attr.standout) {
-			if (*back < VTE_LEGACY_COLOR_SET_SIZE) {
-				*back += VTE_COLOR_BRIGHT_OFFSET;
-			}
-		}
+	/* Handle invisible text by adjusting colors. */
+	if (cell && cell->attr.invisible) {
+		*fore = *back;
 	}
 }
 
diff -ur vte-0.17.4.orig/src/vte-private.h vte-0.17.4/src/vte-private.h
--- vte-0.17.4.orig/src/vte-private.h	2008-09-08 21:48:31.000000000 +0200
+++ vte-0.17.4/src/vte-private.h	2010-04-27 18:45:57.049808000 +0200
@@ -265,6 +265,8 @@
 							   fore/back with no
 							   character data */
 		struct vte_charcell basic_defaults;	/* original defaults */
+		gboolean fg_256, bg_256;	/* whether fg/bg were set by
+						   256 color sequences */
 		gboolean alternate_charset;
 		gboolean status_line;
 		GString *status_line_contents;
diff -ur vte-0.17.4.orig/src/vteseq.c vte-0.17.4/src/vteseq.c
--- vte-0.17.4.orig/src/vteseq.c	2008-08-20 15:09:43.000000000 +0200
+++ vte-0.17.4/src/vteseq.c	2010-04-27 18:53:24.664751000 +0200
@@ -43,6 +43,10 @@
 #include "vteseq-list.h"
 #undef VTE_SEQUENCE_HANDLER
 
+/* Indexes in the "palette" color array for the dim colors.
+ * Only the first VTE_LEGACY_COLOR_SET_SIZE colors have dim versions.  */
+static const guchar corresponding_dim_index[] = {16,88,28,100,18,90,30,102};
+
 /* These two handlers are accessed from vte.c */
 gboolean
 _vte_sequence_handler_bl(VteTerminal *terminal, const char *match, GQuark match_quark, GValueArray *params)
@@ -2792,6 +2796,7 @@
 		case 35:
 		case 36:
 		case 37:
+			terminal->pvt->screen->fg_256 = FALSE;
 			terminal->pvt->screen->defaults.attr.fore = param - 30;
 			break;
 		case 38:
@@ -2806,6 +2811,7 @@
 					break;
 				}
 				param1 = g_value_get_long(value1);
+				terminal->pvt->screen->fg_256 = TRUE;
 				terminal->pvt->screen->defaults.attr.fore = param1;
 				i += 2;
 			}
@@ -2826,6 +2832,7 @@
 		case 45:
 		case 46:
 		case 47:
+			terminal->pvt->screen->bg_256 = FALSE;
 			terminal->pvt->screen->defaults.attr.back = param - 40;
 			break;
 		case 48:
@@ -2840,6 +2847,7 @@
 					break;
 				}
 				param1 = g_value_get_long(value1);
+				terminal->pvt->screen->bg_256 = TRUE;
 				terminal->pvt->screen->defaults.attr.back = param1;
 				i += 2;
 			}
@@ -2847,6 +2855,7 @@
 		}
 		case 49:
 			/* default background */
+			terminal->pvt->screen->bg_256 = FALSE;
 			terminal->pvt->screen->defaults.attr.back = VTE_DEF_BG;
 			break;
 		case 90:
@@ -2857,6 +2866,7 @@
 		case 95:
 		case 96:
 		case 97:
+			terminal->pvt->screen->fg_256 = FALSE;
 			terminal->pvt->screen->defaults.attr.fore = param - 90 + VTE_COLOR_BRIGHT_OFFSET;
 			break;
 		case 100:
@@ -2867,6 +2877,7 @@
 		case 105:
 		case 106:
 		case 107:
+			terminal->pvt->screen->bg_256 = FALSE;
 			terminal->pvt->screen->defaults.attr.back = param - 100 + VTE_COLOR_BRIGHT_OFFSET;
 			break;
 		}
@@ -2875,6 +2886,33 @@
 	if (i == 0) {
 		_vte_terminal_set_default_attributes(terminal);
 	}
+	/* Handle bold, half and standout text by adjusting colors. */
+	if (terminal->pvt->screen->defaults.attr.bold) {
+	        if (terminal->pvt->screen->defaults.attr.fore == VTE_DEF_FG) {
+	                terminal->pvt->screen->defaults.attr.fore = VTE_BOLD_FG;
+                } else
+                if (!terminal->pvt->screen->fg_256
+        	  && terminal->pvt->screen->defaults.attr.fore != VTE_DEF_BG
+        	  && terminal->pvt->screen->defaults.attr.fore < VTE_LEGACY_COLOR_SET_SIZE) {
+        		terminal->pvt->screen->defaults.attr.fore += VTE_COLOR_BRIGHT_OFFSET;
+                }
+	}
+	if (terminal->pvt->screen->defaults.attr.half) {
+	        if (terminal->pvt->screen->defaults.attr.fore == VTE_DEF_FG) {
+                        terminal->pvt->screen->defaults.attr.fore = VTE_DIM_FG;
+                } else
+        	if (!terminal->pvt->screen->fg_256
+        	  && terminal->pvt->screen->defaults.attr.fore != VTE_DEF_FG
+        	  && terminal->pvt->screen->defaults.attr.fore < VTE_LEGACY_COLOR_SET_SIZE) {
+        		terminal->pvt->screen->defaults.attr.fore = corresponding_dim_index[terminal->pvt->screen->defaults.attr.fore];
+                }
+	}
+	if (terminal->pvt->screen->defaults.attr.standout) {
+        	if (!terminal->pvt->screen->bg_256
+        	  && terminal->pvt->screen->defaults.attr.back < VTE_LEGACY_COLOR_SET_SIZE) {
+        		terminal->pvt->screen->defaults.attr.back += VTE_COLOR_BRIGHT_OFFSET;
+                }
+	}
 	/* Save the new colors. */
 	terminal->pvt->screen->color_defaults.attr.fore =
 		terminal->pvt->screen->defaults.attr.fore;
