1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD 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 Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gsv.SourceBuffer;
26 
27 private import glib.ConstructionException;
28 private import glib.ListSG;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 private import gobject.Signals;
32 private import gsv.SourceLanguage;
33 private import gsv.SourceMark;
34 private import gsv.SourceStyleScheme;
35 private import gsv.SourceUndoManager;
36 private import gsv.SourceUndoManagerIF;
37 private import gsvc.gsv;
38 public  import gsvc.gsvtypes;
39 private import gtk.TextBuffer;
40 private import gtk.TextIter;
41 private import gtk.TextMark;
42 private import gtk.TextTagTable;
43 public  import gtkc.gdktypes;
44 
45 
46 public class SourceBuffer : TextBuffer
47 {
48 	/** the main Gtk struct */
49 	protected GtkSourceBuffer* gtkSourceBuffer;
50 
51 	/** Get the main Gtk struct */
52 	public GtkSourceBuffer* getSourceBufferStruct()
53 	{
54 		return gtkSourceBuffer;
55 	}
56 
57 	/** the main Gtk struct as a void* */
58 	protected override void* getStruct()
59 	{
60 		return cast(void*)gtkSourceBuffer;
61 	}
62 
63 	protected override void setStruct(GObject* obj)
64 	{
65 		gtkSourceBuffer = cast(GtkSourceBuffer*)obj;
66 		super.setStruct(obj);
67 	}
68 
69 	/**
70 	 * Sets our main struct and passes it to the parent class.
71 	 */
72 	public this (GtkSourceBuffer* gtkSourceBuffer, bool ownedRef = false)
73 	{
74 		this.gtkSourceBuffer = gtkSourceBuffer;
75 		super(cast(GtkTextBuffer*)gtkSourceBuffer, ownedRef);
76 	}
77 
78 	/**
79 	 */
80 
81 	public static GType getType()
82 	{
83 		return gtk_source_buffer_get_type();
84 	}
85 
86 	/**
87 	 * Creates a new source buffer.
88 	 *
89 	 * Params:
90 	 *     table = a #GtkTextTagTable, or %NULL to create a new one.
91 	 *
92 	 * Return: a new source buffer.
93 	 *
94 	 * Throws: ConstructionException GTK+ fails to create the object.
95 	 */
96 	public this(TextTagTable table)
97 	{
98 		auto p = gtk_source_buffer_new((table is null) ? null : table.getTextTagTableStruct());
99 		
100 		if(p is null)
101 		{
102 			throw new ConstructionException("null returned by new");
103 		}
104 		
105 		this(cast(GtkSourceBuffer*) p, true);
106 	}
107 
108 	/**
109 	 * Creates a new source buffer using the highlighting patterns in
110 	 * @language.  This is equivalent to creating a new source buffer with
111 	 * a new tag table and then calling gtk_source_buffer_set_language().
112 	 *
113 	 * Params:
114 	 *     language = a #GtkSourceLanguage.
115 	 *
116 	 * Return: a new source buffer which will highlight text
117 	 *     according to the highlighting patterns in @language.
118 	 *
119 	 * Throws: ConstructionException GTK+ fails to create the object.
120 	 */
121 	public this(SourceLanguage language)
122 	{
123 		auto p = gtk_source_buffer_new_with_language((language is null) ? null : language.getSourceLanguageStruct());
124 		
125 		if(p is null)
126 		{
127 			throw new ConstructionException("null returned by new_with_language");
128 		}
129 		
130 		this(cast(GtkSourceBuffer*) p, true);
131 	}
132 
133 	/**
134 	 * Moves @iter to the position of the previous #GtkSourceMark of the given
135 	 * category. Returns %TRUE if @iter was moved. If @category is NULL, the
136 	 * previous source mark can be of any category.
137 	 *
138 	 * Params:
139 	 *     iter = an iterator.
140 	 *     category = category to search for, or %NULL
141 	 *
142 	 * Return: whether @iter was moved.
143 	 *
144 	 * Since: 2.2
145 	 */
146 	public bool backwardIterToSourceMark(TextIter iter, string category)
147 	{
148 		return gtk_source_buffer_backward_iter_to_source_mark(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(category)) != 0;
149 	}
150 
151 	/**
152 	 * Marks the beginning of a not undoable action on the buffer,
153 	 * disabling the undo manager.  Typically you would call this function
154 	 * before initially setting the contents of the buffer (e.g. when
155 	 * loading a file in a text editor).
156 	 *
157 	 * You may nest gtk_source_buffer_begin_not_undoable_action() /
158 	 * gtk_source_buffer_end_not_undoable_action() blocks.
159 	 */
160 	public void beginNotUndoableAction()
161 	{
162 		gtk_source_buffer_begin_not_undoable_action(gtkSourceBuffer);
163 	}
164 
165 	/**
166 	 * Determines whether a source buffer can redo the last action
167 	 * (i.e. if the last operation was an undo).
168 	 *
169 	 * Return: %TRUE if a redo is possible.
170 	 */
171 	public bool canRedo()
172 	{
173 		return gtk_source_buffer_can_redo(gtkSourceBuffer) != 0;
174 	}
175 
176 	/**
177 	 * Determines whether a source buffer can undo the last action.
178 	 *
179 	 * Return: %TRUE if it's possible to undo the last action.
180 	 */
181 	public bool canUndo()
182 	{
183 		return gtk_source_buffer_can_undo(gtkSourceBuffer) != 0;
184 	}
185 
186 	/**
187 	 * Changes the case of the text between the specified iterators.
188 	 *
189 	 * Params:
190 	 *     caseType = how to change the case.
191 	 *     start = a #GtkTextIter.
192 	 *     end = a #GtkTextIter.
193 	 *
194 	 * Since: 3.12
195 	 */
196 	public void changeCase(GtkSourceChangeCaseType caseType, TextIter start, TextIter end)
197 	{
198 		gtk_source_buffer_change_case(gtkSourceBuffer, caseType, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct());
199 	}
200 
201 	/**
202 	 * Creates a source mark in the @buffer of category @category.  A source mark is
203 	 * a #GtkTextMark but organised into categories. Depending on the category
204 	 * a pixbuf can be specified that will be displayed along the line of the mark.
205 	 *
206 	 * Like a #GtkTextMark, a #GtkSourceMark can be anonymous if the
207 	 * passed @name is %NULL.  Also, the buffer owns the marks so you
208 	 * shouldn't unreference it.
209 	 *
210 	 * Marks always have left gravity and are moved to the beginning of
211 	 * the line when the user deletes the line they were in.
212 	 *
213 	 * Typical uses for a source mark are bookmarks, breakpoints, current
214 	 * executing instruction indication in a source file, etc..
215 	 *
216 	 * Params:
217 	 *     name = the name of the mark, or %NULL.
218 	 *     category = a string defining the mark category.
219 	 *     where = location to place the mark.
220 	 *
221 	 * Return: a new #GtkSourceMark, owned by the buffer.
222 	 *
223 	 * Since: 2.2
224 	 */
225 	public SourceMark createSourceMark(string name, string category, TextIter where)
226 	{
227 		auto p = gtk_source_buffer_create_source_mark(gtkSourceBuffer, Str.toStringz(name), Str.toStringz(category), (where is null) ? null : where.getTextIterStruct());
228 		
229 		if(p is null)
230 		{
231 			return null;
232 		}
233 		
234 		return ObjectG.getDObject!(SourceMark)(cast(GtkSourceMark*) p);
235 	}
236 
237 	/**
238 	 * Marks the end of a not undoable action on the buffer.  When the
239 	 * last not undoable block is closed through the call to this
240 	 * function, the list of undo actions is cleared and the undo manager
241 	 * is re-enabled.
242 	 */
243 	public void endNotUndoableAction()
244 	{
245 		gtk_source_buffer_end_not_undoable_action(gtkSourceBuffer);
246 	}
247 
248 	/**
249 	 * Forces buffer to analyze and highlight the given area synchronously.
250 	 *
251 	 * <note>
252 	 * <para>
253 	 * This is a potentially slow operation and should be used only
254 	 * when you need to make sure that some text not currently
255 	 * visible is highlighted, for instance before printing.
256 	 * </para>
257 	 * </note>
258 	 *
259 	 * Params:
260 	 *     start = start of the area to highlight.
261 	 *     end = end of the area to highlight.
262 	 */
263 	public void ensureHighlight(TextIter start, TextIter end)
264 	{
265 		gtk_source_buffer_ensure_highlight(gtkSourceBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct());
266 	}
267 
268 	/**
269 	 * Moves @iter to the position of the next #GtkSourceMark of the given
270 	 * @category. Returns %TRUE if @iter was moved. If @category is NULL, the
271 	 * next source mark can be of any category.
272 	 *
273 	 * Params:
274 	 *     iter = an iterator.
275 	 *     category = category to search for, or %NULL
276 	 *
277 	 * Return: whether @iter was moved.
278 	 *
279 	 * Since: 2.2
280 	 */
281 	public bool forwardIterToSourceMark(TextIter iter, string category)
282 	{
283 		return gtk_source_buffer_forward_iter_to_source_mark(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(category)) != 0;
284 	}
285 
286 	/**
287 	 * Get all defined context classes at @iter.
288 	 *
289 	 * See the #GtkSourceBuffer description for the list of default context classes.
290 	 *
291 	 * Params:
292 	 *     iter = a #GtkTextIter.
293 	 *
294 	 * Return: a new %NULL
295 	 *     terminated array of context class names.
296 	 *     Use g_strfreev() to free the array if it is no longer needed.
297 	 *
298 	 * Since: 2.10
299 	 */
300 	public string[] getContextClassesAtIter(TextIter iter)
301 	{
302 		return Str.toStringArray(gtk_source_buffer_get_context_classes_at_iter(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct()));
303 	}
304 
305 	/**
306 	 * Determines whether bracket match highlighting is activated for the
307 	 * source buffer.
308 	 *
309 	 * Return: %TRUE if the source buffer will highlight matching
310 	 *     brackets.
311 	 */
312 	public bool getHighlightMatchingBrackets()
313 	{
314 		return gtk_source_buffer_get_highlight_matching_brackets(gtkSourceBuffer) != 0;
315 	}
316 
317 	/**
318 	 * Determines whether syntax highlighting is activated in the source
319 	 * buffer.
320 	 *
321 	 * Return: %TRUE if syntax highlighting is enabled, %FALSE otherwise.
322 	 */
323 	public bool getHighlightSyntax()
324 	{
325 		return gtk_source_buffer_get_highlight_syntax(gtkSourceBuffer) != 0;
326 	}
327 
328 	/**
329 	 * Return: whether the @buffer has an implicit trailing newline.
330 	 *
331 	 * Since: 3.14
332 	 */
333 	public bool getImplicitTrailingNewline()
334 	{
335 		return gtk_source_buffer_get_implicit_trailing_newline(gtkSourceBuffer) != 0;
336 	}
337 
338 	/**
339 	 * Returns the #GtkSourceLanguage associated with the buffer,
340 	 * see gtk_source_buffer_set_language().  The returned object should not be
341 	 * unreferenced by the user.
342 	 *
343 	 * Return: the #GtkSourceLanguage associated with the buffer, or %NULL.
344 	 */
345 	public SourceLanguage getLanguage()
346 	{
347 		auto p = gtk_source_buffer_get_language(gtkSourceBuffer);
348 		
349 		if(p is null)
350 		{
351 			return null;
352 		}
353 		
354 		return ObjectG.getDObject!(SourceLanguage)(cast(GtkSourceLanguage*) p);
355 	}
356 
357 	/**
358 	 * Determines the number of undo levels the buffer will track for
359 	 * buffer edits.
360 	 *
361 	 * Return: the maximum number of possible undo levels or
362 	 *     -1 if no limit is set.
363 	 */
364 	public int getMaxUndoLevels()
365 	{
366 		return gtk_source_buffer_get_max_undo_levels(gtkSourceBuffer);
367 	}
368 
369 	/**
370 	 * Returns the list of marks of the given category at @iter. If @category
371 	 * is %NULL it returns all marks at @iter.
372 	 *
373 	 * Params:
374 	 *     iter = an iterator.
375 	 *     category = category to search for, or %NULL
376 	 *
377 	 * Return: a newly allocated #GSList.
378 	 *
379 	 * Since: 2.2
380 	 */
381 	public ListSG getSourceMarksAtIter(TextIter iter, string category)
382 	{
383 		auto p = gtk_source_buffer_get_source_marks_at_iter(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(category));
384 		
385 		if(p is null)
386 		{
387 			return null;
388 		}
389 		
390 		return new ListSG(cast(GSList*) p);
391 	}
392 
393 	/**
394 	 * Returns the list of marks of the given category at @line.
395 	 * If @category is %NULL, all marks at @line are returned.
396 	 *
397 	 * Params:
398 	 *     line = a line number.
399 	 *     category = category to search for, or %NULL
400 	 *
401 	 * Return: a newly allocated #GSList.
402 	 *
403 	 * Since: 2.2
404 	 */
405 	public ListSG getSourceMarksAtLine(int line, string category)
406 	{
407 		auto p = gtk_source_buffer_get_source_marks_at_line(gtkSourceBuffer, line, Str.toStringz(category));
408 		
409 		if(p is null)
410 		{
411 			return null;
412 		}
413 		
414 		return new ListSG(cast(GSList*) p);
415 	}
416 
417 	/**
418 	 * Returns the #GtkSourceStyleScheme associated with the buffer,
419 	 * see gtk_source_buffer_set_style_scheme().
420 	 * The returned object should not be unreferenced by the user.
421 	 *
422 	 * Return: the #GtkSourceStyleScheme associated
423 	 *     with the buffer, or %NULL.
424 	 */
425 	public SourceStyleScheme getStyleScheme()
426 	{
427 		auto p = gtk_source_buffer_get_style_scheme(gtkSourceBuffer);
428 		
429 		if(p is null)
430 		{
431 			return null;
432 		}
433 		
434 		return ObjectG.getDObject!(SourceStyleScheme)(cast(GtkSourceStyleScheme*) p);
435 	}
436 
437 	/**
438 	 * Returns the #GtkSourceUndoManager associated with the buffer,
439 	 * see gtk_source_buffer_set_undo_manager().  The returned object should not be
440 	 * unreferenced by the user.
441 	 *
442 	 * Return: the #GtkSourceUndoManager associated
443 	 *     with the buffer, or %NULL.
444 	 */
445 	public SourceUndoManagerIF getUndoManager()
446 	{
447 		auto p = gtk_source_buffer_get_undo_manager(gtkSourceBuffer);
448 		
449 		if(p is null)
450 		{
451 			return null;
452 		}
453 		
454 		return ObjectG.getDObject!(SourceUndoManager, SourceUndoManagerIF)(cast(GtkSourceUndoManager*) p);
455 	}
456 
457 	/**
458 	 * Moves backward to the next toggle (on or off) of the context class. If no
459 	 * matching context class toggles are found, returns %FALSE, otherwise %TRUE.
460 	 * Does not return toggles located at @iter, only toggles after @iter. Sets
461 	 * @iter to the location of the toggle, or to the end of the buffer if no
462 	 * toggle is found.
463 	 *
464 	 * See the #GtkSourceBuffer description for the list of default context classes.
465 	 *
466 	 * Params:
467 	 *     iter = a #GtkTextIter.
468 	 *     contextClass = the context class.
469 	 *
470 	 * Return: whether we found a context class toggle before @iter
471 	 *
472 	 * Since: 2.10
473 	 */
474 	public bool iterBackwardToContextClassToggle(ref TextIter iter, string contextClass)
475 	{
476 		return gtk_source_buffer_iter_backward_to_context_class_toggle(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(contextClass)) != 0;
477 	}
478 
479 	/**
480 	 * Moves forward to the next toggle (on or off) of the context class. If no
481 	 * matching context class toggles are found, returns %FALSE, otherwise %TRUE.
482 	 * Does not return toggles located at @iter, only toggles after @iter. Sets
483 	 * @iter to the location of the toggle, or to the end of the buffer if no
484 	 * toggle is found.
485 	 *
486 	 * See the #GtkSourceBuffer description for the list of default context classes.
487 	 *
488 	 * Params:
489 	 *     iter = a #GtkTextIter.
490 	 *     contextClass = the context class.
491 	 *
492 	 * Return: whether we found a context class toggle after @iter
493 	 *
494 	 * Since: 2.10
495 	 */
496 	public bool iterForwardToContextClassToggle(ref TextIter iter, string contextClass)
497 	{
498 		return gtk_source_buffer_iter_forward_to_context_class_toggle(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(contextClass)) != 0;
499 	}
500 
501 	/**
502 	 * Check if the class @context_class is set on @iter.
503 	 *
504 	 * See the #GtkSourceBuffer description for the list of default context classes.
505 	 *
506 	 * Params:
507 	 *     iter = a #GtkTextIter.
508 	 *     contextClass = class to search for.
509 	 *
510 	 * Return: whether @iter has the context class.
511 	 *
512 	 * Since: 2.10
513 	 */
514 	public bool iterHasContextClass(TextIter iter, string contextClass)
515 	{
516 		return gtk_source_buffer_iter_has_context_class(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(contextClass)) != 0;
517 	}
518 
519 	/**
520 	 * Redoes the last undo operation.  Use gtk_source_buffer_can_redo()
521 	 * to check whether a call to this function will have any effect.
522 	 *
523 	 * This function emits the #GtkSourceBuffer::redo signal.
524 	 */
525 	public void redo()
526 	{
527 		gtk_source_buffer_redo(gtkSourceBuffer);
528 	}
529 
530 	/**
531 	 * Remove all marks of @category between @start and @end from the buffer.
532 	 * If @category is NULL, all marks in the range will be removed.
533 	 *
534 	 * Params:
535 	 *     start = a #GtkTextIter.
536 	 *     end = a #GtkTextIter.
537 	 *     category = category to search for, or %NULL.
538 	 *
539 	 * Since: 2.2
540 	 */
541 	public void removeSourceMarks(TextIter start, TextIter end, string category)
542 	{
543 		gtk_source_buffer_remove_source_marks(gtkSourceBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct(), Str.toStringz(category));
544 	}
545 
546 	/**
547 	 * Controls the bracket match highlighting function in the buffer.  If
548 	 * activated, when you position your cursor over a bracket character
549 	 * (a parenthesis, a square bracket, etc.) the matching opening or
550 	 * closing bracket character will be highlighted.
551 	 *
552 	 * Params:
553 	 *     highlight = %TRUE if you want matching brackets highlighted.
554 	 */
555 	public void setHighlightMatchingBrackets(bool highlight)
556 	{
557 		gtk_source_buffer_set_highlight_matching_brackets(gtkSourceBuffer, highlight);
558 	}
559 
560 	/**
561 	 * Controls whether syntax is highlighted in the buffer. If @highlight
562 	 * is %TRUE, the text will be highlighted according to the syntax
563 	 * patterns specified in the language set with
564 	 * gtk_source_buffer_set_language(). If @highlight is %FALSE, syntax highlighting
565 	 * is disabled and all the GtkTextTag objects that have been added by the
566 	 * syntax highlighting engine are removed from the buffer.
567 	 *
568 	 * Params:
569 	 *     highlight = %TRUE to enable syntax highlighting, %FALSE to disable it.
570 	 */
571 	public void setHighlightSyntax(bool highlight)
572 	{
573 		gtk_source_buffer_set_highlight_syntax(gtkSourceBuffer, highlight);
574 	}
575 
576 	/**
577 	 * Sets whether the @buffer has an implicit trailing newline.
578 	 *
579 	 * If an explicit trailing newline is present in a #GtkTextBuffer, #GtkTextView
580 	 * shows it as an empty line. This is generally not what the user expects.
581 	 *
582 	 * If @implicit_trailing_newline is %TRUE (the default value):
583 	 * - when a #GtkSourceFileLoader loads the content of a file into the @buffer,
584 	 * the trailing newline (if present in the file) is not inserted into the
585 	 * @buffer.
586 	 * - when a #GtkSourceFileSaver saves the content of the @buffer into a file, a
587 	 * trailing newline is added to the file.
588 	 *
589 	 * On the other hand, if @implicit_trailing_newline is %FALSE, the file's
590 	 * content is not modified when loaded into the @buffer, and the @buffer's
591 	 * content is not modified when saved into a file.
592 	 *
593 	 * Params:
594 	 *     implicitTrailingNewline = the new value.
595 	 *
596 	 * Since: 3.14
597 	 */
598 	public void setImplicitTrailingNewline(bool implicitTrailingNewline)
599 	{
600 		gtk_source_buffer_set_implicit_trailing_newline(gtkSourceBuffer, implicitTrailingNewline);
601 	}
602 
603 	/**
604 	 * Associate a #GtkSourceLanguage with the buffer. If @language is
605 	 * not-%NULL and syntax highlighting is enabled (see gtk_source_buffer_set_highlight_syntax()),
606 	 * the syntax patterns defined in @language will be used to highlight the text
607 	 * contained in the buffer. If @language is %NULL, the text contained in the
608 	 * buffer is not highlighted.
609 	 *
610 	 * The buffer holds a reference to @language.
611 	 *
612 	 * Params:
613 	 *     language = a #GtkSourceLanguage to set, or %NULL.
614 	 */
615 	public void setLanguage(SourceLanguage language)
616 	{
617 		gtk_source_buffer_set_language(gtkSourceBuffer, (language is null) ? null : language.getSourceLanguageStruct());
618 	}
619 
620 	/**
621 	 * Sets the number of undo levels for user actions the buffer will
622 	 * track.  If the number of user actions exceeds the limit set by this
623 	 * function, older actions will be discarded.
624 	 *
625 	 * If @max_undo_levels is -1, no limit is set.
626 	 *
627 	 * Params:
628 	 *     maxUndoLevels = the desired maximum number of undo levels.
629 	 */
630 	public void setMaxUndoLevels(int maxUndoLevels)
631 	{
632 		gtk_source_buffer_set_max_undo_levels(gtkSourceBuffer, maxUndoLevels);
633 	}
634 
635 	/**
636 	 * Sets style scheme used by the buffer. If @scheme is %NULL no
637 	 * style scheme is used.
638 	 *
639 	 * Params:
640 	 *     scheme = a #GtkSourceStyleScheme or %NULL.
641 	 */
642 	public void setStyleScheme(SourceStyleScheme scheme)
643 	{
644 		gtk_source_buffer_set_style_scheme(gtkSourceBuffer, (scheme is null) ? null : scheme.getSourceStyleSchemeStruct());
645 	}
646 
647 	/**
648 	 * Set the buffer undo manager. If @manager is %NULL the default undo manager
649 	 * will be set.
650 	 *
651 	 * Params:
652 	 *     manager = A #GtkSourceUndoManager or %NULL.
653 	 */
654 	public void setUndoManager(SourceUndoManagerIF manager)
655 	{
656 		gtk_source_buffer_set_undo_manager(gtkSourceBuffer, (manager is null) ? null : manager.getSourceUndoManagerStruct());
657 	}
658 
659 	/**
660 	 * Undoes the last user action which modified the buffer.  Use
661 	 * gtk_source_buffer_can_undo() to check whether a call to this
662 	 * function will have any effect.
663 	 *
664 	 * This function emits the #GtkSourceBuffer::undo signal.
665 	 */
666 	public void undo()
667 	{
668 		gtk_source_buffer_undo(gtkSourceBuffer);
669 	}
670 
671 	int[string] connectedSignals;
672 
673 	void delegate(TextIter, GtkSourceBracketMatchType, SourceBuffer)[] onBracketMatchedListeners;
674 	/**
675 	 * Sets @iter to a valid iterator pointing to the matching bracket
676 	 * if @state is #GTK_SOURCE_BRACKET_MATCH_FOUND. Otherwise @iter is
677 	 * meaningless.
678 	 *
679 	 * Params:
680 	 *     iter = iterator to initialize.
681 	 *     state = state of bracket matching
682 	 *
683 	 * Since: 2.12
684 	 */
685 	void addOnBracketMatched(void delegate(TextIter, GtkSourceBracketMatchType, SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
686 	{
687 		if ( "bracket-matched" !in connectedSignals )
688 		{
689 			Signals.connectData(
690 				this,
691 				"bracket-matched",
692 				cast(GCallback)&callBackBracketMatched,
693 				cast(void*)this,
694 				null,
695 				connectFlags);
696 			connectedSignals["bracket-matched"] = 1;
697 		}
698 		onBracketMatchedListeners ~= dlg;
699 	}
700 	extern(C) static void callBackBracketMatched(GtkSourceBuffer* sourcebufferStruct, GtkTextIter* iter, GtkSourceBracketMatchType state, SourceBuffer _sourcebuffer)
701 	{
702 		foreach ( void delegate(TextIter, GtkSourceBracketMatchType, SourceBuffer) dlg; _sourcebuffer.onBracketMatchedListeners )
703 		{
704 			dlg(ObjectG.getDObject!(TextIter)(iter), state, _sourcebuffer);
705 		}
706 	}
707 
708 	void delegate(TextIter, TextIter, SourceBuffer)[] onHighlightUpdatedListeners;
709 	/**
710 	 * The ::highlight-updated signal is emitted when the syntax
711 	 * highlighting is updated in a certain region of the @buffer. This
712 	 * signal is useful to be notified when a context class region is
713 	 * updated (e.g. the no-spell-check context class).
714 	 *
715 	 * Params:
716 	 *     start = the start of the updated region
717 	 *     end = the end of the updated region
718 	 */
719 	void addOnHighlightUpdated(void delegate(TextIter, TextIter, SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
720 	{
721 		if ( "highlight-updated" !in connectedSignals )
722 		{
723 			Signals.connectData(
724 				this,
725 				"highlight-updated",
726 				cast(GCallback)&callBackHighlightUpdated,
727 				cast(void*)this,
728 				null,
729 				connectFlags);
730 			connectedSignals["highlight-updated"] = 1;
731 		}
732 		onHighlightUpdatedListeners ~= dlg;
733 	}
734 	extern(C) static void callBackHighlightUpdated(GtkSourceBuffer* sourcebufferStruct, GtkTextIter* start, GtkTextIter* end, SourceBuffer _sourcebuffer)
735 	{
736 		foreach ( void delegate(TextIter, TextIter, SourceBuffer) dlg; _sourcebuffer.onHighlightUpdatedListeners )
737 		{
738 			dlg(ObjectG.getDObject!(TextIter)(start), ObjectG.getDObject!(TextIter)(end), _sourcebuffer);
739 		}
740 	}
741 
742 	void delegate(SourceBuffer)[] onRedoListeners;
743 	/**
744 	 * The ::redo signal is emitted to redo the last undo operation.
745 	 */
746 	void addOnRedo(void delegate(SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
747 	{
748 		if ( "redo" !in connectedSignals )
749 		{
750 			Signals.connectData(
751 				this,
752 				"redo",
753 				cast(GCallback)&callBackRedo,
754 				cast(void*)this,
755 				null,
756 				connectFlags);
757 			connectedSignals["redo"] = 1;
758 		}
759 		onRedoListeners ~= dlg;
760 	}
761 	extern(C) static void callBackRedo(GtkSourceBuffer* sourcebufferStruct, SourceBuffer _sourcebuffer)
762 	{
763 		foreach ( void delegate(SourceBuffer) dlg; _sourcebuffer.onRedoListeners )
764 		{
765 			dlg(_sourcebuffer);
766 		}
767 	}
768 
769 	void delegate(TextMark, SourceBuffer)[] onSourceMarkUpdatedListeners;
770 	/**
771 	 * The ::source_mark_updated signal is emitted each time
772 	 * a mark is added to, moved or removed from the @buffer.
773 	 *
774 	 * Params:
775 	 *     mark = the #GtkSourceMark
776 	 */
777 	void addOnSourceMarkUpdated(void delegate(TextMark, SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
778 	{
779 		if ( "source-mark-updated" !in connectedSignals )
780 		{
781 			Signals.connectData(
782 				this,
783 				"source-mark-updated",
784 				cast(GCallback)&callBackSourceMarkUpdated,
785 				cast(void*)this,
786 				null,
787 				connectFlags);
788 			connectedSignals["source-mark-updated"] = 1;
789 		}
790 		onSourceMarkUpdatedListeners ~= dlg;
791 	}
792 	extern(C) static void callBackSourceMarkUpdated(GtkSourceBuffer* sourcebufferStruct, GtkTextMark* mark, SourceBuffer _sourcebuffer)
793 	{
794 		foreach ( void delegate(TextMark, SourceBuffer) dlg; _sourcebuffer.onSourceMarkUpdatedListeners )
795 		{
796 			dlg(ObjectG.getDObject!(TextMark)(mark), _sourcebuffer);
797 		}
798 	}
799 
800 	void delegate(SourceBuffer)[] onUndoListeners;
801 	/**
802 	 * The ::undo signal is emitted to undo the last user action which
803 	 * modified the buffer.
804 	 */
805 	void addOnUndo(void delegate(SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
806 	{
807 		if ( "undo" !in connectedSignals )
808 		{
809 			Signals.connectData(
810 				this,
811 				"undo",
812 				cast(GCallback)&callBackUndo,
813 				cast(void*)this,
814 				null,
815 				connectFlags);
816 			connectedSignals["undo"] = 1;
817 		}
818 		onUndoListeners ~= dlg;
819 	}
820 	extern(C) static void callBackUndo(GtkSourceBuffer* sourcebufferStruct, SourceBuffer _sourcebuffer)
821 	{
822 		foreach ( void delegate(SourceBuffer) dlg; _sourcebuffer.onUndoListeners )
823 		{
824 			dlg(_sourcebuffer);
825 		}
826 	}
827 }