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