[vte/vte-0-34] emulation: Support italic text



commit ad68297cb8792c5f2927ccac44014507ff310da2
Author: Patrick Niklaus <patrick niklaus student kit edu>
Date:   Fri Oct 5 01:40:28 2012 +0200

    emulation: Support italic text
    
    The escape sequence SGR 3 for italic text is now recognised and supported.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=685223

 src/vte.c        |   67 +++++++++++++++-----------
 src/vtedraw.c    |  140 +++++++++++++++++++++++++++++++++++++----------------
 src/vtedraw.h    |   17 ++++--
 src/vterowdata.h |    9 ++--
 src/vteseq.c     |    6 ++
 5 files changed, 158 insertions(+), 81 deletions(-)
---
diff --git a/src/vte.c b/src/vte.c
index bb8e14c..406115c 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -684,6 +684,7 @@ _vte_invalidate_cell(VteTerminal *terminal, glong col, glong row)
 {
 	const VteRowData *row_data;
 	int columns;
+	guint style;
 
 	if (G_UNLIKELY (! gtk_widget_is_drawable (&terminal->widget)
 				|| terminal->pvt->invalidated_all)) {
@@ -700,11 +701,11 @@ _vte_invalidate_cell(VteTerminal *terminal, glong col, glong row)
 				cell = _vte_row_data_get (row_data, --col);
 			}
 			columns = cell->attr.columns;
+			style = _vte_draw_get_style(cell->attr.bold, cell->attr.italic);
 			if (cell->c != 0 &&
 					_vte_draw_get_char_width (
 						terminal->pvt->draw,
-						cell->c,
-						columns, cell->attr.bold) >
+						cell->c, columns, style) >
 					terminal->char_width * columns) {
 				columns++;
 			}
@@ -728,6 +729,7 @@ _vte_invalidate_cursor_once(VteTerminal *terminal, gboolean periodic)
 	gssize preedit_width;
 	glong column, row;
 	gint columns;
+	guint style;
 
 	if (terminal->pvt->invalidated_all) {
 		return;
@@ -750,11 +752,12 @@ _vte_invalidate_cursor_once(VteTerminal *terminal, gboolean periodic)
 		cell = vte_terminal_find_charcell(terminal, column, row);
 		if (cell != NULL) {
 			columns = cell->attr.columns;
+			style = _vte_draw_get_style(cell->attr.bold, cell->attr.italic);
 			if (cell->c != 0 &&
 					_vte_draw_get_char_width (
 						terminal->pvt->draw,
 						cell->c,
-						columns, cell->attr.bold) >
+						columns, style) >
 			    terminal->char_width * columns) {
 				columns++;
 			}
@@ -9283,11 +9286,6 @@ vte_unichar_is_local_graphic(vteunistr c)
         /* Box Drawing & Block Elements */
         return (c >= 0x2500) && (c <= 0x259f);
 }
-static gboolean
-vte_terminal_unichar_is_local_graphic(VteTerminal *terminal, vteunistr c, gboolean bold)
-{
-	return vte_unichar_is_local_graphic (c);
-}
 
 static void
 vte_terminal_fill_rectangle(VteTerminal *terminal,
@@ -9338,8 +9336,7 @@ static gboolean
 vte_terminal_draw_graphic(VteTerminal *terminal, vteunistr c,
 			  guint fore, guint back, gboolean draw_default_bg,
 			  gint x, gint y,
-			  gint column_width, gint columns, gint row_height,
-			  gboolean bold)
+			  gint column_width, gint columns, gint row_height)
 {
 	gint width, xcenter, xright, ycenter, ybottom, i;
         int upper_half, lower_half, left_half, right_half;
@@ -10077,7 +10074,7 @@ vte_terminal_draw_cells(VteTerminal *terminal,
 			struct _vte_draw_text_request *items, gssize n,
 			guint fore, guint back, gboolean clear,
 			gboolean draw_default_bg,
-			gboolean bold, gboolean underline,
+			gboolean bold, gboolean italic, gboolean underline,
 			gboolean strikethrough, gboolean hilite, gboolean boxed,
 			gint column_width, gint row_height)
 {
@@ -10118,17 +10115,21 @@ vte_terminal_draw_cells(VteTerminal *terminal,
 			columns += items[i].columns;
 		}
 		if (clear && (draw_default_bg || bg != defbg)) {
+			gint bold_offset = _vte_draw_has_bold(terminal->pvt->draw,
+									VTE_DRAW_BOLD) ? 0 : bold;
 			_vte_draw_fill_rectangle(terminal->pvt->draw,
 					x + terminal->pvt->inner_border.left,
                                         y + terminal->pvt->inner_border.top,
-					columns * column_width + (_vte_draw_has_bold(terminal->pvt->draw) ? 0 : bold),
-					row_height,
+					columns * column_width + bold_offset, row_height,
 					bg, VTE_DRAW_OPAQUE);
 		}
 	} while (i < n);
+
 	_vte_draw_text(terminal->pvt->draw,
 			items, n,
-			fg, VTE_DRAW_OPAQUE, bold);
+			fg, VTE_DRAW_OPAQUE,
+			_vte_draw_get_style(bold, italic));
+
 	for (i = 0; i < n; i++) {
 		/* Deadjust for the border. */
 		items[i].x -= terminal->pvt->inner_border.left;
@@ -10435,6 +10436,7 @@ vte_terminal_draw_cells_with_attributes(VteTerminal *terminal,
 					back,
 					TRUE, draw_default_bg,
 					cells[j].attr.bold,
+					cells[j].attr.italic,
 					cells[j].attr.underline,
 					cells[j].attr.strikethrough,
 					FALSE, FALSE, column_width, height);
@@ -10459,7 +10461,7 @@ vte_terminal_draw_rows(VteTerminal *terminal,
 	gint i, j, row, rows, x, y, end_column;
 	guint fore, nfore, back, nback;
 	glong delta;
-	gboolean underline, nunderline, bold, nbold, hilite, nhilite,
+	gboolean underline, nunderline, bold, nbold, italic, nitalic, hilite, nhilite,
 		 selected, nselected, strikethrough, nstrikethrough;
 	guint item_count;
 	const VteCell *cell;
@@ -10520,11 +10522,13 @@ vte_terminal_draw_rows(VteTerminal *terminal,
 					j += cell ? cell->attr.columns : 1;
 				}
 				if (back != VTE_DEF_BG) {
+					gint bold_offset = _vte_draw_has_bold(terminal->pvt->draw,
+											VTE_DRAW_BOLD) ? 0 : bold;
 					_vte_draw_fill_rectangle (
 							terminal->pvt->draw,
 							x + i * column_width,
 							y,
-							(j - i) * column_width + (_vte_draw_has_bold(terminal->pvt->draw) ? 0 : bold),
+							(j - i) * column_width + bold_offset,
 							row_height,
 							&terminal->pvt->palette[back], VTE_DRAW_OPAQUE);
 				}
@@ -10606,6 +10610,7 @@ vte_terminal_draw_rows(VteTerminal *terminal,
 			underline = cell->attr.underline;
 			strikethrough = cell->attr.strikethrough;
 			bold = cell->attr.bold;
+			italic = cell->attr.italic;
 			if (terminal->pvt->show_match) {
 				hilite = vte_cell_is_between(i, row,
 						terminal->pvt->match_start.col,
@@ -10624,7 +10629,7 @@ vte_terminal_draw_rows(VteTerminal *terminal,
 			j = i + items[0].columns;
 
 			/* If this is a graphics character, draw it locally. */
-			if (vte_terminal_unichar_is_local_graphic(terminal, cell->c, cell->attr.bold)) {
+			if (vte_unichar_is_local_graphic(cell->c)) {
 				if (vte_terminal_draw_graphic(terminal,
 							items[0].c,
 							fore, back,
@@ -10633,8 +10638,7 @@ vte_terminal_draw_rows(VteTerminal *terminal,
 							items[0].y,
 							column_width,
 							items[0].columns,
-							row_height,
-							cell->attr.bold)) {
+							row_height)) {
 					i = j;
 					continue;
 				}
@@ -10673,7 +10677,7 @@ vte_terminal_draw_rows(VteTerminal *terminal,
 					selected = vte_cell_is_selected(terminal, j, row, NULL);
 					vte_terminal_determine_colors(terminal, cell, selected, &nfore, &nback);
 					/* Graphic characters must be drawn individually. */
-					if (vte_terminal_unichar_is_local_graphic(terminal, cell->c, cell->attr.bold)) {
+					if (vte_unichar_is_local_graphic(cell->c)) {
 						if (vte_terminal_draw_graphic(terminal,
 									cell->c,
 									nfore, nback,
@@ -10682,8 +10686,7 @@ vte_terminal_draw_rows(VteTerminal *terminal,
 									y,
 									column_width,
 									cell->attr.columns,
-									row_height,
-									cell->attr.bold)) {
+									row_height)) {
 
 							j += cell->attr.columns;
 							continue;
@@ -10696,6 +10699,10 @@ vte_terminal_draw_rows(VteTerminal *terminal,
 					if (nbold != bold) {
 						break;
 					}
+					nitalic = cell->attr.italic;
+					if (nitalic != italic) {
+						break;
+					}
 					/* Break up underlined/not-underlined text. */
 					nunderline = cell->attr.underline;
 					if (nunderline != underline) {
@@ -10760,7 +10767,7 @@ fg_draw:
 					items,
 					item_count,
 					fore, back, FALSE, FALSE,
-					bold, underline,
+					bold, italic, underline,
 					strikethrough, hilite, FALSE,
 					column_width, row_height);
 			item_count = 1;
@@ -10922,8 +10929,11 @@ vte_terminal_paint_cursor(VteTerminal *terminal)
 	item.y = row * height;
 	cursor_width = item.columns * width;
 	if (cell && cell->c != 0) {
-		gint cw = _vte_draw_get_char_width (terminal->pvt->draw,
-				cell->c, cell->attr.columns, cell->attr.bold);
+		guint style;
+		gint cw;
+		style = _vte_draw_get_style(cell->attr.bold, cell->attr.italic);
+		cw = _vte_draw_get_char_width (terminal->pvt->draw, cell->c,
+					cell->attr.columns, style);
 		cursor_width = MAX(cursor_width, cw);
 	}
 
@@ -10968,7 +10978,7 @@ vte_terminal_paint_cursor(VteTerminal *terminal)
 							     x, y,
 							     cursor_width, height);
 
-				if (!vte_terminal_unichar_is_local_graphic(terminal, item.c, cell ? cell->attr.bold : FALSE) ||
+				if (!vte_unichar_is_local_graphic(item.c) ||
 				    !vte_terminal_draw_graphic(terminal,
 							       item.c,
 							       fore, back,
@@ -10977,8 +10987,7 @@ vte_terminal_paint_cursor(VteTerminal *terminal)
 							       item.y,
 							       width,
 							       item.columns,
-							       height,
-							       cell ? cell->attr.bold : FALSE)) {
+							       height)) {
 					gboolean hilite = FALSE;
 					if (cell && terminal->pvt->show_match) {
 						hilite = vte_cell_is_between(col, row,
@@ -10993,6 +11002,7 @@ vte_terminal_paint_cursor(VteTerminal *terminal)
 								&item, 1,
 								fore, back, TRUE, FALSE,
 								cell->attr.bold,
+								cell->attr.italic,
 								cell->attr.underline,
 								cell->attr.strikethrough,
 								hilite,
@@ -11091,6 +11101,7 @@ vte_terminal_paint_im_preedit_string(VteTerminal *terminal)
 						FALSE,
 						FALSE,
 						FALSE,
+						FALSE,
 						TRUE,
 						width, height);
 		}
diff --git a/src/vtedraw.c b/src/vtedraw.c
index a0f6a0b..039342c 100644
--- a/src/vtedraw.c
+++ b/src/vtedraw.c
@@ -744,13 +744,21 @@ font_info_get_unistr_info (struct font_info *info,
 	return uinfo;
 }
 
+guint _vte_draw_get_style(gboolean bold, gboolean italic) {
+	guint style = 0;
+	if (bold)
+		style |= VTE_DRAW_BOLD;
+	if (italic)
+		style |= VTE_DRAW_ITALIC;
+	return style;
+}
+
 struct _vte_draw {
 	GtkWidget *widget;
 
 	gint started;
 
-	struct font_info *font;
-	struct font_info *font_bold;
+	struct font_info *fonts[4];
 	cairo_pattern_t *bg_pattern;
 
 	cairo_t *cr;
@@ -779,6 +787,7 @@ _vte_draw_get_context (struct _vte_draw *draw)
 void
 _vte_draw_free (struct _vte_draw *draw)
 {
+	gint style;
 	_vte_debug_print (VTE_DEBUG_DRAW, "draw_free\n");
 
 	if (draw->bg_pattern != NULL) {
@@ -786,9 +795,13 @@ _vte_draw_free (struct _vte_draw *draw)
 		draw->bg_pattern = NULL;
 	}
 
-	if (draw->font != NULL) {
-		font_info_destroy (draw->font);
-		draw->font = NULL;
+	/* Free all fonts (make sure to destroy every font only once)*/
+	for (style = 3; style >= 0; style--) {
+		if (draw->fonts[style] != NULL &&
+			(style == 0 || draw->fonts[style] != draw->fonts[style-1])) {
+			font_info_destroy (draw->fonts[style]);
+			draw->fonts[style] = NULL;
+		}
 	}
 
 	if (draw->widget != NULL) {
@@ -921,29 +934,68 @@ _vte_draw_set_text_font (struct _vte_draw *draw,
 			const PangoFontDescription *fontdesc,
 			VteTerminalAntiAlias antialias)
 {
-	PangoFontDescription *bolddesc = NULL;
+	PangoFontDescription *bolddesc   = NULL;
+	PangoFontDescription *italicdesc = NULL;
+	PangoFontDescription *bolditalicdesc = NULL;
+	gint style, normal, bold, ratio;
 
 	_vte_debug_print (VTE_DEBUG_DRAW, "draw_set_text_font (aa=%d)\n",
 			  antialias);
 
-	if (draw->font_bold != draw->font)
-		font_info_destroy (draw->font_bold);
-	font_info_destroy (draw->font);
-	draw->font = font_info_create_for_widget (draw->widget, fontdesc, antialias);
+	/* Free all fonts (make sure to destroy every font only once)*/
+	for (style = 3; style >= 0; style--) {
+		if (draw->fonts[style] != NULL &&
+			(style == 0 || draw->fonts[style] != draw->fonts[style-1])) {
+			font_info_destroy (draw->fonts[style]);
+			draw->fonts[style] = NULL;
+		}
+	}
 
 	/* calculate bold font desc */
 	bolddesc = pango_font_description_copy (fontdesc);
 	pango_font_description_set_weight (bolddesc, PANGO_WEIGHT_BOLD);
 
-	draw->font_bold = font_info_create_for_widget (draw->widget, bolddesc, antialias);
+	/* calculate italic font desc */
+	italicdesc = pango_font_description_copy (fontdesc);
+	pango_font_description_set_style (italicdesc, PANGO_STYLE_ITALIC);
+
+	/* calculate bold italic font desc */
+	bolditalicdesc = pango_font_description_copy (bolddesc);
+	pango_font_description_set_style (bolditalicdesc, PANGO_STYLE_ITALIC);
+
+	draw->fonts[VTE_DRAW_NORMAL]  = font_info_create_for_widget (draw->widget,
+										fontdesc, antialias);
+	draw->fonts[VTE_DRAW_BOLD]    = font_info_create_for_widget (draw->widget,
+										bolddesc, antialias);
+	draw->fonts[VTE_DRAW_ITALIC]  = font_info_create_for_widget (draw->widget,
+										italicdesc, antialias);
+	draw->fonts[VTE_DRAW_ITALIC | VTE_DRAW_BOLD] =
+									font_info_create_for_widget (draw->widget,
+										bolditalicdesc, antialias);
 	pango_font_description_free (bolddesc);
+	pango_font_description_free (italicdesc);
+	pango_font_description_free (bolditalicdesc);
 
 	/* Decide if we should keep this bold font face, per bug 54926:
 	 *  - reject bold font if it is not within 10% of normal font width
 	 */
-	if ( abs((draw->font_bold->width * 100 / draw->font->width) - 100) > 10 ) {
-		font_info_destroy (draw->font_bold);
-		draw->font_bold = draw->font;
+	normal = VTE_DRAW_NORMAL;
+	bold   = normal | VTE_DRAW_BOLD;
+	ratio = draw->fonts[bold]->width * 100 / draw->fonts[normal]->width;
+	if (abs(ratio - 100) > 10) {
+		_vte_debug_print (VTE_DEBUG_DRAW,
+			"Rejecting bold font (%i%%).\n", ratio);
+		font_info_destroy (draw->fonts[bold]);
+		draw->fonts[bold] = draw->fonts[normal];
+	}
+	normal = VTE_DRAW_ITALIC;
+	bold   = normal | VTE_DRAW_BOLD;
+	ratio = draw->fonts[bold]->width * 100 / draw->fonts[normal]->width;
+	if (abs(ratio - 100) > 10) {
+		_vte_debug_print (VTE_DEBUG_DRAW,
+			"Rejecting italic bold font (%i%%).\n", ratio);
+		font_info_destroy (draw->fonts[bold]);
+		draw->fonts[bold] = draw->fonts[normal];
 	}
 }
 
@@ -951,33 +1003,33 @@ void
 _vte_draw_get_text_metrics(struct _vte_draw *draw,
 			   gint *width, gint *height, gint *ascent)
 {
-	g_return_if_fail (draw->font != NULL);
+	g_return_if_fail (draw->fonts[VTE_DRAW_NORMAL] != NULL);
 
 	if (width)
-		*width  = draw->font->width;
+		*width  = draw->fonts[VTE_DRAW_NORMAL]->width;
 	if (height)
-		*height = draw->font->height;
+		*height = draw->fonts[VTE_DRAW_NORMAL]->height;
 	if (ascent)
-		*ascent = draw->font->ascent;
+		*ascent = draw->fonts[VTE_DRAW_NORMAL]->ascent;
 }
 
 
 int
 _vte_draw_get_char_width (struct _vte_draw *draw, vteunistr c, int columns,
-			  gboolean bold)
+						  guint style)
 {
 	struct unistr_info *uinfo;
 
-	g_return_val_if_fail (draw->font != NULL, 0);
+	g_return_val_if_fail (draw->fonts[VTE_DRAW_NORMAL] != NULL, 0);
 
-	uinfo = font_info_get_unistr_info (bold ? draw->font_bold : draw->font, c);
+	uinfo = font_info_get_unistr_info (draw->fonts[style], c);
 	return uinfo->width;
 }
 
 gboolean
-_vte_draw_has_bold (struct _vte_draw *draw)
+_vte_draw_has_bold (struct _vte_draw *draw, guint style)
 {
-	return (draw->font != draw->font_bold);
+	return (draw->fonts[style ^ VTE_DRAW_BOLD] != draw->fonts[style]);
 }
 
 void
@@ -995,13 +1047,13 @@ _vte_draw_set_source_color_alpha (struct _vte_draw *draw,
 static void
 _vte_draw_text_internal (struct _vte_draw *draw,
 			 struct _vte_draw_text_request *requests, gsize n_requests,
-			 const PangoColor *color, guchar alpha, gboolean bold)
+			 const PangoColor *color, guchar alpha, guint style)
 {
 	gsize i;
 	cairo_scaled_font_t *last_scaled_font = NULL;
 	int n_cr_glyphs = 0;
 	cairo_glyph_t cr_glyphs[MAX_RUN_LENGTH];
-	struct font_info *font = bold ? draw->font_bold : draw->font;
+	struct font_info *font = draw->fonts[style];
 
 	g_return_if_fail (font != NULL);
 
@@ -1061,7 +1113,7 @@ _vte_draw_text_internal (struct _vte_draw *draw,
 void
 _vte_draw_text (struct _vte_draw *draw,
 	       struct _vte_draw_text_request *requests, gsize n_requests,
-	       const PangoColor *color, guchar alpha, gboolean bold)
+	       const PangoColor *color, guchar alpha, guint style)
 {
 	g_return_if_fail (draw->started);
 
@@ -1073,16 +1125,17 @@ _vte_draw_text (struct _vte_draw *draw,
 			g_string_append_unichar (string, requests[n].c);
 		}
 		str = g_string_free (string, FALSE);
-		g_printerr ("draw_text (\"%s\", len=%"G_GSIZE_FORMAT", color=(%d,%d,%d,%d), %s)\n",
-				str, n_requests, color->red, color->green, color->blue,
-				alpha, bold ? "bold" : "normal");
+		g_printerr ("draw_text (\"%s\", len=%"G_GSIZE_FORMAT", color=(%d,%d,%d,%d), %s - %s)\n",
+				str, n_requests, color->red, color->green, color->blue, alpha,
+				(style & VTE_DRAW_BOLD)   ? "bold"   : "normal",
+				(style & VTE_DRAW_ITALIC) ? "italic" : "regular");
 		g_free (str);
 	}
 
-	_vte_draw_text_internal (draw, requests, n_requests, color, alpha, bold);
+	_vte_draw_text_internal (draw, requests, n_requests, color, alpha, style);
 
 	/* handle fonts that lack a bold face by double-striking */
-	if (bold && !_vte_draw_has_bold (draw)) {
+	if ((style & VTE_DRAW_BOLD) && !_vte_draw_has_bold (draw, style)) {
 		gsize i;
 
 		/* Take a step to the right. */
@@ -1090,7 +1143,7 @@ _vte_draw_text (struct _vte_draw *draw,
 			requests[i].x++;
 		}
 		_vte_draw_text_internal (draw, requests,
-					   n_requests, color, alpha, FALSE);
+					   n_requests, color, alpha, style);
 		/* Now take a step back. */
 		for (i = 0; i < n_requests; i++) {
 			requests[i].x--;
@@ -1099,35 +1152,38 @@ _vte_draw_text (struct _vte_draw *draw,
 }
 
 gboolean
-_vte_draw_has_char (struct _vte_draw *draw, vteunistr c, gboolean bold)
+_vte_draw_has_char (struct _vte_draw *draw, vteunistr c, guint style)
 {
 	struct unistr_info *uinfo;
 
-	_vte_debug_print (VTE_DEBUG_DRAW, "draw_has_char ('0x%04X', %s)\n", c,
-			  bold ? "bold" : "normal");
+	_vte_debug_print (VTE_DEBUG_DRAW, "draw_has_char ('0x%04X', %s - %s)\n", c,
+				(style & VTE_DRAW_BOLD)   ? "bold"   : "normal",
+				(style & VTE_DRAW_ITALIC) ? "italic" : "regular");
 
-	g_return_val_if_fail (draw->font != NULL, FALSE);
+	g_return_val_if_fail (draw->fonts[VTE_DRAW_NORMAL] != NULL, FALSE);
 
-	uinfo = font_info_get_unistr_info (bold ? draw->font_bold : draw->font, c);
+	uinfo = font_info_get_unistr_info (draw->fonts[style], c);
 	return !uinfo->has_unknown_chars;
 }
 
 gboolean
 _vte_draw_char (struct _vte_draw *draw,
 	       struct _vte_draw_text_request *request,
-	       const PangoColor *color, guchar alpha, gboolean bold)
+	       const PangoColor *color, guchar alpha, guint style)
 {
 	gboolean has_char;
 
 	_vte_debug_print (VTE_DEBUG_DRAW,
-			"draw_char ('%c', color=(%d,%d,%d,%d), %s)\n",
+			"draw_char ('%c', color=(%d,%d,%d,%d), %s, %s)\n",
 			request->c,
 			color->red, color->green, color->blue,
-			alpha, bold ? "bold" : "normal");
+			alpha,
+			(style & VTE_DRAW_BOLD)   ? "bold"   : "normal",
+			(style & VTE_DRAW_ITALIC) ? "italic" : "regular");
 
-	has_char =_vte_draw_has_char (draw, request->c, bold);
+	has_char =_vte_draw_has_char (draw, request->c, style);
 	if (has_char)
-		_vte_draw_text (draw, request, 1, color, alpha, bold);
+		_vte_draw_text (draw, request, 1, color, alpha, style);
 
 	return has_char;
 }
diff --git a/src/vtedraw.h b/src/vtedraw.h
index f199b40..4df8775 100644
--- a/src/vtedraw.h
+++ b/src/vtedraw.h
@@ -50,6 +50,10 @@ G_BEGIN_DECLS
 #define VTE_DRAW_OPAQUE 0xff
 #define VTE_DRAW_MAX_LENGTH 1024
 
+#define VTE_DRAW_NORMAL 0
+#define VTE_DRAW_BOLD   1
+#define VTE_DRAW_ITALIC 2
+
 struct _vte_draw;
 
 /* A request to draw a particular character spanning a given number of columns
@@ -61,6 +65,8 @@ struct _vte_draw_text_request {
 	gshort x, y, columns;
 };
 
+guint _vte_draw_get_style(gboolean bold, gboolean italic);
+
 /* Create and destroy a draw structure. */
 struct _vte_draw *_vte_draw_new(GtkWidget *widget);
 void _vte_draw_free(struct _vte_draw *draw);
@@ -96,17 +102,16 @@ void _vte_draw_set_text_font(struct _vte_draw *draw,
 void _vte_draw_get_text_metrics(struct _vte_draw *draw,
 				gint *width, gint *height, gint *ascent);
 int _vte_draw_get_char_width(struct _vte_draw *draw, vteunistr c, int columns,
-			     gboolean bold);
-gboolean _vte_draw_has_bold (struct _vte_draw *draw);
+			     guint style);
+gboolean _vte_draw_has_bold (struct _vte_draw *draw, guint style);
 
 void _vte_draw_text(struct _vte_draw *draw,
 		    struct _vte_draw_text_request *requests, gsize n_requests,
-		    const PangoColor *color, guchar alpha, gboolean);
+		    const PangoColor *color, guchar alpha, guint style);
 gboolean _vte_draw_char(struct _vte_draw *draw,
 			struct _vte_draw_text_request *request,
-			const PangoColor *color, guchar alpha, gboolean bold);
-gboolean _vte_draw_has_char(struct _vte_draw *draw, vteunistr c, gboolean bold);
-
+			const PangoColor *color, guchar alpha, guint style);
+gboolean _vte_draw_has_char(struct _vte_draw *draw, vteunistr c, guint style);
 
 void _vte_draw_fill_rectangle(struct _vte_draw *draw,
 			      gint x, gint y, gint width, gint height,
diff --git a/src/vterowdata.h b/src/vterowdata.h
index a911500..4150095 100644
--- a/src/vterowdata.h
+++ b/src/vterowdata.h
@@ -40,6 +40,8 @@ G_BEGIN_DECLS
  *
  * Ordered by most commonly changed attributes, to
  * optimize the compact representation.
+ *
+ * When adding new attributes, remember to update basic_cell below too.
  */
 
 typedef struct _VteCellAttr {
@@ -50,6 +52,7 @@ typedef struct _VteCellAttr {
 				   Keep at least 4 for tabs to work
 				   */
 	guint32 bold: 1;
+	guint32 italic: 1;
 	guint32 fore: 9;	/* Index into color palette */
 	guint32 back: 9;	/* Index into color palette. */
 
@@ -62,11 +65,6 @@ typedef struct _VteCellAttr {
 	guint32 half: 1;
 
 	guint32 invisible: 1;
-	/* unused; bug 499893
-	guint32 protect: 1;
-	 */
-
-	/* 30 bits */
 } VteCellAttr;
 G_STATIC_ASSERT (sizeof (VteCellAttr) == 4);
 
@@ -102,6 +100,7 @@ static const VteIntCell basic_cell = {
 			0, /* fragment */
 			1, /* columns */
 			0, /* bold */
+			0, /* italic */
 			VTE_DEF_FG, /* fore */
 			VTE_DEF_BG, /* back */
 
diff --git a/src/vteseq.c b/src/vteseq.c
index 23745a1..2a3f0d2 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -2296,6 +2296,9 @@ vte_sequence_handler_character_attributes (VteTerminal *terminal, GValueArray *p
 			terminal->pvt->screen->defaults.attr.half = 1;
 			terminal->pvt->screen->defaults.attr.bold = 0;
 			break;
+		case 3:
+			terminal->pvt->screen->defaults.attr.italic = 1;
+			break;
 		case 4:
 			terminal->pvt->screen->defaults.attr.underline = 1;
 			break;
@@ -2316,6 +2319,9 @@ vte_sequence_handler_character_attributes (VteTerminal *terminal, GValueArray *p
 			terminal->pvt->screen->defaults.attr.bold = 0;
 			terminal->pvt->screen->defaults.attr.half = 0;
 			break;
+		case 23:
+			terminal->pvt->screen->defaults.attr.italic = 0;
+			break;
 		case 24:
 			terminal->pvt->screen->defaults.attr.underline = 0;
 			break;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]