[vte/vte-next: 79/223] Record whether a colour was changed



commit 8720967a9de5de685a1af318389f3382472f67ed
Author: Christian Persch <chpe gnome org>
Date:   Wed May 18 15:37:45 2011 +0200

    Record whether a colour was changed
    
    This will be necessary later on when moving the default colours
    to the style.

 src/vte-private.h |    8 +++++++-
 src/vte.c         |   30 ++++++++++++++++++++----------
 src/vterowdata.h  |    1 -
 src/vteseq.c      |    1 +
 4 files changed, 28 insertions(+), 12 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index fc4a00b..a62885c 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -55,11 +55,16 @@ G_BEGIN_DECLS
 #define VTE_LINE_WIDTH			1
 #define VTE_ROWS			24
 #define VTE_COLUMNS			80
+
 #define VTE_LEGACY_COLOR_SET_SIZE	8
 #define VTE_COLOR_PLAIN_OFFSET		0
 #define VTE_COLOR_BRIGHT_OFFSET		8
 #define VTE_COLOR_DIM_OFFSET		16
-/* More color defines in ring.h */
+/* more color defines in vterowdata.h */
+
+#define VTE_PALETTE_HAS_OVERRIDE(array, idx)    (array[(idx) / 32] & (1U << ((idx) % 32)))
+#define VTE_PALETTE_SET_OVERRIDE(array, idx)    (array[(idx) / 32] |= (guint32)(1U << ((idx) % 32)))
+#define VTE_PALETTE_CLEAR_OVERRIDE(array,idx)   (array[(idx) / 32] &= ~(guint32)(1U << ((idx) % 32)))
 
 #define VTE_SCROLLBACK_INIT		100
 #define VTE_DEFAULT_CURSOR		GDK_XTERM
@@ -333,6 +338,7 @@ struct _VteTerminalPrivate {
 	gboolean highlight_color_set;
 	gboolean cursor_color_set;
 	GdkRGBA palette[VTE_PALETTE_SIZE];
+        guint32 palette_set[(VTE_PALETTE_SIZE + 31) / 32];
 
 	/* Mouse cursors. */
 	gboolean mouse_cursor_visible;
diff --git a/src/vte.c b/src/vte.c
index 3cc0e5f..2b611bb 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -2158,8 +2158,10 @@ vte_terminal_new(void)
 
 /* Set up a palette entry with a more-or-less match for the requested color. */
 static void
-vte_terminal_set_color_internal(VteTerminal *terminal, int entry,
-				const GdkRGBA *proposed)
+vte_terminal_set_color_internal(VteTerminal *terminal,
+                                int entry,
+				const GdkRGBA *proposed,
+                                gboolean override)
 {
         GdkRGBA *color;
 
@@ -2167,6 +2169,12 @@ vte_terminal_set_color_internal(VteTerminal *terminal, int entry,
         if (gdk_rgba_equal(color, proposed))
 		return;
 
+        if (!override) {
+                if (VTE_PALETTE_HAS_OVERRIDE(terminal->pvt->palette_set, entry))
+                        return;
+                VTE_PALETTE_CLEAR_OVERRIDE(terminal->pvt->palette_set, entry);
+        }
+
 	_vte_debug_print(VTE_DEBUG_MISC,
 			"Set color[%d] to rgba(%.3f,%.3f,%.3f,%.3f).\n", entry,
 			proposed->red, proposed->green, proposed->blue, proposed->alpha);
@@ -2302,7 +2310,7 @@ vte_terminal_set_colors_rgba(VteTerminal *terminal,
 
                 /* Take the supplied palette if there is one. */
                 if (i < palette_size) {
-                        vte_terminal_set_color_internal(terminal, i, &palette[i]);
+                        vte_terminal_set_color_internal(terminal, i, &palette[i], TRUE);
                         continue;
                 }
 
@@ -2373,7 +2381,7 @@ vte_terminal_set_colors_rgba(VteTerminal *terminal,
                 }
 
 		/* Set up the color entry. */
-		vte_terminal_set_color_internal(terminal, i, &color);
+		vte_terminal_set_color_internal(terminal, i, &color, TRUE);
 	}
 
 	/* Track that we had a color palette set. */
@@ -2407,7 +2415,7 @@ vte_terminal_set_color_bold_rgba(VteTerminal *terminal,
         _vte_debug_print(VTE_DEBUG_MISC,
                         "Set bold color to rgba(%.3f,%.3f,%.3f,%.3f).\n",
                         rgba->red, rgba->green, rgba->blue, rgba->alpha);
-        vte_terminal_set_color_internal(terminal, VTE_BOLD_FG, rgba);
+        vte_terminal_set_color_internal(terminal, VTE_BOLD_FG, rgba, TRUE);
 }
 
 /**
@@ -2439,7 +2447,7 @@ vte_terminal_set_color_dim_rgba(VteTerminal *terminal,
         _vte_debug_print(VTE_DEBUG_MISC,
                         "Set dim color to rgba(%.3f,%.3f,%.3f,%.3f).\n",
                         rgba->red, rgba->green, rgba->blue, rgba->alpha);
-        vte_terminal_set_color_internal(terminal, VTE_DIM_FG, rgba);
+        vte_terminal_set_color_internal(terminal, VTE_DIM_FG, rgba, TRUE);
 }
 
 /**
@@ -2461,7 +2469,7 @@ vte_terminal_set_color_foreground_rgba(VteTerminal *terminal,
         _vte_debug_print(VTE_DEBUG_MISC,
                         "Set foreground color to rgba(%.3f,%.3f,%.3f,%.3f).\n",
                         rgba->red, rgba->green, rgba->blue, rgba->alpha);
-        vte_terminal_set_color_internal(terminal, VTE_DEF_FG, rgba);
+        vte_terminal_set_color_internal(terminal, VTE_DEF_FG, rgba, TRUE);
 }
 
 /**
@@ -2484,7 +2492,7 @@ vte_terminal_set_color_background_rgba(VteTerminal *terminal,
         _vte_debug_print(VTE_DEBUG_MISC,
                         "Set background color to rgba(%.3f,%.3f,%.3f,%.3f).\n",
                         rgba->red, rgba->green, rgba->blue, rgba->alpha);
-        vte_terminal_set_color_internal(terminal, VTE_DEF_BG, rgba);
+        vte_terminal_set_color_internal(terminal, VTE_DEF_BG, rgba, TRUE);
 }
 
 /**
@@ -2508,7 +2516,7 @@ vte_terminal_set_color_cursor_rgba(VteTerminal *terminal,
                 _vte_debug_print(VTE_DEBUG_MISC,
                                 "Set cursor color to rgba(%.3f,%.3f,%.3f,%.3f).\n",
                                 rgba->red, rgba->green, rgba->blue, rgba->alpha);
-                vte_terminal_set_color_internal(terminal, VTE_CUR_BG, rgba);
+                vte_terminal_set_color_internal(terminal, VTE_CUR_BG, rgba, TRUE);
                 terminal->pvt->cursor_color_set = TRUE;
         } else {
                 _vte_debug_print(VTE_DEBUG_MISC,
@@ -2538,7 +2546,7 @@ vte_terminal_set_color_highlight_rgba(VteTerminal *terminal,
                 _vte_debug_print(VTE_DEBUG_MISC,
                                 "Set highlight color to rgba(%.3f,%.3f,%.3f,%.3f).\n",
                                 rgba->red, rgba->green, rgba->blue, rgba->alpha);
-                vte_terminal_set_color_internal(terminal, VTE_DEF_HL, rgba);
+                vte_terminal_set_color_internal(terminal, VTE_DEF_HL, rgba, TRUE);
                 terminal->pvt->highlight_color_set = TRUE;
         } else {
                 _vte_debug_print(VTE_DEBUG_MISC,
@@ -2557,6 +2565,8 @@ void
 vte_terminal_set_default_colors(VteTerminal *terminal)
 {
 	g_return_if_fail(VTE_IS_TERMINAL(terminal));
+
+        memset(terminal->pvt->palette_set, 0, sizeof(terminal->pvt->palette_set));
 	vte_terminal_set_colors_rgba(terminal, NULL, NULL, NULL, 0);
 }
 
diff --git a/src/vterowdata.h b/src/vterowdata.h
index d75f791..59af48b 100644
--- a/src/vterowdata.h
+++ b/src/vterowdata.h
@@ -25,7 +25,6 @@
 
 G_BEGIN_DECLS
 
-
 #define VTE_DEF_FG			256
 #define VTE_DEF_BG			257
 #define VTE_BOLD_FG			258
diff --git a/src/vteseq.c b/src/vteseq.c
index 04bb811..2de25db 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -1855,6 +1855,7 @@ vte_sequence_handler_change_color (VteTerminal *terminal, GValueArray *params)
 
 			if (vte_parse_color (pairs[i + 1], &color)) {
 				terminal->pvt->palette[idx] = color;
+                                VTE_PALETTE_SET_OVERRIDE(terminal->pvt->palette_set, idx);
 			} else if (strcmp (pairs[i + 1], "?") == 0) {
 				gchar buf[128];
 				g_snprintf (buf, sizeof (buf),



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