[gtksourceview] stylescheme: allow setting border line on gutter



commit 291fa5bc330048d1cb59ccbe0af6cf683482ec03
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jul 29 13:54:12 2021 -0700

    stylescheme: allow setting border line on gutter
    
    If "line-numbers-border" is specified, a line will be drawn between
    between the left gutter and the textview.
    
    This is useful to match styling with some other editors.
    
    Fixes #205

 docs/reference/style-reference.xml.in |  5 +++++
 gtksourceview/gtksourcestylescheme.c  | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+)
---
diff --git a/docs/reference/style-reference.xml.in b/docs/reference/style-reference.xml.in
index 17c6cc67..6aa878d5 100644
--- a/docs/reference/style-reference.xml.in
+++ b/docs/reference/style-reference.xml.in
@@ -216,6 +216,11 @@ is used.</para></listitem>
 numbers are drawn.</para></listitem>
 </varlistentry>
 <varlistentry>
+<term><code>line-numbers-border</code></term>
+<listitem><para>Background color for the border between the left gutter and
+textview.</para></listitem>
+</varlistentry>
+<varlistentry>
 <term><code>current-line-number</code></term>
 <listitem><para>Current line style for the left margin, on which the current
 line number is drawn. Only the <code>background</code> attribute is used.</para></listitem>
diff --git a/gtksourceview/gtksourcestylescheme.c b/gtksourceview/gtksourcestylescheme.c
index 834521af..5a998301 100644
--- a/gtksourceview/gtksourcestylescheme.c
+++ b/gtksourceview/gtksourcestylescheme.c
@@ -59,6 +59,7 @@
 #define STYLE_SECONDARY_CURSOR         "secondary-cursor"
 #define STYLE_CURRENT_LINE             "current-line"
 #define STYLE_LINE_NUMBERS             "line-numbers"
+#define STYLE_LINE_NUMBERS_BORDER      "line-numbers-border"
 #define STYLE_CURRENT_LINE_NUMBER      "current-line-number"
 #define STYLE_RIGHT_MARGIN             "right-margin"
 #define STYLE_DRAW_SPACES              "draw-spaces"
@@ -931,6 +932,24 @@ generate_css_style (GtkSourceStyleScheme *scheme)
                append_css_style (final_style, style, "textview border gutter");
        }
 
+       /* Add border for line-numbers-border if specified */
+       style = gtk_source_style_scheme_get_style (scheme, STYLE_LINE_NUMBERS_BORDER);
+       if (style != NULL)
+       {
+               GdkRGBA color;
+
+               if (get_color (style, FALSE, &color))
+               {
+                       char *bg = gdk_rgba_to_string (&color);
+                       g_string_append_printf (final_style,
+                                               "textview border.left gutter {\n"
+                                               "  border-right: 1px solid %s;\n"
+                                               "}\n",
+                                               bg);
+                       g_free (bg);
+               }
+       }
+
        apply_css_style_cursors (scheme, final_style);
 
        if (*final_style->str != '\0')


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