[vte/vte-next: 105/223] Implement global reverse mode



commit d403bc843f1b426bcf215603dc78c1178ebea669
Author: Christian Persch <chpe gnome org>
Date:   Fri May 27 23:26:05 2011 +0200

    Implement global reverse mode

 src/vte-private.h |    1 +
 src/vte.c         |   34 ++++++++++++++++++++++++++++++++--
 src/vteapp.c      |    3 +++
 3 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index b44791e..5f63d24 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -336,6 +336,7 @@ struct _VteTerminalPrivate {
 	 * when realizing. */
 	struct _vte_draw *draw;
 
+        gboolean reverse;
 	gboolean highlight_color_set;
 	gboolean cursor_color_set;
         gboolean reverse_color_set;
diff --git a/src/vte.c b/src/vte.c
index a6f526e..785c221 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -4267,7 +4267,7 @@ vte_terminal_update_style(VteTerminal *terminal)
 {
         VteTerminalPrivate *pvt = terminal->pvt;
         GtkWidget *widget = &terminal->widget;
-        gboolean allow_bold, scroll_background;
+        gboolean allow_bold, scroll_background, reverse;
         PangoFontDescription *font_desc;
 
         vte_terminal_set_padding(terminal);
@@ -4279,6 +4279,7 @@ vte_terminal_update_style(VteTerminal *terminal)
                              "allow-bold", &allow_bold,
                              "scroll-background", &scroll_background,
                              "font", &font_desc,
+                             "reverse", &reverse,
                              NULL);
 
         vte_terminal_set_font(terminal, font_desc /* adopted */);
@@ -4288,6 +4289,12 @@ vte_terminal_update_style(VteTerminal *terminal)
                 _vte_invalidate_all (terminal);
         }
 
+        if (reverse != pvt->reverse) {
+                pvt->reverse = reverse;
+
+                _vte_invalidate_all(terminal);
+        }
+
         if (scroll_background != pvt->scroll_background) {
                   pvt->scroll_background = scroll_background;
                   vte_terminal_queue_background_update(terminal);
@@ -7621,6 +7628,9 @@ vte_terminal_init(VteTerminal *terminal)
         pvt->cursor_blinks = FALSE;
         pvt->cursor_blink_mode = VTE_CURSOR_BLINK_SYSTEM;
 
+        /* Style properties */
+        pvt->reverse = FALSE;
+
 	/* Matching data. */
 	pvt->match_regexes = g_array_new(FALSE, TRUE,
 					 sizeof(struct vte_match_regex));
@@ -8236,7 +8246,7 @@ vte_terminal_determine_colors_internal(VteTerminal *terminal,
 	back = cell->attr.back;
 
 	/* Reverse-mode switches default fore and back colors */
-	if (G_UNLIKELY (terminal->pvt->screen->reverse_mode)) {
+	if (G_UNLIKELY (terminal->pvt->screen->reverse_mode ^ terminal->pvt->reverse)) {
 		if (fore == VTE_DEF_FG)
 			fore = VTE_DEF_BG;
 		if (back == VTE_DEF_BG)
@@ -11558,6 +11568,26 @@ vte_terminal_class_init(VteTerminalClass *klass)
                                        FALSE,
                                        G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+
+        /**
+         * VteTerminal:reverse:
+         *
+         * In reverse mode, the terminal draws everything with foreground and
+         * background colours reversed.
+         *
+         * This is a global setting; the terminal application can still
+         * set reverse mode explicitly. In case both this style property and
+         * the application select reverse mode, the terminal draws in
+         * non-reverse mode.
+         *
+         * Since: 0.30
+         */
+        gtk_widget_class_install_style_property
+                (widget_class,
+                 g_param_spec_boolean ("reverse", NULL, NULL,
+                                       FALSE,
+                                       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
         /* Colours */
 
 #include "vtepalettedefs.h"
diff --git a/src/vteapp.c b/src/vteapp.c
index e480075..718ff54 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -826,6 +826,9 @@ main(int argc, char **argv)
         if (scroll) {
                 g_string_append (css_string, "-VteTerminal-scroll-background: true;\n");
         }
+        if (reverse) {
+                g_string_append (css_string, "-VteTerminal-reverse: true;\n");
+        }
         g_string_append (css_string, "}\n");
 
         if (css_string->len > 14) {



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