[vte/vte-next] emulation: Support italic text



commit be8edd11181a41cca7f053bdca3e52c7722c44c5
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
    
    Conflicts:
    	src/vte.c
    	src/vtedraw.c
    	src/vtedraw.h

 src/vte.c        |   68 +++++++++++++++-----------
 src/vtedraw.c    |  141 +++++++++++++++++++++++++++++++++++++-----------------
 src/vtedraw.h    |   17 ++++--
 src/vterowdata.h |    9 ++--
 src/vteseq.c     |    6 ++
 5 files changed, 158 insertions(+), 83 deletions(-)
---
diff --git a/src/vte.c b/src/vte.c
index 27fd5ce..8d2006b 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -724,6 +724,7 @@ _vte_invalidate_cell(VteView *terminal, glong col, glong row)
         VteBuffer *buffer;
 	const VteRowData *row_data;
 	int columns;
+	guint style;
 
         if (!gtk_widget_get_realized(&terminal->widget)) {
                 return;
@@ -744,11 +745,11 @@ _vte_invalidate_cell(VteView *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->pvt->char_width * columns) {
 				columns++;
 			}
@@ -773,6 +774,7 @@ _vte_invalidate_cursor_once(VteView *terminal, gboolean periodic)
 	gssize preedit_width;
 	glong column, row;
 	gint columns;
+	guint style;
 
         if (!gtk_widget_get_realized(&terminal->widget)) {
                 return;
@@ -800,11 +802,12 @@ _vte_invalidate_cursor_once(VteView *terminal, gboolean periodic)
 		cell = vte_screen_find_charcell(screen, 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->pvt->char_width * columns) {
 				columns++;
 			}
@@ -8725,12 +8728,6 @@ vte_unichar_is_local_graphic(vteunistr c)
         return (c >= 0x2500) && (c <= 0x259f);
 }
 
-static gboolean
-vte_view_unichar_is_local_graphic(VteView *terminal, vteunistr c, gboolean bold)
-{
-        return vte_unichar_is_local_graphic (c);
-}
-
 static void
 vte_view_fill_rectangle(VteView *terminal,
 			    const GdkRGBA *color,
@@ -8786,8 +8783,7 @@ vte_view_draw_graphic(VteView *view,
                       gint y,
                       gint column_width,
                       gint columns,
-                      gint row_height,
-                      gboolean bold)
+                      gint row_height)
 {
         VteViewPrivate *pvt = view->pvt;
         gint width, xcenter, xright, ycenter, ybottom;
@@ -9522,7 +9518,7 @@ vte_view_draw_cells(VteView *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)
 {
@@ -9562,17 +9558,22 @@ vte_view_draw_cells(VteView *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->padding.left,
                                         y + terminal->pvt->padding.top,
-					columns * column_width + (_vte_draw_has_bold(terminal->pvt->draw) ? 0 : bold),
+					columns * column_width + bold_offset,
 					row_height,
 					bg);
 		}
 	} while (i < n);
+
 	_vte_draw_text(terminal->pvt->draw,
 			items, n,
-			fg, bold);
+			fg,
+			_vte_draw_get_style(bold, italic));
+
 	for (i = 0; i < n; i++) {
 		/* Deadjust for the border. */
 		items[i].x -= terminal->pvt->padding.left;
@@ -9892,6 +9893,7 @@ vte_view_draw_cells_with_attributes(VteView *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);
@@ -9915,7 +9917,8 @@ vte_view_draw_rows(VteView *terminal,
 	struct _vte_draw_text_request items[4*VTE_DRAW_MAX_LENGTH];
 	gint i, j, row, rows, x, y, end_column;
 	guint fore, nfore, back, nback;
-	gboolean underline, nunderline, bold, nbold, hilite, nhilite,
+	glong delta;
+	gboolean underline, nunderline, bold, nbold, italic, nitalic, hilite, nhilite,
 		 selected, nselected, strikethrough, nstrikethrough;
 	guint item_count;
 	const VteCell *cell;
@@ -9975,11 +9978,13 @@ vte_view_draw_rows(VteView *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]);
 				}
@@ -10061,6 +10066,7 @@ vte_view_draw_rows(VteView *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,
@@ -10079,7 +10085,7 @@ vte_view_draw_rows(VteView *terminal,
 			j = i + items[0].columns;
 
 			/* If this is a graphics character, draw it locally. */
-			if (vte_view_unichar_is_local_graphic(terminal, cell->c, cell->attr.bold)) {
+			if (vte_unichar_is_local_graphic(cell->c)) {
 				if (vte_view_draw_graphic(terminal,
 							items[0].c,
 							fore, back,
@@ -10088,8 +10094,7 @@ vte_view_draw_rows(VteView *terminal,
 							items[0].y,
 							column_width,
 							items[0].columns,
-							row_height,
-							cell->attr.bold)) {
+							row_height)) {
 					i = j;
 					continue;
 				}
@@ -10128,7 +10133,7 @@ vte_view_draw_rows(VteView *terminal,
 					selected = vte_view_cell_is_selected(terminal->pvt->buffer, j, row, terminal);
 					vte_view_determine_colors(terminal, cell, selected, &nfore, &nback);
 					/* Graphic characters must be drawn individually. */
-					if (vte_view_unichar_is_local_graphic(terminal, cell->c, cell->attr.bold)) {
+					if (vte_unichar_is_local_graphic(cell->c)) {
 						if (vte_view_draw_graphic(terminal,
 									cell->c,
 									nfore, nback,
@@ -10137,8 +10142,7 @@ vte_view_draw_rows(VteView *terminal,
 									y,
 									column_width,
 									cell->attr.columns,
-									row_height,
-									cell->attr.bold)) {
+									row_height)) {
 
 							j += cell->attr.columns;
 							continue;
@@ -10151,6 +10155,10 @@ vte_view_draw_rows(VteView *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) {
@@ -10215,7 +10223,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;
@@ -10385,8 +10393,11 @@ vte_view_paint_cursor(VteView *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);
 	}
 
@@ -10431,7 +10442,7 @@ vte_view_paint_cursor(VteView *terminal)
 							     x, y,
 							     cursor_width, height);
 
-				if (!vte_view_unichar_is_local_graphic(terminal, item.c, cell ? cell->attr.bold : FALSE) ||
+				if (!vte_unichar_is_local_graphic(item.c) ||
 				    !vte_view_draw_graphic(terminal,
 							       item.c,
 							       fore, back,
@@ -10440,8 +10451,7 @@ vte_view_paint_cursor(VteView *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,
@@ -10456,6 +10466,7 @@ vte_view_paint_cursor(VteView *terminal)
 								&item, 1,
 								fore, back, TRUE, FALSE,
 								cell->attr.bold,
+								cell->attr.italic,
 								cell->attr.underline,
 								cell->attr.strikethrough,
 								hilite,
@@ -10556,6 +10567,7 @@ vte_view_paint_im_preedit_string(VteView *terminal)
 						FALSE,
 						FALSE,
 						FALSE,
+						FALSE,
 						TRUE,
 						width, height);
 		}
diff --git a/src/vtedraw.c b/src/vtedraw.c
index fcf0762..d057474 100644
--- a/src/vtedraw.c
+++ b/src/vtedraw.c
@@ -719,9 +719,17 @@ 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 {
-	struct font_info *font;
-	struct font_info *font_bold;
+	struct font_info *fonts[4];
 
 	cairo_t *cr;
 };
@@ -748,11 +756,16 @@ _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->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;
+		}
 	}
 
 	g_slice_free (struct _vte_draw, draw);
@@ -804,28 +817,66 @@ _vte_draw_set_text_font (struct _vte_draw *draw,
                          GtkWidget *widget,
                          const PangoFontDescription *fontdesc)
 {
-	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\n");
 
-	if (draw->font_bold != draw->font)
-		font_info_destroy (draw->font_bold);
-	font_info_destroy (draw->font);
-	draw->font = font_info_create_for_widget (widget, fontdesc);
+	/* 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 (widget, bolddesc);
+	/* 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 (widget, fontdesc);
+	draw->fonts[VTE_DRAW_BOLD]  = 
+                font_info_create_for_widget (widget, bolddesc);
+	draw->fonts[VTE_DRAW_ITALIC] =
+                font_info_create_for_widget (widget, italicdesc);
+	draw->fonts[VTE_DRAW_ITALIC | VTE_DRAW_BOLD] =
+                font_info_create_for_widget (widget, bolditalicdesc);
 	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];
 	}
 }
 
@@ -833,45 +884,45 @@ 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]);
 }
 
 static void
 _vte_draw_text_internal (struct _vte_draw *draw,
 			 struct _vte_draw_text_request *requests, gsize n_requests,
-			 const GdkRGBA *color, gboolean bold)
+			 const GdkRGBA *color, 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);
 
@@ -932,7 +983,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 GdkRGBA *color, gboolean bold)
+               const GdkRGBA *color, guint style)
 {
 	g_assert(draw->cr);
 
@@ -944,17 +995,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=(%.3f,%.3f,%.3f,%.3f), %s)\n",
-				str, n_requests,
-                                color->red, color->green, color->blue, color->alpha,
-				bold ? "bold" : "normal");
+		g_printerr ("draw_text (\"%s\", len=%"G_GSIZE_FORMAT", color=(%.3f,%.3f,%.3f,%.3f), %s - %s)\n",
+                            str, n_requests, color->red, color->green, color->blue, color->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, bold);
+	_vte_draw_text_internal (draw, requests, n_requests, color, 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. */
@@ -962,7 +1013,7 @@ _vte_draw_text (struct _vte_draw *draw,
 			requests[i].x++;
 		}
 		_vte_draw_text_internal (draw, requests,
-					   n_requests, color, FALSE);
+					   n_requests, color, style);
 		/* Now take a step back. */
 		for (i = 0; i < n_requests; i++) {
 			requests[i].x--;
@@ -971,35 +1022,37 @@ _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 GdkRGBA *color, gboolean bold)
+	       const GdkRGBA *color, guint style)
 {
 	gboolean has_char;
 
 	_vte_debug_print (VTE_DEBUG_DRAW,
-			"draw_char ('%c', color=(%.3f,%.3f,%.3f,%.3f), %s)\n",
+			"draw_char ('%c', color=(%.3f,%.3f,%.3f,%.3f), %s, %s)\n",
 			request->c,
-			color->red, color->green, color->blue, color->alpha,
-			bold ? "bold" : "normal");
+                          color->red, color->green, color->blue, color->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, bold);
+		_vte_draw_text (draw, request, 1, color, style);
 
 	return has_char;
 }
diff --git a/src/vtedraw.h b/src/vtedraw.h
index 0b75060..6cfa655 100644
--- a/src/vtedraw.h
+++ b/src/vtedraw.h
@@ -47,6 +47,10 @@ G_BEGIN_DECLS
 #define VTE_DRAW_DOUBLE_WIDE_IDEOGRAPHS 0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x4e94
 #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
@@ -58,6 +62,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(void);
 void _vte_draw_free(struct _vte_draw *draw);
@@ -77,17 +83,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 GdkRGBA *color, gboolean);
+		    const GdkRGBA *color, guint style);
 gboolean _vte_draw_char(struct _vte_draw *draw,
 			struct _vte_draw_text_request *request,
-			const GdkRGBA *color, gboolean bold);
-gboolean _vte_draw_has_char(struct _vte_draw *draw, vteunistr c, gboolean bold);
-
+			const GdkRGBA *color, 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 47d92b4..ed3d652 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 5e08520..649b91d 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -2213,6 +2213,9 @@ vte_sequence_handler_character_attributes (VteBuffer *buffer, GValueArray *param
 			buffer->pvt->screen->defaults.attr.half = 1;
 			buffer->pvt->screen->defaults.attr.bold = 0;
 			break;
+		case 3:
+			buffer->pvt->screen->defaults.attr.italic = 1;
+			break;
 		case 4:
 			buffer->pvt->screen->defaults.attr.underline = 1;
 			break;
@@ -2233,6 +2236,9 @@ vte_sequence_handler_character_attributes (VteBuffer *buffer, GValueArray *param
 			buffer->pvt->screen->defaults.attr.bold = 0;
 			buffer->pvt->screen->defaults.attr.half = 0;
 			break;
+		case 23:
+			buffer->pvt->screen->defaults.attr.italic = 0;
+			break;
 		case 24:
 			buffer->pvt->screen->defaults.attr.underline = 0;
 			break;



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