1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3  *  ianjuta-editor.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
22  * @title: IAnjutaEditor
23  * @short_description: Text editor interface
24  * @see_also:
25  * @stability: Unstable
26  * @include: libanjuta/interfaces/ianjuta-editor.h
27  *
28  */
29 
30 #include "ianjuta-editor.h"
31 #include "libanjuta-iface-marshallers.h"
32 
33 GQuark
ianjuta_editor_error_quark(void)34 ianjuta_editor_error_quark (void)
35 {
36 	static GQuark quark = 0;
37 
38 	if (quark == 0) {
39 		quark = g_quark_from_static_string ("ianjuta-editor-quark");
40 	}
41 
42 	return quark;
43 }
44 
45 /**
46  * ianjuta_editor_append:
47  * @obj: Self
48  * @text: Text to append.
49  * @length: Length of @text to use.
50  * @err: Error propagation and reporting
51  *
52  * Appends @length characters from @text buffer at the end of editor
53  * buffer. If @length is -1, the whole @text is used. @length is in bytes.
54  */
55 void
ianjuta_editor_append(IAnjutaEditor * obj,const gchar * text,gint length,GError ** err)56 ianjuta_editor_append (IAnjutaEditor *obj, const gchar *text,   gint length, GError **err)
57 {
58 	g_return_if_fail (IANJUTA_IS_EDITOR(obj));
59 	IANJUTA_EDITOR_GET_IFACE (obj)->append (obj, text, length, err);
60 }
61 
62 /* Default implementation */
63 static void
ianjuta_editor_append_default(IAnjutaEditor * obj,const gchar * text,gint length,GError ** err)64 ianjuta_editor_append_default (IAnjutaEditor *obj, const gchar *text,   gint length, GError **err)
65 {
66 	g_return_if_reached ();
67 }
68 
69 /**
70  * ianjuta_editor_erase_range:
71  * @obj: Self
72  * @position_start: Start position of chars to erase.
73  * @position_end: End position of chars to erase.
74  * @err: Error propagation and reporting
75  *
76  * Erases the chars between positions pointed by @position_start and
77  * @position_end. The character pointed by @position_start is included,
78  * while pointed by @position_end is not include in the range. After
79  * the erase operation, all active iters, except these two, are no
80  * longer guranteed to be valid. At the end the operation, these two
81  * iters point to the same position which is the position where erase
82  * happend (usually the original @position_start position).
83  */
84 void
ianjuta_editor_erase(IAnjutaEditor * obj,IAnjutaIterable * position_start,IAnjutaIterable * position_end,GError ** err)85 ianjuta_editor_erase (IAnjutaEditor *obj, IAnjutaIterable *position_start,   IAnjutaIterable *position_end, GError **err)
86 {
87 	g_return_if_fail (IANJUTA_IS_EDITOR(obj));
88 	g_return_if_fail ((position_start == NULL) ||IANJUTA_IS_ITERABLE(position_start));
89 	g_return_if_fail ((position_end == NULL) ||IANJUTA_IS_ITERABLE(position_end));
90 	IANJUTA_EDITOR_GET_IFACE (obj)->erase (obj, position_start, position_end, err);
91 }
92 
93 /* Default implementation */
94 static void
ianjuta_editor_erase_default(IAnjutaEditor * obj,IAnjutaIterable * position_start,IAnjutaIterable * position_end,GError ** err)95 ianjuta_editor_erase_default (IAnjutaEditor *obj, IAnjutaIterable *position_start,   IAnjutaIterable *position_end, GError **err)
96 {
97 	g_return_if_reached ();
98 }
99 
100  	/**
101  * ianjuta_editor_erase_all:
102  	 * @obj: Self
103  	 * @err: Error propagation and reporting
104  	 *
105  * Empties the whole editor buffer. There will be zero characters.
106  * After the erase operation, none of the active iters are guranteed
107  * to be valid.
108  	 */
109 void
ianjuta_editor_erase_all(IAnjutaEditor * obj,GError ** err)110 ianjuta_editor_erase_all (IAnjutaEditor *obj, GError **err)
111 {
112 	g_return_if_fail (IANJUTA_IS_EDITOR(obj));
113 	IANJUTA_EDITOR_GET_IFACE (obj)->erase_all (obj, err);
114 }
115 
116 /* Default implementation */
117 static void
ianjuta_editor_erase_all_default(IAnjutaEditor * obj,GError ** err)118 ianjuta_editor_erase_all_default (IAnjutaEditor *obj, GError **err)
119 {
120 	g_return_if_reached ();
121 }
122 
123 /**
124  * ianjuta_editor_get_current_column:
125  * @obj: Self
126  * @err: Error propagation and reporting
127  *
128  * Obtains number of the current column in the editor.
129  *
130  * Return value: Current column.
131  */
132 gint
ianjuta_editor_get_column(IAnjutaEditor * obj,GError ** err)133 ianjuta_editor_get_column (IAnjutaEditor *obj, GError **err)
134 {
135 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), -1);
136 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_column (obj, err);
137 }
138 
139 /* Default implementation */
140 static gint
ianjuta_editor_get_column_default(IAnjutaEditor * obj,GError ** err)141 ianjuta_editor_get_column_default (IAnjutaEditor *obj, GError **err)
142 {
143 	g_return_val_if_reached (-1);
144 }
145 
146 /**
147  * ianjuta_editor_get_current_word:
148  * @obj: Self
149  * @err: Error propagation and reporting
150  *
151  * Obtains the word on which carat is currently on.
152  *
153  * Return value: Current word.
154  */
155 gchar*
ianjuta_editor_get_current_word(IAnjutaEditor * obj,GError ** err)156 ianjuta_editor_get_current_word (IAnjutaEditor *obj, GError **err)
157 {
158 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), NULL);
159 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_current_word (obj, err);
160 }
161 
162 /* Default implementation */
163 static gchar*
ianjuta_editor_get_current_word_default(IAnjutaEditor * obj,GError ** err)164 ianjuta_editor_get_current_word_default (IAnjutaEditor *obj, GError **err)
165 {
166 	g_return_val_if_reached (NULL);
167 }
168 
169 /**
170  * ianjuta_editor_get_end_position:
171  * @obj: Self
172  * @err: Error propagation and reporting
173  *
174  * Gets the iter positioned at the end of the editor buffer. The
175  * returned iter is the end-iter which does not point to any valid
176  * character in the buffer (it is pointed one step beyond the last
177  * valid character).
178  *
179  * Return value: (transfer none): Cell iter set to the end of the editor (end-iter).
180  */
181 IAnjutaIterable*
ianjuta_editor_get_end_position(IAnjutaEditor * obj,GError ** err)182 ianjuta_editor_get_end_position (IAnjutaEditor *obj, GError **err)
183 {
184 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), NULL);
185 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_end_position (obj, err);
186 }
187 
188 /* Default implementation */
189 static IAnjutaIterable*
ianjuta_editor_get_end_position_default(IAnjutaEditor * obj,GError ** err)190 ianjuta_editor_get_end_position_default (IAnjutaEditor *obj, GError **err)
191 {
192 	g_return_val_if_reached (NULL);
193 }
194 
195 /**
196  * ianjuta_editor_get_indentsize:
197  * @obj: Self
198  * @err: Error propagation and reporting
199  *
200  * Returns the indentation size in spaces currently used by the
201  * editor.
202  *
203  * Returns: indentation size in number of spaces
204  */
205 gint
ianjuta_editor_get_indentsize(IAnjutaEditor * obj,GError ** err)206 ianjuta_editor_get_indentsize (IAnjutaEditor *obj, GError **err)
207 {
208 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), -1);
209 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_indentsize (obj, err);
210 }
211 
212 /* Default implementation */
213 static gint
ianjuta_editor_get_indentsize_default(IAnjutaEditor * obj,GError ** err)214 ianjuta_editor_get_indentsize_default (IAnjutaEditor *obj, GError **err)
215 {
216 	g_return_val_if_reached (-1);
217 }
218 
219 /**
220  * ianjuta_editor_get_length:
221  * @obj: Self
222  * @err: Error propagation and reporting
223  *
224  * Get length of complete text in editor. This will be the total
225  * number of bytes in the file or buffer.
226  *
227  * Return value: Text length.
228  */
229 gint
ianjuta_editor_get_length(IAnjutaEditor * obj,GError ** err)230 ianjuta_editor_get_length (IAnjutaEditor *obj, GError **err)
231 {
232 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), -1);
233 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_length (obj, err);
234 }
235 
236 /* Default implementation */
237 static gint
ianjuta_editor_get_length_default(IAnjutaEditor * obj,GError ** err)238 ianjuta_editor_get_length_default (IAnjutaEditor *obj, GError **err)
239 {
240 	g_return_val_if_reached (-1);
241 }
242 
243 /**
244  * ianjuta_editor_get_line_begin_position:
245  * @obj: Self
246  * @line: fixme
247  * @err: Error propagation and reporting.
248  *
249  * fixme
250  *
251  * Returns: (transfer full): fixme
252  */
253 IAnjutaIterable*
ianjuta_editor_get_line_begin_position(IAnjutaEditor * obj,gint line,GError ** err)254 ianjuta_editor_get_line_begin_position (IAnjutaEditor *obj, gint line, GError **err)
255 {
256 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), NULL);
257 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_line_begin_position (obj, line, err);
258 }
259 
260 /* Default implementation */
261 static IAnjutaIterable*
ianjuta_editor_get_line_begin_position_default(IAnjutaEditor * obj,gint line,GError ** err)262 ianjuta_editor_get_line_begin_position_default (IAnjutaEditor *obj, gint line, GError **err)
263 {
264 	g_return_val_if_reached (NULL);
265 }
266 
267 /**
268  * ianjuta_editor_get_line_end_position:
269  * @obj: Self
270  * @line: fixme
271  * @err: Error propagation and reporting.
272  *
273  * fixme
274  *
275  * Returns: (transfer full): fixme
276  */
277 IAnjutaIterable *
ianjuta_editor_get_line_end_position(IAnjutaEditor * obj,gint line,GError ** err)278 ianjuta_editor_get_line_end_position (IAnjutaEditor *obj, gint line, GError **err)
279 {
280 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), NULL);
281 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_line_end_position (obj, line, err);
282 }
283 
284 /* Default implementation */
285 static IAnjutaIterable *
ianjuta_editor_get_line_end_position_default(IAnjutaEditor * obj,gint line,GError ** err)286 ianjuta_editor_get_line_end_position_default (IAnjutaEditor *obj, gint line, GError **err)
287 {
288 	g_return_val_if_reached (NULL);
289 }
290 
291 /**
292  * ianjuta_editor_line_from_position:
293  * @obj: Self
294  * @position: Position you want to know the line from
295  * @err: Error propagation and reporting
296  *
297  * Get the line number in which @position locates.
298  * Returns: Line which corresponds to @position
299  *
300  */
301 int
ianjuta_editor_get_line_from_position(IAnjutaEditor * obj,IAnjutaIterable * position,GError ** err)302 ianjuta_editor_get_line_from_position (IAnjutaEditor *obj, IAnjutaIterable *position, GError **err)
303 {
304 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), 0);
305 	g_return_val_if_fail ((position == NULL) ||IANJUTA_IS_ITERABLE(position), 0);
306 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_line_from_position (obj, position, err);
307 }
308 
309 /* Default implementation */
310 static int
ianjuta_editor_get_line_from_position_default(IAnjutaEditor * obj,IAnjutaIterable * position,GError ** err)311 ianjuta_editor_get_line_from_position_default (IAnjutaEditor *obj, IAnjutaIterable *position, GError **err)
312 {
313 	g_return_val_if_reached (0);
314 }
315 
316 /**
317  * ianjuta_editor_get_lineno:
318  * @obj: Self
319  * @err: Error propagation and reporting
320  *
321  * Obtains current line number on which carat is.
322  *
323  * Return value: Line number.
324  */
325 gint
ianjuta_editor_get_lineno(IAnjutaEditor * obj,GError ** err)326 ianjuta_editor_get_lineno (IAnjutaEditor *obj, GError **err)
327 {
328 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), -1);
329 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_lineno (obj, err);
330 }
331 
332 /* Default implementation */
333 static gint
ianjuta_editor_get_lineno_default(IAnjutaEditor * obj,GError ** err)334 ianjuta_editor_get_lineno_default (IAnjutaEditor *obj, GError **err)
335 {
336 	g_return_val_if_reached (-1);
337 }
338 
339 /*
340  * ianjuta_editor_get_offset:
341  * @obj: Self
342  * @err: Error propagation and reporting
343  *
344  * Get current caret position in integer character offset. Deprecated.
345  * Use ianjuta_editor_get_position() instead.
346  *
347  * Returns: Current character position since the begining of file.
348  */
349 gint
ianjuta_editor_get_offset(IAnjutaEditor * obj,GError ** err)350 ianjuta_editor_get_offset (IAnjutaEditor *obj, GError **err)
351 {
352 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), -1);
353 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_offset (obj, err);
354 }
355 
356 /* Default implementation */
357 static gint
ianjuta_editor_get_offset_default(IAnjutaEditor * obj,GError ** err)358 ianjuta_editor_get_offset_default (IAnjutaEditor *obj, GError **err)
359 {
360 	g_return_val_if_reached (-1);
361 }
362 
363 /**
364  * ianjuta_editor_get_overwrite:
365  * @obj: Self
366  * @err: Error propagation and reporting
367  *
368  * Obtains editor overwirte mode: TRUE = Override, FALSE = Insert.
369  *
370  * Return value: editor mode.
371  */
372 gboolean
ianjuta_editor_get_overwrite(IAnjutaEditor * obj,GError ** err)373 ianjuta_editor_get_overwrite (IAnjutaEditor *obj, GError **err)
374 {
375 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), FALSE);
376 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_overwrite (obj, err);
377 }
378 
379 /* Default implementation */
380 static gboolean
ianjuta_editor_get_overwrite_default(IAnjutaEditor * obj,GError ** err)381 ianjuta_editor_get_overwrite_default (IAnjutaEditor *obj, GError **err)
382 {
383 	g_return_val_if_reached (FALSE);
384 }
385 
386 /**
387  * ianjuta_editor_get_position:
388  * @obj: Self
389  * @err: Error propagation and reporting
390  *
391  * Get current caret position.
392  *
393  * Returns: (transfer full): Iterator that points to the current position.
394  */
395 IAnjutaIterable*
ianjuta_editor_get_position(IAnjutaEditor * obj,GError ** err)396 ianjuta_editor_get_position (IAnjutaEditor *obj, GError **err)
397 {
398 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), NULL);
399 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_position (obj, err);
400 }
401 
402 /* Default implementation */
403 static IAnjutaIterable*
ianjuta_editor_get_position_default(IAnjutaEditor * obj,GError ** err)404 ianjuta_editor_get_position_default (IAnjutaEditor *obj, GError **err)
405 {
406 	g_return_val_if_reached (NULL);
407 }
408 
409 /**
410  * ianjuta_editor_get_position_from_offset:
411  * @obj: Self
412  * @offset: Character offset position where the iter will be set
413  * @err: Error propagation and reporting
414  *
415  * Creates and returns an iter for editor cells. The iter is
416  * placed at the unicode character position where the given offset
417      * @offset happens to fall. The returned iter is cell (character)
418  * iter and not byte iter, so all iter operations
419  * on it are character (not byte) iteration, including all position
420      * and index references in the iter.
421      *
422      * The iter must be unreferrenced by the caller when done.
423  * The iter navigates (next/previous) in step of unicode
424  * characters (one unicode character == one cell).
425  *
426  * Retrun value: a newly created iter of IAnjutaEditorCell placed at the
427  * given @offset position.
428  */
429 IAnjutaIterable*
ianjuta_editor_get_position_from_offset(IAnjutaEditor * obj,gint offset,GError ** err)430 ianjuta_editor_get_position_from_offset (IAnjutaEditor *obj, gint offset, GError **err)
431 {
432 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), NULL);
433 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_position_from_offset (obj, offset, err);
434 }
435 
436 /* Default implementation */
437 static IAnjutaIterable*
ianjuta_editor_get_position_from_offset_default(IAnjutaEditor * obj,gint offset,GError ** err)438 ianjuta_editor_get_position_from_offset_default (IAnjutaEditor *obj, gint offset, GError **err)
439 {
440 	g_return_val_if_reached (NULL);
441 }
442 
443 /**
444  * ianjuta_editor_get_start_position:
445  * @obj: Self
446  * @err: Error propagation and reporting
447  *
448  * Gets the iter positioned at the start of the editor buffer.
449  *
450  * Return value: (transfer none): Cell iter set to the begining of the editor.
451  */
452 IAnjutaIterable*
ianjuta_editor_get_start_position(IAnjutaEditor * obj,GError ** err)453 ianjuta_editor_get_start_position (IAnjutaEditor *obj, GError **err)
454 {
455 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), NULL);
456 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_start_position (obj, err);
457 }
458 
459 /* Default implementation */
460 static IAnjutaIterable*
ianjuta_editor_get_start_position_default(IAnjutaEditor * obj,GError ** err)461 ianjuta_editor_get_start_position_default (IAnjutaEditor *obj, GError **err)
462 {
463 	g_return_val_if_reached (NULL);
464 }
465 
466 /**
467  * ianjuta_editor_get_tabsize:
468  * @obj: Self
469  * @err: Error propagation and reporting
470  *
471  * Returns the tabsize (in spaces) currently used by the editor.
472  *
473  * Returns: tabsize in number of spaces
474  */
475 gint
ianjuta_editor_get_tabsize(IAnjutaEditor * obj,GError ** err)476 ianjuta_editor_get_tabsize (IAnjutaEditor *obj, GError **err)
477 {
478 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), -1);
479 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_tabsize (obj, err);
480 }
481 
482 /* Default implementation */
483 static gint
ianjuta_editor_get_tabsize_default(IAnjutaEditor * obj,GError ** err)484 ianjuta_editor_get_tabsize_default (IAnjutaEditor *obj, GError **err)
485 {
486 	g_return_val_if_reached (-1);
487 }
488 
489 /**
490  * ianjuta_editor_get_text:
491  * @obj: Self
492  * @begin: Begining iterator
493  * @end: End iterator
494  * @err: Error propagation and reporting
495  *
496  * Gets text characters beginning from @begin (including char
497  * pointed by @begin) and ending with @end (excluding character
498  * pointed by @end). The characters returned are utf-8 encoded.
499  * The iterators @begin and @end could be in either order. The returned
500  * text, however, is in right order. If both @begin and @end points
501  * to the same position, NULL is returned.
502  *
503  * Returns: A buffer of utf-8 characters.
504  * The returned buffer must be freed when no longer required.
505  */
506 gchar*
ianjuta_editor_get_text(IAnjutaEditor * obj,IAnjutaIterable * begin,IAnjutaIterable * end,GError ** err)507 ianjuta_editor_get_text (IAnjutaEditor *obj, IAnjutaIterable *begin,   IAnjutaIterable *end, GError **err)
508 {
509 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), NULL);
510 	g_return_val_if_fail ((begin == NULL) ||IANJUTA_IS_ITERABLE(begin), NULL);
511 	g_return_val_if_fail ((end == NULL) ||IANJUTA_IS_ITERABLE(end), NULL);
512 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_text (obj, begin, end, err);
513 }
514 
515 /* Default implementation */
516 static gchar*
ianjuta_editor_get_text_default(IAnjutaEditor * obj,IAnjutaIterable * begin,IAnjutaIterable * end,GError ** err)517 ianjuta_editor_get_text_default (IAnjutaEditor *obj, IAnjutaIterable *begin,   IAnjutaIterable *end, GError **err)
518 {
519 	g_return_val_if_reached (NULL);
520 }
521 
522 /**
523  * ianjuta_editor_get_text_all:
524  * @obj: Self
525  * @err: Error propagation and reporting
526  *
527  * Gets all text characters in the editor.
528  * The characters returned are utf-8 encoded.
529  *
530  * Returns: A buffer of utf-8 characters containing all text from editor.
531  * The returned buffer must be freed when no longer required.
532  */
533 gchar*
ianjuta_editor_get_text_all(IAnjutaEditor * obj,GError ** err)534 ianjuta_editor_get_text_all (IAnjutaEditor *obj, GError **err)
535 {
536 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), NULL);
537 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_text_all (obj, err);
538 }
539 
540 /* Default implementation */
541 static gchar*
ianjuta_editor_get_text_all_default(IAnjutaEditor * obj,GError ** err)542 ianjuta_editor_get_text_all_default (IAnjutaEditor *obj, GError **err)
543 {
544 	g_return_val_if_reached (NULL);
545 }
546 
547 /**
548  * ianjuta_editor_get_use_spaces:
549  * @obj: Self
550  * @err: Error propagation and reporting
551  *
552  * Returns if the editor uses spaces for filling up tab characters.
553  *
554  * Returns: TRUE if yes, FALSE if no.
555  */
556 gboolean
ianjuta_editor_get_use_spaces(IAnjutaEditor * obj,GError ** err)557 ianjuta_editor_get_use_spaces (IAnjutaEditor *obj, GError **err)
558 {
559 	g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), FALSE);
560 	return IANJUTA_EDITOR_GET_IFACE (obj)->get_use_spaces (obj, err);
561 }
562 
563 /* Default implementation */
564 static gboolean
ianjuta_editor_get_use_spaces_default(IAnjutaEditor * obj,GError ** err)565 ianjuta_editor_get_use_spaces_default (IAnjutaEditor *obj, GError **err)
566 {
567 	g_return_val_if_reached (FALSE);
568 }
569 
570 /**
571  * ianjuta_editor_goto_end:
572  * @obj: Self
573  * @err: Error propagation and reporting
574  *
575  * Carat is moved to the end of editor and text view is scrolled to
576  * bring it in viewable area of the editor.
577  */
578 void
ianjuta_editor_goto_end(IAnjutaEditor * obj,GError ** err)579 ianjuta_editor_goto_end (IAnjutaEditor *obj, GError **err)
580 {
581 	g_return_if_fail (IANJUTA_IS_EDITOR(obj));
582 	IANJUTA_EDITOR_GET_IFACE (obj)->goto_end (obj, err);
583 }
584 
585 /* Default implementation */
586 static void
ianjuta_editor_goto_end_default(IAnjutaEditor * obj,GError ** err)587 ianjuta_editor_goto_end_default (IAnjutaEditor *obj, GError **err)
588 {
589 	g_return_if_reached ();
590 }
591 
592 /**
593  * ianjuta_editor_goto_line:
594  * @obj: Self
595  * @lineno: line number where carat will be moved.
596  * @err: Error propagation and reporting
597  *
598  * Carat is moved to the given @lineno line and text view is scrolled to
599  * bring it in viewable area of the editor.
600  */
601 void
ianjuta_editor_goto_line(IAnjutaEditor * obj,gint lineno,GError ** err)602 ianjuta_editor_goto_line (IAnjutaEditor *obj, gint lineno, GError **err)
603 {
604 	g_return_if_fail (IANJUTA_IS_EDITOR(obj));
605 	IANJUTA_EDITOR_GET_IFACE (obj)->goto_line (obj, lineno, err);
606 }
607 
608 /* Default implementation */
609 static void
ianjuta_editor_goto_line_default(IAnjutaEditor * obj,gint lineno,GError ** err)610 ianjuta_editor_goto_line_default (IAnjutaEditor *obj, gint lineno, GError **err)
611 {
612 	g_return_if_reached ();
613 }
614 
615 /**
616  * ianjuta_editor_goto_position:
617  * @obj: Self
618  * @position: Character position where carat will be moved.
619  * @err: Error propagation and reporting
620  *
621  * Carat is moved to the given @position and text view is scrolled to
622  * bring @position in viewable area of the editor.
623  */
624 void
ianjuta_editor_goto_position(IAnjutaEditor * obj,IAnjutaIterable * position,GError ** err)625 ianjuta_editor_goto_position (IAnjutaEditor *obj, IAnjutaIterable *position, GError **err)
626 {
627 	g_return_if_fail (IANJUTA_IS_EDITOR(obj));
628 	g_return_if_fail ((position == NULL) ||IANJUTA_IS_ITERABLE(position));
629 	IANJUTA_EDITOR_GET_IFACE (obj)->goto_position (obj, position, err);
630 }
631 
632 /* Default implementation */
633 static void
ianjuta_editor_goto_position_default(IAnjutaEditor * obj,IAnjutaIterable * position,GError ** err)634 ianjuta_editor_goto_position_default (IAnjutaEditor *obj, IAnjutaIterable *position, GError **err)
635 {
636 	g_return_if_reached ();
637 }
638 
639 /**
640  * ianjuta_editor_goto_start:
641  * @obj: Self
642  * @err: Error propagation and reporting
643  *
644  * Carat is moved to the begining of editor and text view is scrolled to
645  * bring it in viewable area of the editor.
646  */
647 void
ianjuta_editor_goto_start(IAnjutaEditor * obj,GError ** err)648 ianjuta_editor_goto_start (IAnjutaEditor *obj, GError **err)
649 {
650 	g_return_if_fail (IANJUTA_IS_EDITOR(obj));
651 	IANJUTA_EDITOR_GET_IFACE (obj)->goto_start (obj, err);
652 }
653 
654 /* Default implementation */
655 static void
ianjuta_editor_goto_start_default(IAnjutaEditor * obj,GError ** err)656 ianjuta_editor_goto_start_default (IAnjutaEditor *obj, GError **err)
657 {
658 	g_return_if_reached ();
659 }
660 
661 /**
662  * ianjuta_editor_insert:
663  * @obj: Self
664  * @position: Character position in editor where insert will take place.
665  * @text: Text to append.
666  * @length: Length of @text to use.
667  * @err: Error propagation and reporting
668  *
669  * Inserts @length characters from @text buffer at given @position of
670  * editor buffer. If @length is -1, the whole @text is used.
671  */
672 void
ianjuta_editor_insert(IAnjutaEditor * obj,IAnjutaIterable * position,const gchar * text,gint length,GError ** err)673 ianjuta_editor_insert (IAnjutaEditor *obj, IAnjutaIterable *position,   const gchar *text,   gint length, GError **err)
674 {
675 	g_return_if_fail (IANJUTA_IS_EDITOR(obj));
676 	g_return_if_fail ((position == NULL) ||IANJUTA_IS_ITERABLE(position));
677 	IANJUTA_EDITOR_GET_IFACE (obj)->insert (obj, position, text, length, err);
678 }
679 
680 /* Default implementation */
681 static void
ianjuta_editor_insert_default(IAnjutaEditor * obj,IAnjutaIterable * position,const gchar * text,gint length,GError ** err)682 ianjuta_editor_insert_default (IAnjutaEditor *obj, IAnjutaIterable *position,   const gchar *text,   gint length, GError **err)
683 {
684 	g_return_if_reached ();
685 }
686 
687 /**
688  * ianjuta_editor_set_auto_indent:
689  * @obj: Self
690  * @auto_indent: TRUE to enable auto-indent, FALSE to disable
691  *
692  * Sets whether the editor should auto-indent itself. A plugin that does
693  * custom auto-indent can set this to false and override the preferences
694  * setting
695  */
696 void
ianjuta_editor_set_auto_indent(IAnjutaEditor * obj,gboolean auto_indent,GError ** err)697 ianjuta_editor_set_auto_indent (IAnjutaEditor *obj, gboolean auto_indent, GError **err)
698 {
699 	g_return_if_fail (IANJUTA_IS_EDITOR(obj));
700 	IANJUTA_EDITOR_GET_IFACE (obj)->set_auto_indent (obj, auto_indent, err);
701 }
702 
703 /* Default implementation */
704 static void
ianjuta_editor_set_auto_indent_default(IAnjutaEditor * obj,gboolean auto_indent,GError ** err)705 ianjuta_editor_set_auto_indent_default (IAnjutaEditor *obj, gboolean auto_indent, GError **err)
706 {
707 	g_return_if_reached ();
708 }
709 
710 /**
711  * ianjuta_editor_set_indentsize:
712  * @obj: Self
713  * @indentsize: Indentation size in spaces
714  * @err: Error propagation and reporting
715  *
716  * Sets the indentation size of the editor.
717  */
718 void
ianjuta_editor_set_indentsize(IAnjutaEditor * obj,gint indentsize,GError ** err)719 ianjuta_editor_set_indentsize (IAnjutaEditor *obj, gint indentsize, GError **err)
720 {
721 	g_return_if_fail (IANJUTA_IS_EDITOR(obj));
722 	IANJUTA_EDITOR_GET_IFACE (obj)->set_indentsize (obj, indentsize, err);
723 }
724 
725 /* Default implementation */
726 static void
ianjuta_editor_set_indentsize_default(IAnjutaEditor * obj,gint indentsize,GError ** err)727 ianjuta_editor_set_indentsize_default (IAnjutaEditor *obj, gint indentsize, GError **err)
728 {
729 	g_return_if_reached ();
730 }
731 
732 /**
733  * ianjuta_editor_set_popup_menu:
734  * @obj: Self
735  * @menu: Popupmenu
736  * @err: Error propagation and reporting
737  *
738  * Set Editor popup menu. This is the menu shown in the editor when one
739  * right-clicks on it.
740  *
741  */
742 void
ianjuta_editor_set_popup_menu(IAnjutaEditor * obj,GtkWidget * menu,GError ** err)743 ianjuta_editor_set_popup_menu (IAnjutaEditor *obj, GtkWidget *menu, GError **err)
744 {
745 	g_return_if_fail (IANJUTA_IS_EDITOR(obj));
746 	g_return_if_fail ((menu == NULL) ||GTK_IS_WIDGET(menu));
747 	IANJUTA_EDITOR_GET_IFACE (obj)->set_popup_menu (obj, menu, err);
748 }
749 
750 /* Default implementation */
751 static void
ianjuta_editor_set_popup_menu_default(IAnjutaEditor * obj,GtkWidget * menu,GError ** err)752 ianjuta_editor_set_popup_menu_default (IAnjutaEditor *obj, GtkWidget *menu, GError **err)
753 {
754 	g_return_if_reached ();
755 }
756 
757 /**
758  * ianjuta_editor_set_tabsize:
759  * @obj: Self
760  * @tabsize: Tabsize in spaces
761  * @err: Error propagation and reporting
762  *
763  * Sets the tabsize of the editor.
764  */
765 void
ianjuta_editor_set_tabsize(IAnjutaEditor * obj,gint tabsize,GError ** err)766 ianjuta_editor_set_tabsize (IAnjutaEditor *obj, gint tabsize, GError **err)
767 {
768 	g_return_if_fail (IANJUTA_IS_EDITOR(obj));
769 	IANJUTA_EDITOR_GET_IFACE (obj)->set_tabsize (obj, tabsize, err);
770 }
771 
772 /* Default implementation */
773 static void
ianjuta_editor_set_tabsize_default(IAnjutaEditor * obj,gint tabsize,GError ** err)774 ianjuta_editor_set_tabsize_default (IAnjutaEditor *obj, gint tabsize, GError **err)
775 {
776 	g_return_if_reached ();
777 }
778 
779 /**
780  * ianjuta_editor_set_use_space:
781  * @obj: Self
782  * @use_spaces: TRUE to use spaces, FALSE to use tab char directly.
783  * @err: Error propagation and reporting
784  *
785  * Sets if the editor should use spaces for filling up tab characters.
786  */
787 void
ianjuta_editor_set_use_spaces(IAnjutaEditor * obj,gboolean use_spaces,GError ** err)788 ianjuta_editor_set_use_spaces (IAnjutaEditor *obj, gboolean use_spaces, GError **err)
789 {
790 	g_return_if_fail (IANJUTA_IS_EDITOR(obj));
791 	IANJUTA_EDITOR_GET_IFACE (obj)->set_use_spaces (obj, use_spaces, err);
792 }
793 
794 /* Default implementation */
795 static void
ianjuta_editor_set_use_spaces_default(IAnjutaEditor * obj,gboolean use_spaces,GError ** err)796 ianjuta_editor_set_use_spaces_default (IAnjutaEditor *obj, gboolean use_spaces, GError **err)
797 {
798 	g_return_if_reached ();
799 }
800 
801 static void
ianjuta_editor_base_init(IAnjutaEditorIface * klass)802 ianjuta_editor_base_init (IAnjutaEditorIface* klass)
803 {
804 	static gboolean initialized = FALSE;
805 
806 	klass->append = ianjuta_editor_append_default;
807 	klass->erase = ianjuta_editor_erase_default;
808 	klass->erase_all = ianjuta_editor_erase_all_default;
809 	klass->get_column = ianjuta_editor_get_column_default;
810 	klass->get_current_word = ianjuta_editor_get_current_word_default;
811 	klass->get_end_position = ianjuta_editor_get_end_position_default;
812 	klass->get_indentsize = ianjuta_editor_get_indentsize_default;
813 	klass->get_length = ianjuta_editor_get_length_default;
814 	klass->get_line_begin_position = ianjuta_editor_get_line_begin_position_default;
815 	klass->get_line_end_position = ianjuta_editor_get_line_end_position_default;
816 	klass->get_line_from_position = ianjuta_editor_get_line_from_position_default;
817 	klass->get_lineno = ianjuta_editor_get_lineno_default;
818 	klass->get_offset = ianjuta_editor_get_offset_default;
819 	klass->get_overwrite = ianjuta_editor_get_overwrite_default;
820 	klass->get_position = ianjuta_editor_get_position_default;
821 	klass->get_position_from_offset = ianjuta_editor_get_position_from_offset_default;
822 	klass->get_start_position = ianjuta_editor_get_start_position_default;
823 	klass->get_tabsize = ianjuta_editor_get_tabsize_default;
824 	klass->get_text = ianjuta_editor_get_text_default;
825 	klass->get_text_all = ianjuta_editor_get_text_all_default;
826 	klass->get_use_spaces = ianjuta_editor_get_use_spaces_default;
827 	klass->goto_end = ianjuta_editor_goto_end_default;
828 	klass->goto_line = ianjuta_editor_goto_line_default;
829 	klass->goto_position = ianjuta_editor_goto_position_default;
830 	klass->goto_start = ianjuta_editor_goto_start_default;
831 	klass->insert = ianjuta_editor_insert_default;
832 	klass->set_auto_indent = ianjuta_editor_set_auto_indent_default;
833 	klass->set_indentsize = ianjuta_editor_set_indentsize_default;
834 	klass->set_popup_menu = ianjuta_editor_set_popup_menu_default;
835 	klass->set_tabsize = ianjuta_editor_set_tabsize_default;
836 	klass->set_use_spaces = ianjuta_editor_set_use_spaces_default;
837 
838 	if (!initialized) {
839 
840 		/**
841 		 * IAnjutaEditor::backspace:
842 		 * @obj: Self
843 		 *
844 		 * The signal is emitted when the user presses backspace
845 		 */
846 		g_signal_new ("backspace",
847 			IANJUTA_TYPE_EDITOR,
848 			G_SIGNAL_RUN_LAST,
849 			G_STRUCT_OFFSET (IAnjutaEditorIface, backspace),
850 			NULL, NULL,
851 			libanjuta_iface_cclosure_marshal_VOID__VOID,
852 			G_TYPE_NONE,
853 			0,
854 			NULL);
855 
856 
857 		/**
858 		 * IAnjutaEditor::changed:
859 		 * @position: The iter position where change happend.
860 		 * @added: TRUE if added, FALSE if deleted.
861 		 * @length: Length of the text changed.
862 		 * @lines: Number of lines added or removed.
863 		 * @text: The text added or removed.
864 		 * @obj: Self
865 		 *
866 		 * This signal is emitted when any text change happens in editor.
867 		 * The changes begin at @position. @text is not garanteed to be NULL
868 		 * terminated. Use @length to read the text. @lines represent the
869 		 * number of line breaks in the added or removed text.
870 		 */
871 		g_signal_new ("changed",
872 			IANJUTA_TYPE_EDITOR,
873 			G_SIGNAL_RUN_LAST,
874 			G_STRUCT_OFFSET (IAnjutaEditorIface, changed),
875 			NULL, NULL,
876 			libanjuta_iface_cclosure_marshal_VOID__OBJECT_BOOLEAN_INT_INT_STRING,
877 			G_TYPE_NONE,
878 			5,
879 			IANJUTA_TYPE_ITERABLE,
880 			G_TYPE_BOOLEAN,
881 			G_TYPE_INT,
882 			G_TYPE_INT,
883 			G_TYPE_STRING);
884 
885 
886 		/**
887 		 * IAnjutaEditor::char-added:
888 		 * @position: The iter position where @ch is added.
889 		 * @ch: The character that has been added.
890 		 * @obj: Self
891 		 *
892 		 * This signal is emitted when any character is added inside the editor.
893 		 * The newly added character is @ch which has been inserted at @position.
894 		 */
895 		g_signal_new ("char-added",
896 			IANJUTA_TYPE_EDITOR,
897 			G_SIGNAL_RUN_LAST,
898 			G_STRUCT_OFFSET (IAnjutaEditorIface, char_added),
899 			NULL, NULL,
900 			libanjuta_iface_cclosure_marshal_VOID__OBJECT_CHAR,
901 			G_TYPE_NONE,
902 			2,
903 			IANJUTA_TYPE_ITERABLE,
904 			G_TYPE_CHAR);
905 
906 
907 		/**
908 		 * IAnjutaEditor::code-changed:
909 		 * @position: The iter position where code has been changed or NULL.
910 		 * @code: The code that has been added or NULL.
911 		 * @obj: Self
912 		 *
913 		 * This signal is emitted when code is changed inside the editor.
914 		 * When such information is availabe, @position stores the position where @code was added.
915 		 */
916 		g_signal_new ("code-changed",
917 			IANJUTA_TYPE_EDITOR,
918 			G_SIGNAL_RUN_LAST,
919 			G_STRUCT_OFFSET (IAnjutaEditorIface, code_changed),
920 			NULL, NULL,
921 			libanjuta_iface_cclosure_marshal_VOID__OBJECT_STRING,
922 			G_TYPE_NONE,
923 			2,
924 			IANJUTA_TYPE_ITERABLE,
925 			G_TYPE_STRING);
926 
927 
928 		/**
929 		 * IAnjutaEditor::cursor-moved:
930 		 * @obj: Self
931 		 *
932 		 * The signal is a hint that the cursor was moved.
933 		 */
934 		g_signal_new ("cursor-moved",
935 			IANJUTA_TYPE_EDITOR,
936 			G_SIGNAL_RUN_LAST,
937 			G_STRUCT_OFFSET (IAnjutaEditorIface, cursor_moved),
938 			NULL, NULL,
939 			libanjuta_iface_cclosure_marshal_VOID__VOID,
940 			G_TYPE_NONE,
941 			0,
942 			NULL);
943 
944 
945 		/**
946 		 * IAnjutaEditor::glade-callback-add:
947 		 * @widget_typename: Name of the type of the widget.
948 		 * @signal_name: Name of the signal.
949 		 * @handler_name: Name of the signal handler.
950 		 * @object: Name of the object to be passed.
951 		 * @swap: The "swap" signal property.
952 		 * @after: The "after" signal property.
953 		 * @filename: Path for the .ui file that generated the signal.
954 		 * @obj: Self
955 		 *
956 		 * This signal is emitted when code for a widget must be generated.
957 		 */
958 		g_signal_new ("glade-callback-add",
959 			IANJUTA_TYPE_EDITOR,
960 			G_SIGNAL_RUN_LAST,
961 			G_STRUCT_OFFSET (IAnjutaEditorIface, glade_callback_add),
962 			NULL, NULL,
963 			libanjuta_iface_cclosure_marshal_VOID__STRING_STRING_STRING_STRING_BOOLEAN_BOOLEAN_STRING,
964 			G_TYPE_NONE,
965 			7,
966 			G_TYPE_STRING,
967 			G_TYPE_STRING,
968 			G_TYPE_STRING,
969 			G_TYPE_STRING,
970 			G_TYPE_BOOLEAN,
971 			G_TYPE_BOOLEAN,
972 			G_TYPE_STRING);
973 
974 
975 		/**
976 		 * IAnjutaEditor::glade-member-add:
977 		 * @widget_typename: Name of the type of the widget that will become a member of the class.
978 		 * @widget_name: Name of the widget that will become a member of the class.
979 		 * @filename: Path for the .ui file that generated the signal.
980 		 * @obj: Self
981 		 *
982 		 * This signal is emitted when code for a widget must be generated.
983 		 */
984 		g_signal_new ("glade-member-add",
985 			IANJUTA_TYPE_EDITOR,
986 			G_SIGNAL_RUN_LAST,
987 			G_STRUCT_OFFSET (IAnjutaEditorIface, glade_member_add),
988 			NULL, NULL,
989 			libanjuta_iface_cclosure_marshal_VOID__STRING_STRING_STRING,
990 			G_TYPE_NONE,
991 			3,
992 			G_TYPE_STRING,
993 			G_TYPE_STRING,
994 			G_TYPE_STRING);
995 
996 
997 		/**
998 		 * IAnjutaEditor::line-marks-gutter-clicked:
999 		 * @obj: Self
1000 		 * @double_click: whether the line marks gutter was double clicked
1001 		 * @location: location of the clicked marker
1002 		 *
1003 		 * The signal is emitted when the user clicks on a marker
1004 		 */
1005 		g_signal_new ("line-marks-gutter-clicked",
1006 			IANJUTA_TYPE_EDITOR,
1007 			G_SIGNAL_RUN_LAST,
1008 			G_STRUCT_OFFSET (IAnjutaEditorIface, line_marks_gutter_clicked),
1009 			NULL, NULL,
1010 			libanjuta_iface_cclosure_marshal_VOID__INT,
1011 			G_TYPE_NONE,
1012 			1,
1013 			G_TYPE_INT);
1014 
1015 
1016 		initialized = TRUE;
1017 	}
1018 }
1019 
1020 GType
ianjuta_editor_get_type(void)1021 ianjuta_editor_get_type (void)
1022 {
1023 	static GType type = 0;
1024 	if (!type) {
1025 		static const GTypeInfo info = {
1026 			sizeof (IAnjutaEditorIface),
1027 			(GBaseInitFunc) ianjuta_editor_base_init,
1028 			NULL,
1029 			NULL,
1030 			NULL,
1031 			NULL,
1032 			0,
1033 			0,
1034 			NULL
1035 		};
1036 		type = g_type_register_static (G_TYPE_INTERFACE, "IAnjutaEditor", &info, 0);
1037 		g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
1038 	}
1039 	return type;
1040 }
1041 
1042 GType
ianjuta_editor_attribute_get_type(void)1043 ianjuta_editor_attribute_get_type (void)
1044 {
1045 	static const GEnumValue values[] =
1046 	{
1047 		{ IANJUTA_EDITOR_TEXT, "IANJUTA_EDITOR_TEXT", "text" },
1048 		{ IANJUTA_EDITOR_KEYWORD, "IANJUTA_EDITOR_KEYWORD", "keyword" },
1049 		{ IANJUTA_EDITOR_COMMENT, "IANJUTA_EDITOR_COMMENT", "comment" },
1050 		{ IANJUTA_EDITOR_STRING, "IANJUTA_EDITOR_STRING", "string" },
1051 		{ 0, NULL, NULL }
1052 	};
1053 
1054 	static GType type = 0;
1055 
1056 	if (! type)
1057 	{
1058 		type = g_enum_register_static ("IAnjutaEditorAttribute", values);
1059 	}
1060 
1061 	return type;
1062 }
1063 
1064 GType
ianjuta_editor_error_get_type(void)1065 ianjuta_editor_error_get_type (void)
1066 {
1067 	static const GEnumValue values[] =
1068 	{
1069 		{ IANJUTA_EDITOR_DOESNT_EXIST, "IANJUTA_EDITOR_DOESNT_EXIST", "doesnt-exist" },
1070 		{ 0, NULL, NULL }
1071 	};
1072 
1073 	static GType type = 0;
1074 
1075 	if (! type)
1076 	{
1077 		type = g_enum_register_static ("IAnjutaEditorError", values);
1078 	}
1079 
1080 	return type;
1081 }
1082