gtk.text_buffer

Module for [TextBuffer] class

Types 3

You may wish to begin by reading the

text widget conceptual overview

which gives an overview of all the objects and data types related to the text widget and how they work together.

Methods
GType _gType() @property
TextBuffer self()Returns `this`, for use in `with` statements.
TextBufferGidBuilder builder()Get builder for [gtk.text_buffer.TextBuffer] Returns: New builder object
gtk.target_list.TargetList copyTargetList() @propertyGet `copyTargetList` property. Returns: The list of targets this buffer supports for clipboard copying and as DND source.
int cursorPosition() @propertyGet `cursorPosition` property. Returns: The position of the insert mark (as offset from the beginning of the buffer). It is useful for getting notified when the cursor moves.
bool hasSelection() @propertyGet `hasSelection` property. Returns: Whether the buffer has some text currently selected.
gtk.target_list.TargetList pasteTargetList() @propertyGet `pasteTargetList` property. Returns: The list of targets this buffer supports for clipboard pasting and as DND destination.
string text() @propertyGet `text` property. Returns: The text content of the buffer. Without child widgets and images, see [gtk.text_buffer.TextBuffer.getText] for more information.
void text(string propval) @propertySet `text` property. Params: propval = The text content of the buffer. Without child widgets and images, see [gtk.text_buffer.TextBuffer.getText] for more information.
void addMark(gtk.text_mark.TextMark mark, gtk.text_iter.TextIter where)Adds the mark at position where. The mark must not be added to another buffer, and if its name is not null then there must not be another mark in the buffer with the same name.
void addSelectionClipboard(gtk.clipboard.Clipboard clipboard)Adds clipboard to the list of clipboards in which the selection contents of buffer are available. In most cases, clipboard will be the #GtkClipboard of type `GDKSELECTIONPRIMARY` for a view of buffer.
void applyTag(gtk.text_tag.TextTag tag, gtk.text_iter.TextIter start, gtk.text_iter.TextIter end)Emits the “apply-tag” signal on buffer. The default handler for the signal applies tag to the given range. start and end do not have to be in order.
void applyTagByName(string name, gtk.text_iter.TextIter start, gtk.text_iter.TextIter end)Calls [gtk.texttagtable.TextTagTable.lookup] on the buffer’s tag table to get a #GtkTextTag, then calls [gtk.text_buffer.TextBuffer.applyTag].
bool backspace(gtk.text_iter.TextIter iter, bool interactive, bool defaultEditable)Performs the appropriate action as if the user hit the delete key with the cursor at the position specified by iter. In the normal case a single character will be deleted, but when combining accent...
void beginUserAction()Called to indicate that the buffer operations between here and a call to [gtk.textbuffer.TextBuffer.endUserAction] are part of a single user-visible operation. The operations between [gtk.textbuffe...
void copyClipboard(gtk.clipboard.Clipboard clipboard)Copies the currently-selected text to a clipboard.
gtk.text_child_anchor.TextChildAnchor createChildAnchor(gtk.text_iter.TextIter iter)This is a convenience function which simply creates a child anchor with [gtk.textchildanchor.TextChildAnchor.new] and inserts it into the buffer with [gtk.textbuffer.TextBuffer.insertChildAnchor]. ...
gtk.text_mark.TextMark createMark(string markName, gtk.text_iter.TextIter where, bool leftGravity)Creates a mark at position where. If markname is null, the mark is anonymous; otherwise, the mark can be retrieved by name using [gtk.textbuffer.TextBuffer.getMark]. If a mark has left gravity, and...
void cutClipboard(gtk.clipboard.Clipboard clipboard, bool defaultEditable)Copies the currently-selected text to a clipboard, then deletes said text if it’s editable.
void delete_(gtk.text_iter.TextIter start, gtk.text_iter.TextIter end)Deletes text between start and end. The order of start and end is not actually relevant; [gtk.textbuffer.TextBuffer.delete] will reorder them. This function actually emits the “delete-range” si...
bool deleteInteractive(gtk.text_iter.TextIter startIter, gtk.text_iter.TextIter endIter, bool defaultEditable)Deletes all editable text in the given range. Calls [gtk.textbuffer.TextBuffer.delete] for each editable sub-range of [start,end). start and end are revalidated to point to the location of the last...
void deleteMark(gtk.text_mark.TextMark mark)Deletes mark, so that it’s no longer located anywhere in the buffer. Removes the reference the buffer holds to the mark, so if you haven’t called [gobject.object.ObjectWrap.ref] on the mark, it...
void deleteMarkByName(string name)Deletes the mark named name; the mark must exist. See [gtk.text_buffer.TextBuffer.deleteMark] for details.
bool deleteSelection(bool interactive, bool defaultEditable)Deletes the range between the “insert” and “selection_bound” marks, that is, the currently-selected text. If interactive is true, the editability of the selection will be considered (users ...
bool deserialize(gtk.text_buffer.TextBuffer contentBuffer, gdk.atom.Atom format, gtk.text_iter.TextIter iter, ubyte[] data)This function deserializes rich text in format format and inserts it at iter.
bool deserializeGetCanCreateTags(gdk.atom.Atom format)This functions returns the value set with [gtk.text_buffer.TextBuffer.deserializeSetCanCreateTags]
void deserializeSetCanCreateTags(gdk.atom.Atom format, bool canCreateTags)Use this function to allow a rich text deserialization function to create new tags in the receiving buffer. Note that using this function is almost always a bad idea, because the rich text function...
void endUserAction()Should be paired with a call to [gtk.text_buffer.TextBuffer.beginUserAction]. See that function for a full explanation.
void getBounds(out gtk.text_iter.TextIter start, out gtk.text_iter.TextIter end)Retrieves the first and last iterators in the buffer, i.e. the entire buffer lies within the range [start,end).
int getCharCount()Gets the number of characters in the buffer; note that characters and bytes are not the same, you can’t e.g. expect the contents of the buffer in string form to be this many bytes long. The chara...
gtk.target_list.TargetList getCopyTargetList()This function returns the list of targets this text buffer can provide for copying and as DND source. The targets in the list are added with info values from the #GtkTextBufferTargetInfo enum, usin...
void getEndIter(out gtk.text_iter.TextIter iter)Initializes iter with the “end iterator,” one past the last valid character in the text buffer. If dereferenced with [gtk.textiter.TextIter.getChar], the end iterator has a character value of 0...
bool getHasSelection()Indicates whether the buffer has some text currently selected. Returns: true if the there is text selected
gtk.text_mark.TextMark getInsert()Returns the mark that represents the cursor (insertion point). Equivalent to calling [gtk.text_buffer.TextBuffer.getMark] to get the mark named “insert”, but very slightly more efficient, and i...
void getIterAtChildAnchor(out gtk.text_iter.TextIter iter, gtk.text_child_anchor.TextChildAnchor anchor)Obtains the location of anchor within buffer.
void getIterAtLine(out gtk.text_iter.TextIter iter, int lineNumber)Initializes iter to the start of the given line. If line_number is greater than the number of lines in the buffer, the end iterator is returned.
void getIterAtLineIndex(out gtk.text_iter.TextIter iter, int lineNumber, int byteIndex)Obtains an iterator pointing to byteindex within the given line. byteindex must be the start of a UTF-8 character. Note bytes, not characters; UTF-8 may encode one character as multiple bytes.
void getIterAtLineOffset(out gtk.text_iter.TextIter iter, int lineNumber, int charOffset)Obtains an iterator pointing to char_offset within the given line. Note characters, not bytes; UTF-8 may encode one character as multiple bytes.
void getIterAtMark(out gtk.text_iter.TextIter iter, gtk.text_mark.TextMark mark)Initializes iter with the current position of mark.
void getIterAtOffset(out gtk.text_iter.TextIter iter, int charOffset)Initializes iter to a position charoffset chars from the start of the entire buffer. If charoffset is -1 or greater than the number of characters in the buffer, iter is initialized to the end itera...
int getLineCount()Obtains the number of lines in the buffer. This value is cached, so the function is very fast. Returns: number of lines in the buffer
gtk.text_mark.TextMark getMark(string name)Returns the mark named name in buffer buffer, or null if no such mark exists in the buffer.
bool getModified()Indicates whether the buffer has been modified since the last call to [gtk.text_buffer.TextBuffer.setModified] set the modification flag to false. Used for example to enable a “save” function i...
gtk.target_list.TargetList getPasteTargetList()This function returns the list of targets this text buffer supports for pasting and as DND destination. The targets in the list are added with info values from the #GtkTextBufferTargetInfo enum, us...
gtk.text_mark.TextMark getSelectionBound()Returns the mark that represents the selection bound. Equivalent to calling [gtk.textbuffer.TextBuffer.getMark] to get the mark named “selectionbound”, but very slightly more efficient, and in...
bool getSelectionBounds(out gtk.text_iter.TextIter start, out gtk.text_iter.TextIter end)Returns true if some text is selected; places the bounds of the selection in start and end (if the selection has length 0, then start and end are filled in with the same value). start and end will ...
string getSlice(gtk.text_iter.TextIter start, gtk.text_iter.TextIter end, bool includeHiddenChars)Returns the text in the range [start,end). Excludes undisplayed text (text marked with tags that set the invisibility attribute) if includehiddenchars is false. The returned string includes a 0xFFF...
void getStartIter(out gtk.text_iter.TextIter iter)Initialized iter with the first position in the text buffer. This is the same as using [gtk.text_buffer.TextBuffer.getIterAtOffset] to get the iter at character offset 0.
gtk.text_tag_table.TextTagTable getTagTable()Get the #GtkTextTagTable associated with this buffer. Returns: the buffer’s tag table
string getText(gtk.text_iter.TextIter start, gtk.text_iter.TextIter end, bool includeHiddenChars)Returns the text in the range [start,end). Excludes undisplayed text (text marked with tags that set the invisibility attribute) if includehiddenchars is false. Does not include characters represen...
void insert(gtk.text_iter.TextIter iter, string text)Inserts len bytes of text at position iter. If len is -1, text must be nul-terminated and will be inserted in its entirety. Emits the “insert-text” signal; insertion actually occurs in the def...
void insertAtCursor(string text)Simply calls [gtk.text_buffer.TextBuffer.insert], using the current cursor position as the insertion point.
void insertChildAnchor(gtk.text_iter.TextIter iter, gtk.text_child_anchor.TextChildAnchor anchor)Inserts a child widget anchor into the text buffer at iter. The anchor will be counted as one character in character counts, and when obtaining the buffer contents as a string, will be represented ...
bool insertInteractive(gtk.text_iter.TextIter iter, string text, bool defaultEditable)Like [gtk.text_buffer.TextBuffer.insert], but the insertion will not occur if iter is at a non-editable location in the buffer. Usually you want to prevent insertions at ineditable locations if the...
bool insertInteractiveAtCursor(string text, bool defaultEditable)Calls [gtk.text_buffer.TextBuffer.insertInteractive] at the cursor position.
void insertMarkup(gtk.text_iter.TextIter iter, string markup)Inserts the text in markup at position iter. markup will be inserted in its entirety and must be nul-terminated and valid UTF-8. Emits the #GtkTextBuffer::insert-text signal, possibly multiple time...
void insertPixbuf(gtk.text_iter.TextIter iter, gdkpixbuf.pixbuf.Pixbuf pixbuf)Inserts an image into the text buffer at iter. The image will be counted as one character in character counts, and when obtaining the buffer contents as a string, will be represented by the Unicode...
void insertRange(gtk.text_iter.TextIter iter, gtk.text_iter.TextIter start, gtk.text_iter.TextIter end)Copies text, tags, and pixbufs between start and end (the order of start and end doesn’t matter) and inserts the copy at iter. Used instead of simply getting/inserting text because it preserves i...
bool insertRangeInteractive(gtk.text_iter.TextIter iter, gtk.text_iter.TextIter start, gtk.text_iter.TextIter end, bool defaultEditable)Same as [gtk.textbuffer.TextBuffer.insertRange], but does nothing if the insertion point isn’t editable. The defaulteditable parameter indicates whether the text is editable at iter if no tags en...
void moveMark(gtk.text_mark.TextMark mark, gtk.text_iter.TextIter where)Moves mark to the new location where. Emits the #GtkTextBuffer::mark-set signal as notification of the move.
void moveMarkByName(string name, gtk.text_iter.TextIter where)Moves the mark named name (which must exist) to location where. See [gtk.text_buffer.TextBuffer.moveMark] for details.
void pasteClipboard(gtk.clipboard.Clipboard clipboard, gtk.text_iter.TextIter overrideLocation, bool defaultEditable)Pastes the contents of a clipboard. If override_location is null, the pasted text will be inserted at the cursor position, or the buffer selection will be replaced if the selection is non-empty.
void placeCursor(gtk.text_iter.TextIter where)This function moves the “insert” and “selectionbound” marks simultaneously. If you move them to the same place in two steps with [gtk.textbuffer.TextBuffer.moveMark], you will temporarily ...
gdk.atom.Atom registerDeserializeFormat(string mimeType, gtk.types.TextBufferDeserializeFunc function_)This function registers a rich text deserialization function along with its mime_type with the passed buffer.
gdk.atom.Atom registerDeserializeTagset(string tagsetName = null)This function registers GTK+’s internal rich text serialization format with the passed buffer. See [gtk.text_buffer.TextBuffer.registerSerializeTagset] for details.
gdk.atom.Atom registerSerializeFormat(string mimeType, gtk.types.TextBufferSerializeFunc function_)This function registers a rich text serialization function along with its mime_type with the passed buffer.
gdk.atom.Atom registerSerializeTagset(string tagsetName = null)This function registers GTK+’s internal rich text serialization format with the passed buffer. The internal format does not comply to any standard rich text format and only works between #GtkText...
void removeAllTags(gtk.text_iter.TextIter start, gtk.text_iter.TextIter end)Removes all tags in the range between start and end. Be careful with this function; it could remove tags added in code unrelated to the code you’re currently writing. That is, using this functio...
void removeSelectionClipboard(gtk.clipboard.Clipboard clipboard)Removes a #GtkClipboard added with [gtk.text_buffer.TextBuffer.addSelectionClipboard].
void removeTag(gtk.text_tag.TextTag tag, gtk.text_iter.TextIter start, gtk.text_iter.TextIter end)Emits the “remove-tag” signal. The default handler for the signal removes all occurrences of tag from the given range. start and end don’t have to be in order.
void removeTagByName(string name, gtk.text_iter.TextIter start, gtk.text_iter.TextIter end)Calls [gtk.texttagtable.TextTagTable.lookup] on the buffer’s tag table to get a #GtkTextTag, then calls [gtk.text_buffer.TextBuffer.removeTag].
void selectRange(gtk.text_iter.TextIter ins, gtk.text_iter.TextIter bound)This function moves the “insert” and “selectionbound” marks simultaneously. If you move them in two steps with [gtk.textbuffer.TextBuffer.moveMark], you will temporarily select a region in...
ubyte[] serialize(gtk.text_buffer.TextBuffer contentBuffer, gdk.atom.Atom format, gtk.text_iter.TextIter start, gtk.text_iter.TextIter end)This function serializes the portion of text between start and end in the rich text format represented by format.
void setModified(bool setting)Used to keep track of whether the buffer has been modified since the last time it was saved. Whenever the buffer is saved to disk, call gtktextbuffersetmodified (buffer, FALSE). When the buffer is ...
void setText(string text)Deletes current contents of buffer, and inserts text instead. If len is -1, text must be nul-terminated. text must be valid UTF-8.
void unregisterDeserializeFormat(gdk.atom.Atom format)This function unregisters a rich text format that was previously registered using [gtk.textbuffer.TextBuffer.registerDeserializeFormat] or [gtk.textbuffer.TextBuffer.registerDeserializeTagset].
void unregisterSerializeFormat(gdk.atom.Atom format)This function unregisters a rich text format that was previously registered using [gtk.textbuffer.TextBuffer.registerSerializeFormat] or [gtk.textbuffer.TextBuffer.registerSerializeTagset]
gulong connectApplyTag(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.text_tag.TextTag))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == gtk.text_iter.TextIter))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] == gtk.text_iter.TextIter))) && (Parameters!T.length < 4 || (ParameterStorageClassTuple!T[3] == ParameterStorageClass.none && is(Parameters!T[3] : gtk.text_buffer.TextBuffer))) && Parameters!T.length < 5)Connect to `ApplyTag` signal.
gulong connectBeginUserAction(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.text_buffer.TextBuffer))) && Parameters!T.length < 2)Connect to `BeginUserAction` signal.
gulong connectChanged(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.text_buffer.TextBuffer))) && Parameters!T.length < 2)Connect to `Changed` signal.
gulong connectDeleteRange(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.text_iter.TextIter))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == gtk.text_iter.TextIter))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.text_buffer.TextBuffer))) && Parameters!T.length < 4)Connect to `DeleteRange` signal.
gulong connectEndUserAction(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.text_buffer.TextBuffer))) && Parameters!T.length < 2)Connect to `EndUserAction` signal.
gulong connectInsertChildAnchor(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.text_iter.TextIter))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.text_child_anchor.TextChildAnchor))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.text_buffer.TextBuffer))) && Parameters!T.length < 4)Connect to `InsertChildAnchor` signal.
gulong connectInsertPixbuf(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.text_iter.TextIter))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gdkpixbuf.pixbuf.Pixbuf))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.text_buffer.TextBuffer))) && Parameters!T.length < 4)Connect to `InsertPixbuf` signal.
gulong connectInsertText(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.text_iter.TextIter))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == string))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.text_buffer.TextBuffer))) && Parameters!T.length < 4)Connect to `InsertText` signal.
gulong connectMarkDeleted(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.text_mark.TextMark))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.text_buffer.TextBuffer))) && Parameters!T.length < 3)Connect to `MarkDeleted` signal.
gulong connectMarkSet(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.text_iter.TextIter))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.text_mark.TextMark))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.text_buffer.TextBuffer))) && Parameters!T.length < 4)Connect to `MarkSet` signal.
gulong connectModifiedChanged(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.text_buffer.TextBuffer))) && Parameters!T.length < 2)Connect to `ModifiedChanged` signal.
gulong connectPasteDone(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.clipboard.Clipboard))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.text_buffer.TextBuffer))) && Parameters!T.length < 3)Connect to `PasteDone` signal.
gulong connectRemoveTag(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.text_tag.TextTag))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == gtk.text_iter.TextIter))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] == gtk.text_iter.TextIter))) && (Parameters!T.length < 4 || (ParameterStorageClassTuple!T[3] == ParameterStorageClass.none && is(Parameters!T[3] : gtk.text_buffer.TextBuffer))) && Parameters!T.length < 5)Connect to `RemoveTag` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this(gtk.text_tag_table.TextTagTable table = null)Creates a new text buffer.
Methods
T text(string propval)Set `text` property. Params: propval = The text content of the buffer. Without child widgets and images, see [gtk.text_buffer.TextBuffer.getText] for more information. Returns: Builder instance for...

Fluent builder for [gtk.text_buffer.TextBuffer]

Methods