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 _getGType() static nothrow
GType _gType() @property nothrow
TextBuffer self() nothrowReturns `this`, for use in `with` statements.
TextBufferGidBuilder builder() static nothrowGet builder for [gtk.text_buffer.TextBuffer] Returns: New builder object
bool canRedo() @property nothrowGet `canRedo` property. Returns: Denotes that the buffer can reapply the last undone action.
bool canUndo() @property nothrowGet `canUndo` property. Returns: Denotes that the buffer can undo the last applied action.
int cursorPosition() @property nothrowGet `cursorPosition` property. Returns: The position of the insert mark.
bool enableUndo() @property nothrowGet `enableUndo` property. Returns: Denotes if support for undoing and redoing changes to the buffer is allowed.
void enableUndo(bool propval) @property nothrowSet `enableUndo` property. Params: propval = Denotes if support for undoing and redoing changes to the buffer is allowed.
bool hasSelection() @property nothrowGet `hasSelection` property. Returns: Whether the buffer has some text currently selected.
gtk.text_tag_table.TextTagTable tagTable() @property nothrowGet `tagTable` property. Returns: The GtkTextTagTable for the buffer.
string text() @property nothrowGet `text` property. Returns: The text content of the buffer.
void text(string propval) @property nothrowSet `text` property. Params: propval = The text content of the buffer.
void addMark(gtk.text_mark.TextMark mark, gtk.text_iter.TextIter where) nothrowAdds the mark at position where.
void addSelectionClipboard(gdk.clipboard.Clipboard clipboard) nothrowAdds 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) nothrowEmits the “apply-tag” signal on buffer.
void applyTagByName(string name, gtk.text_iter.TextIter start, gtk.text_iter.TextIter end) nothrowEmits the “apply-tag” signal on buffer.
bool backspace(gtk.text_iter.TextIter iter, bool interactive, bool defaultEditable) nothrowPerforms the appropriate action as if the user hit the delete key with the cursor at the position specified by iter.
void beginIrreversibleAction() nothrowDenotes the beginning of an action that may not be undone.
void beginUserAction() nothrowCalled 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) nothrowCopies the currently-selected text to a clipboard.
gtk.text_child_anchor.TextChildAnchor createChildAnchor(gtk.text_iter.TextIter iter) nothrowCreates and inserts a child anchor.
gtk.text_mark.TextMark createMark(string markName, gtk.text_iter.TextIter where, bool leftGravity) nothrowCreates a mark at position where.
void cutClipboard(gdk.clipboard.Clipboard clipboard, bool defaultEditable) nothrowCopies 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) nothrowDeletes text between start and end.
bool deleteInteractive(gtk.text_iter.TextIter startIter, gtk.text_iter.TextIter endIter, bool defaultEditable) nothrowDeletes all editable text in the given range.
void deleteMark(gtk.text_mark.TextMark mark) nothrowDeletes mark, so that it’s no longer located anywhere in the buffer.
void deleteMarkByName(string name) nothrowDeletes the mark named name; the mark must exist.
bool deleteSelection(bool interactive, bool defaultEditable) nothrowDeletes the range between the “insert” and “selection_bound” marks, that is, the currently-selected text.
void endIrreversibleAction() nothrowDenotes the end of an action that may not be undone.
void endUserAction() nothrowEnds a user-visible operation.
void getBounds(out gtk.text_iter.TextIter start, out gtk.text_iter.TextIter end) nothrowRetrieves the first and last iterators in the buffer, i.e. the entire buffer lies within the range [start,end).
bool getCanRedo() nothrowGets whether there is a redoable action in the history. Returns: true if there is a redoable action
bool getCanUndo() nothrowGets whether there is an undoable action in the history. Returns: true if there is an undoable action
int getCharCount() nothrowGets the number of characters in the buffer.
bool getEnableUndo() nothrowGets whether the buffer is saving modifications to the buffer to allow for undo and redo actions.
void getEndIter(out gtk.text_iter.TextIter iter) nothrowInitializes iter with the “end iterator,” one past the last valid character in the text buffer.
bool getHasSelection() nothrowIndicates whether the buffer has some text currently selected. Returns: true if the there is text selected
gtk.text_mark.TextMark getInsert() nothrowReturns the mark that represents the cursor (insertion point).
void getIterAtChildAnchor(out gtk.text_iter.TextIter iter, gtk.text_child_anchor.TextChildAnchor anchor) nothrowObtains the location of anchor within buffer.
bool getIterAtLine(out gtk.text_iter.TextIter iter, int lineNumber) nothrowInitializes iter to the start of the given line.
bool getIterAtLineIndex(out gtk.text_iter.TextIter iter, int lineNumber, int byteIndex) nothrowObtains an iterator pointing to byte_index within the given line.
bool getIterAtLineOffset(out gtk.text_iter.TextIter iter, int lineNumber, int charOffset) nothrowObtains an iterator pointing to char_offset within the given line.
void getIterAtMark(out gtk.text_iter.TextIter iter, gtk.text_mark.TextMark mark) nothrowInitializes iter with the current position of mark.
void getIterAtOffset(out gtk.text_iter.TextIter iter, int charOffset) nothrowInitializes iter to a position char_offset chars from the start of the entire buffer.
int getLineCount() nothrowObtains the number of lines in the buffer.
gtk.text_mark.TextMark getMark(string name) nothrowReturns the mark named name in buffer buffer, or null if no such mark exists in the buffer.
uint getMaxUndoLevels() nothrowGets the maximum number of undo levels to perform.
bool getModified() nothrowIndicates 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() nothrowReturns the mark that represents the selection bound.
bool getSelectionBounds(out gtk.text_iter.TextIter start, out gtk.text_iter.TextIter end) nothrowReturns true if some text is selected; places the bounds of the selection in start and end.
gdk.content_provider.ContentProvider getSelectionContent() nothrowGet a content provider for this buffer.
string getSlice(gtk.text_iter.TextIter start, gtk.text_iter.TextIter end, bool includeHiddenChars) nothrowReturns the text in the range [start,end).
void getStartIter(out gtk.text_iter.TextIter iter) nothrowInitialized iter with the first position in the text buffer.
gtk.text_tag_table.TextTagTable getTagTable() nothrowGet the [gtk.text_tag_table.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) nothrowReturns the text in the range [start,end).
void insert(gtk.text_iter.TextIter iter, string text) nothrowInserts len bytes of text at position iter.
void insertAtCursor(string text) nothrowInserts text in buffer.
void insertChildAnchor(gtk.text_iter.TextIter iter, gtk.text_child_anchor.TextChildAnchor anchor) nothrowInserts a child widget anchor into the text buffer at iter.
bool insertInteractive(gtk.text_iter.TextIter iter, string text, bool defaultEditable) nothrowInserts text in buffer.
bool insertInteractiveAtCursor(string text, bool defaultEditable) nothrowInserts text in buffer.
void insertMarkup(gtk.text_iter.TextIter iter, string markup) nothrowInserts the text in markup at position iter.
void insertPaintable(gtk.text_iter.TextIter iter, gdk.paintable.Paintable paintable) nothrowInserts 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) nothrowCopies 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) nothrowCopies 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) nothrowMoves mark to the new location where.
void moveMarkByName(string name, gtk.text_iter.TextIter where) nothrowMoves the mark named name (which must exist) to location where.
void pasteClipboard(gdk.clipboard.Clipboard clipboard, gtk.text_iter.TextIter overrideLocation, bool defaultEditable) nothrowPastes the contents of a clipboard.
void placeCursor(gtk.text_iter.TextIter where) nothrowThis function moves the “insert” and “selection_bound” marks simultaneously.
void redo() nothrowRedoes the next redoable action on the buffer, if there is one.
void removeAllTags(gtk.text_iter.TextIter start, gtk.text_iter.TextIter end) nothrowRemoves all tags in the range between start and end.
void removeSelectionClipboard(gdk.clipboard.Clipboard clipboard) nothrowRemoves 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) nothrowEmits the “remove-tag” signal.
void removeTagByName(string name, gtk.text_iter.TextIter start, gtk.text_iter.TextIter end) nothrowEmits the “remove-tag” signal.
void selectRange(gtk.text_iter.TextIter ins, gtk.text_iter.TextIter bound) nothrowThis function moves the “insert” and “selection_bound” marks simultaneously.
void setEnableUndo(bool enableUndo) nothrowSets whether or not to enable undoable actions in the text buffer.
void setMaxUndoLevels(uint maxUndoLevels) nothrowSets the maximum number of undo levels to perform.
void setModified(bool setting) nothrowUsed to keep track of whether the buffer has been modified since the last time it was saved.
void setText(string text) nothrowDeletes 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() nothrowUndoes 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect to `Undo` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this(gtk.text_tag_table.TextTagTable table = null)Creates a new text buffer.

Fluent builder implementation template for gtk.text_buffer.TextBuffer

Methods
T enableUndo(bool propval) nothrowSet `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) nothrowSet `tagTable` property. Params: propval = The GtkTextTagTable for the buffer. Returns: Builder instance for fluent chaining
T text(string propval) nothrowSet `text` property. Params: propval = The text content of the buffer.

Fluent builder for gtk.text_buffer.TextBuffer

Methods
TextBuffer build() nothrowCreate object from builder. Returns: New object