Class: Clutter::TextBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/clutter/text-buffer.rb

Overview

The Clutter::TextBufferClass structure contains only private data.

Instance Method Summary collapse

Constructor Details

#initialize(text, text_len) ⇒ Clutter::TextBuffer

Create a new ClutterTextBuffer object with some text.

Parameters:

  • text (String)

    initial buffer text

  • text_len (Clutter::gssize)

    initial buffer text length, or -1 for null-terminated.

Instance Method Details

#bytesInteger

Retrieves the length in bytes of the buffer. See clutter_text_buffer_get_length().

Returns:

  • (Integer)

    The byte length of the buffer.

#delete_text(position, n_chars) ⇒ Integer

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 (Integer)

    position at which to delete text

  • n_chars (Integer)

    number of characters to delete

Returns:

  • (Integer)

    The number of characters deleted.

#emit_deleted_text(position, n_chars) ⇒ nil

Emits the Clutter::TextBuffer::deleted-text signal on buffer.

Used when subclassing Clutter::TextBuffer

Parameters:

  • position (Integer)

    position at which text was deleted

  • n_chars (Integer)

    number of characters deleted

Returns:

  • (nil)

#emit_inserted_text(position, string) ⇒ nil

Emits the Clutter::TextBuffer::inserted-text signal on buffer.

Used when subclassing Clutter::TextBuffer

Parameters:

  • position (Integer)

    position at which text was inserted

  • chars (String)

    text that was inserted

  • n_chars (Integer)

    number of characters inserted

Returns:

  • (nil)


32
33
34
# File 'lib/clutter/text-buffer.rb', line 32

def emit_inserted_text(position, string)
  emit_inserted_text_raw(position, string, string.length)
end

#emit_inserted_text_rawnil

Emits the Clutter::TextBuffer::inserted-text signal on buffer.

Used when subclassing Clutter::TextBuffer

Parameters:

  • position (Integer)

    position at which text was inserted

  • chars (String)

    text that was inserted

  • n_chars (Integer)

    number of characters inserted

Returns:

  • (nil)


# File 'lib/clutter/text-buffer.rb', line 21

#insert_text(position, string) ⇒ Integer

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 (Integer)

    the position at which to insert text.

  • chars (String)

    the text to insert into the buffer.

  • n_chars (Integer)

    the length of the text in characters, or -1

Returns:

  • (Integer)

    The number of characters actually inserted.



28
29
30
# File 'lib/clutter/text-buffer.rb', line 28

def insert_text(position, string)
  insert_text_raw(position, string, string.length)
end

#insert_text_rawInteger

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 (Integer)

    the position at which to insert text.

  • chars (String)

    the text to insert into the buffer.

  • n_chars (Integer)

    the length of the text in characters, or -1

Returns:

  • (Integer)

    The number of characters actually inserted.



# File 'lib/clutter/text-buffer.rb', line 20

#lengthInteger

The length (in characters) of the text in buffer.

Returns:

  • (Integer)

    length

#length=(length) ⇒ Integer

The length (in characters) of the text in buffer.

Parameters:

  • length (Integer)

Returns:

  • (Integer)

    length

  • (Integer)

    length

#max_lengthInteger

The maximum length (in characters) of the text in the buffer.

Returns:

  • (Integer)

    max-length

#max_length=(max_length) ⇒ Integer

The maximum length (in characters) of the text in the buffer.

Parameters:

  • max_length (Integer)

Returns:

  • (Integer)

    max-length

  • (Integer)

    max-length

#set_text(string) ⇒ nil Also known as: 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.

Parameters:

  • chars (String)

    the new text

  • n_chars (Integer)

    the number of characters in text, or -1

Returns:

  • (nil)


23
24
25
# File 'lib/clutter/text-buffer.rb', line 23

def set_text(string)
  set_text_raw(string, string.length)
end

#set_text_rawnil

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.

Parameters:

  • chars (String)

    the new text

  • n_chars (Integer)

    the number of characters in text, or -1

Returns:

  • (nil)


# File 'lib/clutter/text-buffer.rb', line 19

#textString

The contents of the buffer.

Returns:

  • (String)

    text