gtk.text_view

Module for [TextView] class

Types 3

A widget that displays the contents of a gtk.text_buffer.TextBuffer.

!An example GtkTextview

You may wish to begin by reading the conceptual overview, which gives an overview of all the objects and data types related to the text widget and how they work together.

CSS nodes

textview.view
├── border.top
├── border.left
├── text
│   ╰── [selection]
├── border.right
├── border.bottom
╰── [window.popup]

gtk.text_view.TextView has a main css node with name textview and style class .view, and subnodes for each of the border windows, and the main text area, with names border and text, respectively. The border nodes each get one of the style classes .left, .right, .top or .bottom.

A node representing the selection will appear below the text node.

If a context menu is opened, the window node will appear as a subnode of the main node.

Accessibility

gtk.text_view.TextView uses the gtk.types.AccessibleRole.TextBox role.

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
TextView self() nothrowReturns `this`, for use in `with` statements.
TextViewGidBuilder builder() static nothrowGet builder for [gtk.text_view.TextView] Returns: New builder object
bool acceptsTab() @property nothrowGet `acceptsTab` property. Returns: Whether Tab will result in a tab character being entered.
void acceptsTab(bool propval) @property nothrowSet `acceptsTab` property. Params: propval = Whether Tab will result in a tab character being entered.
int bottomMargin() @property nothrowGet `bottomMargin` property. Returns: The bottom margin for text in the text view.
void bottomMargin(int propval) @property nothrowSet `bottomMargin` property. Params: propval = The bottom margin for text in the text view.
gtk.text_buffer.TextBuffer buffer() @property nothrowGet `buffer` property. Returns: The buffer which is displayed.
void buffer(gtk.text_buffer.TextBuffer propval) @property nothrowSet `buffer` property. Params: propval = The buffer which is displayed.
bool cursorVisible() @property nothrowGet `cursorVisible` property. Returns: If the insertion cursor is shown.
void cursorVisible(bool propval) @property nothrowSet `cursorVisible` property. Params: propval = If the insertion cursor is shown.
bool editable() @property nothrow
void editable(bool propval) @property nothrow
gio.menu_model.MenuModel extraMenu() @property nothrowGet `extraMenu` property. Returns: A menu model whose contents will be appended to the context menu.
void extraMenu(gio.menu_model.MenuModel propval) @property nothrowSet `extraMenu` property. Params: propval = A menu model whose contents will be appended to the context menu.
string imModule() @property nothrowGet `imModule` property. Returns: Which IM (input method) module should be used for this text_view.
void imModule(string propval) @property nothrowSet `imModule` property. Params: propval = Which IM (input method) module should be used for this text_view.
int indent() @property nothrowGet `indent` property. Returns: Amount to indent the paragraph, in pixels.
void indent(int propval) @property nothrowSet `indent` property. Params: propval = Amount to indent the paragraph, in pixels.
gtk.types.InputHints inputHints() @property nothrowGet `inputHints` property. Returns: Additional hints (beyond [gtk.text_view.TextView.inputPurpose]) that allow input methods to fine-tune their behaviour.
void inputHints(gtk.types.InputHints propval) @property nothrowSet `inputHints` property. Params: propval = Additional hints (beyond [gtk.text_view.TextView.inputPurpose]) that allow input methods to fine-tune their behaviour.
gtk.types.InputPurpose inputPurpose() @property nothrowGet `inputPurpose` property. Returns: The purpose of this text field.
void inputPurpose(gtk.types.InputPurpose propval) @property nothrowSet `inputPurpose` property. Params: propval = The purpose of this text field.
void justification(gtk.types.Justification propval) @property nothrow
int leftMargin() @property nothrowGet `leftMargin` property. Returns: The default left margin for text in the text view.
void leftMargin(int propval) @property nothrowSet `leftMargin` property. Params: propval = The default left margin for text in the text view.
bool monospace() @property nothrowGet `monospace` property. Returns: Whether text should be displayed in a monospace font.
void monospace(bool propval) @property nothrowSet `monospace` property. Params: propval = Whether text should be displayed in a monospace font.
bool overwrite() @property nothrowGet `overwrite` property. Returns: Whether entered text overwrites existing contents.
void overwrite(bool propval) @property nothrowSet `overwrite` property. Params: propval = Whether entered text overwrites existing contents.
int pixelsAboveLines() @property nothrow
void pixelsAboveLines(int propval) @property nothrow
int pixelsBelowLines() @property nothrow
void pixelsBelowLines(int propval) @property nothrow
int pixelsInsideWrap() @property nothrow
void pixelsInsideWrap(int propval) @property nothrow
int rightMargin() @property nothrowGet `rightMargin` property. Returns: The default right margin for text in the text view.
void rightMargin(int propval) @property nothrowSet `rightMargin` property. Params: propval = The default right margin for text in the text view.
pango.tab_array.TabArray tabs() @property nothrow
void tabs(pango.tab_array.TabArray propval) @property nothrow
int topMargin() @property nothrowGet `topMargin` property. Returns: The top margin for text in the text view.
void topMargin(int propval) @property nothrowSet `topMargin` property. Params: propval = The top margin for text in the text view.
gtk.types.WrapMode wrapMode() @property nothrow
void wrapMode(gtk.types.WrapMode propval) @property nothrow
gtk.text_view.TextView newWithBuffer(gtk.text_buffer.TextBuffer buffer) static nothrowCreates a new [gtk.text_view.TextView] widget displaying the buffer buffer.
void addChildAtAnchor(gtk.widget.Widget child, gtk.text_child_anchor.TextChildAnchor anchor) nothrowAdds a child widget in the text buffer, at the given anchor.
void addOverlay(gtk.widget.Widget child, int xpos, int ypos) nothrowAdds child at a fixed coordinate in the [gtk.text_view.TextView]'s text window.
bool backwardDisplayLine(gtk.text_iter.TextIter iter) nothrowMoves the given iter backward by one display (wrapped) line.
bool backwardDisplayLineStart(gtk.text_iter.TextIter iter) nothrowMoves the given iter backward to the next display line start.
void bufferToWindowCoords(gtk.types.TextWindowType win, int bufferX, int bufferY, out int windowX, out int windowY) nothrowConverts buffer coordinates to window coordinates.
bool forwardDisplayLine(gtk.text_iter.TextIter iter) nothrowMoves the given iter forward by one display (wrapped) line.
bool forwardDisplayLineEnd(gtk.text_iter.TextIter iter) nothrowMoves the given iter forward to the next display line end.
bool getAcceptsTab() nothrowReturns whether pressing the <kbd>Tab</kbd> key inserts a tab characters.
int getBottomMargin() nothrowGets the bottom margin for text in the text_view. Returns: bottom margin in pixels
gtk.text_buffer.TextBuffer getBuffer() nothrowReturns the [gtk.text_buffer.TextBuffer] being displayed by this text view.
void getCursorLocations(gtk.text_iter.TextIter iter, out gdk.rectangle.Rectangle strong, out gdk.rectangle.Rectangle weak) nothrowDetermine the positions of the strong and weak cursors if the insertion point is at iter.
bool getCursorVisible() nothrowFind out whether the cursor should be displayed. Returns: whether the insertion mark is visible
bool getEditable() nothrowReturns the default editability of the [gtk.text_view.TextView].
gio.menu_model.MenuModel getExtraMenu() nothrowGets the menu model that gets added to the context menu or null if none has been set. Returns: the menu model
gtk.widget.Widget getGutter(gtk.types.TextWindowType win) nothrowGets a [gtk.widget.Widget] that has previously been set as gutter.
int getIndent() nothrowGets the default indentation of paragraphs in text_view.
gtk.types.InputHints getInputHints() nothrowGets the `input-hints` of the [gtk.text_view.TextView]. Returns:
gtk.types.InputPurpose getInputPurpose() nothrowGets the `input-purpose` of the [gtk.text_view.TextView]. Returns:
bool getIterAtLocation(out gtk.text_iter.TextIter iter, int x, int y) nothrowRetrieves the iterator at buffer coordinates `x` and `y`.
bool getIterAtPosition(out gtk.text_iter.TextIter iter, out int trailing, int x, int y) nothrowRetrieves the iterator pointing to the character at buffer coordinates `x` and `y`.
void getIterLocation(gtk.text_iter.TextIter iter, out gdk.rectangle.Rectangle location) nothrowGets a rectangle which roughly contains the character at iter.
gtk.types.Justification getJustification() nothrowGets the default justification of paragraphs in text_view.
int getLeftMargin() nothrowGets the default left margin size of paragraphs in the text_view.
void getLineAtY(out gtk.text_iter.TextIter targetIter, int y, out int lineTop) nothrowGets the [gtk.text_iter.TextIter] at the start of the line containing the coordinate `y`.
void getLineYrange(gtk.text_iter.TextIter iter, out int y, out int height) nothrowGets the y coordinate of the top of the line containing iter, and the height of the line.
pango.context.Context getLtrContext() nothrowGets the [pango.context.Context] that is used for rendering LTR directed text layouts.
bool getMonospace() nothrowGets whether the [gtk.text_view.TextView] uses monospace styling. Returns: true if monospace fonts are desired
bool getOverwrite() nothrowReturns whether the [gtk.text_view.TextView] is in overwrite mode or not. Returns: whether text_view is in overwrite mode or not.
int getPixelsAboveLines() nothrowGets the default number of pixels to put above paragraphs.
int getPixelsBelowLines() nothrowGets the default number of pixels to put below paragraphs.
int getPixelsInsideWrap() nothrowGets the default number of pixels to put between wrapped lines inside a paragraph. Returns: default number of pixels of blank space between wrapped lines
int getRightMargin() nothrowGets the default right margin for text in text_view.
pango.context.Context getRtlContext() nothrowGets the [pango.context.Context] that is used for rendering RTL directed text layouts.
pango.tab_array.TabArray getTabs() nothrowGets the default tabs for text_view.
int getTopMargin() nothrowGets the top margin for text in the text_view. Returns: top margin in pixels
void getVisibleRect(out gdk.rectangle.Rectangle visibleRect) nothrowFills visible_rect with the currently-visible region of the buffer, in buffer coordinates.
gtk.types.WrapMode getWrapMode() nothrowGets the line wrapping for the view. Returns: the line wrap setting
bool imContextFilterKeypress(gdk.event.Event event) nothrowAllow the [gtk.text_view.TextView] input method to internally handle key press and release events.
bool moveMarkOnscreen(gtk.text_mark.TextMark mark) nothrowMoves a mark within the buffer so that it's located within the currently-visible text area.
void moveOverlay(gtk.widget.Widget child, int xpos, int ypos) nothrowUpdates the position of a child.
bool moveVisually(gtk.text_iter.TextIter iter, int count) nothrowMove the iterator a given number of characters visually, treating it as the strong cursor position.
bool placeCursorOnscreen() nothrowMoves the cursor to the currently visible region of the buffer. Returns: true if the cursor had to be moved.
void remove(gtk.widget.Widget child) nothrowRemoves a child widget from text_view.
void resetCursorBlink() nothrowEnsures that the cursor is shown.
void resetImContext() nothrowReset the input method context of the text view if needed.
void scrollMarkOnscreen(gtk.text_mark.TextMark mark) nothrowScrolls text_view the minimum distance such that mark is contained within the visible area of the widget.
bool scrollToIter(gtk.text_iter.TextIter iter, double withinMargin, bool useAlign, double xalign, double yalign) nothrowScrolls text_view so that iter is on the screen in the position indicated by xalign and yalign.
void scrollToMark(gtk.text_mark.TextMark mark, double withinMargin, bool useAlign, double xalign, double yalign) nothrowScrolls text_view so that mark is on the screen in the position indicated by xalign and yalign.
void setAcceptsTab(bool acceptsTab) nothrowSets the behavior of the text widget when the <kbd>Tab</kbd> key is pressed.
void setBottomMargin(int bottomMargin) nothrowSets the bottom margin for text in text_view.
void setBuffer(gtk.text_buffer.TextBuffer buffer = null) nothrowSets buffer as the buffer being displayed by text_view.
void setCursorVisible(bool setting) nothrowToggles whether the insertion point should be displayed.
void setEditable(bool setting) nothrowSets the default editability of the [gtk.text_view.TextView].
void setExtraMenu(gio.menu_model.MenuModel model = null) nothrowSets a menu model to add when constructing the context menu for text_view.
void setGutter(gtk.types.TextWindowType win, gtk.widget.Widget widget = null) nothrowPlaces widget into the gutter specified by win.
void setIndent(int indent) nothrowSets the default indentation for paragraphs in text_view.
void setInputHints(gtk.types.InputHints hints) nothrowSets the `input-hints` of the [gtk.text_view.TextView].
void setInputPurpose(gtk.types.InputPurpose purpose) nothrowSets the `input-purpose` of the [gtk.text_view.TextView].
void setJustification(gtk.types.Justification justification) nothrowSets the default justification of text in text_view.
void setLeftMargin(int leftMargin) nothrowSets the default left margin for text in text_view.
void setMonospace(bool monospace) nothrowSets whether the [gtk.text_view.TextView] should display text in monospace styling.
void setOverwrite(bool overwrite) nothrowChanges the [gtk.text_view.TextView] overwrite mode.
void setPixelsAboveLines(int pixelsAboveLines) nothrowSets the default number of blank pixels above paragraphs in text_view.
void setPixelsBelowLines(int pixelsBelowLines) nothrowSets the default number of pixels of blank space to put below paragraphs in text_view.
void setPixelsInsideWrap(int pixelsInsideWrap) nothrowSets the default number of pixels of blank space to leave between display/wrapped lines within a paragraph.
void setRightMargin(int rightMargin) nothrowSets the default right margin for text in the text view.
void setTabs(pango.tab_array.TabArray tabs) nothrowSets the default tab stops for paragraphs in text_view.
void setTopMargin(int topMargin) nothrowSets the top margin for text in text_view.
void setWrapMode(gtk.types.WrapMode wrapMode) nothrowSets the line wrapping for the view.
bool startsDisplayLine(gtk.text_iter.TextIter iter) nothrowDetermines whether iter is at the start of a display line.
void windowToBufferCoords(gtk.types.TextWindowType win, int windowX, int windowY, out int bufferX, out int bufferY) nothrowConverts coordinates on the window identified by win to buffer coordinates.
gulong connectBackspace(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_view.TextView))) && Parameters!T.length < 2) nothrowConnect to `Backspace` signal.
gulong connectCopyClipboard(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_view.TextView))) && Parameters!T.length < 2) nothrowConnect to `CopyClipboard` signal.
gulong connectCutClipboard(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_view.TextView))) && Parameters!T.length < 2) nothrowConnect to `CutClipboard` signal.
gulong connectDeleteFromCursor(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.types.DeleteType))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == int))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.text_view.TextView))) && Parameters!T.length < 4) nothrowConnect to `DeleteFromCursor` signal.
gulong connectExtendSelection(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == bool) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.types.TextExtendSelection))) && (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_iter.TextIter))) && (Parameters!T.length < 5 || (ParameterStorageClassTuple!T[4] == ParameterStorageClass.none && is(Parameters!T[4] : gtk.text_view.TextView))) && Parameters!T.length < 6) nothrowConnect to `ExtendSelection` signal.
gulong connectInsertAtCursor(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] == string))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.text_view.TextView))) && Parameters!T.length < 3) nothrowConnect to `InsertAtCursor` signal.
gulong connectInsertEmoji(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_view.TextView))) && Parameters!T.length < 2) nothrowConnect to `InsertEmoji` signal.
gulong connectMoveCursor(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.types.MovementStep))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == int))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] == bool))) && (Parameters!T.length < 4 || (ParameterStorageClassTuple!T[3] == ParameterStorageClass.none && is(Parameters!T[3] : gtk.text_view.TextView))) && Parameters!T.length < 5) nothrowConnect to `MoveCursor` signal.
gulong connectMoveViewport(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.types.ScrollStep))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == int))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.text_view.TextView))) && Parameters!T.length < 4) nothrowConnect to `MoveViewport` signal.
gulong connectPasteClipboard(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_view.TextView))) && Parameters!T.length < 2) nothrowConnect to `PasteClipboard` signal.
gulong connectPreeditChanged(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] == string))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.text_view.TextView))) && Parameters!T.length < 3) nothrowConnect to `PreeditChanged` signal.
gulong connectSelectAll(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] == bool))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.text_view.TextView))) && Parameters!T.length < 3) nothrowConnect to `SelectAll` signal.
gulong connectSetAnchor(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_view.TextView))) && Parameters!T.length < 2) nothrowConnect to `SetAnchor` signal.
gulong connectToggleCursorVisible(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_view.TextView))) && Parameters!T.length < 2) nothrowConnect to `ToggleCursorVisible` signal.
gulong connectToggleOverwrite(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_view.TextView))) && Parameters!T.length < 2) nothrowConnect to `ToggleOverwrite` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [gtk.text_view.TextView].

Fluent builder implementation template for gtk.text_view.TextView

Methods
T acceptsTab(bool propval) nothrowSet `acceptsTab` property. Params: propval = Whether Tab will result in a tab character being entered. Returns: Builder instance for fluent chaining
T bottomMargin(int propval) nothrowSet `bottomMargin` property. Params: propval = The bottom margin for text in the text view.
T buffer(gtk.text_buffer.TextBuffer propval) nothrowSet `buffer` property. Params: propval = The buffer which is displayed. Returns: Builder instance for fluent chaining
T cursorVisible(bool propval) nothrowSet `cursorVisible` property. Params: propval = If the insertion cursor is shown. Returns: Builder instance for fluent chaining
T editable(bool propval) nothrow
T extraMenu(gio.menu_model.MenuModel propval) nothrowSet `extraMenu` property. Params: propval = A menu model whose contents will be appended to the context menu. Returns: Builder instance for fluent chaining
T imModule(string propval) nothrowSet `imModule` property. Params: propval = Which IM (input method) module should be used for this text_view.
T indent(int propval) nothrowSet `indent` property. Params: propval = Amount to indent the paragraph, in pixels.
T inputHints(gtk.types.InputHints propval) nothrowSet `inputHints` property. Params: propval = Additional hints (beyond [gtk.text_view.TextView.inputPurpose]) that allow input methods to fine-tune their behaviour. Returns: Builder instance for flu...
T inputPurpose(gtk.types.InputPurpose propval) nothrowSet `inputPurpose` property. Params: propval = The purpose of this text field.
T leftMargin(int propval) nothrowSet `leftMargin` property. Params: propval = The default left margin for text in the text view.
T monospace(bool propval) nothrowSet `monospace` property. Params: propval = Whether text should be displayed in a monospace font.
T overwrite(bool propval) nothrowSet `overwrite` property. Params: propval = Whether entered text overwrites existing contents. Returns: Builder instance for fluent chaining
T pixelsAboveLines(int propval) nothrow
T pixelsBelowLines(int propval) nothrow
T pixelsInsideWrap(int propval) nothrow
T rightMargin(int propval) nothrowSet `rightMargin` property. Params: propval = The default right margin for text in the text view.
T tabs(pango.tab_array.TabArray propval) nothrow
T topMargin(int propval) nothrowSet `topMargin` property. Params: propval = The top margin for text in the text view.
T wrapMode(gtk.types.WrapMode propval) nothrow

Fluent builder for gtk.text_view.TextView

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