Gtk.EntryBuffer¶
class — extends GObject.Object
Holds the text that is displayed in a single-line text entry widget.
A single GtkEntryBuffer object can be shared by multiple widgets
which will then share the same text content, but not the cursor
position, visibility attributes, icon etc.
GtkEntryBuffer 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.
Constructors¶
new¶
Create a new GtkEntryBuffer object.
Optionally, specify initial text to set in the buffer.
Parameters:
initial_chars— initial buffer textn_initial_chars— number of characters ininitial_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.
Parameters:
position— position at which to delete textn_chars— number of characters to delete
emit_deleted_text¶
Used when subclassing GtkEntryBuffer.
Parameters:
position— position at which text was deletedn_chars— number of characters deleted
emit_inserted_text¶
Used when subclassing GtkEntryBuffer.
Parameters:
position— position at which text was insertedchars— text that was insertedn_chars— number of characters inserted
get_bytes¶
Retrieves the length in bytes of the buffer.
get_length¶
Retrieves the length in characters of the buffer.
get_max_length¶
Retrieves the maximum allowed length of the text in buffer.
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.
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.
Parameters:
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
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.
Parameters:
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
EntryBuffer.delete_text and
EntryBuffer.insert_text.
Note that n_chars is in characters, not in bytes.
Parameters:
chars— the new textn_chars— the number of characters intext, or -1
Virtual methods¶
do_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.
Parameters:
position— position at which to delete textn_chars— number of characters to delete
do_deleted_text¶
do_get_length¶
Retrieves the length in characters of the buffer.
do_get_text¶
do_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.
Parameters:
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
do_inserted_text¶
Properties¶
length¶
The length (in characters) of the text in buffer.
max_length¶
The maximum length (in characters) of the text in the buffer.
text¶
The contents of the buffer.
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 GObject.ConnectFlags.AFTER.
inserted-text¶
This signal is emitted after text is inserted into the buffer.