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 gtk.TextBuffer;
26 
27 private import core.vararg;
28 private import gdk.Clipboard;
29 private import gdk.ContentProvider;
30 private import gdk.PaintableIF;
31 private import glib.ConstructionException;
32 private import glib.MemorySlice;
33 private import glib.Str;
34 private import glib.c.functions;
35 private import gobject.ObjectG;
36 private import gobject.Signals;
37 private import gobject.c.functions;
38 private import gtk.TextChildAnchor;
39 private import gtk.TextIter;
40 private import gtk.TextMark;
41 private import gtk.TextTag;
42 private import gtk.TextTagTable;
43 private import gtk.c.functions;
44 public  import gtk.c.types;
45 private import pango.PgFontDescription;
46 private import pango.PgTabArray;
47 private import std.algorithm;
48 private import std.stdio;
49 
50 
51 /**
52  * Stores text and attributes for display in a `GtkTextView`.
53  * 
54  * You may wish to begin by reading the
55  * [text widget conceptual overview](section-text-widget.html),
56  * which gives an overview of all the objects and data types
57  * related to the text widget and how they work together.
58  */
59 public class TextBuffer : ObjectG
60 {
61 	/** the main Gtk struct */
62 	protected GtkTextBuffer* gtkTextBuffer;
63 
64 	/** Get the main Gtk struct */
65 	public GtkTextBuffer* getTextBufferStruct(bool transferOwnership = false)
66 	{
67 		if (transferOwnership)
68 			ownedRef = false;
69 		return gtkTextBuffer;
70 	}
71 
72 	/** the main Gtk struct as a void* */
73 	protected override void* getStruct()
74 	{
75 		return cast(void*)gtkTextBuffer;
76 	}
77 
78 	/**
79 	 * Sets our main struct and passes it to the parent class.
80 	 */
81 	public this (GtkTextBuffer* gtkTextBuffer, bool ownedRef = false)
82 	{
83 		this.gtkTextBuffer = gtkTextBuffer;
84 		super(cast(GObject*)gtkTextBuffer, ownedRef);
85 	}
86 
87 	/**
88 	 * Inserts text into buffer at iter, applying the list of tags to
89 	 * the newly-inserted text. The last tag specified must be NULL to
90 	 * terminate the list. Equivalent to calling gtk_text_buffer_insert(),
91 	 * then gtk_text_buffer_apply_tag() on the inserted text;
92 	 * gtk_text_buffer_insert_with_tags() is just a convenience function.
93 	 * Params:
94 	 *  iter = an iterator in buffer
95 	 *  text = UTF-8 text
96 	 *  tags = list of tags to apply
97 	 */
98 	public void insertWithTags(TextIter iter, string text, TextTag[] tags ... )
99 	{
100 		int startOffset = iter.getOffset();
101 
102 		insert(iter, text);
103 
104 		if ( tags.length == 0 )
105 			return;
106 
107 		TextIter start = new TextIter();
108 		getIterAtOffset(start, startOffset);
109 
110 		foreach( tag; tags )
111 		{
112 			applyTag(tag, start, iter);
113 		}
114 	}
115 
116 	/**
117 	 * Same as gtk_text_buffer_insert_with_tags(), but allows you
118 	 * to pass in tag names instead of tag objects.
119 	 * Params:
120 	 *  iter = position in buffer
121 	 *  text = UTF-8 text
122 	 *  tags = tag names
123 	 */
124 	public void insertWithTagsByName(TextIter iter, string text, string[] tags ... )
125 	{
126 		int startOffset = iter.getOffset();
127 
128 		insert(iter, text);
129 
130 		if ( tags.length == 0 )
131 			return;
132 
133 		TextIter start = new TextIter();
134 		getIterAtOffset(start, startOffset);
135 
136 		foreach( tag; tags )
137 		{
138 			applyTagByName(tag, start, iter);
139 		}
140 	}
141 
142 	/**
143 	 * Creates a tag and adds it to the tag table for buffer. Equivalent to
144 	 * adding a new tag to the buffer's tag table.
145 	 *
146 	 * If tagName is null, the tag is anonymous.
147 	 *
148 	 * If tagName is non-NULL, a tag called tagName must not already exist
149 	 * in the tag table for this buffer.
150 	 *
151 	 * Params:
152 	 *     tagName = the name for the new tag.
153 	 *     ...     = A list of property names and there values.
154 	 */
155 	TextTag createTag(string tagName, ...)
156 	{
157 		TextTag tag = new TextTag(gtk_text_buffer_create_tag(gtkTextBuffer, Str.toStringz(tagName), null, null));
158 
159 		for (size_t i = 0; i < _arguments.length; i+=2)
160 		{
161 			//TODO: Add a proper eception type for this.
162 			if ( _arguments[i] != typeid(string) )
163 				throw new Exception("TextBuffer.CreateTag: The property name must be a string.");
164 
165 			string name = va_arg!(string)(_argptr);
166 
167 			if ( _arguments[i+1] == typeid(bool) ||
168 				_arguments[i+1] == typeid(int) ||
169 			_arguments[i+1] == typeid(GtkJustification) ||
170 			_arguments[i+1] == typeid(GtkTextDirection) ||
171 			_arguments[i+1] == typeid(GtkWrapMode) ||
172 			_arguments[i+1] == typeid(PangoStretch) ||
173 			_arguments[i+1] == typeid(PangoStyle) ||
174 			_arguments[i+1] == typeid(PangoUnderline) ||
175 			_arguments[i+1] == typeid(PangoVariant) ||
176 			_arguments[i+1] == typeid(PangoWeight) )
177 			{
178 
179 				g_object_set(tag.getObjectGStruct(), Str.toStringz(name), va_arg!(int)(_argptr), null);
180 			}
181 			else if ( _arguments[i+1] == typeid(double) )
182 			{
183 				g_object_set(tag.getObjectGStruct(), Str.toStringz(name), va_arg!(double)(_argptr), null);
184 			}
185 			else if ( _arguments[i+1] == typeid(const(double)) )
186 			{
187 				g_object_set(tag.getObjectGStruct(), Str.toStringz(name), va_arg!(double)(_argptr), null);
188 			}
189 			else if ( _arguments[i+1] == typeid(PgFontDescription) )
190 			{
191 				g_object_set(tag.getObjectGStruct(), Str.toStringz(name), va_arg!(PgFontDescription)(_argptr).getPgFontDescriptionStruct(), null);
192 			}
193 			else if ( _arguments[i+1] == typeid(PgTabArray) )
194 			{
195 				g_object_set(tag.getObjectGStruct(), Str.toStringz(name), va_arg!(PgTabArray)(_argptr).getPgTabArrayStruct(), null);
196 			}
197 			else if ( _arguments[i+1] == typeid(string) )
198 			{
199 				g_object_set(tag.getObjectGStruct(), Str.toStringz(name), Str.toStringz(va_arg!(string)(_argptr)), null);
200 			}
201 			else
202 			{
203 				stderr.writefln("TextBuffer.CreateTag: Unsupported type: \"%s\" for property: \"%s\"", _arguments[i+1], name);
204 
205 				//TODO: throw segfaults, druntime bug?
206 				throw new Exception("TextBuffer.CreateTag: Unsupported type: \""~_arguments[i+1].toString()~"\" for property: \""~name~"\"");
207 			}
208 		}
209 
210 		return tag;
211 	}
212 
213 	/**
214 	 * Obtain the entire text
215 	 * Returns: The text string
216 	 */
217 	string getText()
218 	{
219 		TextIter start = new TextIter();
220 		TextIter end = new TextIter();
221 		getBounds(start,end);
222 		return Str.toString(gtk_text_buffer_get_slice(gtkTextBuffer, start.getTextIterStruct(), end.getTextIterStruct(), true));
223 	}
224 
225 	/**
226 	 */
227 
228 	/** */
229 	public static GType getType()
230 	{
231 		return gtk_text_buffer_get_type();
232 	}
233 
234 	/**
235 	 * Creates a new text buffer.
236 	 *
237 	 * Params:
238 	 *     table = a tag table, or %NULL to create a new one
239 	 *
240 	 * Returns: a new text buffer
241 	 *
242 	 * Throws: ConstructionException GTK+ fails to create the object.
243 	 */
244 	public this(TextTagTable table)
245 	{
246 		auto __p = gtk_text_buffer_new((table is null) ? null : table.getTextTagTableStruct());
247 
248 		if(__p is null)
249 		{
250 			throw new ConstructionException("null returned by new");
251 		}
252 
253 		this(cast(GtkTextBuffer*) __p, true);
254 	}
255 
256 	/**
257 	 * Adds the mark at position @where.
258 	 *
259 	 * The mark must not be added to another buffer, and if its name
260 	 * is not %NULL then there must not be another mark in the buffer
261 	 * with the same name.
262 	 *
263 	 * Emits the `GtkTextBuffer`::mark-set signal as notification of
264 	 * the mark's initial placement.
265 	 *
266 	 * Params:
267 	 *     mark = the mark to add
268 	 *     where = location to place mark
269 	 */
270 	public void addMark(TextMark mark, TextIter where)
271 	{
272 		gtk_text_buffer_add_mark(gtkTextBuffer, (mark is null) ? null : mark.getTextMarkStruct(), (where is null) ? null : where.getTextIterStruct());
273 	}
274 
275 	/**
276 	 * Adds @clipboard to the list of clipboards in which the selection
277 	 * contents of @buffer are available.
278 	 *
279 	 * In most cases, @clipboard will be the `GdkClipboard` returned by
280 	 * [method@Gtk.Widget.get_primary_clipboard] for a view of @buffer.
281 	 *
282 	 * Params:
283 	 *     clipboard = a `GdkClipboard`
284 	 */
285 	public void addSelectionClipboard(Clipboard clipboard)
286 	{
287 		gtk_text_buffer_add_selection_clipboard(gtkTextBuffer, (clipboard is null) ? null : clipboard.getClipboardStruct());
288 	}
289 
290 	/**
291 	 * Emits the “apply-tag” signal on @buffer.
292 	 *
293 	 * The default handler for the signal applies
294 	 * @tag to the given range. @start and @end do
295 	 * not have to be in order.
296 	 *
297 	 * Params:
298 	 *     tag = a `GtkTextTag`
299 	 *     start = one bound of range to be tagged
300 	 *     end = other bound of range to be tagged
301 	 */
302 	public void applyTag(TextTag tag, TextIter start, TextIter end)
303 	{
304 		gtk_text_buffer_apply_tag(gtkTextBuffer, (tag is null) ? null : tag.getTextTagStruct(), (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct());
305 	}
306 
307 	/**
308 	 * Emits the “apply-tag” signal on @buffer.
309 	 *
310 	 * Calls [method@Gtk.TextTagTable.lookup] on the buffer’s
311 	 * tag table to get a `GtkTextTag`, then calls
312 	 * [method@Gtk.TextBuffer.apply_tag].
313 	 *
314 	 * Params:
315 	 *     name = name of a named `GtkTextTag`
316 	 *     start = one bound of range to be tagged
317 	 *     end = other bound of range to be tagged
318 	 */
319 	public void applyTagByName(string name, TextIter start, TextIter end)
320 	{
321 		gtk_text_buffer_apply_tag_by_name(gtkTextBuffer, Str.toStringz(name), (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct());
322 	}
323 
324 	/**
325 	 * Performs the appropriate action as if the user hit the delete
326 	 * key with the cursor at the position specified by @iter.
327 	 *
328 	 * In the normal case a single character will be deleted, but when
329 	 * combining accents are involved, more than one character can
330 	 * be deleted, and when precomposed character and accent combinations
331 	 * are involved, less than one character will be deleted.
332 	 *
333 	 * Because the buffer is modified, all outstanding iterators become
334 	 * invalid after calling this function; however, the @iter will be
335 	 * re-initialized to point to the location where text was deleted.
336 	 *
337 	 * Params:
338 	 *     iter = a position in @buffer
339 	 *     interactive = whether the deletion is caused by user interaction
340 	 *     defaultEditable = whether the buffer is editable by default
341 	 *
342 	 * Returns: %TRUE if the buffer was modified
343 	 */
344 	public bool backspace(TextIter iter, bool interactive, bool defaultEditable)
345 	{
346 		return gtk_text_buffer_backspace(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), interactive, defaultEditable) != 0;
347 	}
348 
349 	/**
350 	 * Denotes the beginning of an action that may not be undone.
351 	 *
352 	 * This will cause any previous operations in the undo/redo queue
353 	 * to be cleared.
354 	 *
355 	 * This should be paired with a call to
356 	 * [method@Gtk.TextBuffer.end_irreversible_action] after the irreversible
357 	 * action has completed.
358 	 *
359 	 * You may nest calls to gtk_text_buffer_begin_irreversible_action() and
360 	 * gtk_text_buffer_end_irreversible_action() pairs.
361 	 */
362 	public void beginIrreversibleAction()
363 	{
364 		gtk_text_buffer_begin_irreversible_action(gtkTextBuffer);
365 	}
366 
367 	/**
368 	 * Called to indicate that the buffer operations between here and a
369 	 * call to gtk_text_buffer_end_user_action() are part of a single
370 	 * user-visible operation.
371 	 *
372 	 * The operations between gtk_text_buffer_begin_user_action() and
373 	 * gtk_text_buffer_end_user_action() can then be grouped when creating
374 	 * an undo stack. `GtkTextBuffer` maintains a count of calls to
375 	 * gtk_text_buffer_begin_user_action() that have not been closed with
376 	 * a call to gtk_text_buffer_end_user_action(), and emits the
377 	 * “begin-user-action” and “end-user-action” signals only for the
378 	 * outermost pair of calls. This allows you to build user actions
379 	 * from other user actions.
380 	 *
381 	 * The “interactive” buffer mutation functions, such as
382 	 * [method@Gtk.TextBuffer.insert_interactive], automatically call
383 	 * begin/end user action around the buffer operations they perform,
384 	 * so there's no need to add extra calls if you user action consists
385 	 * solely of a single call to one of those functions.
386 	 */
387 	public void beginUserAction()
388 	{
389 		gtk_text_buffer_begin_user_action(gtkTextBuffer);
390 	}
391 
392 	/**
393 	 * Copies the currently-selected text to a clipboard.
394 	 *
395 	 * Params:
396 	 *     clipboard = the `GdkClipboard` object to copy to
397 	 */
398 	public void copyClipboard(Clipboard clipboard)
399 	{
400 		gtk_text_buffer_copy_clipboard(gtkTextBuffer, (clipboard is null) ? null : clipboard.getClipboardStruct());
401 	}
402 
403 	/**
404 	 * Creates and inserts a child anchor.
405 	 *
406 	 * This is a convenience function which simply creates a child anchor
407 	 * with [ctor@Gtk.TextChildAnchor.new] and inserts it into the buffer
408 	 * with [method@Gtk.TextBuffer.insert_child_anchor].
409 	 *
410 	 * The new anchor is owned by the buffer; no reference count is
411 	 * returned to the caller of this function.
412 	 *
413 	 * Params:
414 	 *     iter = location in the buffer
415 	 *
416 	 * Returns: the created child anchor
417 	 */
418 	public TextChildAnchor createChildAnchor(TextIter iter)
419 	{
420 		auto __p = gtk_text_buffer_create_child_anchor(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct());
421 
422 		if(__p is null)
423 		{
424 			return null;
425 		}
426 
427 		return ObjectG.getDObject!(TextChildAnchor)(cast(GtkTextChildAnchor*) __p);
428 	}
429 
430 	/**
431 	 * Creates a mark at position @where.
432 	 *
433 	 * If @mark_name is %NULL, the mark is anonymous; otherwise, the mark
434 	 * can be retrieved by name using [method@Gtk.TextBuffer.get_mark].
435 	 * If a mark has left gravity, and text is inserted at the mark’s
436 	 * current location, the mark will be moved to the left of the
437 	 * newly-inserted text. If the mark has right gravity
438 	 * (@left_gravity = %FALSE), the mark will end up on the right of
439 	 * newly-inserted text. The standard left-to-right cursor is a mark
440 	 * with right gravity (when you type, the cursor stays on the right
441 	 * side of the text you’re typing).
442 	 *
443 	 * The caller of this function does not own a
444 	 * reference to the returned #GtkTextMark, so you can ignore the
445 	 * return value if you like. Marks are owned by the buffer and go
446 	 * away when the buffer does.
447 	 *
448 	 * Emits the `GtkTextBuffer`::mark-set signal as notification of
449 	 * the mark's initial placement.
450 	 *
451 	 * Params:
452 	 *     markName = name for mark, or %NULL
453 	 *     where = location to place mark
454 	 *     leftGravity = whether the mark has left gravity
455 	 *
456 	 * Returns: the new #GtkTextMark object
457 	 */
458 	public TextMark createMark(string markName, TextIter where, bool leftGravity)
459 	{
460 		auto __p = gtk_text_buffer_create_mark(gtkTextBuffer, Str.toStringz(markName), (where is null) ? null : where.getTextIterStruct(), leftGravity);
461 
462 		if(__p is null)
463 		{
464 			return null;
465 		}
466 
467 		return ObjectG.getDObject!(TextMark)(cast(GtkTextMark*) __p);
468 	}
469 
470 	/**
471 	 * Copies the currently-selected text to a clipboard,
472 	 * then deletes said text if it’s editable.
473 	 *
474 	 * Params:
475 	 *     clipboard = the `GdkClipboard` object to cut to
476 	 *     defaultEditable = default editability of the buffer
477 	 */
478 	public void cutClipboard(Clipboard clipboard, bool defaultEditable)
479 	{
480 		gtk_text_buffer_cut_clipboard(gtkTextBuffer, (clipboard is null) ? null : clipboard.getClipboardStruct(), defaultEditable);
481 	}
482 
483 	alias delet = delete_;
484 	/**
485 	 * Deletes text between @start and @end.
486 	 *
487 	 * The order of @start and @end is not actually relevant;
488 	 * gtk_text_buffer_delete() will reorder them.
489 	 *
490 	 * This function actually emits the “delete-range” signal, and
491 	 * the default handler of that signal deletes the text. Because the
492 	 * buffer is modified, all outstanding iterators become invalid after
493 	 * calling this function; however, the @start and @end will be
494 	 * re-initialized to point to the location where text was deleted.
495 	 *
496 	 * Params:
497 	 *     start = a position in @buffer
498 	 *     end = another position in @buffer
499 	 */
500 	public void delete_(TextIter start, TextIter end)
501 	{
502 		gtk_text_buffer_delete(gtkTextBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct());
503 	}
504 
505 	/**
506 	 * Deletes all editable text in the given range.
507 	 *
508 	 * Calls [method@Gtk.TextBuffer.delete] for each editable
509 	 * sub-range of [@start,@end). @start and @end are revalidated
510 	 * to point to the location of the last deleted range, or left
511 	 * untouched if no text was deleted.
512 	 *
513 	 * Params:
514 	 *     startIter = start of range to delete
515 	 *     endIter = end of range
516 	 *     defaultEditable = whether the buffer is editable by default
517 	 *
518 	 * Returns: whether some text was actually deleted
519 	 */
520 	public bool deleteInteractive(TextIter startIter, TextIter endIter, bool defaultEditable)
521 	{
522 		return gtk_text_buffer_delete_interactive(gtkTextBuffer, (startIter is null) ? null : startIter.getTextIterStruct(), (endIter is null) ? null : endIter.getTextIterStruct(), defaultEditable) != 0;
523 	}
524 
525 	/**
526 	 * Deletes @mark, so that it’s no longer located anywhere in the
527 	 * buffer.
528 	 *
529 	 * Removes the reference the buffer holds to the mark, so if
530 	 * you haven’t called g_object_ref() on the mark, it will be freed.
531 	 * Even if the mark isn’t freed, most operations on @mark become
532 	 * invalid, until it gets added to a buffer again with
533 	 * [method@Gtk.TextBuffer.add_mark]. Use [method@Gtk.TextMark.get_deleted]
534 	 * to find out if a mark has been removed from its buffer.
535 	 *
536 	 * The [signal@Gtk.TextBuffer::mark-deleted] signal will be emitted as
537 	 * notification after the mark is deleted.
538 	 *
539 	 * Params:
540 	 *     mark = a `GtkTextMark` in @buffer
541 	 */
542 	public void deleteMark(TextMark mark)
543 	{
544 		gtk_text_buffer_delete_mark(gtkTextBuffer, (mark is null) ? null : mark.getTextMarkStruct());
545 	}
546 
547 	/**
548 	 * Deletes the mark named @name; the mark must exist.
549 	 *
550 	 * See [method@Gtk.TextBuffer.delete_mark] for details.
551 	 *
552 	 * Params:
553 	 *     name = name of a mark in @buffer
554 	 */
555 	public void deleteMarkByName(string name)
556 	{
557 		gtk_text_buffer_delete_mark_by_name(gtkTextBuffer, Str.toStringz(name));
558 	}
559 
560 	/**
561 	 * Deletes the range between the “insert” and “selection_bound” marks,
562 	 * that is, the currently-selected text.
563 	 *
564 	 * If @interactive is %TRUE, the editability of the selection will be
565 	 * considered (users can’t delete uneditable text).
566 	 *
567 	 * Params:
568 	 *     interactive = whether the deletion is caused by user interaction
569 	 *     defaultEditable = whether the buffer is editable by default
570 	 *
571 	 * Returns: whether there was a non-empty selection to delete
572 	 */
573 	public bool deleteSelection(bool interactive, bool defaultEditable)
574 	{
575 		return gtk_text_buffer_delete_selection(gtkTextBuffer, interactive, defaultEditable) != 0;
576 	}
577 
578 	/**
579 	 * Denotes the end of an action that may not be undone.
580 	 *
581 	 * This will cause any previous operations in the undo/redo
582 	 * queue to be cleared.
583 	 *
584 	 * This should be called after completing modifications to the
585 	 * text buffer after gtk_text_buffer_begin_irreversible_action()
586 	 * was called.
587 	 *
588 	 * You may nest calls to gtk_text_buffer_begin_irreversible_action() and
589 	 * gtk_text_buffer_end_irreversible_action() pairs.
590 	 */
591 	public void endIrreversibleAction()
592 	{
593 		gtk_text_buffer_end_irreversible_action(gtkTextBuffer);
594 	}
595 
596 	/**
597 	 * Ends a user-visible operation.
598 	 *
599 	 * Should be paired with a call to
600 	 * [method@Gtk.TextBuffer.begin_user_action].
601 	 * See that function for a full explanation.
602 	 */
603 	public void endUserAction()
604 	{
605 		gtk_text_buffer_end_user_action(gtkTextBuffer);
606 	}
607 
608 	/**
609 	 * Retrieves the first and last iterators in the buffer, i.e. the
610 	 * entire buffer lies within the range [@start,@end).
611 	 *
612 	 * Params:
613 	 *     start = iterator to initialize with first position in the buffer
614 	 *     end = iterator to initialize with the end iterator
615 	 */
616 	public void getBounds(out TextIter start, out TextIter end)
617 	{
618 		GtkTextIter* outstart = sliceNew!GtkTextIter();
619 		GtkTextIter* outend = sliceNew!GtkTextIter();
620 
621 		gtk_text_buffer_get_bounds(gtkTextBuffer, outstart, outend);
622 
623 		start = ObjectG.getDObject!(TextIter)(outstart, true);
624 		end = ObjectG.getDObject!(TextIter)(outend, true);
625 	}
626 
627 	/**
628 	 * Gets whether there is a redoable action in the history.
629 	 *
630 	 * Returns: %TRUE if there is an redoable action
631 	 */
632 	public bool getCanRedo()
633 	{
634 		return gtk_text_buffer_get_can_redo(gtkTextBuffer) != 0;
635 	}
636 
637 	/**
638 	 * Gets whether there is an undoable action in the history.
639 	 *
640 	 * Returns: %TRUE if there is an undoable action
641 	 */
642 	public bool getCanUndo()
643 	{
644 		return gtk_text_buffer_get_can_undo(gtkTextBuffer) != 0;
645 	}
646 
647 	/**
648 	 * Gets the number of characters in the buffer.
649 	 *
650 	 * Note that characters and bytes are not the same, you can’t e.g.
651 	 * expect the contents of the buffer in string form to be this
652 	 * many bytes long.
653 	 *
654 	 * The character count is cached, so this function is very fast.
655 	 *
656 	 * Returns: number of characters in the buffer
657 	 */
658 	public int getCharCount()
659 	{
660 		return gtk_text_buffer_get_char_count(gtkTextBuffer);
661 	}
662 
663 	/**
664 	 * Gets whether the buffer is saving modifications to the buffer
665 	 * to allow for undo and redo actions.
666 	 *
667 	 * See [method@Gtk.TextBuffer.begin_irreversible_action] and
668 	 * [method@Gtk.TextBuffer.end_irreversible_action] to create
669 	 * changes to the buffer that cannot be undone.
670 	 */
671 	public bool getEnableUndo()
672 	{
673 		return gtk_text_buffer_get_enable_undo(gtkTextBuffer) != 0;
674 	}
675 
676 	/**
677 	 * Initializes @iter with the “end iterator,” one past the last valid
678 	 * character in the text buffer.
679 	 *
680 	 * If dereferenced with [method@Gtk.TextIter.get_char], the end
681 	 * iterator has a character value of 0.
682 	 * The entire buffer lies in the range from the first position in
683 	 * the buffer (call [method@Gtk.TextBuffer.get_start_iter] to get
684 	 * character position 0) to the end iterator.
685 	 *
686 	 * Params:
687 	 *     iter = iterator to initialize
688 	 */
689 	public void getEndIter(out TextIter iter)
690 	{
691 		GtkTextIter* outiter = sliceNew!GtkTextIter();
692 
693 		gtk_text_buffer_get_end_iter(gtkTextBuffer, outiter);
694 
695 		iter = ObjectG.getDObject!(TextIter)(outiter, true);
696 	}
697 
698 	/**
699 	 * Indicates whether the buffer has some text currently selected.
700 	 *
701 	 * Returns: %TRUE if the there is text selected
702 	 */
703 	public bool getHasSelection()
704 	{
705 		return gtk_text_buffer_get_has_selection(gtkTextBuffer) != 0;
706 	}
707 
708 	/**
709 	 * Returns the mark that represents the cursor (insertion point).
710 	 *
711 	 * Equivalent to calling [method@Gtk.TextBuffer.get_mark]
712 	 * to get the mark named “insert”, but very slightly more
713 	 * efficient, and involves less typing.
714 	 *
715 	 * Returns: insertion point mark
716 	 */
717 	public TextMark getInsert()
718 	{
719 		auto __p = gtk_text_buffer_get_insert(gtkTextBuffer);
720 
721 		if(__p is null)
722 		{
723 			return null;
724 		}
725 
726 		return ObjectG.getDObject!(TextMark)(cast(GtkTextMark*) __p);
727 	}
728 
729 	/**
730 	 * Obtains the location of @anchor within @buffer.
731 	 *
732 	 * Params:
733 	 *     iter = an iterator to be initialized
734 	 *     anchor = a child anchor that appears in @buffer
735 	 */
736 	public void getIterAtChildAnchor(out TextIter iter, TextChildAnchor anchor)
737 	{
738 		GtkTextIter* outiter = sliceNew!GtkTextIter();
739 
740 		gtk_text_buffer_get_iter_at_child_anchor(gtkTextBuffer, outiter, (anchor is null) ? null : anchor.getTextChildAnchorStruct());
741 
742 		iter = ObjectG.getDObject!(TextIter)(outiter, true);
743 	}
744 
745 	/**
746 	 * Initializes @iter to the start of the given line.
747 	 *
748 	 * If @line_number is greater than or equal to the number of lines
749 	 * in the @buffer, the end iterator is returned.
750 	 *
751 	 * Params:
752 	 *     iter = iterator to initialize
753 	 *     lineNumber = line number counting from 0
754 	 *
755 	 * Returns: whether the exact position has been found
756 	 */
757 	public bool getIterAtLine(out TextIter iter, int lineNumber)
758 	{
759 		GtkTextIter* outiter = sliceNew!GtkTextIter();
760 
761 		auto __p = gtk_text_buffer_get_iter_at_line(gtkTextBuffer, outiter, lineNumber) != 0;
762 
763 		iter = ObjectG.getDObject!(TextIter)(outiter, true);
764 
765 		return __p;
766 	}
767 
768 	/**
769 	 * Obtains an iterator pointing to @byte_index within the given line.
770 	 *
771 	 * @byte_index must be the start of a UTF-8 character. Note bytes, not
772 	 * characters; UTF-8 may encode one character as multiple bytes.
773 	 *
774 	 * If @line_number is greater than or equal to the number of lines in the @buffer,
775 	 * the end iterator is returned. And if @byte_index is off the
776 	 * end of the line, the iterator at the end of the line is returned.
777 	 *
778 	 * Params:
779 	 *     iter = iterator to initialize
780 	 *     lineNumber = line number counting from 0
781 	 *     byteIndex = byte index from start of line
782 	 *
783 	 * Returns: whether the exact position has been found
784 	 */
785 	public bool getIterAtLineIndex(out TextIter iter, int lineNumber, int byteIndex)
786 	{
787 		GtkTextIter* outiter = sliceNew!GtkTextIter();
788 
789 		auto __p = gtk_text_buffer_get_iter_at_line_index(gtkTextBuffer, outiter, lineNumber, byteIndex) != 0;
790 
791 		iter = ObjectG.getDObject!(TextIter)(outiter, true);
792 
793 		return __p;
794 	}
795 
796 	/**
797 	 * Obtains an iterator pointing to @char_offset within the given line.
798 	 *
799 	 * Note characters, not bytes; UTF-8 may encode one character as multiple
800 	 * bytes.
801 	 *
802 	 * If @line_number is greater than or equal to the number of lines in the @buffer,
803 	 * the end iterator is returned. And if @char_offset is off the
804 	 * end of the line, the iterator at the end of the line is returned.
805 	 *
806 	 * Params:
807 	 *     iter = iterator to initialize
808 	 *     lineNumber = line number counting from 0
809 	 *     charOffset = char offset from start of line
810 	 *
811 	 * Returns: whether the exact position has been found
812 	 */
813 	public bool getIterAtLineOffset(out TextIter iter, int lineNumber, int charOffset)
814 	{
815 		GtkTextIter* outiter = sliceNew!GtkTextIter();
816 
817 		auto __p = gtk_text_buffer_get_iter_at_line_offset(gtkTextBuffer, outiter, lineNumber, charOffset) != 0;
818 
819 		iter = ObjectG.getDObject!(TextIter)(outiter, true);
820 
821 		return __p;
822 	}
823 
824 	/**
825 	 * Initializes @iter with the current position of @mark.
826 	 *
827 	 * Params:
828 	 *     iter = iterator to initialize
829 	 *     mark = a `GtkTextMark` in @buffer
830 	 */
831 	public void getIterAtMark(out TextIter iter, TextMark mark)
832 	{
833 		GtkTextIter* outiter = sliceNew!GtkTextIter();
834 
835 		gtk_text_buffer_get_iter_at_mark(gtkTextBuffer, outiter, (mark is null) ? null : mark.getTextMarkStruct());
836 
837 		iter = ObjectG.getDObject!(TextIter)(outiter, true);
838 	}
839 
840 	/**
841 	 * Initializes @iter to a position @char_offset chars from the start
842 	 * of the entire buffer.
843 	 *
844 	 * If @char_offset is -1 or greater than the number
845 	 * of characters in the buffer, @iter is initialized to the end iterator,
846 	 * the iterator one past the last valid character in the buffer.
847 	 *
848 	 * Params:
849 	 *     iter = iterator to initialize
850 	 *     charOffset = char offset from start of buffer, counting from 0, or -1
851 	 */
852 	public void getIterAtOffset(out TextIter iter, int charOffset)
853 	{
854 		GtkTextIter* outiter = sliceNew!GtkTextIter();
855 
856 		gtk_text_buffer_get_iter_at_offset(gtkTextBuffer, outiter, charOffset);
857 
858 		iter = ObjectG.getDObject!(TextIter)(outiter, true);
859 	}
860 
861 	/**
862 	 * Obtains the number of lines in the buffer.
863 	 *
864 	 * This value is cached, so the function is very fast.
865 	 *
866 	 * Returns: number of lines in the buffer
867 	 */
868 	public int getLineCount()
869 	{
870 		return gtk_text_buffer_get_line_count(gtkTextBuffer);
871 	}
872 
873 	/**
874 	 * Returns the mark named @name in buffer @buffer, or %NULL if no such
875 	 * mark exists in the buffer.
876 	 *
877 	 * Params:
878 	 *     name = a mark name
879 	 *
880 	 * Returns: a #GtkTextMark, or %NULL
881 	 */
882 	public TextMark getMark(string name)
883 	{
884 		auto __p = gtk_text_buffer_get_mark(gtkTextBuffer, Str.toStringz(name));
885 
886 		if(__p is null)
887 		{
888 			return null;
889 		}
890 
891 		return ObjectG.getDObject!(TextMark)(cast(GtkTextMark*) __p);
892 	}
893 
894 	/**
895 	 * Gets the maximum number of undo levels to perform.
896 	 *
897 	 * If 0, unlimited undo actions may be performed. Note that this may
898 	 * have a memory usage impact as it requires storing an additional
899 	 * copy of the inserted or removed text within the text buffer.
900 	 */
901 	public uint getMaxUndoLevels()
902 	{
903 		return gtk_text_buffer_get_max_undo_levels(gtkTextBuffer);
904 	}
905 
906 	/**
907 	 * Indicates whether the buffer has been modified since the last call
908 	 * to [method@Gtk.TextBuffer.set_modified] set the modification flag to
909 	 * %FALSE.
910 	 *
911 	 * Used for example to enable a “save” function in a text editor.
912 	 *
913 	 * Returns: %TRUE if the buffer has been modified
914 	 */
915 	public bool getModified()
916 	{
917 		return gtk_text_buffer_get_modified(gtkTextBuffer) != 0;
918 	}
919 
920 	/**
921 	 * Returns the mark that represents the selection bound.
922 	 *
923 	 * Equivalent to calling [method@Gtk.TextBuffer.get_mark]
924 	 * to get the mark named “selection_bound”, but very slightly
925 	 * more efficient, and involves less typing.
926 	 *
927 	 * The currently-selected text in @buffer is the region between the
928 	 * “selection_bound” and “insert” marks. If “selection_bound” and
929 	 * “insert” are in the same place, then there is no current selection.
930 	 * [method@Gtk.TextBuffer.get_selection_bounds] is another convenient
931 	 * function for handling the selection, if you just want to know whether
932 	 * there’s a selection and what its bounds are.
933 	 *
934 	 * Returns: selection bound mark
935 	 */
936 	public TextMark getSelectionBound()
937 	{
938 		auto __p = gtk_text_buffer_get_selection_bound(gtkTextBuffer);
939 
940 		if(__p is null)
941 		{
942 			return null;
943 		}
944 
945 		return ObjectG.getDObject!(TextMark)(cast(GtkTextMark*) __p);
946 	}
947 
948 	/**
949 	 * Returns %TRUE if some text is selected; places the bounds
950 	 * of the selection in @start and @end.
951 	 *
952 	 * If the selection has length 0, then @start and @end are filled
953 	 * in with the same value. @start and @end will be in ascending order.
954 	 * If @start and @end are %NULL, then they are not filled in, but the
955 	 * return value still indicates whether text is selected.
956 	 *
957 	 * Params:
958 	 *     start = iterator to initialize with selection start
959 	 *     end = iterator to initialize with selection end
960 	 *
961 	 * Returns: whether the selection has nonzero length
962 	 */
963 	public bool getSelectionBounds(out TextIter start, out TextIter end)
964 	{
965 		GtkTextIter* outstart = sliceNew!GtkTextIter();
966 		GtkTextIter* outend = sliceNew!GtkTextIter();
967 
968 		auto __p = gtk_text_buffer_get_selection_bounds(gtkTextBuffer, outstart, outend) != 0;
969 
970 		start = ObjectG.getDObject!(TextIter)(outstart, true);
971 		end = ObjectG.getDObject!(TextIter)(outend, true);
972 
973 		return __p;
974 	}
975 
976 	/**
977 	 * Get a content provider for this buffer.
978 	 *
979 	 * It can be used to make the content of @buffer available
980 	 * in a `GdkClipboard`, see [method@Gdk.Clipboard.set_content].
981 	 *
982 	 * Returns: a new `GdkContentProvider`.
983 	 */
984 	public ContentProvider getSelectionContent()
985 	{
986 		auto __p = gtk_text_buffer_get_selection_content(gtkTextBuffer);
987 
988 		if(__p is null)
989 		{
990 			return null;
991 		}
992 
993 		return ObjectG.getDObject!(ContentProvider)(cast(GdkContentProvider*) __p, true);
994 	}
995 
996 	/**
997 	 * Returns the text in the range [@start,@end).
998 	 *
999 	 * Excludes undisplayed text (text marked with tags that set the
1000 	 * invisibility attribute) if @include_hidden_chars is %FALSE.
1001 	 * The returned string includes a 0xFFFC character whenever the
1002 	 * buffer contains embedded images, so byte and character indexes
1003 	 * into the returned string do correspond to byte and character
1004 	 * indexes into the buffer. Contrast with [method@Gtk.TextBuffer.get_text].
1005 	 * Note that 0xFFFC can occur in normal text as well, so it is not a
1006 	 * reliable indicator that a paintable or widget is in the buffer.
1007 	 *
1008 	 * Params:
1009 	 *     start = start of a range
1010 	 *     end = end of a range
1011 	 *     includeHiddenChars = whether to include invisible text
1012 	 *
1013 	 * Returns: an allocated UTF-8 string
1014 	 */
1015 	public string getSlice(TextIter start, TextIter end, bool includeHiddenChars)
1016 	{
1017 		auto retStr = gtk_text_buffer_get_slice(gtkTextBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct(), includeHiddenChars);
1018 
1019 		scope(exit) Str.freeString(retStr);
1020 		return Str.toString(retStr);
1021 	}
1022 
1023 	/**
1024 	 * Initialized @iter with the first position in the text buffer.
1025 	 *
1026 	 * This is the same as using [method@Gtk.TextBuffer.get_iter_at_offset]
1027 	 * to get the iter at character offset 0.
1028 	 *
1029 	 * Params:
1030 	 *     iter = iterator to initialize
1031 	 */
1032 	public void getStartIter(out TextIter iter)
1033 	{
1034 		GtkTextIter* outiter = sliceNew!GtkTextIter();
1035 
1036 		gtk_text_buffer_get_start_iter(gtkTextBuffer, outiter);
1037 
1038 		iter = ObjectG.getDObject!(TextIter)(outiter, true);
1039 	}
1040 
1041 	/**
1042 	 * Get the `GtkTextTagTable` associated with this buffer.
1043 	 *
1044 	 * Returns: the buffer’s tag table
1045 	 */
1046 	public TextTagTable getTagTable()
1047 	{
1048 		auto __p = gtk_text_buffer_get_tag_table(gtkTextBuffer);
1049 
1050 		if(__p is null)
1051 		{
1052 			return null;
1053 		}
1054 
1055 		return ObjectG.getDObject!(TextTagTable)(cast(GtkTextTagTable*) __p);
1056 	}
1057 
1058 	/**
1059 	 * Returns the text in the range [@start,@end).
1060 	 *
1061 	 * Excludes undisplayed text (text marked with tags that set the
1062 	 * invisibility attribute) if @include_hidden_chars is %FALSE.
1063 	 * Does not include characters representing embedded images, so
1064 	 * byte and character indexes into the returned string do not
1065 	 * correspond to byte and character indexes into the buffer.
1066 	 * Contrast with [method@Gtk.TextBuffer.get_slice].
1067 	 *
1068 	 * Params:
1069 	 *     start = start of a range
1070 	 *     end = end of a range
1071 	 *     includeHiddenChars = whether to include invisible text
1072 	 *
1073 	 * Returns: an allocated UTF-8 string
1074 	 */
1075 	public string getText(TextIter start, TextIter end, bool includeHiddenChars)
1076 	{
1077 		auto retStr = gtk_text_buffer_get_text(gtkTextBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct(), includeHiddenChars);
1078 
1079 		scope(exit) Str.freeString(retStr);
1080 		return Str.toString(retStr);
1081 	}
1082 
1083 	/**
1084 	 * Inserts @len bytes of @text at position @iter.
1085 	 *
1086 	 * If @len is -1, @text must be nul-terminated and will be inserted in its
1087 	 * entirety. Emits the “insert-text” signal; insertion actually occurs
1088 	 * in the default handler for the signal. @iter is invalidated when
1089 	 * insertion occurs (because the buffer contents change), but the
1090 	 * default signal handler revalidates it to point to the end of the
1091 	 * inserted text.
1092 	 *
1093 	 * Params:
1094 	 *     iter = a position in the buffer
1095 	 *     text = text in UTF-8 format
1096 	 */
1097 	public void insert(TextIter iter, string text)
1098 	{
1099 		gtk_text_buffer_insert(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(text), cast(int)text.length);
1100 	}
1101 
1102 	/**
1103 	 * Inserts @text in @buffer.
1104 	 *
1105 	 * Simply calls [method@Gtk.TextBuffer.insert],
1106 	 * using the current cursor position as the insertion point.
1107 	 *
1108 	 * Params:
1109 	 *     text = text in UTF-8 format
1110 	 */
1111 	public void insertAtCursor(string text)
1112 	{
1113 		gtk_text_buffer_insert_at_cursor(gtkTextBuffer, Str.toStringz(text), cast(int)text.length);
1114 	}
1115 
1116 	/**
1117 	 * Inserts a child widget anchor into the text buffer at @iter.
1118 	 *
1119 	 * The anchor will be counted as one character in character counts, and
1120 	 * when obtaining the buffer contents as a string, will be represented
1121 	 * by the Unicode “object replacement character” 0xFFFC. Note that the
1122 	 * “slice” variants for obtaining portions of the buffer as a string
1123 	 * include this character for child anchors, but the “text” variants do
1124 	 * not. E.g. see [method@Gtk.TextBuffer.get_slice] and
1125 	 * [method@Gtk.TextBuffer.get_text].
1126 	 *
1127 	 * Consider [method@Gtk.TextBuffer.create_child_anchor] as a more
1128 	 * convenient alternative to this function. The buffer will add a
1129 	 * reference to the anchor, so you can unref it after insertion.
1130 	 *
1131 	 * Params:
1132 	 *     iter = location to insert the anchor
1133 	 *     anchor = a `GtkTextChildAnchor`
1134 	 */
1135 	public void insertChildAnchor(TextIter iter, TextChildAnchor anchor)
1136 	{
1137 		gtk_text_buffer_insert_child_anchor(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), (anchor is null) ? null : anchor.getTextChildAnchorStruct());
1138 	}
1139 
1140 	/**
1141 	 * Inserts @text in @buffer.
1142 	 *
1143 	 * Like [method@Gtk.TextBuffer.insert], but the insertion will not occur
1144 	 * if @iter is at a non-editable location in the buffer. Usually you
1145 	 * want to prevent insertions at ineditable locations if the insertion
1146 	 * results from a user action (is interactive).
1147 	 *
1148 	 * @default_editable indicates the editability of text that doesn't
1149 	 * have a tag affecting editability applied to it. Typically the
1150 	 * result of [method@Gtk.TextView.get_editable] is appropriate here.
1151 	 *
1152 	 * Params:
1153 	 *     iter = a position in @buffer
1154 	 *     text = some UTF-8 text
1155 	 *     defaultEditable = default editability of buffer
1156 	 *
1157 	 * Returns: whether text was actually inserted
1158 	 */
1159 	public bool insertInteractive(TextIter iter, string text, bool defaultEditable)
1160 	{
1161 		return gtk_text_buffer_insert_interactive(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(text), cast(int)text.length, defaultEditable) != 0;
1162 	}
1163 
1164 	/**
1165 	 * Inserts @text in @buffer.
1166 	 *
1167 	 * Calls [method@Gtk.TextBuffer.insert_interactive]
1168 	 * at the cursor position.
1169 	 *
1170 	 * @default_editable indicates the editability of text that doesn't
1171 	 * have a tag affecting editability applied to it. Typically the
1172 	 * result of [method@Gtk.TextView.get_editable] is appropriate here.
1173 	 *
1174 	 * Params:
1175 	 *     text = text in UTF-8 format
1176 	 *     defaultEditable = default editability of buffer
1177 	 *
1178 	 * Returns: whether text was actually inserted
1179 	 */
1180 	public bool insertInteractiveAtCursor(string text, bool defaultEditable)
1181 	{
1182 		return gtk_text_buffer_insert_interactive_at_cursor(gtkTextBuffer, Str.toStringz(text), cast(int)text.length, defaultEditable) != 0;
1183 	}
1184 
1185 	/**
1186 	 * Inserts the text in @markup at position @iter.
1187 	 *
1188 	 * @markup will be inserted in its entirety and must be nul-terminated
1189 	 * and valid UTF-8. Emits the [signal@Gtk.TextBuffer::insert-text] signal,
1190 	 * possibly multiple times; insertion actually occurs in the default handler
1191 	 * for the signal. @iter will point to the end of the inserted text on return.
1192 	 *
1193 	 * Params:
1194 	 *     iter = location to insert the markup
1195 	 *     markup = a nul-terminated UTF-8 string containing Pango markup
1196 	 *     len = length of @markup in bytes, or -1
1197 	 */
1198 	public void insertMarkup(TextIter iter, string markup, int len)
1199 	{
1200 		gtk_text_buffer_insert_markup(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(markup), len);
1201 	}
1202 
1203 	/**
1204 	 * Inserts an image into the text buffer at @iter.
1205 	 *
1206 	 * The image will be counted as one character in character counts,
1207 	 * and when obtaining the buffer contents as a string, will be
1208 	 * represented by the Unicode “object replacement character” 0xFFFC.
1209 	 * Note that the “slice” variants for obtaining portions of the buffer
1210 	 * as a string include this character for paintable, but the “text”
1211 	 * variants do not. e.g. see [method@Gtk.TextBuffer.get_slice] and
1212 	 * [method@Gtk.TextBuffer.get_text].
1213 	 *
1214 	 * Params:
1215 	 *     iter = location to insert the paintable
1216 	 *     paintable = a `GdkPaintable`
1217 	 */
1218 	public void insertPaintable(TextIter iter, PaintableIF paintable)
1219 	{
1220 		gtk_text_buffer_insert_paintable(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), (paintable is null) ? null : paintable.getPaintableStruct());
1221 	}
1222 
1223 	/**
1224 	 * Copies text, tags, and paintables between @start and @end
1225 	 * and inserts the copy at @iter.
1226 	 *
1227 	 * The order of @start and @end doesn’t matter.
1228 	 *
1229 	 * Used instead of simply getting/inserting text because it preserves
1230 	 * images and tags. If @start and @end are in a different buffer from
1231 	 * @buffer, the two buffers must share the same tag table.
1232 	 *
1233 	 * Implemented via emissions of the insert_text and apply_tag signals,
1234 	 * so expect those.
1235 	 *
1236 	 * Params:
1237 	 *     iter = a position in @buffer
1238 	 *     start = a position in a `GtkTextBuffer`
1239 	 *     end = another position in the same buffer as @start
1240 	 */
1241 	public void insertRange(TextIter iter, TextIter start, TextIter end)
1242 	{
1243 		gtk_text_buffer_insert_range(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct());
1244 	}
1245 
1246 	/**
1247 	 * Copies text, tags, and paintables between @start and @end
1248 	 * and inserts the copy at @iter.
1249 	 *
1250 	 * Same as [method@Gtk.TextBuffer.insert_range], but does nothing
1251 	 * if the insertion point isn’t editable. The @default_editable
1252 	 * parameter indicates whether the text is editable at @iter if
1253 	 * no tags enclosing @iter affect editability. Typically the result
1254 	 * of [method@Gtk.TextView.get_editable] is appropriate here.
1255 	 *
1256 	 * Params:
1257 	 *     iter = a position in @buffer
1258 	 *     start = a position in a `GtkTextBuffer`
1259 	 *     end = another position in the same buffer as @start
1260 	 *     defaultEditable = default editability of the buffer
1261 	 *
1262 	 * Returns: whether an insertion was possible at @iter
1263 	 */
1264 	public bool insertRangeInteractive(TextIter iter, TextIter start, TextIter end, bool defaultEditable)
1265 	{
1266 		return gtk_text_buffer_insert_range_interactive(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct(), defaultEditable) != 0;
1267 	}
1268 
1269 	/**
1270 	 * Moves @mark to the new location @where.
1271 	 *
1272 	 * Emits the `GtkTextBuffer`::mark-set
1273 	 * signal as notification of the move.
1274 	 *
1275 	 * Params:
1276 	 *     mark = a `GtkTextMark`
1277 	 *     where = new location for @mark in @buffer
1278 	 */
1279 	public void moveMark(TextMark mark, TextIter where)
1280 	{
1281 		gtk_text_buffer_move_mark(gtkTextBuffer, (mark is null) ? null : mark.getTextMarkStruct(), (where is null) ? null : where.getTextIterStruct());
1282 	}
1283 
1284 	/**
1285 	 * Moves the mark named @name (which must exist) to location @where.
1286 	 *
1287 	 * See [method@Gtk.TextBuffer.move_mark] for details.
1288 	 *
1289 	 * Params:
1290 	 *     name = name of a mark
1291 	 *     where = new location for mark
1292 	 */
1293 	public void moveMarkByName(string name, TextIter where)
1294 	{
1295 		gtk_text_buffer_move_mark_by_name(gtkTextBuffer, Str.toStringz(name), (where is null) ? null : where.getTextIterStruct());
1296 	}
1297 
1298 	/**
1299 	 * Pastes the contents of a clipboard.
1300 	 *
1301 	 * If @override_location is %NULL, the pasted text will be inserted
1302 	 * at the cursor position, or the buffer selection will be replaced
1303 	 * if the selection is non-empty.
1304 	 *
1305 	 * Note: pasting is asynchronous, that is, we’ll ask for the paste data
1306 	 * and return, and at some point later after the main loop runs, the paste
1307 	 * data will be inserted.
1308 	 *
1309 	 * Params:
1310 	 *     clipboard = the `GdkClipboard` to paste from
1311 	 *     overrideLocation = location to insert pasted text, or %NULL
1312 	 *     defaultEditable = whether the buffer is editable by default
1313 	 */
1314 	public void pasteClipboard(Clipboard clipboard, TextIter overrideLocation, bool defaultEditable)
1315 	{
1316 		gtk_text_buffer_paste_clipboard(gtkTextBuffer, (clipboard is null) ? null : clipboard.getClipboardStruct(), (overrideLocation is null) ? null : overrideLocation.getTextIterStruct(), defaultEditable);
1317 	}
1318 
1319 	/**
1320 	 * This function moves the “insert” and “selection_bound” marks
1321 	 * simultaneously.
1322 	 *
1323 	 * If you move them to the same place in two steps with
1324 	 * [method@Gtk.TextBuffer.move_mark], you will temporarily select a
1325 	 * region in between their old and new locations, which can be pretty
1326 	 * inefficient since the temporarily-selected region will force stuff
1327 	 * to be recalculated. This function moves them as a unit, which can
1328 	 * be optimized.
1329 	 *
1330 	 * Params:
1331 	 *     where = where to put the cursor
1332 	 */
1333 	public void placeCursor(TextIter where)
1334 	{
1335 		gtk_text_buffer_place_cursor(gtkTextBuffer, (where is null) ? null : where.getTextIterStruct());
1336 	}
1337 
1338 	/**
1339 	 * Redoes the next redoable action on the buffer, if there is one.
1340 	 */
1341 	public void redo()
1342 	{
1343 		gtk_text_buffer_redo(gtkTextBuffer);
1344 	}
1345 
1346 	/**
1347 	 * Removes all tags in the range between @start and @end.
1348 	 *
1349 	 * Be careful with this function; it could remove tags added in code
1350 	 * unrelated to the code you’re currently writing. That is, using this
1351 	 * function is probably a bad idea if you have two or more unrelated
1352 	 * code sections that add tags.
1353 	 *
1354 	 * Params:
1355 	 *     start = one bound of range to be untagged
1356 	 *     end = other bound of range to be untagged
1357 	 */
1358 	public void removeAllTags(TextIter start, TextIter end)
1359 	{
1360 		gtk_text_buffer_remove_all_tags(gtkTextBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct());
1361 	}
1362 
1363 	/**
1364 	 * Removes a `GdkClipboard` added with
1365 	 * gtk_text_buffer_add_selection_clipboard().
1366 	 *
1367 	 * Params:
1368 	 *     clipboard = a `GdkClipboard` added to @buffer by
1369 	 *         [method@Gtk.TextBuffer.add_selection_clipboard]
1370 	 */
1371 	public void removeSelectionClipboard(Clipboard clipboard)
1372 	{
1373 		gtk_text_buffer_remove_selection_clipboard(gtkTextBuffer, (clipboard is null) ? null : clipboard.getClipboardStruct());
1374 	}
1375 
1376 	/**
1377 	 * Emits the “remove-tag” signal.
1378 	 *
1379 	 * The default handler for the signal removes all occurrences
1380 	 * of @tag from the given range. @start and @end don’t have
1381 	 * to be in order.
1382 	 *
1383 	 * Params:
1384 	 *     tag = a `GtkTextTag`
1385 	 *     start = one bound of range to be untagged
1386 	 *     end = other bound of range to be untagged
1387 	 */
1388 	public void removeTag(TextTag tag, TextIter start, TextIter end)
1389 	{
1390 		gtk_text_buffer_remove_tag(gtkTextBuffer, (tag is null) ? null : tag.getTextTagStruct(), (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct());
1391 	}
1392 
1393 	/**
1394 	 * Emits the “remove-tag” signal.
1395 	 *
1396 	 * Calls [method@Gtk.TextTagTable.lookup] on the buffer’s
1397 	 * tag table to get a `GtkTextTag`, then calls
1398 	 * [method@Gtk.TextBuffer.remove_tag].
1399 	 *
1400 	 * Params:
1401 	 *     name = name of a `GtkTextTag`
1402 	 *     start = one bound of range to be untagged
1403 	 *     end = other bound of range to be untagged
1404 	 */
1405 	public void removeTagByName(string name, TextIter start, TextIter end)
1406 	{
1407 		gtk_text_buffer_remove_tag_by_name(gtkTextBuffer, Str.toStringz(name), (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct());
1408 	}
1409 
1410 	/**
1411 	 * This function moves the “insert” and “selection_bound” marks
1412 	 * simultaneously.
1413 	 *
1414 	 * If you move them in two steps with
1415 	 * [method@Gtk.TextBuffer.move_mark], you will temporarily select a
1416 	 * region in between their old and new locations, which can be pretty
1417 	 * inefficient since the temporarily-selected region will force stuff
1418 	 * to be recalculated. This function moves them as a unit, which can
1419 	 * be optimized.
1420 	 *
1421 	 * Params:
1422 	 *     ins = where to put the “insert” mark
1423 	 *     bound = where to put the “selection_bound” mark
1424 	 */
1425 	public void selectRange(TextIter ins, TextIter bound)
1426 	{
1427 		gtk_text_buffer_select_range(gtkTextBuffer, (ins is null) ? null : ins.getTextIterStruct(), (bound is null) ? null : bound.getTextIterStruct());
1428 	}
1429 
1430 	/**
1431 	 * Sets whether or not to enable undoable actions in the text buffer.
1432 	 *
1433 	 * If enabled, the user will be able to undo the last number of actions
1434 	 * up to [method@Gtk.TextBuffer.get_max_undo_levels].
1435 	 *
1436 	 * See [method@Gtk.TextBuffer.begin_irreversible_action] and
1437 	 * [method@Gtk.TextBuffer.end_irreversible_action] to create
1438 	 * changes to the buffer that cannot be undone.
1439 	 *
1440 	 * Params:
1441 	 *     enableUndo = %TRUE to enable undo
1442 	 */
1443 	public void setEnableUndo(bool enableUndo)
1444 	{
1445 		gtk_text_buffer_set_enable_undo(gtkTextBuffer, enableUndo);
1446 	}
1447 
1448 	/**
1449 	 * Sets the maximum number of undo levels to perform.
1450 	 *
1451 	 * If 0, unlimited undo actions may be performed. Note that this may
1452 	 * have a memory usage impact as it requires storing an additional
1453 	 * copy of the inserted or removed text within the text buffer.
1454 	 *
1455 	 * Params:
1456 	 *     maxUndoLevels = the maximum number of undo actions to perform
1457 	 */
1458 	public void setMaxUndoLevels(uint maxUndoLevels)
1459 	{
1460 		gtk_text_buffer_set_max_undo_levels(gtkTextBuffer, maxUndoLevels);
1461 	}
1462 
1463 	/**
1464 	 * Used to keep track of whether the buffer has been
1465 	 * modified since the last time it was saved.
1466 	 *
1467 	 * Whenever the buffer is saved to disk, call
1468 	 * `gtk_text_buffer_set_modified (@buffer, FALSE)`.
1469 	 * When the buffer is modified, it will automatically
1470 	 * toggled on the modified bit again. When the modified
1471 	 * bit flips, the buffer emits the
1472 	 * [signal@Gtk.TextBuffer::modified-changed] signal.
1473 	 *
1474 	 * Params:
1475 	 *     setting = modification flag setting
1476 	 */
1477 	public void setModified(bool setting)
1478 	{
1479 		gtk_text_buffer_set_modified(gtkTextBuffer, setting);
1480 	}
1481 
1482 	/**
1483 	 * Deletes current contents of @buffer, and inserts @text instead.
1484 	 *
1485 	 * If @len is -1, @text must be nul-terminated.
1486 	 * @text must be valid UTF-8.
1487 	 *
1488 	 * Params:
1489 	 *     text = UTF-8 text to insert
1490 	 */
1491 	public void setText(string text)
1492 	{
1493 		gtk_text_buffer_set_text(gtkTextBuffer, Str.toStringz(text), cast(int)text.length);
1494 	}
1495 
1496 	/**
1497 	 * Undoes the last undoable action on the buffer, if there is one.
1498 	 */
1499 	public void undo()
1500 	{
1501 		gtk_text_buffer_undo(gtkTextBuffer);
1502 	}
1503 
1504 	/**
1505 	 * Emitted to apply a tag to a range of text in a `GtkTextBuffer`.
1506 	 *
1507 	 * Applying actually occurs in the default handler.
1508 	 *
1509 	 * Note that if your handler runs before the default handler
1510 	 * it must not invalidate the @start and @end iters (or has to
1511 	 * revalidate them).
1512 	 *
1513 	 * See also:
1514 	 * [method@Gtk.TextBuffer.apply_tag],
1515 	 * [method@Gtk.TextBuffer.insert_with_tags],
1516 	 * [method@Gtk.TextBuffer.insert_range].
1517 	 *
1518 	 * Params:
1519 	 *     tag = the applied tag
1520 	 *     start = the start of the range the tag is applied to
1521 	 *     end = the end of the range the tag is applied to
1522 	 */
1523 	gulong addOnApplyTag(void delegate(TextTag, TextIter, TextIter, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1524 	{
1525 		return Signals.connect(this, "apply-tag", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1526 	}
1527 
1528 	/**
1529 	 * Emitted at the beginning of a single user-visible
1530 	 * operation on a `GtkTextBuffer`.
1531 	 *
1532 	 * See also:
1533 	 * [method@Gtk.TextBuffer.begin_user_action],
1534 	 * [method@Gtk.TextBuffer.insert_interactive],
1535 	 * [method@Gtk.TextBuffer.insert_range_interactive],
1536 	 * [method@Gtk.TextBuffer.delete_interactive],
1537 	 * [method@Gtk.TextBuffer.backspace],
1538 	 * [method@Gtk.TextBuffer.delete_selection].
1539 	 */
1540 	gulong addOnBeginUserAction(void delegate(TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1541 	{
1542 		return Signals.connect(this, "begin-user-action", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1543 	}
1544 
1545 	/**
1546 	 * Emitted when the content of a `GtkTextBuffer` has changed.
1547 	 */
1548 	gulong addOnChanged(void delegate(TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1549 	{
1550 		return Signals.connect(this, "changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1551 	}
1552 
1553 	/**
1554 	 * Emitted to delete a range from a `GtkTextBuffer`.
1555 	 *
1556 	 * Note that if your handler runs before the default handler
1557 	 * it must not invalidate the @start and @end iters (or has
1558 	 * to revalidate them). The default signal handler revalidates
1559 	 * the @start and @end iters to both point to the location
1560 	 * where text was deleted. Handlers which run after the default
1561 	 * handler (see g_signal_connect_after()) do not have access to
1562 	 * the deleted text.
1563 	 *
1564 	 * See also: [method@Gtk.TextBuffer.delete].
1565 	 *
1566 	 * Params:
1567 	 *     start = the start of the range to be deleted
1568 	 *     end = the end of the range to be deleted
1569 	 */
1570 	gulong addOnDeleteRange(void delegate(TextIter, TextIter, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1571 	{
1572 		return Signals.connect(this, "delete-range", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1573 	}
1574 
1575 	/**
1576 	 * Emitted at the end of a single user-visible
1577 	 * operation on the `GtkTextBuffer`.
1578 	 *
1579 	 * See also:
1580 	 * [method@Gtk.TextBuffer.end_user_action],
1581 	 * [method@Gtk.TextBuffer.insert_interactive],
1582 	 * [method@Gtk.TextBuffer.insert_range_interactive],
1583 	 * [method@Gtk.TextBuffer.delete_interactive],
1584 	 * [method@Gtk.TextBuffer.backspace],
1585 	 * [method@Gtk.TextBuffer.delete_selection],
1586 	 * [method@Gtk.TextBuffer.backspace].
1587 	 */
1588 	gulong addOnEndUserAction(void delegate(TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1589 	{
1590 		return Signals.connect(this, "end-user-action", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1591 	}
1592 
1593 	/**
1594 	 * Emitted to insert a `GtkTextChildAnchor` in a `GtkTextBuffer`.
1595 	 *
1596 	 * Insertion actually occurs in the default handler.
1597 	 *
1598 	 * Note that if your handler runs before the default handler
1599 	 * it must not invalidate the @location iter (or has to
1600 	 * revalidate it). The default signal handler revalidates
1601 	 * it to be placed after the inserted @anchor.
1602 	 *
1603 	 * See also: [method@Gtk.TextBuffer.insert_child_anchor].
1604 	 *
1605 	 * Params:
1606 	 *     location = position to insert @anchor in @textbuffer
1607 	 *     anchor = the `GtkTextChildAnchor` to be inserted
1608 	 */
1609 	gulong addOnInsertChildAnchor(void delegate(TextIter, TextChildAnchor, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1610 	{
1611 		return Signals.connect(this, "insert-child-anchor", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1612 	}
1613 
1614 	/**
1615 	 * Emitted to insert a `GdkPaintable` in a `GtkTextBuffer`.
1616 	 *
1617 	 * Insertion actually occurs in the default handler.
1618 	 *
1619 	 * Note that if your handler runs before the default handler
1620 	 * it must not invalidate the @location iter (or has to
1621 	 * revalidate it). The default signal handler revalidates
1622 	 * it to be placed after the inserted @paintable.
1623 	 *
1624 	 * See also: [method@Gtk.TextBuffer.insert_paintable].
1625 	 *
1626 	 * Params:
1627 	 *     location = position to insert @paintable in @textbuffer
1628 	 *     paintable = the `GdkPaintable` to be inserted
1629 	 */
1630 	gulong addOnInsertPaintable(void delegate(TextIter, PaintableIF, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1631 	{
1632 		return Signals.connect(this, "insert-paintable", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1633 	}
1634 
1635 	/**
1636 	 * Emitted to insert text in a `GtkTextBuffer`.
1637 	 *
1638 	 * Insertion actually occurs in the default handler.
1639 	 *
1640 	 * Note that if your handler runs before the default handler
1641 	 * it must not invalidate the @location iter (or has to
1642 	 * revalidate it). The default signal handler revalidates
1643 	 * it to point to the end of the inserted text.
1644 	 *
1645 	 * See also: [method@Gtk,TextBuffer.insert],
1646 	 * [method@Gtk.TextBuffer.insert_range].
1647 	 *
1648 	 * Params:
1649 	 *     location = position to insert @text in @textbuffer
1650 	 *     text = the UTF-8 text to be inserted
1651 	 *     len = length of the inserted text in bytes
1652 	 */
1653 	gulong addOnInsertText(void delegate(TextIter, string, int, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1654 	{
1655 		return Signals.connect(this, "insert-text", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1656 	}
1657 
1658 	/**
1659 	 * Emitted as notification after a `GtkTextMark` is deleted.
1660 	 *
1661 	 * See also: [method@Gtk.TextBuffer.delete_mark].
1662 	 *
1663 	 * Params:
1664 	 *     mark = The mark that was deleted
1665 	 */
1666 	gulong addOnMarkDeleted(void delegate(TextMark, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1667 	{
1668 		return Signals.connect(this, "mark-deleted", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1669 	}
1670 
1671 	/**
1672 	 * Emitted as notification after a `GtkTextMark` is set.
1673 	 *
1674 	 * See also:
1675 	 * [method@Gtk.TextBuffer.create_mark],
1676 	 * [method@Gtk.TextBuffer.move_mark].
1677 	 *
1678 	 * Params:
1679 	 *     location = The location of @mark in @textbuffer
1680 	 *     mark = The mark that is set
1681 	 */
1682 	gulong addOnMarkSet(void delegate(TextIter, TextMark, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1683 	{
1684 		return Signals.connect(this, "mark-set", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1685 	}
1686 
1687 	/**
1688 	 * Emitted when the modified bit of a `GtkTextBuffer` flips.
1689 	 *
1690 	 * See also: [method@Gtk.TextBuffer.set_modified].
1691 	 */
1692 	gulong addOnModifiedChanged(void delegate(TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1693 	{
1694 		return Signals.connect(this, "modified-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1695 	}
1696 
1697 	/**
1698 	 * Emitted after paste operation has been completed.
1699 	 *
1700 	 * This is useful to properly scroll the view to the end
1701 	 * of the pasted text. See [method@Gtk.TextBuffer.paste_clipboard]
1702 	 * for more details.
1703 	 *
1704 	 * Params:
1705 	 *     clipboard = the `GdkClipboard` pasted from
1706 	 */
1707 	gulong addOnPasteDone(void delegate(Clipboard, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1708 	{
1709 		return Signals.connect(this, "paste-done", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1710 	}
1711 
1712 	/**
1713 	 * Emitted when a request has been made to redo the
1714 	 * previously undone operation.
1715 	 */
1716 	gulong addOnRedo(void delegate(TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1717 	{
1718 		return Signals.connect(this, "redo", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1719 	}
1720 
1721 	/**
1722 	 * Emitted to remove all occurrences of @tag from a range
1723 	 * of text in a `GtkTextBuffer`.
1724 	 *
1725 	 * Removal actually occurs in the default handler.
1726 	 *
1727 	 * Note that if your handler runs before the default handler
1728 	 * it must not invalidate the @start and @end iters (or has
1729 	 * to revalidate them).
1730 	 *
1731 	 * See also: [method@Gtk.TextBuffer.remove_tag].
1732 	 *
1733 	 * Params:
1734 	 *     tag = the tag to be removed
1735 	 *     start = the start of the range the tag is removed from
1736 	 *     end = the end of the range the tag is removed from
1737 	 */
1738 	gulong addOnRemoveTag(void delegate(TextTag, TextIter, TextIter, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1739 	{
1740 		return Signals.connect(this, "remove-tag", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1741 	}
1742 
1743 	/**
1744 	 * Emitted when a request has been made to undo the
1745 	 * previous operation or set of operations that have
1746 	 * been grouped together.
1747 	 */
1748 	gulong addOnUndo(void delegate(TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1749 	{
1750 		return Signals.connect(this, "undo", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1751 	}
1752 }