Trait gtk4::prelude::TextViewExt

source ·
pub trait TextViewExt: 'static {
Show 123 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) -> Inhibit + '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

Required Methods§

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

child

a Widget

anchor

a TextChildAnchor in the TextBuffer for @self

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

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

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

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

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

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

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.

Gets the bottom margin for text in the @self.

Returns

bottom margin in pixels

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

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

Find out whether the cursor should be displayed.

Returns

whether the insertion mark is visible

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

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

Returns

the menu model

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

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

Gets the input-hints of the TextView.

Gets the input-purpose of the TextView.

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

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.

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

Gets the default justification of paragraphs in @self.

Tags in the buffer may override the default.

Returns

default justification

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

Tags in the buffer may override the default.

Returns

left margin in pixels

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

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

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

Gets whether the TextView uses monospace styling.

Returns

true if monospace fonts are desired

Returns whether the TextView is in overwrite mode or not.

Returns

whether @self is in overwrite mode or not.

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

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

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

Gets the default right margin for text in @self.

Tags in the buffer may override the default.

Returns

right margin in pixels

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

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().

Gets the top margin for text in the @self.

Returns

top margin in pixels

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

Gets the line wrapping for the view.

Returns

the line wrap setting

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.

Implementors§