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