Gnome::Gtk4::EntryBuffer
Description
A Gnome::Gtk4::EntryBuffer hold the text displayed in a Gnome::Gtk4::Text widget.
A single Gnome::Gtk4::EntryBuffer object can be shared by multiple widgets which will then share the same text content, but not the cursor position, visibility attributes, icon etc.
Gnome::Gtk4::EntryBuffer may be derived from. Such a derived class might allow text to be stored in an alternate location, such as non-pageable memory, useful in the case of important passwords. Or a derived class could integrate with an application’s concept of undo/redo.
Class initialization
new
:native-object
Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.
multi method new ( N-Object :$native-object! )
new-entrybuffer
Create a new Gnome::Gtk4::EntryBuffer object.
Optionally, specify initial text to set in the buffer.
method new-entrybuffer ( Str $initial-chars, Int() $n-initial-chars --> Gnome::Gtk4::EntryBuffer \)
$initial-chars; initial buffer text.
$n-initial-chars; number of characters in
$initial-chars
, or -1.
Methods
delete-text
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.
method delete-text ( UInt() $position, Int() $n-chars --> UInt )
$position; position at which to delete text.
$n-chars; number of characters to delete.
Return value; The number of characters deleted..
emit-deleted-text
Used when subclassing Gnome::Gtk4::EntryBuffer.
method emit-deleted-text ( UInt() $position, UInt() $n-chars )
$position; position at which text was deleted.
$n-chars; number of characters deleted.
emit-inserted-text
Used when subclassing Gnome::Gtk4::EntryBuffer.
method emit-inserted-text ( UInt() $position, Str $chars, UInt() $n-chars )
$position; position at which text was inserted.
$chars; text that was inserted.
$n-chars; number of characters inserted.
get-bytes
Retrieves the length in bytes of the buffer.
See .get-length()
.
method get-bytes (--> Int )
Return value; The byte length of the buffer..
get-length
Retrieves the length in characters of the buffer.
method get-length (--> UInt )
Return value; The number of characters in the buffer..
get-max-length
Retrieves the maximum allowed length of the text in $buffer
.
method get-max-length (--> Int )
Return value; the maximum allowed number of characters in Gnome::Gtk4::EntryBuffer, or 0 if there is no maximum..
get-text
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.
method get-text (--> Str )
Return value; 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..
insert-text
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.
method insert-text ( UInt() $position, Str $chars, Int() $n-chars --> UInt )
$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.
Return value; The number of characters actually inserted..
set-max-length
Sets the maximum allowed length of the contents of the buffer.
If the current contents are longer than the given length, then they will be truncated to fit.
method set-max-length ( Int() $max-length )
$max-length; the maximum length of the entry buffer, or 0 for no maximum. (other than the maximum length of entries.) The value passed in will be clamped to the range 0-65536..
set-text
Sets the text in the buffer.
This is roughly equivalent to calling .delete-text()
and .insert-text()
.
Note that $n-chars
is in characters, not in bytes.
method set-text ( Str $chars, Int() $n-chars )
$chars; the new text.
$n-chars; the number of characters in
$text
, or -1.
Signals
deleted-text
The text is altered in the default handler for this signal.
If you want access to the text after the text has been modified, use G_CONNECT_AFTER
.
method handler ( guint $position, guint $n-chars, Int :$_handle_id, N-GObject :$_native-object, Gnome::Gtk4::EntryBuffer :$_widget, *C<user>-options )
$position; the position the text was deleted at..
$n-chars; The number of characters that were deleted..
$_handle_id; The registered event handler id.
$_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::EntryBuffer object.
$_widget; The object which registered the signal. User code may have left the object going out of scope.
user
-options; A list of named arguments provided at the.register-signal()
method from Gnome::GObject::Object.
inserted-text
This signal is emitted after text is inserted into the buffer.
method handler ( guint $position, Str $chars, guint $n-chars, Int :$_handle_id, N-GObject :$_native-object, Gnome::Gtk4::EntryBuffer :$_widget, *C<user>-options )
$position; the position the text was inserted at..
$chars; The text that was inserted..
$n-chars; The number of characters that were inserted..
$_handle_id; The registered event handler id.
$_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::EntryBuffer object.
$_widget; The object which registered the signal. User code may have left the object going out of scope.
user
-options; A list of named arguments provided at the.register-signal()
method from Gnome::GObject::Object.