Next: , Previous: ClutterText, Up: Top


66 ClutterTextBuffer

Text buffer for ClutterText

66.1 Overview

The <clutter-text-buffer> class contains the actual text displayed in a <clutter-text> widget.

A single <clutter-text-buffer> object can be shared by multiple <clutter-text> widgets which will then share the same text content, but not the cursor position, visibility attributes, icon etc.

<clutter-text-buffer> 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.

66.2 Usage

— Function: clutter-text-buffer-new ⇒  (ret <clutter-text-buffer>)

Create a new ClutterTextBuffer object.

ret
A new ClutterTextBuffer object.

Since 1.10

— Function: clutter-text-buffer-new-with-text (text mchars) (text_len ssize_t) ⇒  (ret <clutter-text-buffer>)

Create a new ClutterTextBuffer object with some text.

text
initial buffer text.
text-len
initial buffer text length, or -1 for null-terminated.
ret
A new ClutterTextBuffer object.

Since 1.10

— Function: clutter-text-buffer-set-text (self <clutter-text-buffer>) (chars mchars) (n_chars int)
— Method: set-text

Sets the text in the buffer.

This is roughly equivalent to calling clutter-text-buffer-delete-text and clutter-text-buffer-insert-text.

Note that n-chars is in characters, not in bytes.

buffer
a <clutter-text-buffer>
chars
the new text
n-chars
the number of characters in text, or -1

Since 1.10

— Function: clutter-text-buffer-get-text (self <clutter-text-buffer>) ⇒  (ret mchars)
— Method: 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.

buffer
a <clutter-text-buffer>
ret
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.

Since 1.10

— Function: clutter-text-buffer-get-bytes (self <clutter-text-buffer>) ⇒  (ret size_t)
— Method: get-bytes

Retrieves the length in bytes of the buffer. See clutter-text-buffer-get-length.

buffer
a <clutter-text-buffer>
ret
The byte length of the buffer.

Since 1.10

— Function: clutter-text-buffer-get-length (self <clutter-text-buffer>) ⇒  (ret unsigned-int)
— Method: get-length

Retrieves the length in characters of the buffer.

buffer
a <clutter-text-buffer>
ret
The number of characters in the buffer.

Since 1.10

— Function: clutter-text-buffer-set-max-length (self <clutter-text-buffer>) (max_length int)
— Method: 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.

buffer
a <clutter-text-buffer>
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, ‘CLUTTER_TEXT_BUFFER_MAX_SIZE’ ].

Since 1.10

— Function: clutter-text-buffer-get-max-length (self <clutter-text-buffer>) ⇒  (ret int)
— Method: get-max-length

Retrieves the maximum allowed length of the text in buffer. See clutter-text-buffer-set-max-length.

buffer
a <clutter-text-buffer>
ret
the maximum allowed number of characters in <clutter-text-buffer>, or 0 if there is no maximum.

Since 1.10

— Function: clutter-text-buffer-insert-text (self <clutter-text-buffer>) (position unsigned-int) (chars mchars) (n_chars int) ⇒  (ret unsigned-int)
— Method: 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.

buffer
a <clutter-text-buffer>
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
ret
The number of characters actually inserted.

Since 1.10

— Function: clutter-text-buffer-delete-text (self <clutter-text-buffer>) (position unsigned-int) (n_chars int) ⇒  (ret unsigned-int)
— Method: 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.

buffer
a <clutter-text-buffer>
position
position at which to delete text
n-chars
number of characters to delete
ret
The number of characters deleted.

Since 1.10