gtk.text_buffer

Module for [TextBuffer] class

Types 3

Stores text and attributes for display in a [gtk.text_view.TextView].

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.

GtkTextBuffer can support undoing changes to the buffer content, see [gtk.text_buffer.TextBuffer.setEnableUndo].

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
bool canRedo() @propertyGet `canRedo` property. Returns: Denotes that the buffer can reapply the last undone action.
bool canUndo() @propertyGet `canUndo` property. Returns: Denotes that the buffer can undo the last applied action.
int cursorPosition() @propertyGet `cursorPosition` property. Returns: The position of the insert mark.
bool enableUndo() @propertyGet `enableUndo` property. Returns: Denotes if support for undoing and redoing changes to the buffer is allowed.
void enableUndo(bool propval) @propertySet `enableUndo` property. Params: propval = Denotes if support for undoing and redoing changes to the buffer is allowed.
bool hasSelection() @propertyGet `hasSelection` property. Returns: Whether the buffer has some text currently selected.
gtk.text_tag_table.TextTagTable tagTable() @propertyGet `tagTable` property. Returns: The GtkTextTagTable for the buffer.
string text() @propertyGet `text` property. Returns: The text content of the buffer.
void text(string propval) @propertySet `text` property. Params: propval = The text content of the buffer.
void addMark(gtk.text_mark.TextMark mark, gtk.text_iter.TextIter where)Adds the mark at position where.
void addSelectionClipboard(gdk.clipboard.Clipboard clipboard)Adds clipboard to the list of clipboards in which the selection contents of buffer are available.
void applyTag(gtk.text_tag.TextTag tag, gtk.text_iter.TextIter start, gtk.text_iter.TextIter end)Emits the “apply-tag” signal on buffer.
void applyTagByName(string name, gtk.text_iter.TextIter start, gtk.text_iter.TextIter end)Emits the “apply-tag” signal on buffer.
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.
void beginIrreversibleAction()Denotes the beginning of an action that may not be undone.
void beginUserAction()Called to indicate that the buffer operations between here and a call to [gtk.text_buffer.TextBuffer.endUserAction] are part of a single user-visible operation.
void copyClipboard(gdk.clipboard.Clipboard clipboard)Copies the currently-selected text to a clipboard.
gtk.text_mark.TextMark createMark(string markName, gtk.text_iter.TextIter where, bool leftGravity)Creates a mark at position where.
void cutClipboard(gdk.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.
bool deleteInteractive(gtk.text_iter.TextIter startIter, gtk.text_iter.TextIter endIter, bool defaultEditable)Deletes all editable text in the given range.
void deleteMark(gtk.text_mark.TextMark mark)Deletes mark, so that it’s no longer located anywhere in the buffer.
void deleteMarkByName(string name)Deletes the mark named name; the mark must exist.
bool deleteSelection(bool interactive, bool defaultEditable)Deletes the range between the “insert” and “selection_bound” marks, that is, the currently-selected text.
void endIrreversibleAction()Denotes the end of an action that may not be undone.
void endUserAction()Ends a user-visible operation.
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).
bool getCanRedo()Gets whether there is a redoable action in the history. Returns: true if there is a redoable action
bool getCanUndo()Gets whether there is an undoable action in the history. Returns: true if there is an undoable action
int getCharCount()Gets the number of characters in the buffer.
bool getEnableUndo()Gets whether the buffer is saving modifications to the buffer to allow for undo and redo actions.
void getEndIter(out gtk.text_iter.TextIter iter)Initializes iter with the “end iterator,” one past the last valid character in the text buffer.
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).
void getIterAtChildAnchor(out gtk.text_iter.TextIter iter, gtk.text_child_anchor.TextChildAnchor anchor)Obtains the location of anchor within buffer.
bool getIterAtLine(out gtk.text_iter.TextIter iter, int lineNumber)Initializes iter to the start of the given line.
bool getIterAtLineIndex(out gtk.text_iter.TextIter iter, int lineNumber, int byteIndex)Obtains an iterator pointing to byte_index within the given line.
bool getIterAtLineOffset(out gtk.text_iter.TextIter iter, int lineNumber, int charOffset)Obtains an iterator pointing to char_offset within the given line.
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 char_offset chars from the start of the entire buffer.
int getLineCount()Obtains the 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.
uint getMaxUndoLevels()Gets the maximum number of undo levels to perform.
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.
gtk.text_mark.TextMark getSelectionBound()Returns the mark that represents the selection bound.
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.
gdk.content_provider.ContentProvider getSelectionContent()Get a content provider for this buffer.
string getSlice(gtk.text_iter.TextIter start, gtk.text_iter.TextIter end, bool includeHiddenChars)Returns the text in the range [start,end).
void getStartIter(out gtk.text_iter.TextIter iter)Initialized iter with the first position in the text buffer.
gtk.text_tag_table.TextTagTable getTagTable()Get the [gtk.texttagtable.TextTagTable] 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).
void insert(gtk.text_iter.TextIter iter, string text)Inserts len bytes of text at position iter.
void insertAtCursor(string text)Inserts text in buffer.
void insertChildAnchor(gtk.text_iter.TextIter iter, gtk.text_child_anchor.TextChildAnchor anchor)Inserts a child widget anchor into the text buffer at iter.
bool insertInteractive(gtk.text_iter.TextIter iter, string text, bool defaultEditable)Inserts text in buffer.
bool insertInteractiveAtCursor(string text, bool defaultEditable)Inserts text in buffer.
void insertMarkup(gtk.text_iter.TextIter iter, string markup)Inserts the text in markup at position iter.
void insertPaintable(gtk.text_iter.TextIter iter, gdk.paintable.Paintable paintable)Inserts an image into the text buffer at iter.
void insertRange(gtk.text_iter.TextIter iter, gtk.text_iter.TextIter start, gtk.text_iter.TextIter end)Copies text, tags, and paintables between start and end and inserts the copy at iter.
bool insertRangeInteractive(gtk.text_iter.TextIter iter, gtk.text_iter.TextIter start, gtk.text_iter.TextIter end, bool defaultEditable)Copies text, tags, and paintables between start and end and inserts the copy at iter.
void moveMark(gtk.text_mark.TextMark mark, gtk.text_iter.TextIter where)Moves mark to the new location where.
void moveMarkByName(string name, gtk.text_iter.TextIter where)Moves the mark named name (which must exist) to location where.
void pasteClipboard(gdk.clipboard.Clipboard clipboard, gtk.text_iter.TextIter overrideLocation, bool defaultEditable)Pastes the contents of a clipboard.
void placeCursor(gtk.text_iter.TextIter where)This function moves the “insert” and “selection_bound” marks simultaneously.
void redo()Redoes the next redoable action on the buffer, if there is one.
void removeAllTags(gtk.text_iter.TextIter start, gtk.text_iter.TextIter end)Removes all tags in the range between start and end.
void removeSelectionClipboard(gdk.clipboard.Clipboard clipboard)Removes a [gdk.clipboard.Clipboard] 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.
void removeTagByName(string name, gtk.text_iter.TextIter start, gtk.text_iter.TextIter end)Emits the “remove-tag” signal.
void selectRange(gtk.text_iter.TextIter ins, gtk.text_iter.TextIter bound)This function moves the “insert” and “selection_bound” marks simultaneously.
void setEnableUndo(bool enableUndo)Sets whether or not to enable undoable actions in the text buffer.
void setMaxUndoLevels(uint maxUndoLevels)Sets the maximum number of undo levels to perform.
void setModified(bool setting)Used to keep track of whether the buffer has been modified since the last time it was saved.
void setText(string text)Deletes current contents of buffer, and inserts text instead. This is automatically marked as an irreversible action in the undo stack. If you wish to mark this action as part of a larger undo oper...
void undo()Undoes the last undoable action on the buffer, if there is one.
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 connectInsertPaintable(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] : gdk.paintable.Paintable))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.text_buffer.TextBuffer))) && Parameters!T.length < 4)Connect to `InsertPaintable` 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] : gdk.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 connectRedo(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 `Redo` 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.
gulong connectUndo(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 `Undo` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this(gtk.text_tag_table.TextTagTable table = null)Creates a new text buffer.
Methods
T enableUndo(bool propval)Set `enableUndo` property. Params: propval = Denotes if support for undoing and redoing changes to the buffer is allowed. Returns: Builder instance for fluent chaining
T tagTable(gtk.text_tag_table.TextTagTable propval)Set `tagTable` property. Params: propval = The GtkTextTagTable for the buffer. Returns: Builder instance for fluent chaining
T text(string propval)Set `text` property. Params: propval = The text content of the buffer.

Fluent builder for [gtk.text_buffer.TextBuffer]

Methods