[][src]Trait gtk::TextViewExt

pub trait TextViewExt: 'static {
    fn add_child_at_anchor<P: IsA<Widget>, Q: IsA<TextChildAnchor>>(
        &self,
        child: &P,
        anchor: &Q
    );
fn add_child_in_window<P: IsA<Widget>>(
        &self,
        child: &P,
        which_window: TextWindowType,
        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 get_accepts_tab(&self) -> bool;
fn get_border_window_size(&self, type_: TextWindowType) -> i32;
fn get_bottom_margin(&self) -> i32;
fn get_buffer(&self) -> Option<TextBuffer>;
fn get_cursor_locations(
        &self,
        iter: Option<&TextIter>
    ) -> (Rectangle, Rectangle);
fn get_cursor_visible(&self) -> bool;
fn get_default_attributes(&self) -> TextAttributes;
fn get_editable(&self) -> bool;
fn get_indent(&self) -> i32;
fn get_input_hints(&self) -> InputHints;
fn get_input_purpose(&self) -> InputPurpose;
fn get_iter_at_location(&self, x: i32, y: i32) -> Option<TextIter>;
fn get_iter_at_position(&self, x: i32, y: i32) -> Option<(TextIter, i32)>;
fn get_iter_location(&self, iter: &TextIter) -> Rectangle;
fn get_justification(&self) -> Justification;
fn get_left_margin(&self) -> i32;
fn get_line_at_y(&self, y: i32) -> (TextIter, i32);
fn get_line_yrange(&self, iter: &TextIter) -> (i32, i32);
fn get_monospace(&self) -> bool;
fn get_overwrite(&self) -> bool;
fn get_pixels_above_lines(&self) -> i32;
fn get_pixels_below_lines(&self) -> i32;
fn get_pixels_inside_wrap(&self) -> i32;
fn get_right_margin(&self) -> i32;
fn get_tabs(&self) -> Option<TabArray>;
fn get_top_margin(&self) -> i32;
fn get_visible_rect(&self) -> Rectangle;
fn get_window(&self, win: TextWindowType) -> Option<Window>;
fn get_window_type<P: IsA<Window>>(&self, window: &P) -> TextWindowType;
fn get_wrap_mode(&self) -> WrapMode;
fn im_context_filter_keypress(&self, event: &EventKey) -> bool;
fn move_child<P: IsA<Widget>>(&self, child: &P, xpos: i32, ypos: i32);
fn move_mark_onscreen<P: IsA<TextMark>>(&self, mark: &P) -> bool;
fn move_visually(&self, iter: &mut TextIter, count: i32) -> bool;
fn place_cursor_onscreen(&self) -> bool;
fn reset_cursor_blink(&self);
fn reset_im_context(&self);
fn scroll_mark_onscreen<P: IsA<TextMark>>(&self, mark: &P);
fn scroll_to_iter(
        &self,
        iter: &mut TextIter,
        within_margin: f64,
        use_align: bool,
        xalign: f64,
        yalign: f64
    ) -> bool;
fn scroll_to_mark<P: IsA<TextMark>>(
        &self,
        mark: &P,
        within_margin: f64,
        use_align: bool,
        xalign: f64,
        yalign: f64
    );
fn set_accepts_tab(&self, accepts_tab: bool);
fn set_border_window_size(&self, type_: TextWindowType, size: i32);
fn set_bottom_margin(&self, bottom_margin: i32);
fn set_buffer<P: IsA<TextBuffer>>(&self, buffer: Option<&P>);
fn set_cursor_visible(&self, setting: bool);
fn set_editable(&self, setting: bool);
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 get_property_im_module(&self) -> Option<GString>;
fn set_property_im_module(&self, im_module: Option<&str>);
fn get_property_monospace(&self) -> bool;
fn set_property_monospace(&self, monospace: bool);
fn get_property_populate_all(&self) -> bool;
fn set_property_populate_all(&self, populate_all: bool);
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_populate_popup<F: Fn(&Self, &Widget) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
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_property_accepts_tab_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_bottom_margin_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_buffer_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_cursor_visible_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_editable_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_im_module_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_indent_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_input_hints_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_input_purpose_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_justification_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_left_margin_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_monospace_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_overwrite_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_pixels_above_lines_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_pixels_below_lines_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_pixels_inside_wrap_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_populate_all_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_right_margin_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_tabs_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_top_margin_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_wrap_mode_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; }

Trait containing all TextView methods.

Implementors

TextView

Required methods

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

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

child

a Widget

anchor

a TextChildAnchor in the TextBuffer for self

fn add_child_in_window<P: IsA<Widget>>(
    &self,
    child: &P,
    which_window: TextWindowType,
    xpos: i32,
    ypos: i32
)

Adds a child at fixed coordinates in one of the text widget's windows.

The window must have nonzero size (see TextViewExt::set_border_window_size). Note that the child coordinates are given relative to scrolling. When placing a child in TextWindowType::Widget, scrolling is irrelevant, the child floats above all scrollable areas. But when placing a child in one of the scrollable windows (border windows or text window) it will move with the scrolling as needed.

child

a Widget

which_window

which window the child should appear in

xpos

X position of child in window coordinates

ypos

Y position of child in window coordinates

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

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

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

Converts coordinate (buffer_x, buffer_y) to coordinates for the window win, and stores the result in (window_x, window_y).

Note that you can’t convert coordinates for a nonexisting window (see TextViewExt::set_border_window_size).

win

a TextWindowType, except TextWindowType::Private

buffer_x

buffer x coordinate

buffer_y

buffer y coordinate

window_x

window x coordinate return location or None

window_y

window y coordinate return location or None

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

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

fn get_accepts_tab(&self) -> bool

Returns whether pressing the Tab key inserts a tab characters. TextViewExt::set_accepts_tab.

Returns

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

fn get_border_window_size(&self, type_: TextWindowType) -> i32

Gets the width of the specified border window. See TextViewExt::set_border_window_size.

type_

window to return size from

Returns

width of window

fn get_bottom_margin(&self) -> i32

Gets the bottom margin for text in the self.

Feature: v3_18

Returns

bottom margin in pixels

fn get_buffer(&self) -> Option<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

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

Given an iter within a text layout, determine the positions of the strong and weak cursors if the insertion point is at that iterator. 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 TextViewExt::buffer_to_window_coords to convert these coordinates to coordinates for one of the windows in the text view.

iter

a TextIter

strong

location to store the strong cursor position (may be None)

weak

location to store the weak cursor position (may be None)

fn get_cursor_visible(&self) -> bool

Find out whether the cursor should be displayed.

Returns

whether the insertion mark is visible

fn get_default_attributes(&self) -> TextAttributes

Obtains a copy of the default text attributes. These are the attributes used for text unless a tag overrides them. You’d typically pass the default attributes in to TextIter::get_attributes in order to get the attributes in effect at a given text position.

The return value is a copy owned by the caller of this function, and should be freed with TextAttributes::unref.

Returns

a new TextAttributes

fn get_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

fn get_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

fn get_input_hints(&self) -> InputHints

Gets the value of the TextView:input-hints property.

fn get_input_purpose(&self) -> InputPurpose

Gets the value of the TextView:input-purpose property.

fn get_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 TextViewExt::window_to_buffer_coords.

iter

a TextIter

x

x position, in buffer coordinates

y

y position, in buffer coordinates

Returns

true if the position is over text

fn get_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 TextViewExt::window_to_buffer_coords.

Note that this is different from TextViewExt::get_iter_at_location, which returns cursor locations, i.e. positions between characters.

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.

x

x position, in buffer coordinates

y

y position, in buffer coordinates

Returns

true if the position is over text

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

Gets a rectangle which roughly contains the character at iter. The rectangle position is in buffer coordinates; use TextViewExt::buffer_to_window_coords to convert these coordinates to coordinates for one of the windows in the text view.

iter

a TextIter

location

bounds of the character at iter

fn get_justification(&self) -> Justification

Gets the default justification of paragraphs in self. Tags in the buffer may override the default.

Returns

default justification

fn get_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

fn get_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 TextViewExt::window_to_buffer_coords. If non-None, line_top will be filled with the coordinate of the top edge of the line.

target_iter

a TextIter

y

a y coordinate

line_top

return location for top coordinate of the line

fn get_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 TextViewExt::buffer_to_window_coords.

iter

a TextIter

y

return location for a y coordinate

height

return location for a height

fn get_monospace(&self) -> bool

Gets the value of the TextView:monospace property.

Feature: v3_16

Returns

true if monospace fonts are desired

fn get_overwrite(&self) -> bool

Returns whether the TextView is in overwrite mode or not.

Returns

whether self is in overwrite mode or not.

fn get_pixels_above_lines(&self) -> i32

Gets the default number of pixels to put above paragraphs. Adding this function with TextViewExt::get_pixels_below_lines is equal to the line space between each paragraph.

Returns

default number of pixels above paragraphs

fn get_pixels_below_lines(&self) -> i32

Gets the value set by TextViewExt::set_pixels_below_lines.

The line space is the sum of the value returned by this function and the value returned by TextViewExt::get_pixels_above_lines.

Returns

default number of blank pixels below paragraphs

fn get_pixels_inside_wrap(&self) -> i32

Gets the value set by TextViewExt::set_pixels_inside_wrap.

Returns

default number of pixels of blank space between wrapped lines

fn get_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

fn get_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.

fn get_top_margin(&self) -> i32

Gets the top margin for text in the self.

Feature: v3_18

Returns

top margin in pixels

fn get_visible_rect(&self) -> Rectangle

Fills visible_rect with the currently-visible region of the buffer, in buffer coordinates. Convert to window coordinates with TextViewExt::buffer_to_window_coords.

visible_rect

rectangle to fill

fn get_window(&self, win: TextWindowType) -> Option<Window>

Retrieves the gdk::Window corresponding to an area of the text view; possible windows include the overall widget window, child windows on the left, right, top, bottom, and the window that displays the text buffer. Windows are None and nonexistent if their width or height is 0, and are nonexistent before the widget has been realized.

win

window to get

Returns

a gdk::Window, or None

fn get_window_type<P: IsA<Window>>(&self, window: &P) -> TextWindowType

Usually used to find out which window an event corresponds to.

If you connect to an event signal on self, this function should be called on event->window to see which window it was.

window

a window type

Returns

the window type.

fn get_wrap_mode(&self) -> WrapMode

Gets the line wrapping for the view.

Returns

the line wrap setting

fn im_context_filter_keypress(&self, event: &EventKey) -> 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.

static gboolean
gtk_foo_bar_key_press_event (GtkWidget   *widget,
                             GdkEventKey *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.

fn move_child<P: IsA<Widget>>(&self, child: &P, xpos: i32, ypos: i32)

Updates the position of a child, as for TextViewExt::add_child_in_window.

child

child widget already added to the text view

xpos

new X position in window coordinates

ypos

new Y position in window coordinates

fn move_mark_onscreen<P: IsA<TextMark>>(&self, mark: &P) -> 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)

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

fn place_cursor_onscreen(&self) -> bool

Moves the cursor to the currently visible region of the buffer, it it isn’t there already.

Returns

true if the cursor had to be moved.

Ensures that the cursor is shown (i.e. not in an 'off' blink interval) and 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 Widget::key-press-event handler).

Feature: v3_20

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.

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

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

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 TextViewExt::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

fn scroll_to_mark<P: IsA<TextMark>>(
    &self,
    mark: &P,
    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

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.

accepts_tab

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

fn set_border_window_size(&self, type_: TextWindowType, size: i32)

Sets the width of TextWindowType::Left or TextWindowType::Right, or the height of TextWindowType::Top or TextWindowType::Bottom. Automatically destroys the corresponding window if the size is set to 0, and creates the window if the size is set to non-zero. This function can only be used for the “border windows”, and it won’t work with TextWindowType::Widget, TextWindowType::Text, or TextWindowType::Private.

type_

window to affect

size

width or height of the window

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.

Feature: v3_18

bottom_margin

bottom margin in pixels

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

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

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 Settings:gtk-keynave-use-caret settings.

setting

whether to show the insertion cursor

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

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

fn set_input_hints(&self, hints: InputHints)

Sets the TextView:input-hints property, which allows input methods to fine-tune their behaviour.

hints

the hints

fn set_input_purpose(&self, purpose: InputPurpose)

Sets the TextView:input-purpose property which can be used by on-screen keyboards and other input methods to adjust their behaviour.

purpose

the purpose

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

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

fn set_monospace(&self, monospace: bool)

Sets the TextView:monospace property, which indicates that the text view should use monospace fonts.

Feature: v3_16

monospace

true to request monospace styling

fn set_overwrite(&self, overwrite: bool)

Changes the TextView overwrite mode.

overwrite

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

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

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

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

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

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

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.

Feature: v3_18

top_margin

top margin in pixels

fn set_wrap_mode(&self, wrap_mode: WrapMode)

Sets the line wrapping for the view.

wrap_mode

a WrapMode

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

Determines whether iter is at the start of a display line. See TextViewExt::forward_display_line for an explanation of display lines vs. paragraphs.

iter

a TextIter

Returns

true if iter begins a wrapped line

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, storing the result in (buffer_x,buffer_y).

Note that you can’t convert coordinates for a nonexisting window (see TextViewExt::set_border_window_size).

win

a TextWindowType except TextWindowType::Private

window_x

window x coordinate

window_y

window y coordinate

buffer_x

buffer x coordinate return location or None

buffer_y

buffer y coordinate return location or None

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

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

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

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

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

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

fn get_property_monospace(&self) -> bool

fn set_property_monospace(&self, monospace: bool)

fn get_property_populate_all(&self) -> bool

If :populate-all is true, the TextView::populate-popup signal is also emitted for touch popups.

fn set_property_populate_all(&self, populate_all: bool)

If :populate-all is true, the TextView::populate-popup signal is also emitted for touch popups.

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

The ::backspace signal is a [keybinding signal][BindingSignal] which gets emitted when the user asks for it.

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

fn emit_backspace(&self)

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

The ::copy-clipboard signal is a [keybinding signal][BindingSignal] which gets emitted to copy the selection to the clipboard.

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

fn emit_copy_clipboard(&self)

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

The ::cut-clipboard signal is a [keybinding signal][BindingSignal] which gets emitted to cut the selection to the clipboard.

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

fn emit_cut_clipboard(&self)

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

The ::delete-from-cursor signal is a [keybinding signal][BindingSignal] which gets emitted when the user initiates a text deletion.

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 backwords.

type_

the granularity of the deletion, as a DeleteType

count

the number of type_ units to delete

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

The ::extend-selection signal is emitted when the selection needs to be extended at location.

Feature: v3_16

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.

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

The ::insert-at-cursor signal is a [keybinding signal][BindingSignal] which gets emitted when the user initiates the insertion of a fixed string at the cursor.

This signal has no default bindings.

string

the string to insert

fn emit_insert_at_cursor(&self, string: &str)

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

The ::insert-emoji signal is a [keybinding signal][BindingSignal] which gets emitted to present the Emoji chooser for the text_view.

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

Feature: v3_22_27

fn emit_insert_emoji(&self)

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

The ::move-cursor signal is a [keybinding signal][BindingSignal] which gets emitted when the user initiates a cursor movement. 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 the Shift modifer does not. There are too many key combinations to list them all here.

  • Arrow keys move by individual characters/lines
  • Ctrl-arrow key combinations move by words/paragraphs
  • Home/End keys move to the ends of the buffer
  • PageUp/PageDown keys move vertically by pages
  • Ctrl-PageUp/PageDown keys 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

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

The ::move-viewport signal is a [keybinding signal][BindingSignal] 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

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

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

The ::paste-clipboard signal is a [keybinding signal][BindingSignal] which gets emitted to paste the contents of the clipboard into the text view.

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

fn emit_paste_clipboard(&self)

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

The ::populate-popup signal gets emitted before showing the context menu of the text view.

If you need to add items to the context menu, connect to this signal and append your items to the popup, which will be a Menu in this case.

If TextView:populate-all is true, this signal will also be emitted to populate touch popups. In this case, popup will be a different container, e.g. a Toolbar.

The signal handler should not make assumptions about the type of widget, but check whether popup is a Menu or Toolbar or another kind of container.

the container that is being populated

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

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

fn emit_preedit_changed(&self, preedit: &str)

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

The ::select-all signal is a [keybinding signal][BindingSignal] which gets emitted to select or unselect the complete contents of the text view.

The default bindings for this signal are Ctrl-a and Ctrl-/ for selecting and Shift-Ctrl-a and Ctrl-\ for unselecting.

select

true to select, false to unselect

fn emit_select_all(&self, select: bool)

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

The ::set-anchor signal is a [keybinding signal][BindingSignal] 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.

fn emit_set_anchor(&self)

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

The ::toggle-cursor-visible signal is a [keybinding signal][BindingSignal] which gets emitted to toggle the TextView:cursor-visible property.

The default binding for this signal is F7.

fn emit_toggle_cursor_visible(&self)

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

The ::toggle-overwrite signal is a [keybinding signal][BindingSignal] which gets emitted to toggle the overwrite mode of the text view.

The default bindings for this signal is Insert.

fn emit_toggle_overwrite(&self)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading content...

Implementors

impl<O: IsA<TextView>> TextViewExt for O[src]

Loading content...