RunList
(size, initial)¶List of contiguous runs of values.
A RunList is an efficient encoding of a sequence of values. For
example, the sequence aaaabbccccc
is encoded as (4, a), (2, b),
(5, c)
. The class provides methods for modifying and querying the
run list without needing to deal with the tricky cases of splitting and
merging the run list entries.
Run lists are used to represent formatted character data in pyglet. A separate run list is maintained for each style attribute, for example, bold, italic, font size, and so on. Unless you are overriding the document interfaces, the only interaction with run lists is via RunIterator.
The length and ranges of a run list always refer to the character
positions in the decoded list. For example, in the above sequence,
set_run(2, 5, 'x')
would change the sequence to aaxxxbccccc
.
Constructor:
__init__
(size, initial)¶Create a run list of the given size and a default value.
Parameters: |
|
---|
Methods:
delete
(start, end)Remove characters from the run list. get_run_iterator
()Get an extended iterator over the run list. insert
(pos, length)Insert characters into the run list. set_run
(start, end, value)Set the value of a range of characters.
RunList.
delete
(start, end)¶Remove characters from the run list.
Parameters: |
|
---|
RunList.
get_run_iterator
()¶Get an extended iterator over the run list.
Return type: | RunIterator |
---|
RunList.
insert
(pos, length)¶Insert characters into the run list.
The inserted characters will take on the value immediately preceding the insertion point (or the value of the first character, if pos is 0).
Parameters: |
|
---|
RunList.
set_run
(start, end, value)¶Set the value of a range of characters.
Parameters: |
|
---|