InfText.Chunk¶
Fields¶
None
Methods¶
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class InfText.Chunk¶
InfText.Chunkis an opaque data type. You should only access it via the public API functions.- classmethod new(encoding)¶
- Parameters:
encoding (
str) – A content encoding, such as “UTF-8” or “LATIN1”.- Returns:
A new
InfText.Chunk.- Return type:
Creates a new
InfText.Chunkwith no initial content that holds text in the given encoding. TODO: Allow binary data withNoneencoding.
- copy()¶
- Returns:
A new
InfText.Chunk.- Return type:
Returns a copy of self.
- equal(other)¶
- Parameters:
other (
InfText.Chunk) – AnotherInfText.Chunk.- Returns:
Whether the two chunks are equal.
- Return type:
Returns whether the two text chunks contain the same text and the same segments were written by the same authors.
- erase(begin, length)¶
- Parameters:
Removes length characters of self, starting from character offset begin.
- free()¶
Frees a
InfText.Chunkallocated withInfText.Chunk.new(),InfText.Chunk.copy() orInfText.Chunk.substring().
- get_encoding()¶
- Returns:
The encoding of self.
- Return type:
Returns the character encoding in which the content of self is encoded.
- get_length()¶
- Returns:
The number of characters of self.
- Return type:
Returns the number of characters contained in self.
- get_text()¶
-
Returns the content of self as an array. The text is encoded in self's encoding. length is set to the number of bytes in the returned buffer, if non-
None. The result is _not_ zero-terminated.
- insert_chunk(offset, text)¶
- Parameters:
offset (
int) – Character offset at which to insert text.text (
InfText.Chunk) – Chunk to insert into self.
Inserts text into self at position offset. text and self must have the same encoding.
- insert_text(offset, text, bytes, length, author)¶
- Parameters:
Inserts text written by author into self. text is expected to be in the chunk’s encoding.
- iter_init_begin()¶
- Returns:
Whether iter was set.
- iter:
- Return type:
(
bool, iter:InfText.ChunkIter)
Sets iter to point to the first segment of self. If there are no segments (i.e. self is empty), iter is left untouched and the function returns
False.
- iter_init_end()¶
- Returns:
Whether iter was set.
- iter:
- Return type:
(
bool, iter:InfText.ChunkIter)
Sets iter to point to the last segment of self. If there are no segments (i.e. self is empty), iter is left untouched and the function returns
False.
- substring(begin, length)¶
- Parameters:
- Returns:
A new
InfText.Chunk.- Return type:
Returns a new
InfText.Chunkcontaining a substring of self, beginning at character offset begin and length characters long.