[gnome-terminal] profile: Add cursor colour prefs



commit c57b08b625853800b91e84c8b975ca07acf02e8a
Author: Tony Houghton <h realh co uk>
Date:   Sat Feb 13 20:23:10 2016 +0100

    profile: Add cursor colour prefs
    
    https://bugzilla.gnome.org/show_bug.cgi?id=85821

 src/org.gnome.Terminal.gschema.xml |   17 ++++++++++++++++-
 src/terminal-schemas.h             |    3 +++
 src/terminal-screen.c              |   17 +++++++++++++++--
 3 files changed, 34 insertions(+), 3 deletions(-)
---
diff --git a/src/org.gnome.Terminal.gschema.xml b/src/org.gnome.Terminal.gschema.xml
index 2a834ea..37220b5 100644
--- a/src/org.gnome.Terminal.gschema.xml
+++ b/src/org.gnome.Terminal.gschema.xml
@@ -130,13 +130,28 @@
     <key name="bold-color" type="s">
       <default>'#000000'</default>
       <summary>Default color of bold text in the terminal</summary>
-      <description>Default color of bold text in the terminal, as a color specification (can be HTML-style 
hex digits, or a color name such as "red"). This is ignored if bold_color_same_as_fg is true.</description>
+      <description>Default color of bold text in the terminal, as a color specification (can be HTML-style 
hex digits, or a color name such as "red"). This is ignored if bold-color-same-as-fg is true.</description>
     </key>
     <key name="bold-color-same-as-fg" type="b">
       <default>true</default>
       <summary>Whether bold text should use the same color as normal text</summary>
       <description>If true, boldface text will be rendered using the same color as normal text.</description>
     </key>
+    <key name="cursor-colors-set" type="b">
+      <default>false</default>
+      <summary>Whether to use custom cursor colors</summary>
+      <description>If true, use the cursor colors from the profile.</description>
+    </key>
+    <key name="cursor-background-color" type="s">
+      <default>'#000000'</default>
+      <summary>Cursor background color</summary>
+      <description>Custom color of the background of the terminal's cursor, as a color specification (can be 
HTML-style hex digits, or a color name such as "red"). This is ignored if cursor-colors-set is 
false.</description>
+    </key>
+    <key name="cursor-foreground-color" type="s">
+      <default>'#ffffff'</default>
+      <summary>Cursor foreground colour</summary>
+      <description>Custom color for the foreground of the text character at the terminal's cursor position, 
as a color specification (can be HTML-style hex digits, or a color name such as "red"). This is ignored if 
cursor-colors-set is false.</description>
+    </key>
     <key name="allow-bold" type="b">
       <default>true</default>
       <summary>Whether to allow bold text</summary>
diff --git a/src/terminal-schemas.h b/src/terminal-schemas.h
index 2c85c67..941b342 100644
--- a/src/terminal-schemas.h
+++ b/src/terminal-schemas.h
@@ -36,6 +36,9 @@ G_BEGIN_DECLS
 #define TERMINAL_PROFILE_BACKSPACE_BINDING_KEY          "backspace-binding"
 #define TERMINAL_PROFILE_BOLD_COLOR_KEY                 "bold-color"
 #define TERMINAL_PROFILE_BOLD_COLOR_SAME_AS_FG_KEY      "bold-color-same-as-fg"
+#define TERMINAL_PROFILE_CURSOR_COLORS_SET_KEY          "cursor-colors-set"
+#define TERMINAL_PROFILE_CURSOR_BACKGROUND_COLOR_KEY    "cursor-background-color"
+#define TERMINAL_PROFILE_CURSOR_FOREGROUND_COLOR_KEY    "cursor-foreground-color"
 #define TERMINAL_PROFILE_CJK_UTF8_AMBIGUOUS_WIDTH_KEY   "cjk-utf8-ambiguous-width"
 #define TERMINAL_PROFILE_CURSOR_BLINK_MODE_KEY          "cursor-blink-mode"
 #define TERMINAL_PROFILE_CURSOR_SHAPE_KEY               "cursor-shape"
diff --git a/src/terminal-screen.c b/src/terminal-screen.c
index d786d7e..81613b9 100644
--- a/src/terminal-screen.c
+++ b/src/terminal-screen.c
@@ -823,6 +823,9 @@ terminal_screen_profile_changed_cb (GSettings     *profile,
       prop_name == I_(TERMINAL_PROFILE_BACKGROUND_COLOR_KEY) ||
       prop_name == I_(TERMINAL_PROFILE_BOLD_COLOR_SAME_AS_FG_KEY) ||
       prop_name == I_(TERMINAL_PROFILE_BOLD_COLOR_KEY) ||
+      prop_name == I_(TERMINAL_PROFILE_CURSOR_COLORS_SET_KEY) ||
+      prop_name == I_(TERMINAL_PROFILE_CURSOR_BACKGROUND_COLOR_KEY) ||
+      prop_name == I_(TERMINAL_PROFILE_CURSOR_FOREGROUND_COLOR_KEY) ||
       prop_name == I_(TERMINAL_PROFILE_PALETTE_KEY))
     update_color_scheme (screen);
 
@@ -886,8 +889,8 @@ update_color_scheme (TerminalScreen *screen)
   GSettings *profile = priv->profile;
   gs_free GdkRGBA *colors;
   gsize n_colors;
-  GdkRGBA fg, bg, bold, theme_fg, theme_bg;
-  GdkRGBA *boldp;
+  GdkRGBA fg, bg, bold, theme_fg, theme_bg, cursor_bg, cursor_fg;
+  GdkRGBA *boldp, *cursor_bgp = NULL, *cursor_fgp = NULL;
   GtkStyleContext *context;
 
   context = gtk_widget_get_style_context (widget);
@@ -908,10 +911,20 @@ update_color_scheme (TerminalScreen *screen)
   else
     boldp = NULL;
 
+  if (g_settings_get_boolean (profile, TERMINAL_PROFILE_CURSOR_COLORS_SET_KEY))
+    {
+      if (terminal_g_settings_get_rgba (profile, TERMINAL_PROFILE_CURSOR_BACKGROUND_COLOR_KEY, &cursor_bg))
+        cursor_bgp = &cursor_bg;
+      if (terminal_g_settings_get_rgba (profile, TERMINAL_PROFILE_CURSOR_FOREGROUND_COLOR_KEY, &cursor_fg))
+        cursor_fgp = &cursor_fg;
+    }
+
   colors = terminal_g_settings_get_rgba_palette (priv->profile, TERMINAL_PROFILE_PALETTE_KEY, &n_colors);
   vte_terminal_set_colors (VTE_TERMINAL (screen), &fg, &bg,
                            colors, n_colors);
   vte_terminal_set_color_bold (VTE_TERMINAL (screen), boldp);
+  vte_terminal_set_color_cursor (VTE_TERMINAL (screen), cursor_bgp);
+  vte_terminal_set_color_cursor_foreground (VTE_TERMINAL (screen), cursor_fgp);
 }
 
 static void


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