1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * ianjuta-editor-selection.c -- Autogenerated from libanjuta.idl
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 /**
21 * SECTION:ianjuta-editor-selection
22 * @title: IAnjutaEditorSelection
23 * @short_description: Text editor selection interface
24 * @see_also:
25 * @stability: Unstable
26 * @include: libanjuta/interfaces/ianjuta-editor-selection.h
27 *
28 */
29
30 #include "ianjuta-editor-selection.h"
31 #include "libanjuta-iface-marshallers.h"
32
33 GQuark
ianjuta_editor_selection_error_quark(void)34 ianjuta_editor_selection_error_quark (void)
35 {
36 static GQuark quark = 0;
37
38 if (quark == 0) {
39 quark = g_quark_from_static_string ("ianjuta-editor-selection-quark");
40 }
41
42 return quark;
43 }
44
45 /**
46 * ianjuta_editor_selection_get:
47 * @obj: Self
48 * @err: Error propagation and reporting
49 *
50 * Gets curerntly selected text in editor.
51 *
52 * Returns: A newly allocated buffer of currently selected characters.
53 * NULL if there is no selection. The returned buffer must be freed after
54 * use.
55 */
56 gchar*
ianjuta_editor_selection_get(IAnjutaEditorSelection * obj,GError ** err)57 ianjuta_editor_selection_get (IAnjutaEditorSelection *obj, GError **err)
58 {
59 g_return_val_if_fail (IANJUTA_IS_EDITOR_SELECTION(obj), NULL);
60 return IANJUTA_EDITOR_SELECTION_GET_IFACE (obj)->get (obj, err);
61 }
62
63 /* Default implementation */
64 static gchar*
ianjuta_editor_selection_get_default(IAnjutaEditorSelection * obj,GError ** err)65 ianjuta_editor_selection_get_default (IAnjutaEditorSelection *obj, GError **err)
66 {
67 g_return_val_if_reached (NULL);
68 }
69
70 /**
71 * ianjuta_editor_selection_get_end:
72 * @obj: Self
73 * @err: Error propagation and reporting
74 *
75 * Get end position of selection. If there is no selection, returns
76 * NULL.
77 *
78 * Returns: End of selection or NULL if there is no selection.
79 */
80 IAnjutaIterable*
ianjuta_editor_selection_get_end(IAnjutaEditorSelection * obj,GError ** err)81 ianjuta_editor_selection_get_end (IAnjutaEditorSelection *obj, GError **err)
82 {
83 g_return_val_if_fail (IANJUTA_IS_EDITOR_SELECTION(obj), NULL);
84 return IANJUTA_EDITOR_SELECTION_GET_IFACE (obj)->get_end (obj, err);
85 }
86
87 /* Default implementation */
88 static IAnjutaIterable*
ianjuta_editor_selection_get_end_default(IAnjutaEditorSelection * obj,GError ** err)89 ianjuta_editor_selection_get_end_default (IAnjutaEditorSelection *obj, GError **err)
90 {
91 g_return_val_if_reached (NULL);
92 }
93
94 /**
95 * ianjuta_editor_selection_get_start:
96 * @obj: Self
97 * @err: Error propagation and reporting
98 *
99 * Gets start position of selection text.
100 *
101 * Return: Start of selection or NULL if there is no selection.
102 */
103 IAnjutaIterable*
ianjuta_editor_selection_get_start(IAnjutaEditorSelection * obj,GError ** err)104 ianjuta_editor_selection_get_start (IAnjutaEditorSelection *obj, GError **err)
105 {
106 g_return_val_if_fail (IANJUTA_IS_EDITOR_SELECTION(obj), NULL);
107 return IANJUTA_EDITOR_SELECTION_GET_IFACE (obj)->get_start (obj, err);
108 }
109
110 /* Default implementation */
111 static IAnjutaIterable*
ianjuta_editor_selection_get_start_default(IAnjutaEditorSelection * obj,GError ** err)112 ianjuta_editor_selection_get_start_default (IAnjutaEditorSelection *obj, GError **err)
113 {
114 g_return_val_if_reached (NULL);
115 }
116
117 /**
118 * ianjuta_editor_selection_has_selection:
119 * @obj: Self
120 * @err: Error propagation and reporting
121 *
122 * Returns TRUE if editor has any text selected. The selection
123 * positions can be retrieved with ianjuta_editor_selection_get_start()
124 * and ianjuta_editor_selection_get_end().
125 *
126 * Returns: TRUE if there is text selected else FALSE.
127 */
128 gboolean
ianjuta_editor_selection_has_selection(IAnjutaEditorSelection * obj,GError ** err)129 ianjuta_editor_selection_has_selection (IAnjutaEditorSelection *obj, GError **err)
130 {
131 g_return_val_if_fail (IANJUTA_IS_EDITOR_SELECTION(obj), FALSE);
132 return IANJUTA_EDITOR_SELECTION_GET_IFACE (obj)->has_selection (obj, err);
133 }
134
135 /* Default implementation */
136 static gboolean
ianjuta_editor_selection_has_selection_default(IAnjutaEditorSelection * obj,GError ** err)137 ianjuta_editor_selection_has_selection_default (IAnjutaEditorSelection *obj, GError **err)
138 {
139 g_return_val_if_reached (FALSE);
140 }
141
142 /**
143 * ianjuta_editor_selection_replace:
144 * @obj: Self
145 * @text: Replacement text.
146 * @length: Length of the text to used in @text.
147 * @err: Error propagation and reporting
148 *
149 * Replaces currently selected text with the @text. Only @length amount
150 * of characters are used from @text buffer to replace.
151 */
152 void
ianjuta_editor_selection_replace(IAnjutaEditorSelection * obj,const gchar * text,gint length,GError ** err)153 ianjuta_editor_selection_replace (IAnjutaEditorSelection *obj, const gchar *text, gint length, GError **err)
154 {
155 g_return_if_fail (IANJUTA_IS_EDITOR_SELECTION(obj));
156 IANJUTA_EDITOR_SELECTION_GET_IFACE (obj)->replace (obj, text, length, err);
157 }
158
159 /* Default implementation */
160 static void
ianjuta_editor_selection_replace_default(IAnjutaEditorSelection * obj,const gchar * text,gint length,GError ** err)161 ianjuta_editor_selection_replace_default (IAnjutaEditorSelection *obj, const gchar *text, gint length, GError **err)
162 {
163 g_return_if_reached ();
164 }
165
166 /**
167 * ianjuta_editor_edit_select_all:
168 * @obj: Self
169 * @err: Error propagation and reporting
170 *
171 * Select whole buffer.
172 */
173 void
ianjuta_editor_selection_select_all(IAnjutaEditorSelection * obj,GError ** err)174 ianjuta_editor_selection_select_all (IAnjutaEditorSelection *obj, GError **err)
175 {
176 g_return_if_fail (IANJUTA_IS_EDITOR_SELECTION(obj));
177 IANJUTA_EDITOR_SELECTION_GET_IFACE (obj)->select_all (obj, err);
178 }
179
180 /* Default implementation */
181 static void
ianjuta_editor_selection_select_all_default(IAnjutaEditorSelection * obj,GError ** err)182 ianjuta_editor_selection_select_all_default (IAnjutaEditorSelection *obj, GError **err)
183 {
184 g_return_if_reached ();
185 }
186
187 /**
188 * ianjuta_editor_selection_select_block:
189 * @obj: Self
190 * @err: Error propagation and reporting
191 *
192 * Selects current block of code. The definition of block of code
193 * depends on highlight mode used (programming language). Some
194 * highlight mode does not have block concept, in that case this
195 * method does not do anything.
196 */
197 void
ianjuta_editor_selection_select_block(IAnjutaEditorSelection * obj,GError ** err)198 ianjuta_editor_selection_select_block (IAnjutaEditorSelection *obj, GError **err)
199 {
200 g_return_if_fail (IANJUTA_IS_EDITOR_SELECTION(obj));
201 IANJUTA_EDITOR_SELECTION_GET_IFACE (obj)->select_block (obj, err);
202 }
203
204 /* Default implementation */
205 static void
ianjuta_editor_selection_select_block_default(IAnjutaEditorSelection * obj,GError ** err)206 ianjuta_editor_selection_select_block_default (IAnjutaEditorSelection *obj, GError **err)
207 {
208 g_return_if_reached ();
209 }
210
211 /**
212 * ianjuta_editor_selection_select_function:
213 * @obj: Self
214 * @err: Error propagation and reporting
215 *
216 * Select current function block. The definition of function block
217 * depends on highlight mode used (programming language). Some
218 * highlight mode does not have function concept, in that case this
219 * method does not do anything.
220 */
221 void
ianjuta_editor_selection_select_function(IAnjutaEditorSelection * obj,GError ** err)222 ianjuta_editor_selection_select_function (IAnjutaEditorSelection *obj, GError **err)
223 {
224 g_return_if_fail (IANJUTA_IS_EDITOR_SELECTION(obj));
225 IANJUTA_EDITOR_SELECTION_GET_IFACE (obj)->select_function (obj, err);
226 }
227
228 /* Default implementation */
229 static void
ianjuta_editor_selection_select_function_default(IAnjutaEditorSelection * obj,GError ** err)230 ianjuta_editor_selection_select_function_default (IAnjutaEditorSelection *obj, GError **err)
231 {
232 g_return_if_reached ();
233 }
234
235 /**
236 * ianjuta_editor_selection_set:
237 * @obj: Self
238 * @start: Begin of selection
239 * @end: End of selection
240 * @scroll: Scroll selection onscreen
241 * @err: Error propagation and reporting
242 *
243 * Select characters between start and end. Start and end don't have to
244 * be ordered.
245 */
246 void
ianjuta_editor_selection_set(IAnjutaEditorSelection * obj,IAnjutaIterable * start,IAnjutaIterable * end,gboolean scroll,GError ** err)247 ianjuta_editor_selection_set (IAnjutaEditorSelection *obj, IAnjutaIterable* start, IAnjutaIterable* end, gboolean scroll, GError **err)
248 {
249 g_return_if_fail (IANJUTA_IS_EDITOR_SELECTION(obj));
250 g_return_if_fail ((start == NULL) ||IANJUTA_IS_ITERABLE(start));
251 g_return_if_fail ((end == NULL) ||IANJUTA_IS_ITERABLE(end));
252 IANJUTA_EDITOR_SELECTION_GET_IFACE (obj)->set (obj, start, end, scroll, err);
253 }
254
255 /* Default implementation */
256 static void
ianjuta_editor_selection_set_default(IAnjutaEditorSelection * obj,IAnjutaIterable * start,IAnjutaIterable * end,gboolean scroll,GError ** err)257 ianjuta_editor_selection_set_default (IAnjutaEditorSelection *obj, IAnjutaIterable* start, IAnjutaIterable* end, gboolean scroll, GError **err)
258 {
259 g_return_if_reached ();
260 }
261
262 static void
ianjuta_editor_selection_base_init(IAnjutaEditorSelectionIface * klass)263 ianjuta_editor_selection_base_init (IAnjutaEditorSelectionIface* klass)
264 {
265 static gboolean initialized = FALSE;
266
267 klass->get = ianjuta_editor_selection_get_default;
268 klass->get_end = ianjuta_editor_selection_get_end_default;
269 klass->get_start = ianjuta_editor_selection_get_start_default;
270 klass->has_selection = ianjuta_editor_selection_has_selection_default;
271 klass->replace = ianjuta_editor_selection_replace_default;
272 klass->select_all = ianjuta_editor_selection_select_all_default;
273 klass->select_block = ianjuta_editor_selection_select_block_default;
274 klass->select_function = ianjuta_editor_selection_select_function_default;
275 klass->set = ianjuta_editor_selection_set_default;
276
277 if (!initialized) {
278
279 initialized = TRUE;
280 }
281 }
282
283 GType
ianjuta_editor_selection_get_type(void)284 ianjuta_editor_selection_get_type (void)
285 {
286 static GType type = 0;
287 if (!type) {
288 static const GTypeInfo info = {
289 sizeof (IAnjutaEditorSelectionIface),
290 (GBaseInitFunc) ianjuta_editor_selection_base_init,
291 NULL,
292 NULL,
293 NULL,
294 NULL,
295 0,
296 0,
297 NULL
298 };
299 type = g_type_register_static (G_TYPE_INTERFACE, "IAnjutaEditorSelection", &info, 0);
300 g_type_interface_add_prerequisite (type, IANJUTA_TYPE_EDITOR);
301 }
302 return type;
303 }
304