Index: vte.c
===================================================================
RCS file: /cvs/gnome/vte/src/vte.c,v
retrieving revision 1.422
diff -u -r1.422 vte.c
--- vte.c	11 Jun 2005 21:05:07 -0000	1.422
+++ vte.c	13 Jun 2005 18:57:06 -0000
@@ -286,6 +286,7 @@
 	gboolean text_modified_flag;
 	glong text_inserted_count;
 	glong text_deleted_count;
+	gboolean deccolm_mode;  /* Deccolm mode allowed -> xterm activates this with \033[?40h */
 
 	/* Scrolling options. */
 	gboolean scroll_background;
@@ -4666,8 +4667,11 @@
 		 NULL, NULL,},
 		/* 2: disallowed, we don't do VT52. */
 		{2, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},
-		/* 3: disallowed, window size is set by user. */
-		{3, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},
+		/* 3: allow DECCOLM set/reset to and from 132/80 columns */
+		{3, NULL, NULL, NULL, 
+		 GINT_TO_POINTER(FALSE),
+		 GINT_TO_POINTER(TRUE),
+		 NULL, NULL,},
 		/* 4: Smooth scroll. */
 		{4, &terminal->pvt->smooth_scroll, NULL, NULL,
 		 GINT_TO_POINTER(FALSE),
@@ -4708,8 +4712,11 @@
 		/* 35/rxvt: disallowed, fonts set by user. */
 		{35, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},
 		/* 38: enter Tektronix mode. */
-		/* 40: disallowed, the user sizes dynamically. */
-		{40, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},
+		/* 40: Enable DECCOLM mode */
+		{40, &terminal->pvt->deccolm_mode, NULL, NULL, 
+		 GINT_TO_POINTER(FALSE),
+		 GINT_TO_POINTER(TRUE),
+		 NULL, NULL,},
 		/* 41: more(1) fix. */
 		/* 42: Enable NLS replacements. */
 		{42, &terminal->pvt->nrc_mode, NULL, NULL,
@@ -4896,16 +4903,19 @@
 #endif
 		break;
 	case 3:
-		vte_terminal_emit_resize_window(terminal,
-						(set ? 132 : 80) *
-						terminal->char_width +
-						VTE_PAD_WIDTH * 2,
-						terminal->row_count *
-						terminal->char_height +
-						VTE_PAD_WIDTH * 2);
-		/* Request a resize and redraw. */
-		vte_invalidate_all(terminal);
-		again = TRUE;
+		/* We allow DECCOLM only if deccolm_mode is true */
+		if (terminal->pvt->deccolm_mode) {
+			vte_terminal_emit_resize_window(terminal,
+							(set ? 132 : 80) *
+							terminal->char_width +
+							VTE_PAD_WIDTH * 2,
+							terminal->row_count *
+							terminal->char_height +
+							VTE_PAD_WIDTH * 2);
+			/* Request a resize and redraw. */
+			vte_invalidate_all(terminal);
+			again = TRUE;
+		}
 		break;
 	case 5:
 		/* Repaint everything in reverse mode. */
@@ -11431,6 +11441,7 @@
 	pvt->text_modified_flag = FALSE;
 	pvt->text_inserted_count = 0;
 	pvt->text_deleted_count = 0;
+	pvt->deccolm_mode = FALSE;
 	vte_terminal_set_default_tabstops(terminal);
 
 	/* Scrolling options. */
@@ -15507,6 +15518,8 @@
 	terminal->pvt->margin_bell = FALSE;
 	/* Enable iso2022/NRC processing. */
 	terminal->pvt->nrc_mode = TRUE;
+	/* Reset DECCOLM mode */
+	terminal->pvt->deccolm_mode = FALSE;
 	/* Reset saved settings. */
 	if (terminal->pvt->dec_saved != NULL) {
 		g_hash_table_destroy(terminal->pvt->dec_saved);
