1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*- */
2 /* gtksourcespacedrawer.h
3  * This file is part of GtkSourceView
4  *
5  * Copyright (C) 2016 - Sébastien Wilmet <swilmet@gnome.org>
6  *
7  * GtkSourceView is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * GtkSourceView is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 
22 #ifndef GTK_SOURCE_SPACE_DRAWER_H
23 #define GTK_SOURCE_SPACE_DRAWER_H
24 
25 #if !defined (GTK_SOURCE_H_INSIDE) && !defined (GTK_SOURCE_COMPILATION)
26 #  if defined (__GNUC__)
27 #    warning "Only <gtksourceview/gtksource.h> can be included directly."
28 #  elif defined (G_OS_WIN32)
29 #    pragma message("Only <gtksourceview/gtksource.h> can be included directly.")
30 #  endif
31 #endif
32 
33 #include <gtk/gtk.h>
34 #include <gtksourceview/gtksourcetypes.h>
35 
36 G_BEGIN_DECLS
37 
38 #define GTK_SOURCE_TYPE_SPACE_DRAWER             (gtk_source_space_drawer_get_type ())
39 #define GTK_SOURCE_SPACE_DRAWER(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_SOURCE_TYPE_SPACE_DRAWER, GtkSourceSpaceDrawer))
40 #define GTK_SOURCE_SPACE_DRAWER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_SOURCE_TYPE_SPACE_DRAWER, GtkSourceSpaceDrawerClass))
41 #define GTK_SOURCE_IS_SPACE_DRAWER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_SOURCE_TYPE_SPACE_DRAWER))
42 #define GTK_SOURCE_IS_SPACE_DRAWER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_SOURCE_TYPE_SPACE_DRAWER))
43 #define GTK_SOURCE_SPACE_DRAWER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_SOURCE_TYPE_SPACE_DRAWER, GtkSourceSpaceDrawerClass))
44 
45 typedef struct _GtkSourceSpaceDrawerClass    GtkSourceSpaceDrawerClass;
46 typedef struct _GtkSourceSpaceDrawerPrivate  GtkSourceSpaceDrawerPrivate;
47 
48 struct _GtkSourceSpaceDrawer
49 {
50 	GObject parent;
51 
52 	GtkSourceSpaceDrawerPrivate *priv;
53 };
54 
55 struct _GtkSourceSpaceDrawerClass
56 {
57 	GObjectClass parent_class;
58 
59 	gpointer padding[20];
60 };
61 
62 /**
63  * GtkSourceSpaceTypeFlags:
64  * @GTK_SOURCE_SPACE_TYPE_NONE: No flags.
65  * @GTK_SOURCE_SPACE_TYPE_SPACE: Space character.
66  * @GTK_SOURCE_SPACE_TYPE_TAB: Tab character.
67  * @GTK_SOURCE_SPACE_TYPE_NEWLINE: Line break character. If the
68  *   #GtkSourceBuffer:implicit-trailing-newline property is %TRUE,
69  *   #GtkSourceSpaceDrawer also draws a line break at the end of the buffer.
70  * @GTK_SOURCE_SPACE_TYPE_NBSP: Non-breaking space character.
71  * @GTK_SOURCE_SPACE_TYPE_ALL: All white spaces.
72  *
73  * #GtkSourceSpaceTypeFlags contains flags for white space types.
74  *
75  * Since: 3.24
76  */
77 typedef enum _GtkSourceSpaceTypeFlags
78 {
79 	GTK_SOURCE_SPACE_TYPE_NONE	= 0,
80 	GTK_SOURCE_SPACE_TYPE_SPACE	= 1 << 0,
81 	GTK_SOURCE_SPACE_TYPE_TAB	= 1 << 1,
82 	GTK_SOURCE_SPACE_TYPE_NEWLINE	= 1 << 2,
83 	GTK_SOURCE_SPACE_TYPE_NBSP	= 1 << 3,
84 	GTK_SOURCE_SPACE_TYPE_ALL	= 0xf
85 } GtkSourceSpaceTypeFlags;
86 
87 /**
88  * GtkSourceSpaceLocationFlags:
89  * @GTK_SOURCE_SPACE_LOCATION_NONE: No flags.
90  * @GTK_SOURCE_SPACE_LOCATION_LEADING: Leading white spaces on a line, i.e. the
91  *   indentation.
92  * @GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT: White spaces inside a line of text.
93  * @GTK_SOURCE_SPACE_LOCATION_TRAILING: Trailing white spaces on a line.
94  * @GTK_SOURCE_SPACE_LOCATION_ALL: White spaces anywhere.
95  *
96  * #GtkSourceSpaceLocationFlags contains flags for white space locations.
97  *
98  * If a line contains only white spaces (no text), the white spaces match both
99  * %GTK_SOURCE_SPACE_LOCATION_LEADING and %GTK_SOURCE_SPACE_LOCATION_TRAILING.
100  *
101  * Since: 3.24
102  */
103 typedef enum _GtkSourceSpaceLocationFlags
104 {
105 	GTK_SOURCE_SPACE_LOCATION_NONE		= 0,
106 	GTK_SOURCE_SPACE_LOCATION_LEADING	= 1 << 0,
107 	GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT	= 1 << 1,
108 	GTK_SOURCE_SPACE_LOCATION_TRAILING	= 1 << 2,
109 	GTK_SOURCE_SPACE_LOCATION_ALL		= 0x7
110 } GtkSourceSpaceLocationFlags;
111 
112 GTK_SOURCE_AVAILABLE_IN_3_24
113 GType			gtk_source_space_drawer_get_type		(void) G_GNUC_CONST;
114 
115 GTK_SOURCE_AVAILABLE_IN_3_24
116 GtkSourceSpaceDrawer *	gtk_source_space_drawer_new			(void);
117 
118 GTK_SOURCE_AVAILABLE_IN_3_24
119 GtkSourceSpaceTypeFlags	gtk_source_space_drawer_get_types_for_locations	(GtkSourceSpaceDrawer        *drawer,
120 									 GtkSourceSpaceLocationFlags  locations);
121 
122 GTK_SOURCE_AVAILABLE_IN_3_24
123 void			gtk_source_space_drawer_set_types_for_locations	(GtkSourceSpaceDrawer        *drawer,
124 									 GtkSourceSpaceLocationFlags  locations,
125 									 GtkSourceSpaceTypeFlags      types);
126 
127 GTK_SOURCE_AVAILABLE_IN_3_24
128 GVariant *		gtk_source_space_drawer_get_matrix		(GtkSourceSpaceDrawer *drawer);
129 
130 GTK_SOURCE_AVAILABLE_IN_3_24
131 void			gtk_source_space_drawer_set_matrix		(GtkSourceSpaceDrawer *drawer,
132 									 GVariant             *matrix);
133 
134 GTK_SOURCE_AVAILABLE_IN_3_24
135 gboolean		gtk_source_space_drawer_get_enable_matrix	(GtkSourceSpaceDrawer *drawer);
136 
137 GTK_SOURCE_AVAILABLE_IN_3_24
138 void			gtk_source_space_drawer_set_enable_matrix	(GtkSourceSpaceDrawer *drawer,
139 									 gboolean              enable_matrix);
140 
141 GTK_SOURCE_AVAILABLE_IN_3_24
142 void			gtk_source_space_drawer_bind_matrix_setting	(GtkSourceSpaceDrawer *drawer,
143 									 GSettings            *settings,
144 									 const gchar          *key,
145 									 GSettingsBindFlags    flags);
146 
147 G_END_DECLS
148 
149 #endif /* GTK_SOURCE_SPACE_DRAWER_H */
150