GLXCurses.Editable module

class GLXCurses.Editable.Editable[source]

Bases: object

select_region(editable=None, start_pos=None, end_pos=None)[source]

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 (GLXCurses.Editable or None) – a GLXCurses.Editable
  • start_pos (int or None) – start of region
  • end_pos (int or None) – end of region
Raises:
  • TypeError – if start_pos is not a int type or None.
  • TypeError – if end_pos is not a int type or None.
  • TypeError – if editable is not a valid GLXCurses type.
  • TypeError – if editable is not a instance of GLXCurses.Editable.
get_selection_bounds(editable=None)[source]

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 (GLXC.Editable or None) – a GLXC.Editable

Returns:

True if an area is selected, False otherwise

Return type:

bool

Raises:
  • TypeError – if editable is not a valid GLXCurses type.
  • TypeError – if editable is not a instance of GLXCurses.Editable.
insert_text(editable=None, new_text=None, new_text_length=-1, position=None)[source]

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 (GLXC.Editable or None) – a GLXC.Editable
  • new_text (str) – the text to append
  • new_text_length (int) – the length of the text in bytes, or -1
  • position (int or None) – location of the position text will be inserted at. None for insert at actual position.
Raises:
  • TypeError – if editable is not a valid GLXCurses type.
  • TypeError – if editable is not a instance of GLXCurses.Editable.
  • TypeError – if new_text is not a str or None.
  • TypeError – if new_text_length is not a int or None.
  • TypeError – if position is not a int or None.
delete_text(editable=None, start_pos=None, end_pos=None)[source]

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.

Parameters:
  • editable (GLXC.Editable or None) – a GLXC.Editable
  • start_pos (int or None) – start position
  • end_pos (int or None) – end position
Raises:
  • TypeError – if editable is not a valid GLXCurses type.
  • TypeError – if editable is not a instance of GLXCurses.Editable.
  • TypeError – if start_pos is not a int type or None.
  • TypeError – if end_pos is not a int type or None.
get_chars(editable=None, start_pos=None, end_pos=None)[source]

Retrieves a sequence of characters. The characters that are retrieved are those characters at positions from start_pos up to, but n ot 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 (GLXC.Editable or None) – a GLXC.Editable
  • start_pos (int) – start of text
  • end_pos (int) – end of text
Returns:

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

Raises:
  • TypeError – if editable is not a valid GLXCurses type.
  • ImportError – if editable is not a instance of GLXCurses.Editable.
  • TypeError – if start_pos is not a int type or None.
  • TypeError – if end_pos is not a int type or None.
cut_clipboard(editable=None)[source]

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

Parameters:

editable (GLXCurses.Editable or None) – a instance of GLXCurses.Editable.

Raises:
  • TypeError – if editable is not a valid GLXCurses type.
  • TypeError – if editable is not a instance of GLXCurses.Editable.
copy_clipboard(editable=None)[source]

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

Parameters:

editable (GLXCurses.Editable or None) – a GLXCurses.Editable

Raises:
  • TypeError – if editable is not a valid GLXCurses type.
  • TypeError – if editable is not a instance of Editable.
paste_clipboard(editable=None)[source]

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

Parameters:

editable (GLXC.Editable or None) – a GLXC.Editable

Raises:
  • TypeError – if editable is not a valid GLXCurses type.
  • TypeError – if editable is not a instance of GLXCurses.Editable.
delete_selection(editable=None)[source]

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

Parameters:

editable (GLXC.Editable) – a Class Name contain on the list GLXC.Editable

Raises:
  • TypeError – if editable is not a valid GLXCurses type.
  • TypeError – if editable is not a instance of GLXCurses.Editable.
set_position(editable=None, position=-1)[source]

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 (GLXC.Editable) – a Class Name contain on the list GLXC.Editable
  • position (int) – the position of the cursor
Raises:
  • TypeError – if editable is not a valid GLXCurses type.
  • TypeError – if editable is not a instance of GLXCurses.Editable.
  • TypeError – if position is not a int type.
get_position(editable=None)[source]

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 (GLXC.Editable) – a Class Name contain on the list GLXC.Editable

Returns:

the cursor position

Return type:

int

Raises:
  • TypeError – if editable is not a valid GLXCurses type.
  • TypeError – if editable is not a instance of GLXCurses.Editable.
set_editable(editable=None, is_editable=True)[source]

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

Parameters:
  • editable (GLXC.Editable) – a Class Name contain on the list GLXC.Editable
  • is_editable (bool) – True if the user is allowed to edit the text in the widget
Raises:
  • TypeError – if is_editable is not a int type.
  • TypeError – if editable is not a valid GLXCurses type.
  • TypeError – if editable is not a instance of GLXCurses.Editable.
get_editable(editable=None)[source]

Retrieves whether editable is editable.

See GLXCurses.Editable.set_editable().

Parameters:

editable (GLXC.Editable) – a Class Name contain on the list GLXC.Editable

Returns:

True if editable is editable.

Raises:
  • TypeError – if editable is not a valid GLXCurses type.
  • TypeError – if editable is not a instance of GLXCurses.Editable.