gtk.text_view
Module for [TextView] class
Types 3
A widget that displays the contents of a [gtk.text_buffer.TextBuffer].
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.
TextViewGidBuilder builder()Get builder for [gtk.text_view.TextView] Returns: New builder objectbool acceptsTab() @propertyGet `acceptsTab` property. Returns: Whether Tab will result in a tab character being entered.void acceptsTab(bool propval) @propertySet `acceptsTab` property. Params: propval = Whether Tab will result in a tab character being entered.int bottomMargin() @propertyGet `bottomMargin` property. Returns: The bottom margin for text in the text view.void bottomMargin(int propval) @propertySet `bottomMargin` property. Params: propval = The bottom margin for text in the text view.gtk.text_buffer.TextBuffer buffer() @propertyGet `buffer` property. Returns: The buffer which is displayed.void buffer(gtk.text_buffer.TextBuffer propval) @propertySet `buffer` property. Params: propval = The buffer which is displayed.bool cursorVisible() @propertyGet `cursorVisible` property. Returns: If the insertion cursor is shown.void cursorVisible(bool propval) @propertySet `cursorVisible` property. Params: propval = If the insertion cursor is shown.bool editable() @propertyvoid editable(bool propval) @propertygio.menu_model.MenuModel extraMenu() @propertyGet `extraMenu` property. Returns: A menu model whose contents will be appended to the context menu.void extraMenu(gio.menu_model.MenuModel propval) @propertySet `extraMenu` property. Params: propval = A menu model whose contents will be appended to the context menu.string imModule() @propertyGet `imModule` property. Returns: Which IM (input method) module should be used for this text_view.void imModule(string propval) @propertySet `imModule` property. Params: propval = Which IM (input method) module should be used for this text_view.void indent(int propval) @propertySet `indent` property. Params: propval = Amount to indent the paragraph, in pixels.gtk.types.InputHints inputHints() @propertyGet `inputHints` property. Returns: Additional hints (beyond `property@Gtk.TextView:input-purpose`) that allow input methods to fine-tune their behaviour.void inputHints(gtk.types.InputHints propval) @propertySet `inputHints` property. Params: propval = Additional hints (beyond `property@Gtk.TextView:input-purpose`) that allow input methods to fine-tune their behaviour.gtk.types.InputPurpose inputPurpose() @propertyGet `inputPurpose` property. Returns: The purpose of this text field.void inputPurpose(gtk.types.InputPurpose propval) @propertySet `inputPurpose` property. Params: propval = The purpose of this text field.gtk.types.Justification justification() @propertyvoid justification(gtk.types.Justification propval) @propertyint leftMargin() @propertyGet `leftMargin` property. Returns: The default left margin for text in the text view.void leftMargin(int propval) @propertySet `leftMargin` property. Params: propval = The default left margin for text in the text view.bool monospace() @propertyGet `monospace` property. Returns: Whether text should be displayed in a monospace font.void monospace(bool propval) @propertySet `monospace` property. Params: propval = Whether text should be displayed in a monospace font.bool overwrite() @propertyGet `overwrite` property. Returns: Whether entered text overwrites existing contents.void overwrite(bool propval) @propertySet `overwrite` property. Params: propval = Whether entered text overwrites existing contents.int pixelsAboveLines() @propertyvoid pixelsAboveLines(int propval) @propertyint pixelsBelowLines() @propertyvoid pixelsBelowLines(int propval) @propertyint pixelsInsideWrap() @propertyvoid pixelsInsideWrap(int propval) @propertyint rightMargin() @propertyGet `rightMargin` property. Returns: The default right margin for text in the text view.void rightMargin(int propval) @propertySet `rightMargin` property. Params: propval = The default right margin for text in the text view.pango.tab_array.TabArray tabs() @propertyvoid tabs(pango.tab_array.TabArray propval) @propertyint topMargin() @propertyGet `topMargin` property. Returns: The top margin for text in the text view.void topMargin(int propval) @propertySet `topMargin` property. Params: propval = The top margin for text in the text view.gtk.types.WrapMode wrapMode() @propertyvoid wrapMode(gtk.types.WrapMode propval) @propertygtk.text_view.TextView newWithBuffer(gtk.text_buffer.TextBuffer buffer)Creates a new [gtk.text_view.TextView] widget displaying the buffer buffer.void addChildAtAnchor(gtk.widget.Widget child, gtk.text_child_anchor.TextChildAnchor anchor)Adds a child widget in the text buffer, at the given anchor.void addOverlay(gtk.widget.Widget child, int xpos, int ypos)Adds child at a fixed coordinate in the [gtk.text_view.TextView]'s text window.bool backwardDisplayLine(gtk.text_iter.TextIter iter)Moves the given iter backward by one display (wrapped) line.bool backwardDisplayLineStart(gtk.text_iter.TextIter iter)Moves 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)Converts buffer coordinates to window coordinates.bool forwardDisplayLine(gtk.text_iter.TextIter iter)Moves the given iter forward by one display (wrapped) line.bool forwardDisplayLineEnd(gtk.text_iter.TextIter iter)Moves the given iter forward to the next display line end.bool getAcceptsTab()Returns whether pressing the <kbd>Tab</kbd> key inserts a tab characters.int getBottomMargin()Gets the bottom margin for text in the text_view. Returns: bottom margin in pixelsgtk.text_buffer.TextBuffer getBuffer()Returns 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)Determine the positions of the strong and weak cursors if the insertion point is at iter.bool getCursorVisible()Find out whether the cursor should be displayed. Returns: whether the insertion mark is visiblebool getEditable()Returns the default editability of the [gtk.text_view.TextView].gio.menu_model.MenuModel getExtraMenu()Gets the menu model that gets added to the context menu or null if none has been set. Returns: the menu modelgtk.widget.Widget getGutter(gtk.types.TextWindowType win)Gets a [gtk.widget.Widget] that has previously been set as gutter.int getIndent()Gets the default indentation of paragraphs in text_view.gtk.types.InputHints getInputHints()Gets the `input-hints` of the [gtk.text_view.TextView]. Returns:gtk.types.InputPurpose getInputPurpose()Gets the `input-purpose` of the [gtk.text_view.TextView]. Returns:bool getIterAtLocation(out gtk.text_iter.TextIter iter, int x, int y)Retrieves the iterator at buffer coordinates `x` and `y`.bool getIterAtPosition(out gtk.text_iter.TextIter iter, out int trailing, int x, int y)Retrieves the iterator pointing to the character at buffer coordinates `x` and `y`.void getIterLocation(gtk.text_iter.TextIter iter, out gdk.rectangle.Rectangle location)Gets a rectangle which roughly contains the character at iter.gtk.types.Justification getJustification()Gets the default justification of paragraphs in text_view.int getLeftMargin()Gets the default left margin size of paragraphs in the text_view.void getLineAtY(out gtk.text_iter.TextIter targetIter, int y, out int lineTop)Gets 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)Gets the y coordinate of the top of the line containing iter, and the height of the line.pango.context.Context getLtrContext()Gets the [pango.context.Context] that is used for rendering LTR directed text layouts.bool getMonospace()Gets whether the [gtk.text_view.TextView] uses monospace styling. Returns: true if monospace fonts are desiredbool getOverwrite()Returns whether the [gtk.textview.TextView] is in overwrite mode or not. Returns: whether textview is in overwrite mode or not.int getPixelsAboveLines()Gets the default number of pixels to put above paragraphs.int getPixelsBelowLines()Gets the default number of pixels to put below paragraphs.int getPixelsInsideWrap()Gets the default number of pixels to put between wrapped lines inside a paragraph. Returns: default number of pixels of blank space between wrapped linesint getRightMargin()Gets the default right margin for text in text_view.pango.context.Context getRtlContext()Gets the [pango.context.Context] that is used for rendering RTL directed text layouts.pango.tab_array.TabArray getTabs()Gets the default tabs for text_view.int getTopMargin()Gets the top margin for text in the text_view. Returns: top margin in pixelsvoid getVisibleRect(out gdk.rectangle.Rectangle visibleRect)Fills visible_rect with the currently-visible region of the buffer, in buffer coordinates.gtk.types.WrapMode getWrapMode()Gets the line wrapping for the view. Returns: the line wrap settingbool imContextFilterKeypress(gdk.event.Event event)Allow the [gtk.text_view.TextView] input method to internally handle key press and release events.bool moveMarkOnscreen(gtk.text_mark.TextMark mark)Moves 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)Updates the position of a child.bool moveVisually(gtk.text_iter.TextIter iter, int count)Move the iterator a given number of characters visually, treating it as the strong cursor position.bool placeCursorOnscreen()Moves 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)Removes a child widget from text_view.void resetCursorBlink()Ensures that the cursor is shown.void resetImContext()Reset the input method context of the text view if needed.void scrollMarkOnscreen(gtk.text_mark.TextMark mark)Scrolls 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)Scrolls 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)Scrolls text_view so that mark is on the screen in the position indicated by xalign and yalign.void setAcceptsTab(bool acceptsTab)Sets the behavior of the text widget when the <kbd>Tab</kbd> key is pressed.void setBottomMargin(int bottomMargin)Sets the bottom margin for text in text_view.void setBuffer(gtk.text_buffer.TextBuffer buffer = null)Sets buffer as the buffer being displayed by text_view.void setCursorVisible(bool setting)Toggles whether the insertion point should be displayed.void setEditable(bool setting)Sets the default editability of the [gtk.text_view.TextView].void setExtraMenu(gio.menu_model.MenuModel model = null)Sets a menu model to add when constructing the context menu for text_view.void setGutter(gtk.types.TextWindowType win, gtk.widget.Widget widget = null)Places widget into the gutter specified by win.void setIndent(int indent)Sets the default indentation for paragraphs in text_view.void setInputHints(gtk.types.InputHints hints)Sets the `input-hints` of the [gtk.text_view.TextView].void setInputPurpose(gtk.types.InputPurpose purpose)Sets the `input-purpose` of the [gtk.text_view.TextView].void setJustification(gtk.types.Justification justification)Sets the default justification of text in text_view.void setLeftMargin(int leftMargin)Sets the default left margin for text in text_view.void setMonospace(bool monospace)Sets whether the [gtk.text_view.TextView] should display text in monospace styling.void setOverwrite(bool overwrite)Changes the [gtk.text_view.TextView] overwrite mode.void setPixelsAboveLines(int pixelsAboveLines)Sets the default number of blank pixels above paragraphs in text_view.void setPixelsBelowLines(int pixelsBelowLines)Sets the default number of pixels of blank space to put below paragraphs in text_view.void setPixelsInsideWrap(int pixelsInsideWrap)Sets the default number of pixels of blank space to leave between display/wrapped lines within a paragraph.void setRightMargin(int rightMargin)Sets the default right margin for text in the text view.void setTabs(pango.tab_array.TabArray tabs)Sets the default tab stops for paragraphs in text_view.void setTopMargin(int topMargin)Sets the top margin for text in text_view.void setWrapMode(gtk.types.WrapMode wrapMode)Sets the line wrapping for the view.bool startsDisplayLine(gtk.text_iter.TextIter iter)Determines 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)Converts 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)Connect 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)Connect 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)Connect 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)Connect 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)Connect 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)Connect 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)Connect 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)Connect 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)Connect 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)Connect 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)Connect 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)Connect 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)Connect 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)Connect 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)Connect to `ToggleOverwrite` signal.T acceptsTab(bool propval)Set `acceptsTab` property. Params: propval = Whether Tab will result in a tab character being entered. Returns: Builder instance for fluent chainingT bottomMargin(int propval)Set `bottomMargin` property. Params: propval = The bottom margin for text in the text view.T buffer(gtk.text_buffer.TextBuffer propval)Set `buffer` property. Params: propval = The buffer which is displayed. Returns: Builder instance for fluent chainingT cursorVisible(bool propval)Set `cursorVisible` property. Params: propval = If the insertion cursor is shown. Returns: Builder instance for fluent chainingT editable(bool propval)T extraMenu(gio.menu_model.MenuModel propval)Set `extraMenu` property. Params: propval = A menu model whose contents will be appended to the context menu. Returns: Builder instance for fluent chainingT imModule(string propval)Set `imModule` property. Params: propval = Which IM (input method) module should be used for this text_view.T indent(int propval)Set `indent` property. Params: propval = Amount to indent the paragraph, in pixels.T inputHints(gtk.types.InputHints propval)Set `inputHints` property. Params: propval = Additional hints (beyond `property@Gtk.TextView:input-purpose`) that allow input methods to fine-tune their behaviour. Returns: Builder instance for flu...T inputPurpose(gtk.types.InputPurpose propval)Set `inputPurpose` property. Params: propval = The purpose of this text field.T justification(gtk.types.Justification propval)T leftMargin(int propval)Set `leftMargin` property. Params: propval = The default left margin for text in the text view.T monospace(bool propval)Set `monospace` property. Params: propval = Whether text should be displayed in a monospace font.T overwrite(bool propval)Set `overwrite` property. Params: propval = Whether entered text overwrites existing contents. Returns: Builder instance for fluent chainingT pixelsAboveLines(int propval)T pixelsBelowLines(int propval)T pixelsInsideWrap(int propval)T rightMargin(int propval)Set `rightMargin` property. Params: propval = The default right margin for text in the text view.T tabs(pango.tab_array.TabArray propval)T topMargin(int propval)Set `topMargin` property. Params: propval = The top margin for text in the text view.T wrapMode(gtk.types.WrapMode propval)