The editable interface is an interface which should be implemented by text editing widgets, such as entry. It contains functions for generically manipulating an editable widget, a large number of action signals used for key bindings, and several signals that an application can connect to to modify the behavior of a widget.
Slots:
boolean
. Accessor: editable-editable
.
Whether the user can edit the text in the editable widget or not.
integer
. Accessor: editable-position
.
The cursor position in the editable.
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.
Signals:
This signal is emitted at the end of a single user-visible operation on the contents of the editable.
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).
integer
), (end-position integer
) => void. Options: run-last.
This signal is 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
(TODO), 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 editable-delete-text.
string
), (new-text-length integer
), (position gpointer) => void. Options: run-last.
This signal is emitted when text is inserted into the widget by the user. The default handler for this signal will normally be responsible for inserting the text, so by connecting to this signal and then stopping the signal with g_signal_stop_emission(), it is possible to modify the inserted text, or prevent it from being inserted entirely.
position: a pointer to the position (of the CFFI foreign type :integer
), in characters, at which to insert the new text. After the signal emission is finished, it should point after the newly inserted text.
(editable-select-region editable start end)
Selects a region of text in editable. The characters that are selected are those characters at positions from start (an integer) up to, but not including end (an integer). If end is negative, then the the characters selected are those characters from start to the end of the text.
Note that positions are specified in characters, not bytes.
(editable-selection editable) => (values selected-p start end)
Retrieves the selection bounds of the editable. selected-p is a boolean
specifying whether there is a selection, start is the start of the selection and end is the end of the selection. If no text was selected, start and end will be identical and selected-p will be NIL
.
Note that positions are specified in characters, not bytes.
(editable-insert-text editable text position) => new-position
Inserts the text (a string) into the contents of the editable, at position specified by position (an integer). Returns the position after the inserted text.
Note that the position is in characters, not in bytes.
(editable-delete-text editable start end)
Deletes a sequence of characters. The characters that are deleted are those characters at positions from start up to, but not including end. If end is negative, then the the characters deleted are those from start to the end of the text.
Note that the positions are specified in characters, not bytes.
(editable-get-chars editable &key (start 0) (end -1)) => string
Retrieves a substring from editable contents. The characters that are retrieved are those characters at positions from start up to, but not including end. If end is negative, then the the characters retrieved are those characters from start to the end of the text.
(editable-cut-clipboard editable)
Removes the contents of the currently selected content in the editable and puts it on the clipboard.
(editable-copy-clipboard editable)
Copies the contents of the currently selected content in the editable and puts it on the clipboard.
(editable-paste-clipboard editable)
Pastes the content of the clipboard to the current position of the cursor in the editable.