Trait gtk4::prelude::EditableExt[][src]

pub trait EditableExt: 'static {
Show 37 methods fn delete_selection(&self);
fn delete_text(&self, start_pos: i32, end_pos: i32);
fn finish_delegate(&self);
fn alignment(&self) -> f32;
fn chars(&self, start_pos: i32, end_pos: i32) -> GString;
fn delegate(&self) -> Option<Editable>;
fn is_editable(&self) -> bool;
fn enables_undo(&self) -> bool;
fn max_width_chars(&self) -> i32;
fn position(&self) -> i32;
fn selection_bounds(&self) -> Option<(i32, i32)>;
fn text(&self) -> GString;
fn width_chars(&self) -> i32;
fn init_delegate(&self);
fn insert_text(&self, text: &str, position: &mut i32);
fn select_region(&self, start_pos: i32, end_pos: i32);
fn set_alignment(&self, xalign: f32);
fn set_editable(&self, is_editable: bool);
fn set_enable_undo(&self, enable_undo: bool);
fn set_max_width_chars(&self, n_chars: i32);
fn set_position(&self, position: i32);
fn set_text(&self, text: &str);
fn set_width_chars(&self, n_chars: i32);
fn cursor_position(&self) -> i32;
fn selection_bound(&self) -> i32;
fn xalign(&self) -> f32;
fn set_xalign(&self, xalign: f32);
fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_delete_text<F: Fn(&Self, i32, i32) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_cursor_position_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_editable_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_enable_undo_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_max_width_chars_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_selection_bound_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_text_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_width_chars_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_xalign_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
}
Expand description

Required methods

Deletes the currently selected text of the editable.

This call doesn’t do anything if there is no selected text.

Deletes a sequence of characters.

The characters that are deleted are those characters at positions from start_pos up to, but not including end_pos. If end_pos is negative, then the characters deleted are those from start_pos to the end of the text.

Note that the positions are specified in characters, not bytes.

start_pos

start position

end_pos

end position

Undoes the setup done by init_delegate().

This is a helper function that should be called from dispose, before removing the delegate object.

Gets the alignment of the editable.

Returns

the alignment

Retrieves a sequence of characters.

The characters that are retrieved are those characters at positions from start_pos up to, but not including end_pos. If end_pos is negative, then the characters retrieved are those characters from start_pos to the end of the text.

Note that positions are specified in characters, not bytes.

start_pos

start of text

end_pos

end of text

Returns

a pointer to the contents of the widget as a string. This string is allocated by the Editable implementation and should be freed by the caller.

Gets the Editable that self is delegating its implementation to.

Typically, the delegate is a Text widget.

Returns

the delegate Editable

Retrieves whether self is editable.

Returns

true if self is editable.

Gets if undo/redo actions are enabled for self

Returns

true if undo is enabled

Retrieves the desired maximum width of self, in characters.

Returns

the maximum width of the entry, in characters

Retrieves the current position of the cursor relative to the start of the content of the editable.

Note that this position is in characters, not in bytes.

Returns

the cursor position

Retrieves the selection bound of the editable.

start_pos will be filled with the start of the selection and end_pos with end. If no text was selected both will be identical and false will be returned.

Note that positions are specified in characters, not bytes.

Returns

true if there is a non-empty selection, false otherwise

start_pos

location to store the starting position

end_pos

location to store the end position

Retrieves the contents of self.

The returned string is owned by GTK and must not be modified or freed.

Returns

a pointer to the contents of the editable

Gets the number of characters of space reserved for the contents of the editable.

Returns

number of chars to request space for, or negative if unset

Sets up a delegate for Editable.

This is assuming that the get_delegate vfunc in the Editable interface has been set up for the self’s type.

This is a helper function that should be called in instance init, after creating the delegate object.

Inserts length bytes of text into the contents of the widget, at position position.

Note that the position is in characters, not in bytes. The function updates position to point after the newly inserted text.

text

the text to append

length

the length of the text in bytes, or -1

position

location of the position text will be inserted at

Selects a region of text.

The characters that are selected are those characters at positions from start_pos up to, but not including end_pos. If end_pos is negative, then the characters selected are those characters from start_pos to the end of the text.

Note that positions are specified in characters, not bytes.

start_pos

start of region

end_pos

end of region

Sets the alignment for the contents of the editable.

This controls the horizontal positioning of the contents when the displayed text is shorter than the width of the editable.

xalign

The horizontal alignment, from 0 (left) to 1 (right). Reversed for RTL layouts

Determines if the user can edit the text in the editable widget.

is_editable

true if the user is allowed to edit the text in the widget

If enabled, changes to self will be saved for undo/redo actions.

This results in an additional copy of text changes and are not stored in secure memory. As such, undo is forcefully disabled when property::Text::visibility is set to false.

enable_undo

if undo/redo should be enabled

Sets the desired maximum width in characters of self.

n_chars

the new desired maximum width, in characters

Sets the cursor position in the editable to the given value.

The cursor is displayed before the character with the given (base 0) index in the contents of the editable. The value must be less than or equal to the number of characters in the editable. A value of -1 indicates that the position should be set after the last character of the editable. Note that position is in characters, not in bytes.

position

the position of the cursor

Sets the text in the editable to the given value.

This is replacing the current contents.

text

the text to set

Changes the size request of the editable to be about the right size for n_chars characters.

Note that it changes the size request, the size can still be affected by how you pack the widget into containers. If n_chars is -1, the size reverts to the default size.

n_chars

width in chars

The current position of the insertion cursor in chars.

The position of the opposite end of the selection from the cursor in chars.

The horizontal alignment, from 0 (left) to 1 (right).

Reversed for RTL layouts.

The horizontal alignment, from 0 (left) to 1 (right).

Reversed for RTL layouts.

Emitted at the end of a single user-visible operation on the contents.

E.g., a paste operation that replaces the contents of the selection will cause only one signal emission (even though it is implemented by first deleting the selection, then inserting the new content, and may cause multiple ::notify::text signals to be emitted).

Emitted when text is deleted from the widget by the user.

The default handler for this signal will normally be responsible for deleting the text, so by connecting to this signal and then stopping the signal with g_signal_stop_emission(), it is possible to modify the range of deleted text, or prevent it from being deleted entirely.

The start_pos and end_pos parameters are interpreted as for delete_text().

start_pos

the starting position

end_pos

the end position

Implementors