Trait gtk4::prelude::EntryBufferExtManual
source · pub trait EntryBufferExtManual: 'static {
// Required methods
fn delete_text(&self, position: u16, n_chars: Option<u16>) -> u16;
fn bytes(&self) -> usize;
fn length(&self) -> u16;
fn max_length(&self) -> Option<u16>;
fn text(&self) -> GString;
fn insert_text(&self, position: u16, chars: impl IntoGStr) -> u16;
fn set_max_length(&self, max_length: Option<u16>);
fn set_text(&self, chars: impl IntoGStr);
}
Expand description
Trait containing manually implemented methods of EntryBuffer
.
Required Methods§
sourcefn delete_text(&self, position: u16, n_chars: Option<u16>) -> u16
fn delete_text(&self, position: u16, n_chars: Option<u16>) -> u16
Deletes a sequence of characters from the buffer.
@n_chars characters are deleted starting at @position. If @n_chars is negative, then all characters until the end of the text are deleted.
If @position or @n_chars are out of bounds, then they are coerced to sane values.
Note that the positions are specified in characters, not bytes.
position
position at which to delete text
n_chars
number of characters to delete
Returns
The number of characters deleted.
sourcefn bytes(&self) -> usize
fn bytes(&self) -> usize
Retrieves the length in bytes of the buffer.
See EntryBufferExtManual::length()
.
Returns
The byte length of the buffer.
sourcefn max_length(&self) -> Option<u16>
fn max_length(&self) -> Option<u16>
Retrieves the maximum allowed length of the text in @self.
Returns
the maximum allowed number of characters
in EntryBuffer
, or 0 if there is no maximum.
sourcefn text(&self) -> GString
fn text(&self) -> GString
Retrieves the contents of the buffer.
The memory pointer returned by this call will not change unless this object emits a signal, or is finalized.
Returns
a pointer to the contents of the widget as a string. This string points to internally allocated storage in the buffer and must not be freed, modified or stored.
sourcefn insert_text(&self, position: u16, chars: impl IntoGStr) -> u16
fn insert_text(&self, position: u16, chars: impl IntoGStr) -> u16
Inserts @n_chars characters of @chars into the contents of the buffer, at position @position.
If @n_chars is negative, then characters from chars will be inserted until a null-terminator is found. If @position or @n_chars are out of bounds, or the maximum buffer text length is exceeded, then they are coerced to sane values.
Note that the position and length are in characters, not in bytes.
position
the position at which to insert text.
chars
the text to insert into the buffer.
n_chars
the length of the text in characters, or -1
Returns
The number of characters actually inserted.