Trait gtk4::prelude::TextViewExt

source ·
pub trait TextViewExt: IsA<TextView> + Sealed + 'static {
Show 123 methods // Provided methods fn add_child_at_anchor( &self, child: &impl IsA<Widget>, anchor: &impl IsA<TextChildAnchor> ) { ... } fn add_overlay(&self, child: &impl IsA<Widget>, xpos: i32, ypos: i32) { ... } fn backward_display_line(&self, iter: &mut TextIter) -> bool { ... } fn backward_display_line_start(&self, iter: &mut TextIter) -> bool { ... } fn buffer_to_window_coords( &self, win: TextWindowType, buffer_x: i32, buffer_y: i32 ) -> (i32, i32) { ... } fn forward_display_line(&self, iter: &mut TextIter) -> bool { ... } fn forward_display_line_end(&self, iter: &mut TextIter) -> bool { ... } fn accepts_tab(&self) -> bool { ... } fn bottom_margin(&self) -> i32 { ... } fn buffer(&self) -> TextBuffer { ... } fn cursor_locations( &self, iter: Option<&TextIter> ) -> (Rectangle, Rectangle) { ... } fn is_cursor_visible(&self) -> bool { ... } fn is_editable(&self) -> bool { ... } fn extra_menu(&self) -> MenuModel { ... } fn gutter(&self, win: TextWindowType) -> Option<Widget> { ... } fn indent(&self) -> i32 { ... } fn input_hints(&self) -> InputHints { ... } fn input_purpose(&self) -> InputPurpose { ... } fn iter_at_location(&self, x: i32, y: i32) -> Option<TextIter> { ... } fn iter_at_position(&self, x: i32, y: i32) -> Option<(TextIter, i32)> { ... } fn iter_location(&self, iter: &TextIter) -> Rectangle { ... } fn justification(&self) -> Justification { ... } fn left_margin(&self) -> i32 { ... } fn line_at_y(&self, y: i32) -> (TextIter, i32) { ... } fn line_yrange(&self, iter: &TextIter) -> (i32, i32) { ... } fn ltr_context(&self) -> Context { ... } fn is_monospace(&self) -> bool { ... } fn overwrites(&self) -> bool { ... } fn pixels_above_lines(&self) -> i32 { ... } fn pixels_below_lines(&self) -> i32 { ... } fn pixels_inside_wrap(&self) -> i32 { ... } fn right_margin(&self) -> i32 { ... } fn rtl_context(&self) -> Context { ... } fn tabs(&self) -> Option<TabArray> { ... } fn top_margin(&self) -> i32 { ... } fn visible_rect(&self) -> Rectangle { ... } fn wrap_mode(&self) -> WrapMode { ... } fn im_context_filter_keypress(&self, event: impl AsRef<Event>) -> bool { ... } fn move_mark_onscreen(&self, mark: &impl IsA<TextMark>) -> bool { ... } fn move_overlay(&self, child: &impl IsA<Widget>, xpos: i32, ypos: i32) { ... } fn move_visually(&self, iter: &mut TextIter, count: i32) -> bool { ... } fn place_cursor_onscreen(&self) -> bool { ... } fn remove(&self, child: &impl IsA<Widget>) { ... } fn reset_cursor_blink(&self) { ... } fn reset_im_context(&self) { ... } fn scroll_mark_onscreen(&self, mark: &impl IsA<TextMark>) { ... } fn scroll_to_iter( &self, iter: &mut TextIter, within_margin: f64, use_align: bool, xalign: f64, yalign: f64 ) -> bool { ... } fn scroll_to_mark( &self, mark: &impl IsA<TextMark>, within_margin: f64, use_align: bool, xalign: f64, yalign: f64 ) { ... } fn set_accepts_tab(&self, accepts_tab: bool) { ... } fn set_bottom_margin(&self, bottom_margin: i32) { ... } fn set_buffer(&self, buffer: Option<&impl IsA<TextBuffer>>) { ... } fn set_cursor_visible(&self, setting: bool) { ... } fn set_editable(&self, setting: bool) { ... } fn set_extra_menu(&self, model: Option<&impl IsA<MenuModel>>) { ... } fn set_gutter(&self, win: TextWindowType, widget: Option<&impl IsA<Widget>>) { ... } fn set_indent(&self, indent: i32) { ... } fn set_input_hints(&self, hints: InputHints) { ... } fn set_input_purpose(&self, purpose: InputPurpose) { ... } fn set_justification(&self, justification: Justification) { ... } fn set_left_margin(&self, left_margin: i32) { ... } fn set_monospace(&self, monospace: bool) { ... } fn set_overwrite(&self, overwrite: bool) { ... } fn set_pixels_above_lines(&self, pixels_above_lines: i32) { ... } fn set_pixels_below_lines(&self, pixels_below_lines: i32) { ... } fn set_pixels_inside_wrap(&self, pixels_inside_wrap: i32) { ... } fn set_right_margin(&self, right_margin: i32) { ... } fn set_tabs(&self, tabs: &TabArray) { ... } fn set_top_margin(&self, top_margin: i32) { ... } fn set_wrap_mode(&self, wrap_mode: WrapMode) { ... } fn starts_display_line(&self, iter: &TextIter) -> bool { ... } fn window_to_buffer_coords( &self, win: TextWindowType, window_x: i32, window_y: i32 ) -> (i32, i32) { ... } fn im_module(&self) -> Option<GString> { ... } fn set_im_module(&self, im_module: Option<&str>) { ... } fn connect_backspace<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { ... } fn emit_backspace(&self) { ... } fn connect_copy_clipboard<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn emit_copy_clipboard(&self) { ... } fn connect_cut_clipboard<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn emit_cut_clipboard(&self) { ... } fn connect_delete_from_cursor<F: Fn(&Self, DeleteType, i32) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn emit_delete_from_cursor(&self, type_: DeleteType, count: i32) { ... } fn connect_extend_selection<F: Fn(&Self, TextExtendSelection, &TextIter, &TextIter, &TextIter) -> Propagation + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_insert_at_cursor<F: Fn(&Self, &str) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn emit_insert_at_cursor(&self, string: &str) { ... } fn connect_insert_emoji<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn emit_insert_emoji(&self) { ... } fn connect_move_cursor<F: Fn(&Self, MovementStep, i32, bool) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn emit_move_cursor( &self, step: MovementStep, count: i32, extend_selection: bool ) { ... } fn connect_move_viewport<F: Fn(&Self, ScrollStep, i32) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn emit_move_viewport(&self, step: ScrollStep, count: i32) { ... } fn connect_paste_clipboard<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn emit_paste_clipboard(&self) { ... } fn connect_preedit_changed<F: Fn(&Self, &str) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn emit_preedit_changed(&self, preedit: &str) { ... } fn connect_select_all<F: Fn(&Self, bool) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn emit_select_all(&self, select: bool) { ... } fn connect_set_anchor<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn emit_set_anchor(&self) { ... } fn connect_toggle_cursor_visible<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn emit_toggle_cursor_visible(&self) { ... } fn connect_toggle_overwrite<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn emit_toggle_overwrite(&self) { ... } fn connect_accepts_tab_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_bottom_margin_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_buffer_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_cursor_visible_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_editable_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_extra_menu_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_im_module_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_indent_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_input_hints_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_input_purpose_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_justification_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_left_margin_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_monospace_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_overwrite_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_pixels_above_lines_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_pixels_below_lines_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_pixels_inside_wrap_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_right_margin_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_tabs_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_top_margin_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_wrap_mode_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... }
}
Expand description

Trait containing all TextView methods.

§Implementors

TextView

Provided Methods§

source

fn add_child_at_anchor( &self, child: &impl IsA<Widget>, anchor: &impl IsA<TextChildAnchor> )

Adds a child widget in the text buffer, at the given @anchor.

§child

a Widget

§anchor

a TextChildAnchor in the TextBuffer for @self

source

fn add_overlay(&self, child: &impl IsA<Widget>, xpos: i32, ypos: i32)

Adds @child at a fixed coordinate in the TextView’s text window.

The @xpos and @ypos must be in buffer coordinates (see iter_location() to convert to buffer coordinates).

@child will scroll with the text view.

If instead you want a widget that will not move with the TextView contents see Overlay.

§child

a Widget

§xpos

X position of child in window coordinates

§ypos

Y position of child in window coordinates

source

fn backward_display_line(&self, iter: &mut TextIter) -> bool

Moves the given @iter backward by one display (wrapped) line.

A display line is different from a paragraph. Paragraphs are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a paragraph. If wrapping is turned off, display lines and paragraphs will be the same. Display lines are divided differently for each view, since they depend on the view’s width; paragraphs are the same in all views, since they depend on the contents of the TextBuffer.

§iter

a TextIter

§Returns

true if @iter was moved and is not on the end iterator

source

fn backward_display_line_start(&self, iter: &mut TextIter) -> bool

Moves the given @iter backward to the next display line start.

A display line is different from a paragraph. Paragraphs are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a paragraph. If wrapping is turned off, display lines and paragraphs will be the same. Display lines are divided differently for each view, since they depend on the view’s width; paragraphs are the same in all views, since they depend on the contents of the TextBuffer.

§iter

a TextIter

§Returns

true if @iter was moved and is not on the end iterator

source

fn buffer_to_window_coords( &self, win: TextWindowType, buffer_x: i32, buffer_y: i32 ) -> (i32, i32)

Converts buffer coordinates to window coordinates.

§win

a TextWindowType

§buffer_x

buffer x coordinate

§buffer_y

buffer y coordinate

§Returns
§window_x

window x coordinate return location

§window_y

window y coordinate return location

source

fn forward_display_line(&self, iter: &mut TextIter) -> bool

Moves the given @iter forward by one display (wrapped) line.

A display line is different from a paragraph. Paragraphs are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a paragraph. If wrapping is turned off, display lines and paragraphs will be the same. Display lines are divided differently for each view, since they depend on the view’s width; paragraphs are the same in all views, since they depend on the contents of the TextBuffer.

§iter

a TextIter

§Returns

true if @iter was moved and is not on the end iterator

source

fn forward_display_line_end(&self, iter: &mut TextIter) -> bool

Moves the given @iter forward to the next display line end.

A display line is different from a paragraph. Paragraphs are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a paragraph. If wrapping is turned off, display lines and paragraphs will be the same. Display lines are divided differently for each view, since they depend on the view’s width; paragraphs are the same in all views, since they depend on the contents of the TextBuffer.

§iter

a TextIter

§Returns

true if @iter was moved and is not on the end iterator

source

fn accepts_tab(&self) -> bool

Returns whether pressing the Tab key inserts a tab characters.

See set_accepts_tab().

§Returns

true if pressing the Tab key inserts a tab character, false if pressing the Tab key moves the keyboard focus.

source

fn bottom_margin(&self) -> i32

Gets the bottom margin for text in the @self.

§Returns

bottom margin in pixels

source

fn buffer(&self) -> TextBuffer

Returns the TextBuffer being displayed by this text view.

The reference count on the buffer is not incremented; the caller of this function won’t own a new reference.

§Returns

a TextBuffer

source

fn cursor_locations(&self, iter: Option<&TextIter>) -> (Rectangle, Rectangle)

Determine the positions of the strong and weak cursors if the insertion point is at @iter.

The position of each cursor is stored as a zero-width rectangle. The strong cursor location is the location where characters of the directionality equal to the base direction of the paragraph are inserted. The weak cursor location is the location where characters of the directionality opposite to the base direction of the paragraph are inserted.

If @iter is None, the actual cursor position is used.

Note that if @iter happens to be the actual cursor position, and there is currently an IM preedit sequence being entered, the returned locations will be adjusted to account for the preedit cursor’s offset within the preedit sequence.

The rectangle position is in buffer coordinates; use buffer_to_window_coords() to convert these coordinates to coordinates for one of the windows in the text view.

§iter

a TextIter

§Returns
§strong

location to store the strong cursor position

§weak

location to store the weak cursor position

source

fn is_cursor_visible(&self) -> bool

Find out whether the cursor should be displayed.

§Returns

whether the insertion mark is visible

source

fn is_editable(&self) -> bool

Returns the default editability of the TextView.

Tags in the buffer may override this setting for some ranges of text.

§Returns

whether text is editable by default

source

fn extra_menu(&self) -> MenuModel

Gets the menu model that gets added to the context menu or None if none has been set.

§Returns

the menu model

source

fn gutter(&self, win: TextWindowType) -> Option<Widget>

Gets a Widget that has previously been set as gutter.

See set_gutter().

@win must be one of TextWindowType::Left, TextWindowType::Right, TextWindowType::Top, or TextWindowType::Bottom.

§win

a TextWindowType

§Returns

a Widget

source

fn indent(&self) -> i32

Gets the default indentation of paragraphs in @self.

Tags in the view’s buffer may override the default. The indentation may be negative.

§Returns

number of pixels of indentation

source

fn input_hints(&self) -> InputHints

Gets the input-hints of the TextView.

source

fn input_purpose(&self) -> InputPurpose

Gets the input-purpose of the TextView.

source

fn iter_at_location(&self, x: i32, y: i32) -> Option<TextIter>

Retrieves the iterator at buffer coordinates @x and @y.

Buffer coordinates are coordinates for the entire buffer, not just the currently-displayed portion. If you have coordinates from an event, you have to convert those to buffer coordinates with window_to_buffer_coords().

§x

x position, in buffer coordinates

§y

y position, in buffer coordinates

§Returns

true if the position is over text

§iter

a TextIter

source

fn iter_at_position(&self, x: i32, y: i32) -> Option<(TextIter, i32)>

Retrieves the iterator pointing to the character at buffer coordinates @x and @y.

Buffer coordinates are coordinates for the entire buffer, not just the currently-displayed portion. If you have coordinates from an event, you have to convert those to buffer coordinates with window_to_buffer_coords().

Note that this is different from iter_at_location(), which returns cursor locations, i.e. positions between characters.

§x

x position, in buffer coordinates

§y

y position, in buffer coordinates

§Returns

true if the position is over text

§iter

a TextIter

§trailing

if non-None, location to store an integer indicating where in the grapheme the user clicked. It will either be zero, or the number of characters in the grapheme. 0 represents the trailing edge of the grapheme.

source

fn iter_location(&self, iter: &TextIter) -> Rectangle

Gets a rectangle which roughly contains the character at @iter.

The rectangle position is in buffer coordinates; use buffer_to_window_coords() to convert these coordinates to coordinates for one of the windows in the text view.

§iter

a TextIter

§Returns
§location

bounds of the character at @iter

source

fn justification(&self) -> Justification

Gets the default justification of paragraphs in @self.

Tags in the buffer may override the default.

§Returns

default justification

source

fn left_margin(&self) -> i32

Gets the default left margin size of paragraphs in the @self.

Tags in the buffer may override the default.

§Returns

left margin in pixels

source

fn line_at_y(&self, y: i32) -> (TextIter, i32)

Gets the TextIter at the start of the line containing the coordinate @y.

@y is in buffer coordinates, convert from window coordinates with window_to_buffer_coords(). If non-None, @line_top will be filled with the coordinate of the top edge of the line.

§y

a y coordinate

§Returns
§target_iter

a TextIter

§line_top

return location for top coordinate of the line

source

fn line_yrange(&self, iter: &TextIter) -> (i32, i32)

Gets the y coordinate of the top of the line containing @iter, and the height of the line.

The coordinate is a buffer coordinate; convert to window coordinates with buffer_to_window_coords().

§iter

a TextIter

§Returns
§y

return location for a y coordinate

§height

return location for a height

source

fn ltr_context(&self) -> Context

Available on crate feature v4_4 only.

Gets the pango::Context that is used for rendering LTR directed text layouts.

The context may be replaced when CSS changes occur.

§Returns

a pango::Context

source

fn is_monospace(&self) -> bool

Gets whether the TextView uses monospace styling.

§Returns

true if monospace fonts are desired

source

fn overwrites(&self) -> bool

Returns whether the TextView is in overwrite mode or not.

§Returns

whether @self is in overwrite mode or not.

source

fn pixels_above_lines(&self) -> i32

Gets the default number of pixels to put above paragraphs.

Adding this function with pixels_below_lines() is equal to the line space between each paragraph.

§Returns

default number of pixels above paragraphs

source

fn pixels_below_lines(&self) -> i32

Gets the default number of pixels to put below paragraphs.

The line space is the sum of the value returned by this function and the value returned by pixels_above_lines().

§Returns

default number of blank pixels below paragraphs

source

fn pixels_inside_wrap(&self) -> i32

Gets the default number of pixels to put between wrapped lines inside a paragraph.

§Returns

default number of pixels of blank space between wrapped lines

source

fn right_margin(&self) -> i32

Gets the default right margin for text in @self.

Tags in the buffer may override the default.

§Returns

right margin in pixels

source

fn rtl_context(&self) -> Context

Available on crate feature v4_4 only.

Gets the pango::Context that is used for rendering RTL directed text layouts.

The context may be replaced when CSS changes occur.

§Returns

a pango::Context

source

fn tabs(&self) -> Option<TabArray>

Gets the default tabs for @self.

Tags in the buffer may override the defaults. The returned array will be None if “standard” (8-space) tabs are used. Free the return value with Pango::TabArray::free().

§Returns

copy of default tab array, or None if standard tabs are used; must be freed with Pango::TabArray::free().

source

fn top_margin(&self) -> i32

Gets the top margin for text in the @self.

§Returns

top margin in pixels

source

fn visible_rect(&self) -> Rectangle

Fills @visible_rect with the currently-visible region of the buffer, in buffer coordinates.

Convert to window coordinates with buffer_to_window_coords().

§Returns
§visible_rect

rectangle to fill

source

fn wrap_mode(&self) -> WrapMode

Gets the line wrapping for the view.

§Returns

the line wrap setting

source

fn im_context_filter_keypress(&self, event: impl AsRef<Event>) -> bool

Allow the TextView input method to internally handle key press and release events.

If this function returns true, then no further processing should be done for this key event. See IMContextExt::filter_keypress().

Note that you are expected to call this function from your handler when overriding key event handling. This is needed in the case when you need to insert your own key handling between the input method and the default key event handling of the TextView.

⚠️ The following code is in c ⚠️

static gboolean
gtk_foo_bar_key_press_event (GtkWidget *widget,
                             GdkEvent  *event)
{
  guint keyval;

  gdk_event_get_keyval ((GdkEvent*)event, &keyval);

  if (keyval == GDK_KEY_Return || keyval == GDK_KEY_KP_Enter)
    {
      if (gtk_text_view_im_context_filter_keypress (GTK_TEXT_VIEW (widget), event))
        return TRUE;
    }

  // Do some stuff

  return GTK_WIDGET_CLASS (gtk_foo_bar_parent_class)->key_press_event (widget, event);
}
§event

the key event

§Returns

true if the input method handled the key event.

source

fn move_mark_onscreen(&self, mark: &impl IsA<TextMark>) -> bool

Moves a mark within the buffer so that it’s located within the currently-visible text area.

§mark

a TextMark

§Returns

true if the mark moved (wasn’t already onscreen)

source

fn move_overlay(&self, child: &impl IsA<Widget>, xpos: i32, ypos: i32)

Updates the position of a child.

See add_overlay().

§child

a widget already added with add_overlay()

§xpos

new X position in buffer coordinates

§ypos

new Y position in buffer coordinates

source

fn move_visually(&self, iter: &mut TextIter, count: i32) -> bool

Move the iterator a given number of characters visually, treating it as the strong cursor position.

If @count is positive, then the new strong cursor position will be @count positions to the right of the old cursor position. If @count is negative then the new strong cursor position will be @count positions to the left of the old cursor position.

In the presence of bi-directional text, the correspondence between logical and visual order will depend on the direction of the current run, and there may be jumps when the cursor is moved off of the end of a run.

§iter

a TextIter

§count

number of characters to move (negative moves left, positive moves right)

§Returns

true if @iter moved and is not on the end iterator

source

fn place_cursor_onscreen(&self) -> bool

Moves the cursor to the currently visible region of the buffer.

§Returns

true if the cursor had to be moved.

source

fn remove(&self, child: &impl IsA<Widget>)

Removes a child widget from @self.

§child

the child to remove

Ensures that the cursor is shown.

This also resets the time that it will stay blinking (or visible, in case blinking is disabled).

This function should be called in response to user input (e.g. from derived classes that override the textview’s event handlers).

source

fn reset_im_context(&self)

Reset the input method context of the text view if needed.

This can be necessary in the case where modifying the buffer would confuse on-going input method behavior.

source

fn scroll_mark_onscreen(&self, mark: &impl IsA<TextMark>)

Scrolls @self the minimum distance such that @mark is contained within the visible area of the widget.

§mark

a mark in the buffer for @self

source

fn scroll_to_iter( &self, iter: &mut TextIter, within_margin: f64, use_align: bool, xalign: f64, yalign: f64 ) -> bool

Scrolls @self so that @iter is on the screen in the position indicated by @xalign and @yalign.

An alignment of 0.0 indicates left or top, 1.0 indicates right or bottom, 0.5 means center. If @use_align is false, the text scrolls the minimal distance to get the mark onscreen, possibly not scrolling at all. The effective screen for purposes of this function is reduced by a margin of size @within_margin.

Note that this function uses the currently-computed height of the lines in the text buffer. Line heights are computed in an idle handler; so this function may not have the desired effect if it’s called before the height computations. To avoid oddness, consider using scroll_to_mark() which saves a point to be scrolled to after line validation.

§iter

a TextIter

§within_margin

margin as a [0.0,0.5) fraction of screen size

§use_align

whether to use alignment arguments (if false, just get the mark onscreen)

§xalign

horizontal alignment of mark within visible area

§yalign

vertical alignment of mark within visible area

§Returns

true if scrolling occurred

source

fn scroll_to_mark( &self, mark: &impl IsA<TextMark>, within_margin: f64, use_align: bool, xalign: f64, yalign: f64 )

Scrolls @self so that @mark is on the screen in the position indicated by @xalign and @yalign.

An alignment of 0.0 indicates left or top, 1.0 indicates right or bottom, 0.5 means center. If @use_align is false, the text scrolls the minimal distance to get the mark onscreen, possibly not scrolling at all. The effective screen for purposes of this function is reduced by a margin of size @within_margin.

§mark

a TextMark

§within_margin

margin as a [0.0,0.5) fraction of screen size

§use_align

whether to use alignment arguments (if false, just get the mark onscreen)

§xalign

horizontal alignment of mark within visible area

§yalign

vertical alignment of mark within visible area

source

fn set_accepts_tab(&self, accepts_tab: bool)

Sets the behavior of the text widget when the Tab key is pressed.

If @accepts_tab is true, a tab character is inserted. If @accepts_tab is false the keyboard focus is moved to the next widget in the focus chain.

Focus can always be moved using Ctrl+Tab.

§accepts_tab

true if pressing the Tab key should insert a tab character, false, if pressing the Tab key should move the keyboard focus.

source

fn set_bottom_margin(&self, bottom_margin: i32)

Sets the bottom margin for text in @self.

Note that this function is confusingly named. In CSS terms, the value set here is padding.

§bottom_margin

bottom margin in pixels

source

fn set_buffer(&self, buffer: Option<&impl IsA<TextBuffer>>)

Sets @buffer as the buffer being displayed by @self.

The previous buffer displayed by the text view is unreferenced, and a reference is added to @buffer. If you owned a reference to @buffer before passing it to this function, you must remove that reference yourself; TextView will not “adopt” it.

§buffer

a TextBuffer

source

fn set_cursor_visible(&self, setting: bool)

Toggles whether the insertion point should be displayed.

A buffer with no editable text probably shouldn’t have a visible cursor, so you may want to turn the cursor off.

Note that this property may be overridden by the gtk-keynav-use-caret setting.

§setting

whether to show the insertion cursor

source

fn set_editable(&self, setting: bool)

Sets the default editability of the TextView.

You can override this default setting with tags in the buffer, using the “editable” attribute of tags.

§setting

whether it’s editable

source

fn set_extra_menu(&self, model: Option<&impl IsA<MenuModel>>)

Sets a menu model to add when constructing the context menu for @self.

You can pass None to remove a previously set extra menu.

§model

a GMenuModel

source

fn set_gutter(&self, win: TextWindowType, widget: Option<&impl IsA<Widget>>)

Places @widget into the gutter specified by @win.

@win must be one of TextWindowType::Left, TextWindowType::Right, TextWindowType::Top, or TextWindowType::Bottom.

§win

a TextWindowType

§widget

a Widget

source

fn set_indent(&self, indent: i32)

Sets the default indentation for paragraphs in @self.

Tags in the buffer may override the default.

§indent

indentation in pixels

source

fn set_input_hints(&self, hints: InputHints)

Sets the input-hints of the TextView.

The input-hints allow input methods to fine-tune their behaviour.

§hints

the hints

source

fn set_input_purpose(&self, purpose: InputPurpose)

Sets the input-purpose of the TextView.

The input-purpose can be used by on-screen keyboards and other input methods to adjust their behaviour.

§purpose

the purpose

source

fn set_justification(&self, justification: Justification)

Sets the default justification of text in @self.

Tags in the view’s buffer may override the default.

§justification

justification

source

fn set_left_margin(&self, left_margin: i32)

Sets the default left margin for text in @self.

Tags in the buffer may override the default.

Note that this function is confusingly named. In CSS terms, the value set here is padding.

§left_margin

left margin in pixels

source

fn set_monospace(&self, monospace: bool)

Sets whether the TextView should display text in monospace styling.

§monospace

true to request monospace styling

source

fn set_overwrite(&self, overwrite: bool)

Changes the TextView overwrite mode.

§overwrite

true to turn on overwrite mode, false to turn it off

source

fn set_pixels_above_lines(&self, pixels_above_lines: i32)

Sets the default number of blank pixels above paragraphs in @self.

Tags in the buffer for @self may override the defaults.

§pixels_above_lines

pixels above paragraphs

source

fn set_pixels_below_lines(&self, pixels_below_lines: i32)

Sets the default number of pixels of blank space to put below paragraphs in @self.

May be overridden by tags applied to @self’s buffer.

§pixels_below_lines

pixels below paragraphs

source

fn set_pixels_inside_wrap(&self, pixels_inside_wrap: i32)

Sets the default number of pixels of blank space to leave between display/wrapped lines within a paragraph.

May be overridden by tags in @self’s buffer.

§pixels_inside_wrap

default number of pixels between wrapped lines

source

fn set_right_margin(&self, right_margin: i32)

Sets the default right margin for text in the text view.

Tags in the buffer may override the default.

Note that this function is confusingly named. In CSS terms, the value set here is padding.

§right_margin

right margin in pixels

source

fn set_tabs(&self, tabs: &TabArray)

Sets the default tab stops for paragraphs in @self.

Tags in the buffer may override the default.

§tabs

tabs as a pango::TabArray

source

fn set_top_margin(&self, top_margin: i32)

Sets the top margin for text in @self.

Note that this function is confusingly named. In CSS terms, the value set here is padding.

§top_margin

top margin in pixels

source

fn set_wrap_mode(&self, wrap_mode: WrapMode)

Sets the line wrapping for the view.

§wrap_mode

a WrapMode

source

fn starts_display_line(&self, iter: &TextIter) -> bool

Determines whether @iter is at the start of a display line.

See forward_display_line() for an explanation of display lines vs. paragraphs.

§iter

a TextIter

§Returns

true if @iter begins a wrapped line

source

fn window_to_buffer_coords( &self, win: TextWindowType, window_x: i32, window_y: i32 ) -> (i32, i32)

Converts coordinates on the window identified by @win to buffer coordinates.

§win

a TextWindowType

§window_x

window x coordinate

§window_y

window y coordinate

§Returns
§buffer_x

buffer x coordinate return location

§buffer_y

buffer y coordinate return location

source

fn im_module(&self) -> Option<GString>

Which IM (input method) module should be used for this text_view.

See IMMulticontext.

Setting this to a non-None value overrides the system-wide IM module setting. See the GtkSettings gtk-im-module property.

source

fn set_im_module(&self, im_module: Option<&str>)

Which IM (input method) module should be used for this text_view.

See IMMulticontext.

Setting this to a non-None value overrides the system-wide IM module setting. See the GtkSettings gtk-im-module property.

source

fn connect_backspace<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Gets emitted when the user asks for it.

The ::backspace signal is a keybinding signal.

The default bindings for this signal are Backspace and Shift+Backspace.

source

fn emit_backspace(&self)

source

fn connect_copy_clipboard<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

Gets emitted to copy the selection to the clipboard.

The ::copy-clipboard signal is a keybinding signal.

The default bindings for this signal are Ctrl+c and Ctrl+Insert.

source

fn emit_copy_clipboard(&self)

source

fn connect_cut_clipboard<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Gets emitted to cut the selection to the clipboard.

The ::cut-clipboard signal is a keybinding signal.

The default bindings for this signal are Ctrl+x and Shift+Delete.

source

fn emit_cut_clipboard(&self)

source

fn connect_delete_from_cursor<F: Fn(&Self, DeleteType, i32) + 'static>( &self, f: F ) -> SignalHandlerId

Gets emitted when the user initiates a text deletion.

The ::delete-from-cursor signal is a keybinding signal.

If the @type_ is DeleteType::Chars, GTK deletes the selection if there is one, otherwise it deletes the requested number of characters.

The default bindings for this signal are Delete for deleting a character, Ctrl+Delete for deleting a word and Ctrl+Backspace for deleting a word backwards.

§type_

the granularity of the deletion, as a DeleteType

§count

the number of @type_ units to delete

source

fn emit_delete_from_cursor(&self, type_: DeleteType, count: i32)

source

fn connect_extend_selection<F: Fn(&Self, TextExtendSelection, &TextIter, &TextIter, &TextIter) -> Propagation + 'static>( &self, f: F ) -> SignalHandlerId

Emitted when the selection needs to be extended at @location.

§granularity

the granularity type

§location

the location where to extend the selection

§start

where the selection should start

§end

where the selection should end

§Returns

GDK_EVENT_STOP to stop other handlers from being invoked for the event. GDK_EVENT_PROPAGATE to propagate the event further.

source

fn connect_insert_at_cursor<F: Fn(&Self, &str) + 'static>( &self, f: F ) -> SignalHandlerId

Gets emitted when the user initiates the insertion of a fixed string at the cursor.

The ::insert-at-cursor signal is a keybinding signal.

This signal has no default bindings.

§string

the string to insert

source

fn emit_insert_at_cursor(&self, string: &str)

source

fn connect_insert_emoji<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Gets emitted to present the Emoji chooser for the @text_view.

The ::insert-emoji signal is a keybinding signal.

The default bindings for this signal are Ctrl+. and Ctrl+;

source

fn emit_insert_emoji(&self)

source

fn connect_move_cursor<F: Fn(&Self, MovementStep, i32, bool) + 'static>( &self, f: F ) -> SignalHandlerId

Gets emitted when the user initiates a cursor movement.

The ::move-cursor signal is a keybinding signal. If the cursor is not visible in @text_view, this signal causes the viewport to be moved instead.

Applications should not connect to it, but may emit it with g_signal_emit_by_name() if they need to control the cursor programmatically.

The default bindings for this signal come in two variants, the variant with the Shift modifier extends the selection, the variant without it does not. There are too many key combinations to list them all here.

  • , , , move by individual characters/lines
  • Ctrl+, etc. move by words/paragraphs
  • Home and End move to the ends of the buffer
  • PgUp and PgDn move vertically by pages
  • Ctrl+PgUp and Ctrl+PgDn move horizontally by pages
§step

the granularity of the move, as a MovementStep

§count

the number of @step units to move

§extend_selection

true if the move should extend the selection

source

fn emit_move_cursor( &self, step: MovementStep, count: i32, extend_selection: bool )

source

fn connect_move_viewport<F: Fn(&Self, ScrollStep, i32) + 'static>( &self, f: F ) -> SignalHandlerId

Gets emitted to move the viewport.

The ::move-viewport signal is a keybinding signal, which can be bound to key combinations to allow the user to move the viewport, i.e. change what part of the text view is visible in a containing scrolled window.

There are no default bindings for this signal.

§step

the granularity of the movement, as a ScrollStep

§count

the number of @step units to move

source

fn emit_move_viewport(&self, step: ScrollStep, count: i32)

source

fn connect_paste_clipboard<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

Gets emitted to paste the contents of the clipboard into the text view.

The ::paste-clipboard signal is a keybinding signal.

The default bindings for this signal are Ctrl+v and Shift+Insert.

source

fn emit_paste_clipboard(&self)

source

fn connect_preedit_changed<F: Fn(&Self, &str) + 'static>( &self, f: F ) -> SignalHandlerId

Emitted when preedit text of the active IM changes.

If an input method is used, the typed text will not immediately be committed to the buffer. So if you are interested in the text, connect to this signal.

This signal is only emitted if the text at the given position is actually editable.

§preedit

the current preedit string

source

fn emit_preedit_changed(&self, preedit: &str)

source

fn connect_select_all<F: Fn(&Self, bool) + 'static>( &self, f: F ) -> SignalHandlerId

Gets emitted to select or unselect the complete contents of the text view.

The ::select-all signal is a keybinding signal.

The default bindings for this signal are Ctrl+a and Ctrl+/ for selecting and Shift+Ctrl+a and Ctrl+</kbd> for unselecting.

§select

true to select, false to unselect

source

fn emit_select_all(&self, select: bool)

source

fn connect_set_anchor<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Gets emitted when the user initiates settings the “anchor” mark.

The ::set-anchor signal is a keybinding signal which gets emitted when the user initiates setting the “anchor” mark. The “anchor” mark gets placed at the same position as the “insert” mark.

This signal has no default bindings.

source

fn emit_set_anchor(&self)

source

fn connect_toggle_cursor_visible<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

Gets emitted to toggle the cursor-visible property.

The ::toggle-cursor-visible signal is a keybinding signal.

The default binding for this signal is F7.

source

fn emit_toggle_cursor_visible(&self)

source

fn connect_toggle_overwrite<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

Gets emitted to toggle the overwrite mode of the text view.

The ::toggle-overwrite signal is a keybinding signal.

The default binding for this signal is Insert.

source

fn emit_toggle_overwrite(&self)

source

fn connect_accepts_tab_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_bottom_margin_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

source

fn connect_cursor_visible_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_editable_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_extra_menu_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_im_module_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_indent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

source

fn connect_input_hints_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_input_purpose_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_justification_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_left_margin_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_monospace_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_overwrite_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_pixels_above_lines_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_pixels_below_lines_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_pixels_inside_wrap_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_right_margin_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_tabs_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

source

fn connect_top_margin_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_wrap_mode_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

Object Safety§

This trait is not object safe.

Implementors§