1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*-
2  *
3  * This file is part of GtkSourceView
4  *
5  * Copyright (C) 2001 - Mikael Hermansson <tyan@linux.se> and
6  *                       Chris Phelps <chicane@reninet.com>
7  * Copyright (C) 2003 - Gustavo Giráldez and Paolo Maggi
8  *
9  * GtkSourceView is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * GtkSourceView is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this library; if not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef GTK_SOURCE_VIEW_H
24 #define GTK_SOURCE_VIEW_H
25 
26 #if !defined (GTK_SOURCE_H_INSIDE) && !defined (GTK_SOURCE_COMPILATION)
27 #error "Only <gtksourceview/gtksource.h> can be included directly."
28 #endif
29 
30 #include <gtk/gtk.h>
31 #include <gtksourceview/gtksourcetypes.h>
32 
33 G_BEGIN_DECLS
34 
35 #define GTK_SOURCE_TYPE_VIEW             (gtk_source_view_get_type ())
36 #define GTK_SOURCE_VIEW(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_SOURCE_TYPE_VIEW, GtkSourceView))
37 #define GTK_SOURCE_VIEW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_SOURCE_TYPE_VIEW, GtkSourceViewClass))
38 #define GTK_SOURCE_IS_VIEW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_SOURCE_TYPE_VIEW))
39 #define GTK_SOURCE_IS_VIEW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_SOURCE_TYPE_VIEW))
40 #define GTK_SOURCE_VIEW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_SOURCE_TYPE_VIEW, GtkSourceViewClass))
41 
42 typedef struct _GtkSourceViewClass GtkSourceViewClass;
43 typedef struct _GtkSourceViewPrivate GtkSourceViewPrivate;
44 
45 /**
46  * GtkSourceViewGutterPosition:
47  * @GTK_SOURCE_VIEW_GUTTER_POSITION_LINES: the gutter position of the lines
48  * renderer
49  * @GTK_SOURCE_VIEW_GUTTER_POSITION_MARKS: the gutter position of the marks
50  * renderer
51  */
52 typedef enum _GtkSourceViewGutterPosition
53 {
54 	GTK_SOURCE_VIEW_GUTTER_POSITION_LINES = -30,
55 	GTK_SOURCE_VIEW_GUTTER_POSITION_MARKS = -20
56 } GtkSourceViewGutterPosition;
57 
58 /**
59  * GtkSourceSmartHomeEndType:
60  * @GTK_SOURCE_SMART_HOME_END_DISABLED: smart-home-end disabled.
61  * @GTK_SOURCE_SMART_HOME_END_BEFORE: move to the first/last
62  * non-whitespace character on the first press of the HOME/END keys and
63  * to the beginning/end of the line on the second press.
64  * @GTK_SOURCE_SMART_HOME_END_AFTER: move to the beginning/end of the
65  * line on the first press of the HOME/END keys and to the first/last
66  * non-whitespace character on the second press.
67  * @GTK_SOURCE_SMART_HOME_END_ALWAYS: always move to the first/last
68  * non-whitespace character when the HOME/END keys are pressed.
69  */
70 typedef enum _GtkSourceSmartHomeEndType
71 {
72 	GTK_SOURCE_SMART_HOME_END_DISABLED,
73 	GTK_SOURCE_SMART_HOME_END_BEFORE,
74 	GTK_SOURCE_SMART_HOME_END_AFTER,
75 	GTK_SOURCE_SMART_HOME_END_ALWAYS
76 } GtkSourceSmartHomeEndType;
77 
78 /**
79  * GtkSourceBackgroundPatternType:
80  * @GTK_SOURCE_BACKGROUND_PATTERN_TYPE_NONE: no pattern
81  * @GTK_SOURCE_BACKGROUND_PATTERN_TYPE_GRID: grid pattern
82  *
83  * Since: 3.16
84  */
85 typedef enum _GtkSourceBackgroundPatternType
86 {
87 	GTK_SOURCE_BACKGROUND_PATTERN_TYPE_NONE,
88 	GTK_SOURCE_BACKGROUND_PATTERN_TYPE_GRID
89 } GtkSourceBackgroundPatternType;
90 
91 struct _GtkSourceView
92 {
93 	GtkTextView parent;
94 
95 	GtkSourceViewPrivate *priv;
96 };
97 
98 struct _GtkSourceViewClass
99 {
100 	GtkTextViewClass parent_class;
101 
102 	void (*undo) (GtkSourceView *view);
103 	void (*redo) (GtkSourceView *view);
104 	void (*line_mark_activated) (GtkSourceView *view,
105 	                             GtkTextIter   *iter,
106 	                             GdkEvent      *event);
107 	void (*show_completion) (GtkSourceView *view);
108 	void (*move_lines) (GtkSourceView *view,
109 			    gboolean       down);
110 
111 	void (*move_words) (GtkSourceView *view,
112 	                    gint           step);
113 
114 	/* Padding for future expansion */
115 	gpointer padding[20];
116 };
117 
118 GTK_SOURCE_AVAILABLE_IN_ALL
119 GType		 gtk_source_view_get_type		(void) G_GNUC_CONST;
120 
121 GTK_SOURCE_AVAILABLE_IN_ALL
122 GtkWidget	*gtk_source_view_new			(void);
123 
124 GTK_SOURCE_AVAILABLE_IN_ALL
125 GtkWidget 	*gtk_source_view_new_with_buffer	(GtkSourceBuffer *buffer);
126 
127 GTK_SOURCE_AVAILABLE_IN_ALL
128 void		 gtk_source_view_set_show_line_numbers 	(GtkSourceView   *view,
129 							 gboolean         show);
130 
131 GTK_SOURCE_AVAILABLE_IN_ALL
132 gboolean 	 gtk_source_view_get_show_line_numbers 	(GtkSourceView   *view);
133 
134 GTK_SOURCE_AVAILABLE_IN_ALL
135 void		 gtk_source_view_set_tab_width          (GtkSourceView   *view,
136 							 guint            width);
137 
138 GTK_SOURCE_AVAILABLE_IN_ALL
139 guint            gtk_source_view_get_tab_width          (GtkSourceView   *view);
140 
141 GTK_SOURCE_AVAILABLE_IN_ALL
142 void		 gtk_source_view_set_indent_width 	(GtkSourceView   *view,
143 							 gint             width);
144 
145 GTK_SOURCE_AVAILABLE_IN_ALL
146 gint		 gtk_source_view_get_indent_width	(GtkSourceView   *view);
147 
148 GTK_SOURCE_AVAILABLE_IN_ALL
149 void		 gtk_source_view_set_auto_indent 	(GtkSourceView   *view,
150 							 gboolean         enable);
151 
152 GTK_SOURCE_AVAILABLE_IN_ALL
153 gboolean	 gtk_source_view_get_auto_indent 	(GtkSourceView   *view);
154 
155 GTK_SOURCE_AVAILABLE_IN_ALL
156 void		 gtk_source_view_set_insert_spaces_instead_of_tabs
157 							(GtkSourceView   *view,
158 							 gboolean         enable);
159 
160 GTK_SOURCE_AVAILABLE_IN_ALL
161 gboolean	 gtk_source_view_get_insert_spaces_instead_of_tabs
162 							(GtkSourceView   *view);
163 
164 GTK_SOURCE_AVAILABLE_IN_ALL
165 void		 gtk_source_view_set_indent_on_tab 	(GtkSourceView   *view,
166 							 gboolean         enable);
167 
168 GTK_SOURCE_AVAILABLE_IN_ALL
169 gboolean	 gtk_source_view_get_indent_on_tab 	(GtkSourceView   *view);
170 
171 GTK_SOURCE_AVAILABLE_IN_3_16
172 void		 gtk_source_view_indent_lines		(GtkSourceView   *view,
173 							 GtkTextIter     *start,
174 							 GtkTextIter     *end);
175 
176 GTK_SOURCE_AVAILABLE_IN_3_16
177 void		 gtk_source_view_unindent_lines		(GtkSourceView   *view,
178 							 GtkTextIter     *start,
179 							 GtkTextIter     *end);
180 
181 GTK_SOURCE_AVAILABLE_IN_ALL
182 void		 gtk_source_view_set_highlight_current_line
183 							(GtkSourceView   *view,
184 							 gboolean         highlight);
185 
186 GTK_SOURCE_AVAILABLE_IN_ALL
187 gboolean 	 gtk_source_view_get_highlight_current_line
188 							(GtkSourceView   *view);
189 
190 GTK_SOURCE_AVAILABLE_IN_ALL
191 void		 gtk_source_view_set_show_right_margin 	(GtkSourceView   *view,
192 							 gboolean         show);
193 
194 GTK_SOURCE_AVAILABLE_IN_ALL
195 gboolean 	 gtk_source_view_get_show_right_margin 	(GtkSourceView   *view);
196 
197 GTK_SOURCE_AVAILABLE_IN_ALL
198 void		 gtk_source_view_set_right_margin_position
199 					 		(GtkSourceView   *view,
200 							 guint            pos);
201 
202 GTK_SOURCE_AVAILABLE_IN_ALL
203 guint		 gtk_source_view_get_right_margin_position
204 					 		(GtkSourceView   *view);
205 
206 GTK_SOURCE_AVAILABLE_IN_ALL
207 void 		 gtk_source_view_set_show_line_marks    (GtkSourceView   *view,
208 							 gboolean         show);
209 
210 GTK_SOURCE_AVAILABLE_IN_ALL
211 gboolean	 gtk_source_view_get_show_line_marks    (GtkSourceView   *view);
212 
213 GTK_SOURCE_AVAILABLE_IN_ALL
214 void             gtk_source_view_set_mark_attributes    (GtkSourceView           *view,
215                                                          const gchar             *category,
216                                                          GtkSourceMarkAttributes *attributes,
217                                                          gint                     priority);
218 
219 GTK_SOURCE_AVAILABLE_IN_ALL
220 GtkSourceMarkAttributes *
221                  gtk_source_view_get_mark_attributes    (GtkSourceView           *view,
222                                                          const gchar             *category,
223                                                          gint                    *priority);
224 
225 GTK_SOURCE_AVAILABLE_IN_3_18
226 void		 gtk_source_view_set_smart_backspace	(GtkSourceView   *view,
227 							 gboolean        smart_backspace);
228 
229 GTK_SOURCE_AVAILABLE_IN_3_18
230 gboolean	 gtk_source_view_get_smart_backspace	(GtkSourceView   *view);
231 
232 GTK_SOURCE_AVAILABLE_IN_ALL
233 void		 gtk_source_view_set_smart_home_end	(GtkSourceView             *view,
234 							 GtkSourceSmartHomeEndType  smart_home_end);
235 
236 GTK_SOURCE_AVAILABLE_IN_ALL
237 GtkSourceSmartHomeEndType
238 		 gtk_source_view_get_smart_home_end	(GtkSourceView   *view);
239 
240 GTK_SOURCE_AVAILABLE_IN_ALL
241 guint		 gtk_source_view_get_visual_column	(GtkSourceView     *view,
242 							 const GtkTextIter *iter);
243 
244 GTK_SOURCE_AVAILABLE_IN_ALL
245 GtkSourceCompletion *
246 		 gtk_source_view_get_completion		(GtkSourceView   *view);
247 
248 GTK_SOURCE_AVAILABLE_IN_ALL
249 GtkSourceGutter *gtk_source_view_get_gutter		(GtkSourceView     *view,
250                                                          GtkTextWindowType  window_type);
251 
252 GTK_SOURCE_AVAILABLE_IN_3_16
253 void		 gtk_source_view_set_background_pattern	(GtkSourceView                  *view,
254                                                          GtkSourceBackgroundPatternType  background_pattern);
255 
256 GTK_SOURCE_AVAILABLE_IN_3_16
257 GtkSourceBackgroundPatternType
258 		 gtk_source_view_get_background_pattern	(GtkSourceView   *view);
259 
260 GTK_SOURCE_AVAILABLE_IN_3_24
261 GtkSourceSpaceDrawer *
262 		 gtk_source_view_get_space_drawer	(GtkSourceView   *view);
263 
264 G_END_DECLS
265 
266 #endif /* end of GTK_SOURCE_VIEW_H */
267