[vte] [ring] Ease default attr computations



commit 99b5708db5a7bf04e8cf12195ed2b4309b199bf9
Author: Behdad Esfahbod <behdad behdad org>
Date:   Mon Sep 7 21:25:08 2009 -0400

    [ring] Ease default attr computations

 src/ring.c   |    6 +++---
 src/ring.h   |   40 ++++++++++++++++++++++++----------------
 src/vte.c    |    6 +++---
 src/vteseq.c |    2 +-
 4 files changed, 31 insertions(+), 23 deletions(-)
---
diff --git a/src/ring.c b/src/ring.c
index ee1ed47..90d4710 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -228,7 +228,7 @@ _vte_row_storage_compute (const VteCell *cells, guint len)
 {
 	guint i;
 	guint32 *c = (guint32 *) cells;
-	guint32 basic_attrs = * (guint32 *) &basic_cell.attr;
+	guint32 basic_attrs = basic_cell.i.attr;
 	guint32 chars = 0, attrs = 0;
 	VteRowStorage storage;
 
@@ -243,7 +243,7 @@ _vte_row_storage_compute (const VteCell *cells, guint len)
 	}
 
 	storage.compact = 0;
-	return storage; /* XXX disable compacting for now */
+	return storage; /* XXX no compact for now */
 	storage.flags.compact = 1;
 	storage.flags.charbytes = _width_bytes (chars);
 	storage.flags.attrbytes = _width_bytes (attrs);
@@ -300,7 +300,7 @@ _store (char *out, guint32 *from, guint xor, guint width, guint len)
 static void
 _vte_row_storage_compact (VteRowStorage storage, char *out, const VteCell *cells, guint len)
 {
-	guint32 basic_attrs = * (guint32 *) &basic_cell.attr;
+	guint32 basic_attrs = basic_cell.i.attr;
 
 	if (!storage.compact) {
 		memcpy (out, cells, len * sizeof (VteCell));
diff --git a/src/ring.h b/src/ring.h
index 36a7f6b..50c3e28 100644
--- a/src/ring.h
+++ b/src/ring.h
@@ -84,23 +84,31 @@ typedef struct _VteCell {
 } VteCell;
 ASSERT_STATIC (sizeof (VteCell) == 8);
 
-static const VteCell basic_cell = {
-	0,
+static const union {
+	VteCell cell;
+	struct {
+		guint32 c;
+		guint32 attr;
+	} i;
+} basic_cell = {
 	{
-	1, /* columns */
-	VTE_DEF_FG, /* fore */
-	VTE_DEF_BG, /* back */
-
-	0, /* standout */
-	0, /* underline */
-	0, /* strikethrough */
-
-	0, /* reverse */
-	0, /* blink */
-	0, /* half */
-	0, /* bold */
-
-	0  /* invisible */
+		0,
+		{
+			1, /* columns */
+			VTE_DEF_FG, /* fore */
+			VTE_DEF_BG, /* back */
+
+			0, /* standout */
+			0, /* underline */
+			0, /* strikethrough */
+
+			0, /* reverse */
+			0, /* blink */
+			0, /* half */
+			0, /* bold */
+
+			0  /* invisible */
+		}
 	}
 };
 
diff --git a/src/vte.c b/src/vte.c
index d05688d..a83cd81 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -293,7 +293,7 @@ _vte_terminal_set_default_attributes(VteTerminal *terminal)
 
 	screen = terminal->pvt->screen;
 
-	screen->defaults = basic_cell;
+	screen->defaults = basic_cell.cell;
 	screen->color_defaults = screen->defaults;
 	screen->fill_defaults = screen->defaults;
 }
@@ -2293,7 +2293,7 @@ vte_terminal_ensure_cursor(VteTerminal *terminal)
 	VteRowData *row;
 
 	row = _vte_terminal_ensure_row (terminal);
-	_vte_row_data_fill (row, &basic_cell, terminal->pvt->screen->cursor_current.col);
+	_vte_row_data_fill (row, &basic_cell.cell, terminal->pvt->screen->cursor_current.col);
 
 	return row;
 }
@@ -3054,7 +3054,7 @@ _vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
 		for (i = 0; i < columns; i++)
 			_vte_row_data_insert (row, col + i, &screen->color_defaults);
 	} else {
-		_vte_row_data_fill (row, &basic_cell, col + columns);
+		_vte_row_data_fill (row, &basic_cell.cell, col + columns);
 	}
 
 	/* Convert any wide characters we may have broken into single
diff --git a/src/vteseq.c b/src/vteseq.c
index c21d42a..fb3e0bb 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -2983,7 +2983,7 @@ vte_sequence_handler_screen_alignment_test (VteTerminal *terminal, GValueArray *
 		_vte_terminal_emit_text_deleted(terminal);
 		/* Fill this row. */
 		cell.c = 'E';
-		cell.attr = basic_cell.attr;
+		cell.attr = basic_cell.cell.attr;
 		cell.attr.columns = 1;
 		_vte_row_data_fill (rowdata, &cell, terminal->column_count);
 		_vte_terminal_emit_text_inserted(terminal);



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