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