[gtksourceview/wip/new-space-drawing-api] New API to draw whitespaces, with two enums (space types vs locations)



commit a31b075c8989b9d2b603c83b062c1c498ed7d8e7
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Jul 23 17:37:25 2016 +0200

    New API to draw whitespaces, with two enums (space types vs locations)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=683678

 docs/reference/gtksourceview-3.0-sections.txt |   10 ++++
 gtksourceview/gtksourcespacedrawer.c          |   34 +++++++++++++
 gtksourceview/gtksourcespacedrawer.h          |   67 +++++++++++++++++++++++++
 3 files changed, 111 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtksourceview-3.0-sections.txt b/docs/reference/gtksourceview-3.0-sections.txt
index d0c6101..137c4a9 100644
--- a/docs/reference/gtksourceview-3.0-sections.txt
+++ b/docs/reference/gtksourceview-3.0-sections.txt
@@ -743,6 +743,12 @@ gtk_source_search_settings_get_type
 <FILE>spacedrawer</FILE>
 <TITLE>GtkSourceSpaceDrawer</TITLE>
 GtkSourceSpaceDrawer
+GtkSourceSpaceTypeFlags
+GtkSourceSpaceLocationFlags
+gtk_source_space_drawer_get_types_for_locations
+gtk_source_space_drawer_set_types_for_locations
+gtk_source_space_drawer_get_locations_for_types
+gtk_source_space_drawer_set_locations_for_types
 <SUBSECTION Standard>
 GTK_SOURCE_IS_SPACE_DRAWER
 GTK_SOURCE_IS_SPACE_DRAWER_CLASS
@@ -753,6 +759,10 @@ GTK_SOURCE_TYPE_SPACE_DRAWER
 GtkSourceSpaceDrawerClass
 GtkSourceSpaceDrawerPrivate
 gtk_source_space_drawer_get_type
+GTK_SOURCE_TYPE_SPACE_LOCATION_FLAGS
+GTK_SOURCE_TYPE_SPACE_TYPE_FLAGS
+gtk_source_space_location_flags_get_type
+gtk_source_space_type_flags_get_type
 </SECTION>
 
 <SECTION>
diff --git a/gtksourceview/gtksourcespacedrawer.c b/gtksourceview/gtksourcespacedrawer.c
index fc4416e..02be363 100644
--- a/gtksourceview/gtksourcespacedrawer.c
+++ b/gtksourceview/gtksourcespacedrawer.c
@@ -109,6 +109,40 @@ _gtk_source_space_drawer_set_flags (GtkSourceSpaceDrawer     *drawer,
        return changed;
 }
 
+GtkSourceSpaceTypeFlags
+gtk_source_space_drawer_get_types_for_locations (GtkSourceSpaceDrawer        *drawer,
+                                                GtkSourceSpaceLocationFlags  locations)
+{
+       g_return_val_if_fail (GTK_SOURCE_IS_SPACE_DRAWER (drawer), GTK_SOURCE_SPACE_TYPE_NONE);
+
+       return GTK_SOURCE_SPACE_TYPE_NONE;
+}
+
+void
+gtk_source_space_drawer_set_types_for_locations (GtkSourceSpaceDrawer        *drawer,
+                                                GtkSourceSpaceLocationFlags  locations,
+                                                GtkSourceSpaceTypeFlags      types)
+{
+       g_return_if_fail (GTK_SOURCE_IS_SPACE_DRAWER (drawer));
+}
+
+GtkSourceSpaceLocationFlags
+gtk_source_space_drawer_get_locations_for_types (GtkSourceSpaceDrawer    *drawer,
+                                                GtkSourceSpaceTypeFlags  types)
+{
+       g_return_val_if_fail (GTK_SOURCE_IS_SPACE_DRAWER (drawer), GTK_SOURCE_SPACE_LOCATION_NONE);
+
+       return GTK_SOURCE_SPACE_LOCATION_NONE;
+}
+
+void
+gtk_source_space_drawer_set_locations_for_types (GtkSourceSpaceDrawer        *drawer,
+                                                GtkSourceSpaceTypeFlags      types,
+                                                GtkSourceSpaceLocationFlags  locations)
+{
+       g_return_if_fail (GTK_SOURCE_IS_SPACE_DRAWER (drawer));
+}
+
 void
 _gtk_source_space_drawer_update_color (GtkSourceSpaceDrawer *drawer,
                                       GtkSourceView        *view)
diff --git a/gtksourceview/gtksourcespacedrawer.h b/gtksourceview/gtksourcespacedrawer.h
index 63ca162..8bc9364 100644
--- a/gtksourceview/gtksourcespacedrawer.h
+++ b/gtksourceview/gtksourcespacedrawer.h
@@ -51,9 +51,76 @@ struct _GtkSourceSpaceDrawerClass
        gpointer padding[20];
 };
 
+/**
+ * GtkSourceSpaceTypeFlags:
+ * @GTK_SOURCE_SPACE_TYPE_NONE: No flags.
+ * @GTK_SOURCE_SPACE_TYPE_SPACE: Space character.
+ * @GTK_SOURCE_SPACE_TYPE_TAB: Tab character.
+ * @GTK_SOURCE_SPACE_TYPE_NEWLINE: Line break character.
+ * @GTK_SOURCE_SPACE_TYPE_NBSP: Non-breaking space character.
+ * @GTK_SOURCE_SPACE_TYPE_ALL: All whitespaces.
+ *
+ * #GtkSourceSpaceTypeFlags contains flags for whitespace types.
+ *
+ * Since: 3.24
+ */
+typedef enum _GtkSourceSpaceTypeFlags
+{
+       GTK_SOURCE_SPACE_TYPE_NONE      = 0,
+       GTK_SOURCE_SPACE_TYPE_SPACE     = 1 << 0,
+       GTK_SOURCE_SPACE_TYPE_TAB       = 1 << 1,
+       GTK_SOURCE_SPACE_TYPE_NEWLINE   = 1 << 2,
+       GTK_SOURCE_SPACE_TYPE_NBSP      = 1 << 3,
+       GTK_SOURCE_SPACE_TYPE_ALL       = 0xff
+} GtkSourceSpaceTypeFlags;
+
+/**
+ * GtkSourceSpaceLocationFlags:
+ * @GTK_SOURCE_SPACE_LOCATION_NONE: No flags.
+ * @GTK_SOURCE_SPACE_LOCATION_LEADING: Leading whitespaces on a line, i.e. the
+ *   indentation.
+ * @GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT: Whitespaces inside a line of text.
+ * @GTK_SOURCE_SPACE_LOCATION_TRAILING: Trailing whitespaces on a line.
+ * @GTK_SOURCE_SPACE_LOCATION_ALL: Whitespaces anywhere.
+ *
+ * #GtkSourceSpaceLocationFlags contains flags for whitespace locations.
+ *
+ * If a line contains only whitespaces (no text), the whitespaces match both
+ * %GTK_SOURCE_SPACE_LOCATION_LEADING and %GTK_SOURCE_SPACE_LOCATION_TRAILING.
+ *
+ * Since: 3.24
+ */
+typedef enum _GtkSourceSpaceLocationFlags
+{
+       GTK_SOURCE_SPACE_LOCATION_NONE          = 0,
+       GTK_SOURCE_SPACE_LOCATION_LEADING       = 1 << 0,
+       GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT   = 1 << 1,
+       GTK_SOURCE_SPACE_LOCATION_TRAILING      = 1 << 2,
+       GTK_SOURCE_SPACE_LOCATION_ALL           = 0xff
+} GtkSourceSpaceLocationFlags;
+
 GTK_SOURCE_AVAILABLE_IN_3_24
 GType                  gtk_source_space_drawer_get_type                (void) G_GNUC_CONST;
 
+GTK_SOURCE_AVAILABLE_IN_3_24
+GtkSourceSpaceTypeFlags        gtk_source_space_drawer_get_types_for_locations (GtkSourceSpaceDrawer        
*drawer,
+                                                                        GtkSourceSpaceLocationFlags  
locations);
+
+GTK_SOURCE_AVAILABLE_IN_3_24
+void                   gtk_source_space_drawer_set_types_for_locations (GtkSourceSpaceDrawer        *drawer,
+                                                                        GtkSourceSpaceLocationFlags  
locations,
+                                                                        GtkSourceSpaceTypeFlags      types);
+
+GTK_SOURCE_AVAILABLE_IN_3_24
+GtkSourceSpaceLocationFlags
+                       gtk_source_space_drawer_get_locations_for_types (GtkSourceSpaceDrawer    *drawer,
+                                                                        GtkSourceSpaceTypeFlags  types);
+
+GTK_SOURCE_AVAILABLE_IN_3_24
+void                   gtk_source_space_drawer_set_locations_for_types (GtkSourceSpaceDrawer        *drawer,
+                                                                        GtkSourceSpaceTypeFlags      types,
+                                                                        GtkSourceSpaceLocationFlags  
locations);
+
 G_END_DECLS
 
 #endif /* GTK_SOURCE_SPACE_DRAWER_H */


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