Gtk.Editable

Entities

Simple Types

Access Types

Subtypes

Constants

Subprograms

Description

The Gtk.Editable.Gtk_Editable interface is an interface which should be implemented by text editing widgets, such as Gtk.GEntry.Gtk_Entry and Gtk.Spin_Button.Gtk_Spin_Button. 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.

As an example of the latter usage, by connecting the following handler to Gtk.Editable.Gtk_Editable::insert-text, an application can convert all entry into a widget into uppercase.

## Forcing entry to uppercase.

include <ctype.h>;

void
insert_text_handler (GtkEditable *editable,
                     const gchar *text,
                     gint         length,
                     gint        *position,
                     gpointer     data)
{
  gchar *result = g_utf8_strup (text, length);

  g_signal_handlers_block_by_func (editable,
                               (gpointer) insert_text_handler, data);
  gtk_editable_insert_text (editable, result, length, position);
  g_signal_handlers_unblock_by_func (editable,
                                     (gpointer) insert_text_handler, data);

  g_signal_stop_emission_by_name (editable, "insert_text");

  g_free (result);
}

"+"

function "+" (W : Gtk_Editable) return Gtk_Editable
Parameters
W
Return Value

Cb_GObject_Gint_Gint_Void

type Cb_GObject_Gint_Gint_Void is not null access procedure
  (Self      : access Glib.Object.GObject_Record'Class;
   Start_Pos : Glib.Gint;
   End_Pos   : Glib.Gint);
Parameters
Self
Start_Pos
End_Pos

Cb_GObject_UTF8_String_Gint_Gint_Void

type Cb_GObject_UTF8_String_Gint_Gint_Void is not null access procedure
  (Self            : access Glib.Object.GObject_Record'Class;
   New_Text        : UTF8_String;
   New_Text_Length : Glib.Gint;
   Position        : access Glib.Gint);
Parameters
Self
New_Text
New_Text_Length
Position

Cb_GObject_Void

type Cb_GObject_Void is not null access procedure
  (Self : access Glib.Object.GObject_Record'Class);
Parameters
Self

Cb_Gtk_Editable_Gint_Gint_Void

type Cb_Gtk_Editable_Gint_Gint_Void is not null access procedure
  (Self      : Gtk_Editable;
   Start_Pos : Glib.Gint;
   End_Pos   : Glib.Gint);
Parameters
Self
Start_Pos
End_Pos

Cb_Gtk_Editable_UTF8_String_Gint_Gint_Void

type Cb_Gtk_Editable_UTF8_String_Gint_Gint_Void is not null access procedure
  (Self            : Gtk_Editable;
   New_Text        : UTF8_String;
   New_Text_Length : Glib.Gint;
   Position        : access Glib.Gint);
Parameters
Self
New_Text
New_Text_Length
Position

Cb_Gtk_Editable_Void

type Cb_Gtk_Editable_Void is not null access procedure (Self : Gtk_Editable);
Parameters
Self

Copy_Clipboard

procedure Copy_Clipboard (Editable : Gtk_Editable)

Copies the contents of the currently selected content in the editable and puts it on the clipboard.

Parameters
Editable

Cut_Clipboard

procedure Cut_Clipboard (Editable : Gtk_Editable)

Removes the contents of the currently selected content in the editable and puts it on the clipboard.

Parameters
Editable

Delete_Selection

procedure Delete_Selection (Editable : Gtk_Editable)

Deletes the currently selected text of the editable. This call doesn't do anything if there is no selected text.

Parameters
Editable

Delete_Text

procedure Delete_Text
   (Editable  : Gtk_Editable;
    Start_Pos : Glib.Gint;
    End_Pos   : Glib.Gint := -1)

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.

Parameters
Editable
Start_Pos

start position

End_Pos

end position

Editable_Interface_Descr

subtype Editable_Interface_Descr is Glib.Object.Interface_Description;

Get_Chars

function Get_Chars
   (Editable  : Gtk_Editable;
    Start_Pos : Glib.Gint;
    End_Pos   : Glib.Gint := -1) return UTF8_String

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.

Parameters
Editable
Start_Pos

start of text

End_Pos

end of text

Return Value

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

Get_Editable

function Get_Editable (Editable : Gtk_Editable) return Boolean

Retrieves whether Editable is editable. See Gtk.Editable.Set_Editable.

Parameters
Editable
Return Value

True if Editable is editable.

Get_Position

function Get_Position (Editable : Gtk_Editable) return Glib.Gint

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.

Parameters
Editable
Return Value

the cursor position

Get_Selection_Bounds

procedure Get_Selection_Bounds
   (Editable      : Gtk_Editable;
    Start_Pos     : out Glib.Gint;
    End_Pos       : out Glib.Gint;
    Has_Selection : out Boolean)

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.

Parameters
Editable
Start_Pos

location to store the starting position, or null

End_Pos

location to store the end position, or null @return True if an area is selected, False otherwise

Has_Selection

Get_Type

function Get_Type return Glib.GType
Return Value

Gtk_Editable

type Gtk_Editable is new Glib.Types.GType_Interface;

Insert_Text

procedure Insert_Text
  (Editable : Gtk_Editable;
   New_Text : UTF8_String;
   Position : in out Gint)

Convenience subprogram, identical to Insert_Text above without the requirement to supply the New_Text_Length argument.

Parameters
Editable
New_Text
Position

Insert_Text

procedure Insert_Text
   (Editable        : Gtk_Editable;
    New_Text        : UTF8_String;
    New_Text_Length : Glib.Gint;
    Position        : in out Glib.Gint)

Inserts New_Text_Length bytes of New_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.

Parameters
Editable
New_Text

the text to append

New_Text_Length

the length of the text in bytes, or -1

Position

location of the position text will be inserted at

Null_Gtk_Editable

Null_Gtk_Editable : constant Gtk_Editable;

On_Changed

procedure On_Changed
   (Self  : Gtk_Editable;
    Call  : Cb_GObject_Void;
    Slot  : not null access Glib.Object.GObject_Record'Class;
    After : Boolean := False)

The ::changed signal is emitted at the end of a single user-visible operation on the contents of the Gtk.Editable.Gtk_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).

Parameters
Self
Call
Slot
After

On_Changed

procedure On_Changed
   (Self  : Gtk_Editable;
    Call  : Cb_Gtk_Editable_Void;
    After : Boolean := False)

The ::changed signal is emitted at the end of a single user-visible operation on the contents of the Gtk.Editable.Gtk_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).

Parameters
Self
Call
After

On_Delete_Text

procedure On_Delete_Text
   (Self  : Gtk_Editable;
    Call  : Cb_GObject_Gint_Gint_Void;
    Slot  : not null access Glib.Object.GObject_Record'Class;
    After : Boolean := False)

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, 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 Gtk.Editable.Delete_Text.

Callback parameters: -- @param Start_Pos the starting position -- @param End_Pos the end position

Parameters
Self
Call
Slot
After

On_Delete_Text

procedure On_Delete_Text
   (Self  : Gtk_Editable;
    Call  : Cb_Gtk_Editable_Gint_Gint_Void;
    After : Boolean := False)

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, 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 Gtk.Editable.Delete_Text.

Callback parameters: -- @param Start_Pos the starting position -- @param End_Pos the end position

Parameters
Self
Call
After

On_Insert_Text

procedure On_Insert_Text
   (Self  : Gtk_Editable;
    Call  : Cb_GObject_UTF8_String_Gint_Gint_Void;
    Slot  : not null access Glib.Object.GObject_Record'Class;
    After : Boolean := False)

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.

Callback parameters: -- @param New_Text the new text to insert -- @param New_Text_Length the length of the new text, in bytes, or -1 if -- new_text is nul-terminated -- @param Position the position, in characters, at which to insert the new -- text. this is an in-out parameter. After the signal emission is -- finished, it should point after the newly inserted text.

Parameters
Self
Call
Slot
After

On_Insert_Text

procedure On_Insert_Text
   (Self  : Gtk_Editable;
    Call  : Cb_Gtk_Editable_UTF8_String_Gint_Gint_Void;
    After : Boolean := False)

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.

Callback parameters: -- @param New_Text the new text to insert -- @param New_Text_Length the length of the new text, in bytes, or -1 if -- new_text is nul-terminated -- @param Position the position, in characters, at which to insert the new -- text. this is an in-out parameter. After the signal emission is -- finished, it should point after the newly inserted text.

Parameters
Self
Call
After

Paste_Clipboard

procedure Paste_Clipboard (Editable : Gtk_Editable)

Pastes the content of the clipboard to the current position of the cursor in the editable.

Parameters
Editable

Select_Region

procedure Select_Region
   (Editable  : Gtk_Editable;
    Start_Pos : Glib.Gint;
    End_Pos   : Glib.Gint := -1)

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.

Parameters
Editable
Start_Pos

start of region

End_Pos

end of region

Set_Changed

procedure Set_Changed
  (Self    : Editable_Interface_Descr;
   Handler : Virtual_Changed)
Parameters
Self
Handler

Set_Delete_Text

procedure Set_Delete_Text
  (Self    : Editable_Interface_Descr;
   Handler : Virtual_Delete_Text)
Parameters
Self
Handler

Set_Do_Delete_Text

procedure Set_Do_Delete_Text
  (Self    : Editable_Interface_Descr;
   Handler : Virtual_Do_Delete_Text)
Parameters
Self
Handler

Set_Do_Insert_Text

procedure Set_Do_Insert_Text
  (Self    : Editable_Interface_Descr;
   Handler : Virtual_Do_Insert_Text)
Parameters
Self
Handler

Set_Editable

procedure Set_Editable (Editable : Gtk_Editable; Is_Editable : Boolean)

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

Parameters
Editable
Is_Editable

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

Set_Get_Chars

procedure Set_Get_Chars
  (Self    : Editable_Interface_Descr;
   Handler : Virtual_Get_Chars)
Parameters
Self
Handler

Set_Get_Position

procedure Set_Get_Position
  (Self    : Editable_Interface_Descr;
   Handler : Virtual_Get_Position)
Parameters
Self
Handler

Set_Get_Selection_Bounds

procedure Set_Get_Selection_Bounds
  (Self    : Editable_Interface_Descr;
   Handler : Virtual_Get_Selection_Bounds)
Parameters
Self
Handler

Set_Insert_Text

procedure Set_Insert_Text
  (Self    : Editable_Interface_Descr;
   Handler : Virtual_Insert_Text)
Parameters
Self
Handler

Set_Position

procedure Set_Position (Editable : Gtk_Editable; Position : Glib.Gint)

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.

Parameters
Editable
Position

the position of the cursor

Set_Set_Position

procedure Set_Set_Position
  (Self    : Editable_Interface_Descr;
   Handler : Virtual_Set_Position)
Parameters
Self
Handler

Set_Set_Selection_Bounds

procedure Set_Set_Selection_Bounds
  (Self    : Editable_Interface_Descr;
   Handler : Virtual_Set_Selection_Bounds)

See Glib.Object.Add_Interface

Parameters
Self
Handler

Signal_Changed

Signal_Changed : constant Glib.Signal_Name := "changed";

The ::changed signal is emitted at the end of a single user-visible operation on the contents of the Gtk.Editable.Gtk_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).

Signal_Delete_Text

Signal_Delete_Text : constant Glib.Signal_Name := "delete-text";

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, 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 Gtk.Editable.Delete_Text.

Callback parameters: -- @param Start_Pos the starting position -- @param End_Pos the end position

Signal_Insert_Text

Signal_Insert_Text : constant Glib.Signal_Name := "insert-text";

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.

Callback parameters: -- @param New_Text the new text to insert -- @param New_Text_Length the length of the new text, in bytes, or -1 if -- new_text is nul-terminated -- @param Position the position, in characters, at which to insert the new -- text. this is an in-out parameter. After the signal emission is -- finished, it should point after the newly inserted text.

Virtual_Changed

type Virtual_Changed is access procedure (Editable : Gtk_Editable);
Parameters
Editable

Virtual_Delete_Text

type Virtual_Delete_Text is access procedure
  (Editable  : Gtk_Editable;
   Start_Pos : Glib.Gint;
   End_Pos   : Glib.Gint);

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.

Parameters
Editable
Start_Pos

start position

End_Pos

end position

Virtual_Do_Delete_Text

type Virtual_Do_Delete_Text is access procedure
  (Editable  : Gtk_Editable;
   Start_Pos : Glib.Gint;
   End_Pos   : Glib.Gint);

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.

Parameters
Editable
Start_Pos

start position

End_Pos

end position

Virtual_Do_Insert_Text

type Virtual_Do_Insert_Text is access procedure
  (Editable        : Gtk_Editable;
   New_Text        : Gtkada.Types.Chars_Ptr;
   New_Text_Length : Glib.Gint;
   Position        : in out Glib.Gint);

Inserts New_Text_Length bytes of New_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.

Parameters
Editable
New_Text

the text to append

New_Text_Length

the length of the text in bytes, or -1

Position

location of the position text will be inserted at

Virtual_Get_Chars

type Virtual_Get_Chars is access function
  (Editable  : Gtk_Editable;
   Start_Pos : Glib.Gint;
   End_Pos   : Glib.Gint) return Gtkada.Types.Chars_Ptr;

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.

Parameters
Editable
Start_Pos

start of text

End_Pos

end of text

Return Value

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

Virtual_Get_Position

type Virtual_Get_Position is access function (Editable : Gtk_Editable) return Glib.Gint;

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.

Parameters
Editable
Return Value

the cursor position

Virtual_Get_Selection_Bounds

type Virtual_Get_Selection_Bounds is access function
  (Editable  : Gtk_Editable;
   Start_Pos : access Glib.Gint;
   End_Pos   : access Glib.Gint) return Glib.Gboolean;

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.

Parameters
Editable
Start_Pos

location to store the starting position, or null

End_Pos

location to store the end position, or null

Return Value

True if an area is selected, False otherwise

Virtual_Insert_Text

type Virtual_Insert_Text is access procedure
  (Editable        : Gtk_Editable;
   New_Text        : Gtkada.Types.Chars_Ptr;
   New_Text_Length : Glib.Gint;
   Position        : in out Glib.Gint);

Inserts New_Text_Length bytes of New_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.

Parameters
Editable
New_Text

the text to append

New_Text_Length

the length of the text in bytes, or -1

Position

location of the position text will be inserted at

Virtual_Set_Position

type Virtual_Set_Position is access procedure (Editable : Gtk_Editable; Position : Glib.Gint);

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.

Parameters
Editable
Position

the position of the cursor

Virtual_Set_Selection_Bounds

type Virtual_Set_Selection_Bounds is access procedure
  (Editable  : Gtk_Editable;
   Start_Pos : Glib.Gint;
   End_Pos   : Glib.Gint);

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.

Parameters
Editable
Start_Pos

start of region

End_Pos

end of region