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 buffer edits.
359 	 *
360 	 * Return: the maximum number of possible undo levels or -1 if no limit is set.
361 	 */
362 	public int getMaxUndoLevels()
363 	{
364 		return gtk_source_buffer_get_max_undo_levels(gtkSourceBuffer);
365 	}
366 
367 	/**
368 	 * Returns the list of marks of the given category at @iter. If @category
369 	 * is %NULL it returns all marks at @iter.
370 	 *
371 	 * Params:
372 	 *     iter = an iterator.
373 	 *     category = category to search for, or %NULL
374 	 *
375 	 * Return: a newly allocated #GSList.
376 	 *
377 	 * Since: 2.2
378 	 */
379 	public ListSG getSourceMarksAtIter(TextIter iter, string category)
380 	{
381 		auto p = gtk_source_buffer_get_source_marks_at_iter(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(category));
382 		
383 		if(p is null)
384 		{
385 			return null;
386 		}
387 		
388 		return new ListSG(cast(GSList*) p);
389 	}
390 
391 	/**
392 	 * Returns the list of marks of the given category at @line.
393 	 * If @category is %NULL, all marks at @line are returned.
394 	 *
395 	 * Params:
396 	 *     line = a line number.
397 	 *     category = category to search for, or %NULL
398 	 *
399 	 * Return: a newly allocated #GSList.
400 	 *
401 	 * Since: 2.2
402 	 */
403 	public ListSG getSourceMarksAtLine(int line, string category)
404 	{
405 		auto p = gtk_source_buffer_get_source_marks_at_line(gtkSourceBuffer, line, Str.toStringz(category));
406 		
407 		if(p is null)
408 		{
409 			return null;
410 		}
411 		
412 		return new ListSG(cast(GSList*) p);
413 	}
414 
415 	/**
416 	 * Returns the #GtkSourceStyleScheme associated with the buffer,
417 	 * see gtk_source_buffer_set_style_scheme().
418 	 * The returned object should not be unreferenced by the user.
419 	 *
420 	 * Return: the #GtkSourceStyleScheme associated
421 	 *     with the buffer, or %NULL.
422 	 */
423 	public SourceStyleScheme getStyleScheme()
424 	{
425 		auto p = gtk_source_buffer_get_style_scheme(gtkSourceBuffer);
426 		
427 		if(p is null)
428 		{
429 			return null;
430 		}
431 		
432 		return ObjectG.getDObject!(SourceStyleScheme)(cast(GtkSourceStyleScheme*) p);
433 	}
434 
435 	/**
436 	 * Returns the #GtkSourceUndoManager associated with the buffer,
437 	 * see gtk_source_buffer_set_undo_manager().  The returned object should not be
438 	 * unreferenced by the user.
439 	 *
440 	 * Return: the #GtkSourceUndoManager associated
441 	 *     with the buffer, or %NULL.
442 	 */
443 	public SourceUndoManagerIF getUndoManager()
444 	{
445 		auto p = gtk_source_buffer_get_undo_manager(gtkSourceBuffer);
446 		
447 		if(p is null)
448 		{
449 			return null;
450 		}
451 		
452 		return ObjectG.getDObject!(SourceUndoManager, SourceUndoManagerIF)(cast(GtkSourceUndoManager*) p);
453 	}
454 
455 	/**
456 	 * Moves backward to the next toggle (on or off) of the context class. If no
457 	 * matching context class toggles are found, returns %FALSE, otherwise %TRUE.
458 	 * Does not return toggles located at @iter, only toggles after @iter. Sets
459 	 * @iter to the location of the toggle, or to the end of the buffer if no
460 	 * toggle is found.
461 	 *
462 	 * See the #GtkSourceBuffer description for the list of default context classes.
463 	 *
464 	 * Params:
465 	 *     iter = a #GtkTextIter.
466 	 *     contextClass = the context class.
467 	 *
468 	 * Return: whether we found a context class toggle before @iter
469 	 *
470 	 * Since: 2.10
471 	 */
472 	public bool iterBackwardToContextClassToggle(ref TextIter iter, string contextClass)
473 	{
474 		return gtk_source_buffer_iter_backward_to_context_class_toggle(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(contextClass)) != 0;
475 	}
476 
477 	/**
478 	 * Moves forward to the next toggle (on or off) of the context class. If no
479 	 * matching context class toggles are found, returns %FALSE, otherwise %TRUE.
480 	 * Does not return toggles located at @iter, only toggles after @iter. Sets
481 	 * @iter to the location of the toggle, or to the end of the buffer if no
482 	 * toggle is found.
483 	 *
484 	 * See the #GtkSourceBuffer description for the list of default context classes.
485 	 *
486 	 * Params:
487 	 *     iter = a #GtkTextIter.
488 	 *     contextClass = the context class.
489 	 *
490 	 * Return: whether we found a context class toggle after @iter
491 	 *
492 	 * Since: 2.10
493 	 */
494 	public bool iterForwardToContextClassToggle(ref TextIter iter, string contextClass)
495 	{
496 		return gtk_source_buffer_iter_forward_to_context_class_toggle(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(contextClass)) != 0;
497 	}
498 
499 	/**
500 	 * Check if the class @context_class is set on @iter.
501 	 *
502 	 * See the #GtkSourceBuffer description for the list of default context classes.
503 	 *
504 	 * Params:
505 	 *     iter = a #GtkTextIter.
506 	 *     contextClass = class to search for.
507 	 *
508 	 * Return: whether @iter has the context class.
509 	 *
510 	 * Since: 2.10
511 	 */
512 	public bool iterHasContextClass(TextIter iter, string contextClass)
513 	{
514 		return gtk_source_buffer_iter_has_context_class(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(contextClass)) != 0;
515 	}
516 
517 	/**
518 	 * Joins the lines of text between the specified iterators.
519 	 *
520 	 * Params:
521 	 *     start = a #GtkTextIter.
522 	 *     end = a #GtkTextIter.
523 	 *
524 	 * Since: 3.16
525 	 */
526 	public void joinLines(TextIter start, TextIter end)
527 	{
528 		gtk_source_buffer_join_lines(gtkSourceBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct());
529 	}
530 
531 	/**
532 	 * Redoes the last undo operation.  Use gtk_source_buffer_can_redo()
533 	 * to check whether a call to this function will have any effect.
534 	 *
535 	 * This function emits the #GtkSourceBuffer::redo signal.
536 	 */
537 	public void redo()
538 	{
539 		gtk_source_buffer_redo(gtkSourceBuffer);
540 	}
541 
542 	/**
543 	 * Remove all marks of @category between @start and @end from the buffer.
544 	 * If @category is NULL, all marks in the range will be removed.
545 	 *
546 	 * Params:
547 	 *     start = a #GtkTextIter.
548 	 *     end = a #GtkTextIter.
549 	 *     category = category to search for, or %NULL.
550 	 *
551 	 * Since: 2.2
552 	 */
553 	public void removeSourceMarks(TextIter start, TextIter end, string category)
554 	{
555 		gtk_source_buffer_remove_source_marks(gtkSourceBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct(), Str.toStringz(category));
556 	}
557 
558 	/**
559 	 * Controls the bracket match highlighting function in the buffer.  If
560 	 * activated, when you position your cursor over a bracket character
561 	 * (a parenthesis, a square bracket, etc.) the matching opening or
562 	 * closing bracket character will be highlighted.
563 	 *
564 	 * Params:
565 	 *     highlight = %TRUE if you want matching brackets highlighted.
566 	 */
567 	public void setHighlightMatchingBrackets(bool highlight)
568 	{
569 		gtk_source_buffer_set_highlight_matching_brackets(gtkSourceBuffer, highlight);
570 	}
571 
572 	/**
573 	 * Controls whether syntax is highlighted in the buffer. If @highlight
574 	 * is %TRUE, the text will be highlighted according to the syntax
575 	 * patterns specified in the language set with
576 	 * gtk_source_buffer_set_language(). If @highlight is %FALSE, syntax highlighting
577 	 * is disabled and all the GtkTextTag objects that have been added by the
578 	 * syntax highlighting engine are removed from the buffer.
579 	 *
580 	 * Params:
581 	 *     highlight = %TRUE to enable syntax highlighting, %FALSE to disable it.
582 	 */
583 	public void setHighlightSyntax(bool highlight)
584 	{
585 		gtk_source_buffer_set_highlight_syntax(gtkSourceBuffer, highlight);
586 	}
587 
588 	/**
589 	 * Sets whether the @buffer has an implicit trailing newline.
590 	 *
591 	 * If an explicit trailing newline is present in a #GtkTextBuffer, #GtkTextView
592 	 * shows it as an empty line. This is generally not what the user expects.
593 	 *
594 	 * If @implicit_trailing_newline is %TRUE (the default value):
595 	 * - when a #GtkSourceFileLoader loads the content of a file into the @buffer,
596 	 * the trailing newline (if present in the file) is not inserted into the
597 	 * @buffer.
598 	 * - when a #GtkSourceFileSaver saves the content of the @buffer into a file, a
599 	 * trailing newline is added to the file.
600 	 *
601 	 * On the other hand, if @implicit_trailing_newline is %FALSE, the file's
602 	 * content is not modified when loaded into the @buffer, and the @buffer's
603 	 * content is not modified when saved into a file.
604 	 *
605 	 * Params:
606 	 *     implicitTrailingNewline = the new value.
607 	 *
608 	 * Since: 3.14
609 	 */
610 	public void setImplicitTrailingNewline(bool implicitTrailingNewline)
611 	{
612 		gtk_source_buffer_set_implicit_trailing_newline(gtkSourceBuffer, implicitTrailingNewline);
613 	}
614 
615 	/**
616 	 * Associate a #GtkSourceLanguage with the buffer. If @language is
617 	 * not-%NULL and syntax highlighting is enabled (see gtk_source_buffer_set_highlight_syntax()),
618 	 * the syntax patterns defined in @language will be used to highlight the text
619 	 * contained in the buffer. If @language is %NULL, the text contained in the
620 	 * buffer is not highlighted.
621 	 *
622 	 * The buffer holds a reference to @language.
623 	 *
624 	 * Params:
625 	 *     language = a #GtkSourceLanguage to set, or %NULL.
626 	 */
627 	public void setLanguage(SourceLanguage language)
628 	{
629 		gtk_source_buffer_set_language(gtkSourceBuffer, (language is null) ? null : language.getSourceLanguageStruct());
630 	}
631 
632 	/**
633 	 * Sets the number of undo levels for user actions the buffer will
634 	 * track.  If the number of user actions exceeds the limit set by this
635 	 * function, older actions will be discarded.
636 	 *
637 	 * If @max_undo_levels is -1, no limit is set.
638 	 *
639 	 * Params:
640 	 *     maxUndoLevels = the desired maximum number of undo levels.
641 	 */
642 	public void setMaxUndoLevels(int maxUndoLevels)
643 	{
644 		gtk_source_buffer_set_max_undo_levels(gtkSourceBuffer, maxUndoLevels);
645 	}
646 
647 	/**
648 	 * Sets style scheme used by the buffer. If @scheme is %NULL no
649 	 * style scheme is used.
650 	 *
651 	 * Params:
652 	 *     scheme = a #GtkSourceStyleScheme or %NULL.
653 	 */
654 	public void setStyleScheme(SourceStyleScheme scheme)
655 	{
656 		gtk_source_buffer_set_style_scheme(gtkSourceBuffer, (scheme is null) ? null : scheme.getSourceStyleSchemeStruct());
657 	}
658 
659 	/**
660 	 * Set the buffer undo manager. If @manager is %NULL the default undo manager
661 	 * will be set.
662 	 *
663 	 * Params:
664 	 *     manager = A #GtkSourceUndoManager or %NULL.
665 	 */
666 	public void setUndoManager(SourceUndoManagerIF manager)
667 	{
668 		gtk_source_buffer_set_undo_manager(gtkSourceBuffer, (manager is null) ? null : manager.getSourceUndoManagerStruct());
669 	}
670 
671 	/**
672 	 * Undoes the last user action which modified the buffer.  Use
673 	 * gtk_source_buffer_can_undo() to check whether a call to this
674 	 * function will have any effect.
675 	 *
676 	 * This function emits the #GtkSourceBuffer::undo signal.
677 	 */
678 	public void undo()
679 	{
680 		gtk_source_buffer_undo(gtkSourceBuffer);
681 	}
682 
683 	int[string] connectedSignals;
684 
685 	void delegate(TextIter, GtkSourceBracketMatchType, SourceBuffer)[] onBracketMatchedListeners;
686 	/**
687 	 * Sets @iter to a valid iterator pointing to the matching bracket
688 	 * if @state is #GTK_SOURCE_BRACKET_MATCH_FOUND. Otherwise @iter is
689 	 * meaningless.
690 	 *
691 	 * Params:
692 	 *     iter = iterator to initialize.
693 	 *     state = state of bracket matching
694 	 *
695 	 * Since: 2.12
696 	 */
697 	void addOnBracketMatched(void delegate(TextIter, GtkSourceBracketMatchType, SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
698 	{
699 		if ( "bracket-matched" !in connectedSignals )
700 		{
701 			Signals.connectData(
702 				this,
703 				"bracket-matched",
704 				cast(GCallback)&callBackBracketMatched,
705 				cast(void*)this,
706 				null,
707 				connectFlags);
708 			connectedSignals["bracket-matched"] = 1;
709 		}
710 		onBracketMatchedListeners ~= dlg;
711 	}
712 	extern(C) static void callBackBracketMatched(GtkSourceBuffer* sourcebufferStruct, GtkTextIter* iter, GtkSourceBracketMatchType state, SourceBuffer _sourcebuffer)
713 	{
714 		foreach ( void delegate(TextIter, GtkSourceBracketMatchType, SourceBuffer) dlg; _sourcebuffer.onBracketMatchedListeners )
715 		{
716 			dlg(ObjectG.getDObject!(TextIter)(iter), state, _sourcebuffer);
717 		}
718 	}
719 
720 	void delegate(TextIter, TextIter, SourceBuffer)[] onHighlightUpdatedListeners;
721 	/**
722 	 * The ::highlight-updated signal is emitted when the syntax
723 	 * highlighting is updated in a certain region of the @buffer. This
724 	 * signal is useful to be notified when a context class region is
725 	 * updated (e.g. the no-spell-check context class).
726 	 *
727 	 * Params:
728 	 *     start = the start of the updated region
729 	 *     end = the end of the updated region
730 	 */
731 	void addOnHighlightUpdated(void delegate(TextIter, TextIter, SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
732 	{
733 		if ( "highlight-updated" !in connectedSignals )
734 		{
735 			Signals.connectData(
736 				this,
737 				"highlight-updated",
738 				cast(GCallback)&callBackHighlightUpdated,
739 				cast(void*)this,
740 				null,
741 				connectFlags);
742 			connectedSignals["highlight-updated"] = 1;
743 		}
744 		onHighlightUpdatedListeners ~= dlg;
745 	}
746 	extern(C) static void callBackHighlightUpdated(GtkSourceBuffer* sourcebufferStruct, GtkTextIter* start, GtkTextIter* end, SourceBuffer _sourcebuffer)
747 	{
748 		foreach ( void delegate(TextIter, TextIter, SourceBuffer) dlg; _sourcebuffer.onHighlightUpdatedListeners )
749 		{
750 			dlg(ObjectG.getDObject!(TextIter)(start), ObjectG.getDObject!(TextIter)(end), _sourcebuffer);
751 		}
752 	}
753 
754 	void delegate(SourceBuffer)[] onRedoListeners;
755 	/**
756 	 * The ::redo signal is emitted to redo the last undo operation.
757 	 */
758 	void addOnRedo(void delegate(SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
759 	{
760 		if ( "redo" !in connectedSignals )
761 		{
762 			Signals.connectData(
763 				this,
764 				"redo",
765 				cast(GCallback)&callBackRedo,
766 				cast(void*)this,
767 				null,
768 				connectFlags);
769 			connectedSignals["redo"] = 1;
770 		}
771 		onRedoListeners ~= dlg;
772 	}
773 	extern(C) static void callBackRedo(GtkSourceBuffer* sourcebufferStruct, SourceBuffer _sourcebuffer)
774 	{
775 		foreach ( void delegate(SourceBuffer) dlg; _sourcebuffer.onRedoListeners )
776 		{
777 			dlg(_sourcebuffer);
778 		}
779 	}
780 
781 	void delegate(TextMark, SourceBuffer)[] onSourceMarkUpdatedListeners;
782 	/**
783 	 * The ::source_mark_updated signal is emitted each time
784 	 * a mark is added to, moved or removed from the @buffer.
785 	 *
786 	 * Params:
787 	 *     mark = the #GtkSourceMark
788 	 */
789 	void addOnSourceMarkUpdated(void delegate(TextMark, SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
790 	{
791 		if ( "source-mark-updated" !in connectedSignals )
792 		{
793 			Signals.connectData(
794 				this,
795 				"source-mark-updated",
796 				cast(GCallback)&callBackSourceMarkUpdated,
797 				cast(void*)this,
798 				null,
799 				connectFlags);
800 			connectedSignals["source-mark-updated"] = 1;
801 		}
802 		onSourceMarkUpdatedListeners ~= dlg;
803 	}
804 	extern(C) static void callBackSourceMarkUpdated(GtkSourceBuffer* sourcebufferStruct, GtkTextMark* mark, SourceBuffer _sourcebuffer)
805 	{
806 		foreach ( void delegate(TextMark, SourceBuffer) dlg; _sourcebuffer.onSourceMarkUpdatedListeners )
807 		{
808 			dlg(ObjectG.getDObject!(TextMark)(mark), _sourcebuffer);
809 		}
810 	}
811 
812 	void delegate(SourceBuffer)[] onUndoListeners;
813 	/**
814 	 * The ::undo signal is emitted to undo the last user action which
815 	 * modified the buffer.
816 	 */
817 	void addOnUndo(void delegate(SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
818 	{
819 		if ( "undo" !in connectedSignals )
820 		{
821 			Signals.connectData(
822 				this,
823 				"undo",
824 				cast(GCallback)&callBackUndo,
825 				cast(void*)this,
826 				null,
827 				connectFlags);
828 			connectedSignals["undo"] = 1;
829 		}
830 		onUndoListeners ~= dlg;
831 	}
832 	extern(C) static void callBackUndo(GtkSourceBuffer* sourcebufferStruct, SourceBuffer _sourcebuffer)
833 	{
834 		foreach ( void delegate(SourceBuffer) dlg; _sourcebuffer.onUndoListeners )
835 		{
836 			dlg(_sourcebuffer);
837 		}
838 	}
839 }