
    \
jg                        d Z ddlZddlZddlmZ ddlmZ  eed          oej        Z	dZ
 G d d          Z G d	 d
ej                  Ze                    d           e                    d           e                    d            G d de          Z G d de          Zd Z G d dej                  Z G d d          Z G d d          Z e            ZdS )a  Formatted and unformatted document interfaces used by text layout.

Abstract representation
=======================

Styled text in pyglet is represented by one of the :py:class:`~pyglet.text.document.AbstractDocument` classes,
which manage the state representation of text and style independently of how
it is loaded or rendered.

A document consists of the document text (a Unicode string) and a set of
named style ranges.  For example, consider the following (artificial)
example::

    0    5   10   15   20
    The cat sat on the mat.
    +++++++        +++++++    "bold"
                ++++++      "italic"

If this example were to be rendered, "The cat" and "the mat" would be in bold,
and "on the" in italics.  Note that the second "the" is both bold and italic.

The document styles recorded for this example would be ``"bold"`` over ranges
(0-7, 15-22) and ``"italic"`` over range (12-18).  Overlapping styles are
permitted; unlike HTML and other structured markup, the ranges need not be
nested.

The document has no knowledge of the semantics of ``"bold"`` or ``"italic"``,
it stores only the style names.  The pyglet layout classes give meaning to
these style names in the way they are rendered; but you are also free to
invent your own style names (which will be ignored by the layout classes).
This can be useful to tag areas of interest in a document, or maintain
references back to the source material.

As well as text, the document can contain arbitrary elements represented by
:py:class:`~pyglet.text.document.InlineElement`.  An inline element behaves like a single character in the
documented, but can be rendered by the application.

Paragraph breaks
================

Paragraph breaks are marked with a "newline" character (U+0010).  The Unicode
paragraph break (U+2029) can also be used.

Line breaks (U+2028) can be used to force a line break within a paragraph.

See Unicode recommendation UTR #13 for more information:
http://unicode.org/reports/tr13/tr13-5.html.

Document classes
================

Any class implementing :py:class:`~pyglet.text.document.AbstractDocument` provides an interface to a
document model as described above.  In theory a structured document such as
HTML or XML could export this model, though the classes provided by pyglet
implement only unstructured documents.

The :py:class:`~pyglet.text.document.UnformattedDocument` class assumes any styles set are set over the entire
document.  So, regardless of the range specified when setting a ``"bold"``
style attribute, for example, the entire document will receive that style.

The :py:class:`~pyglet.text.document.FormattedDocument` class implements the document model directly, using
the `RunList` class to represent style runs efficiently.

Style attributes
================

The following character style attribute names are recognised by pyglet:

``font_name``
    Font family name, as given to :py:func:`pyglet.font.load`.
``font_size``
    Font size, in points.
``bold``
    Boolean.
``italic``
    Boolean.
``underline``
    4-tuple of ints in range (0, 255) giving RGBA underline color, or None
    (default) for no underline.
``kerning``
    Additional space to insert between glyphs, in points.  Defaults to 0.
``baseline``
    Offset of glyph baseline from line baseline, in points.  Positive values
    give a superscript, negative values give a subscript.  Defaults to 0.
``color``
    4-tuple of ints in range (0, 255) giving RGBA text color
``background_color``
    4-tuple of ints in range (0, 255) giving RGBA text background color; or
    ``None`` for no background fill.

The following paragraph style attribute names are recognised by pyglet.  Note
that paragraph styles are handled no differently from character styles by the
document: it is the application's responsibility to set the style over an
entire paragraph, otherwise results are undefined.

``align``
    ``left`` (default), ``center`` or ``right``.
``indent``
    Additional horizontal space to insert before the first
``leading``
    Additional space to insert between consecutive lines within a paragraph,
    in points.  Defaults to 0.
``line_spacing``
    Distance between consecutive baselines in a paragraph, in points.
    Defaults to ``None``, which automatically calculates the tightest line
    spacing for each line based on the font ascent and descent.
``margin_left``
    Left paragraph margin, in pixels.
``margin_right``
    Right paragraph margin, in pixels.
``margin_top``
    Margin above paragraph, in pixels.
``margin_bottom``
    Margin below paragraph, in pixels.  Adjacent margins do not collapse.
``tab_stops``
    List of horizontal tab stops, in pixels, measured from the left edge of
    the text layout.  Defaults to the empty list.  When the tab stops
    are exhausted, they implicitly continue at 50 pixel intervals.
``wrap``
    Boolean.  If True (the default), text wraps within the width of the layout.

Other attributes can be used to store additional style information within the
document; it will be ignored by the built-in text classes.

All style attributes (including those not present in a document) default to
``None`` (including the so-called "boolean" styles listed above).  The meaning
of a ``None`` style is style- and application-dependent.

.. versionadded:: 1.1
    N)event)runlistis_pyglet_doc_runindeterminatec                   @    e Zd ZdZd Z ed d          Zd Zd ZdS )	InlineElementa  Arbitrary inline element positioned within a formatted document.

    Elements behave like a single glyph in the document.  They are
    measured by their horizontal advance, ascent above the baseline, and
    descent below the baseline.

    The pyglet layout classes reserve space in the layout for elements and
    call the element's methods to ensure they are rendered at the
    appropriate position.

    If the size of a element (any of the `advance`, `ascent`, or `descent`
    instance variables) is modified it is the application's responsibility to
    trigger a reflow of the appropriate area in the affected layouts.  This
    can be done by forcing a style change over the element's position.

    :Ivariables:
        `ascent` : int
            Ascent of the element above the baseline, in pixels.
        `descent` : int
            Descent of the element below the baseline, in pixels.
            Typically negative.
        `advance` : int
            Width of the element, in pixels.

    c                 >    || _         || _        || _        d | _        d S N)ascentdescentadvance	_position)selfr   r   r   s       N/DATA/AppData/hermes/venv/lib/python3.11/site-packages/pyglet/text/document.py__init__zInlineElement.__init__   s"        c                     | j         S r
   )r   r   s    r   <lambda>zInlineElement.<lambda>   s    T^ r   z]Position of the element within the
        document.  Read-only.

        :type: int
        )docc                      t          d          )a  Construct an instance of the element at the given coordinates.

        Called when the element's position within a layout changes, either
        due to the initial condition, changes in the document or changes in
        the layout size.

        It is the responsibility of the element to clip itself against
        the layout boundaries, and position itself appropriately with respect
        to the layout's position and viewport offset.

        The `TextLayout.top_state` graphics state implements this transform
        and clipping into window space.

        :Parameters:
            `layout` : `pyglet.text.layout.TextLayout`
                The layout the element moved within.
            `x` : int
                Position of the left edge of the element, relative
                to the left edge of the document, in pixels.
            `y` : int
                Position of the baseline, relative to the top edge of the
                document, in pixels.  Note that this is typically negative.

        abstractNotImplementedError)r   layoutxys       r   placezInlineElement.place   s    2 "*---r   c                      t          d          )a!  Remove this element from a layout.

        The counterpart of `place`; called when the element is no longer
        visible in the given layout.

        :Parameters:
            `layout` : `pyglet.text.layout.TextLayout`
                The layout the element was removed from.

        r   r   )r   r   s     r   removezInlineElement.remove        "*---r   N)	__name__
__module____qualname____doc__r   propertypositionr   r     r   r   r   r      sn         4   x33  H. . .6. . . . .r   r   c                   "    e Zd ZdZ ej        d          Z ej        d          Zd fd	Ze	d             Z
e
j        d             Z
d Zd	 Zd
 ZddZd ZddZddZddZd Zd Zd ZddZd Zd Zd Zd Zerd Zd Zd Z xZ S  xZ S ) AbstractDocumenta  Abstract document interface used by all :py:mod:`pyglet.text` classes.

    This class can be overridden to interface pyglet with a third-party
    document format.  It may be easier to implement the document format in
    terms of one of the supplied concrete classes :py:class:`~pyglet.text.document.FormattedDocument` or
    :py:class:`~pyglet.text.document.UnformattedDocument`.
    u
   
[^
 ]*$u   [
 ] c                     t          t          |                                            d| _        g | _        |r|                     d|           d S d S )Nr+   r   )superr*   r   _text	_elementsinsert_textr   text	__class__s     r   r   zAbstractDocument.__init__  s\    %%..000
 	&Q%%%%%	& 	&r   c                     | j         S )a  Document text.

        For efficient incremental updates, use the :py:func:`~pyglet.text.document.AbstractDocument.insert_text` and
        :py:func:`~pyglet.text.document.AbstractDocument.delete_text` methods instead of replacing this property.

        :type: str
        )r.   r   s    r   r2   zAbstractDocument.text  s     zr   c                     || j         k    rd S |                     dt          | j                              |                     d|           d S Nr   )r.   delete_textlenr0   )r   r2   s     r   r2   zAbstractDocument.text!  sN    4:FC
OO,,,D!!!!!r   c                    | j         d|dz                                d          s%| j         d|dz                                d          r|S | j                            | j         d|dz             }|sdS |                                dz   S )zGet the starting position of a paragraph.

        :Parameters:
            `pos` : int
                Character position within paragraph.

        :rtype: int
        N   
u    r   )r.   endswith_previous_paragraph_researchstartr   posms      r   get_paragraph_startz$AbstractDocument.get_paragraph_start(  s     Jxax ))$// 	
8C!G8$--i88	J'..tz1cAgFF 	1wwyy1}r   c                     | j                             | j        |          }|st          | j                  S |                                dz   S )zGet the end position of a paragraph.

        :Parameters:
            `pos` : int
                Character position within paragraph.

        :rtype: int
        r:   )_next_paragraph_rer>   r.   r8   r?   r@   s      r   get_paragraph_endz"AbstractDocument.get_paragraph_end<  sF     #**4:s;; 	#tz??"wwyy1}r   c                      t          d          )zGet a style iterator over the given style attribute.

        :Parameters:
            `attribute` : str
                Name of style attribute to query.

        :rtype: `AbstractRunIterator`
        r   r   r   	attributes     r   get_style_runszAbstractDocument.get_style_runsJ  s     "*---r   r   c                      t          d          )a;  Get an attribute style at the given position.

        :Parameters:
            `attribute` : str
                Name of style attribute to query.
            `position` : int
                Character position of document to query.

        :return: The style set for the attribute at the given position.
        r   r   r   rI   r'   s      r   	get_stylezAbstractDocument.get_styleU  r!   r   c                     |                      |          }t          |                    ||                    \  }}}||k     rt          S |S )a  Get an attribute style over the given range.

        If the style varies over the range, `STYLE_INDETERMINATE` is returned.

        :Parameters:
            `attribute` : str
                Name of style attribute to query.
            `start` : int
                Starting character position.
            `end` : int
                Ending character position (exclusive).

        :return: The style set for the attribute over the given range, or
            `STYLE_INDETERMINATE` if more than one value is set.
        )rJ   nextrangesSTYLE_INDETERMINATE)r   rI   r?   enditerable_	value_endvalues           r   get_style_rangez AbstractDocument.get_style_rangeb  sM      &&y11"8??5##>#>??9es??&&Lr   Nc                      t          d          )a  Get a style iterator over the `pyglet.font.Font` instances used in
        the document.

        The font instances are created on-demand by inspection of the
        ``font_name``, ``font_size``, ``bold`` and ``italic`` style
        attributes.

        :Parameters:
            `dpi` : float
                Optional resolution to construct fonts at.  See
                :py:func:`pyglet.font.load`.

        :rtype: `AbstractRunIterator`
        r   r   r   dpis     r   get_font_runszAbstractDocument.get_font_runsy       "*---r   c                      t          d          )a  Get the font instance used at the given position.

        :see: `get_font_runs`

        :Parameters:
            `position` : int
                Character position of document to query.
            `dpi` : float
                Optional resolution to construct fonts at.  See
                :py:func:`pyglet.font.load`.

        :rtype: `pyglet.font.Font`
        :return: The font at the given position.
        r   r   )r   r'   rZ   s      r   get_fontzAbstractDocument.get_font  r\   r   c                 b    |                      |||           |                     d||           dS )aT  Insert text into the document.

        :Parameters:
            `start` : int
                Character insertion point within document.
            `text` : str
                Text to insert.
            `attributes` : dict
                Optional dictionary giving named style attributes of the
                inserted text.

        on_insert_textN)_insert_textdispatch_event)r   r?   r2   
attributess       r   r0   zAbstractDocument.insert_text  s;     	%z222,eT:::::r   c                     d                     | j        d |         || j        |d          f          | _        t          |          }| j        D ]}|j        |k    r|xj        |z  c_        d S )Nr+   )joinr.   r8   r/   r   )r   r?   r2   rc   len_textelements         r   ra   zAbstractDocument._insert_text  s{    XXtz&5&14EFF9KLMM
t99~ 	. 	.G E))!!X-!!	. 	.r   c                 `    |                      ||           |                     d||           dS )zDelete text from the document.

        :Parameters:
            `start` : int
                Starting character position to delete from.
            `end` : int
                Ending character position to delete to (exclusive).

        on_delete_textN)_delete_textrb   r   r?   rR   s      r   r7   zAbstractDocument.delete_text  s9     	%%%%,eS99999r   c                    t          | j                  D ]P}||j        cxk    r|k     rn n| j                            |           2|j        |k    r|xj        ||z
  z  c_        Q| j        d |         | j        |d          z   | _        d S r
   )listr/   r   r    r.   )r   r?   rR   rg   s       r   rj   zAbstractDocument._delete_text  s    DN++ 	3 	3G)////C/////%%g...."c))!!cEk2!!Z'$*STT*::


r   c                     |j         
J d            |                     |d|           ||_         | j                            |           | j                            d            dS )a  Insert a element into the document.

        See the :py:class:`~pyglet.text.document.InlineElement` class documentation for details of
        usage.

        :Parameters:
            `position` : int
                Character insertion point within document.
            `element` : `~pyglet.text.document.InlineElement`
                Element to insert.
            `attributes` : dict
                Optional dictionary giving named style attributes of the
                inserted text.

        Nz!Element is already in a document. c                     | j         S r
   r'   )ds    r   r   z1AbstractDocument.insert_element.<locals>.<lambda>  s    !* r   )key)r   r0   r/   appendsort)r   r'   rg   rc   s       r   insert_elementzAbstractDocument.insert_element  su       ((*M(((4444$g&&& 4 455555r   c                 X    | j         D ]}|j        |k    r|c S t          d|z            )zGet the element at a specified position.

        :Parameters:
            `position` : int
                Position in the document of the element.

        :rtype: :py:class:`~pyglet.text.document.InlineElement`
        zNo element at position %d)r/   r   RuntimeError)r   r'   rg   s      r   get_elementzAbstractDocument.get_element  sE     ~ 	 	G H,, -6ABBBr   c                 d    |                      |||           |                     d|||           dS )aJ  Set text style of some or all of the document.

        :Parameters:
            `start` : int
                Starting character position.
            `end` : int
                Ending character position (exclusive).
            `attributes` : dict
                Dictionary giving named style attributes of the text.

        on_style_textN)
_set_stylerb   r   r?   rR   rc   s       r   	set_stylezAbstractDocument.set_style  s:     	sJ///OUCDDDDDr   c                      t          d          )Nr   r   r}   s       r   r|   zAbstractDocument._set_style  s    !*---r   c                     |                      |          }|                     |          }|                     |||           |                     d|||           dS )a  Set the style for a range of paragraphs.

        This is a convenience method for `set_style` that aligns the
        character range to the enclosing paragraph(s).

        :Parameters:
            `start` : int
                Starting character position.
            `end` : int
                Ending character position (exclusive).
            `attributes` : dict
                Dictionary giving named style attributes of the paragraphs.

        r{   N)rC   rF   r|   rb   r}   s       r   set_paragraph_stylez$AbstractDocument.set_paragraph_style  s`     ((//$$S))sJ///OUCDDDDDr   c                     dS )a
  Text was inserted into the document.

            :Parameters:
                `start` : int
                    Character insertion point within document.
                `text` : str
                    The text that was inserted.

            :event:
            Nr(   )r   r?   r2   s      r   r`   zAbstractDocument.on_insert_text        r   c                     dS )a%  Text was deleted from the document.

            :Parameters:
                `start` : int
                    Starting character position of deleted text.
                `end` : int
                    Ending character position of deleted text (exclusive).

            :event:
            Nr(   rk   s      r   ri   zAbstractDocument.on_delete_text  r   r   c                     dS )a  Text character style was modified.

            :Parameters:
                `start` : int
                    Starting character position of modified text.
                `end` : int
                    Ending character position of modified text (exclusive).
                `attributes` : dict
                    Dictionary giving updated named style attributes of the
                    text.

            :event:
            Nr(   r}   s       r   r{   zAbstractDocument.on_style_text+  r   r   r+   r   r
   )!r"   r#   r$   r%   recompiler=   rE   r   r&   r2   setterrC   rF   rJ   rM   rW   r[   r^   r0   ra   r7   rj   rv   ry   r~   r|   r   _is_pyglet_doc_runr`   ri   r{   __classcell__r3   s   @r   r*   r*     s         (RZ(:;;#M22& & & & & &   X 
[" " ["  (  	. 	. 	.. . . .  .. . . .". . . ."; ; ; ; . . .: : :; ; ;6 6 6 6,C C CE E E. . .E E E(  &
	 
	 
	
	 
	 
		 	 	 	 	 	 	3& & & &r   r*   r`   ri   r{   c                   b     e Zd ZdZd fd	Zd ZddZ fdZd Z fd	Z	dd
Z
ddZd Z xZS )UnformattedDocumentzA document having uniform style over all text.

    Changes to the style of text within the document affects the entire
    document.  For convenience, the ``position`` parameters of the style
    methods may therefore be omitted.
    r+   c                 f    t          t          |                               |           i | _        d S r
   )r-   r   r   stylesr1   s     r   r   zUnformattedDocument.__init__H  s-    !4((11$777r   c                     | j                             |          }t          j        t	          | j                  |          S r
   )r   getr   ConstRunIteratorr8   r2   )r   rI   rV   s      r   rJ   z"UnformattedDocument.get_style_runsL  s0    	**'DI>>>r   Nc                 6    | j                             |          S r
   )r   r   rL   s      r   rM   zUnformattedDocument.get_styleP  s    {y)))r   c                 |    t          t          |                               dt          | j                  |          S r6   )r-   r   r~   r8   r2   r   r?   rR   rc   r3   s       r   r~   zUnformattedDocument.set_styleS  s5    ($//99s49~~z+ + 	+r   c                 :    | j                             |           d S r
   )r   updater}   s       r   r|   zUnformattedDocument._set_styleW  s    :&&&&&r   c                 |    t          t          |                               dt          | j                  |          S r6   )r-   r   r   r8   r2   r   s       r   r   z'UnformattedDocument.set_paragraph_styleZ  s5    ($//CCs49~~z+ + 	+r   c                 |    |                      |          }t          j        t          | j                  |          S )N)rZ   )r^   r   r   r8   r2   )r   rZ   fts      r   r[   z!UnformattedDocument.get_font_runs^  s0    ]]s]##'DI;;;r   c                 N   ddl m} | j                            d          }| j                            d          }| j                            dd          }| j                            dd          }| j                            dd          }|                    ||||||	          S )
Nr   font	font_name	font_sizeboldFitalicstretchr   r   r   rZ   )pygletr   r   r   load)	r   r'   rZ   r   r   r   r   r   r   s	            r   r^   zUnformattedDocument.get_fontb  s    KOOK00	KOOK00	{vu--511+//)U33yyI"67  M M 	Mr   c                 P    t          j        t          | j                  d           S r
   )r   r   r8   r.   r   s    r   get_element_runsz$UnformattedDocument.get_element_runsl  s    'DJ>>>r   r   r
   )NN)r"   r#   r$   r%   r   rJ   rM   r~   r|   r   r[   r^   r   r   r   s   @r   r   r   @  s              ? ? ?* * * *+ + + + +' ' '+ + + + +< < < <M M M M? ? ? ? ? ? ?r   r   c                   b     e Zd ZdZd fd	Zd ZddZd Zdd	Zdd
Z	d Z
 fdZ fdZ xZS )FormattedDocumentzSimple implementation of a document that maintains text formatting.

    Changes to text style are applied according to the description in
    :py:class:`~pyglet.text.document.AbstractDocument`.  All styles default to ``None``.
    r+   c                 f    i | _         t          t          |                               |           d S r
   )_style_runsr-   r   r   r1   s     r   r   zFormattedDocument.__init__w  s0    &&//55555r   c                 p    	 | j         |                                         S # t          $ r
 t          cY S w xY wr
   )r   get_run_iteratorKeyError_no_style_range_iteratorrH   s     r   rJ   z FormattedDocument.get_style_runs{  sH    	,#I.??AAA 	, 	, 	,++++	,s   ! 55r   c                 L    	 | j         |         |         S # t          $ r Y d S w xY wr
   )r   r   rL   s      r   rM   zFormattedDocument.get_style  s<    	#I.x88 	 	 	44	s    
##c                 4   |                                 D ]\  }}	 | j        |         }nW# t          $ rJ t          j        dd           x}| j        |<   |                    dt          | j                             Y nw xY w|                    |||           d S r6   )	itemsr   r   r   RunListinsertr8   r.   set_run)r   r?   rR   rc   rI   rV   runss          r   r|   zFormattedDocument._set_style  s     * 0 0 2 2 	, 	,Iu0'	2 0 0 05<_Q5M5MMt'	2As4://///0 LLU++++	, 	,s   )AA=<A=Nc           	          t          |                     d          |                     d          |                     d          |                     d          |                     d          |          S )Nr   r   r   r   r   )_FontStyleRunsRangeIteratorrJ   rY   s     r   r[   zFormattedDocument.get_font_runs  sl    *,,,,''))	**  	r   c                 <    |                      |          }||         S r
   )r[   )r   r'   rZ   	runs_iters       r   r^   zFormattedDocument.get_font  s     &&s++	""r   c                 P    t          | j        t          | j                            S r
   )_ElementIteratorr/   r8   r.   r   s    r   r   z"FormattedDocument.get_element_runs  s    DJ@@@r   c                    t          t          |                               |||           t          |          }| j                                        D ]}|                    ||           ||                                D ]\  }}	 | j        |         }nW# t          $ rJ t          j
        dd           x}| j        |<   |                    dt          | j                             Y nw xY w|                    |||z   |           d S d S r6   )r-   r   ra   r8   r   valuesr   r   r   r   r   r2   r   )	r   r?   r2   rc   rf   r   rI   rV   r3   s	           r   ra   zFormattedDocument._insert_text  s-   &&33E4LLLt99$++-- 	) 	)DKKx((((!$.$4$4$6$6 = = 	53+I6DD 3 3 39@D9Q9QQD4+I6KK3ty>>222223 UEH$4e<<<< "!= =s   	BAC+*C+c                     t          t          |                               ||           | j                                        D ]}|                    ||           d S r
   )r-   r   rj   r   r   delete)r   r?   rR   r   r3   s       r   rj   zFormattedDocument._delete_text  sc    &&33E3???$++-- 	$ 	$DKKs####	$ 	$r   r   r   r
   )r"   r#   r$   r%   r   rJ   rM   r|   r[   r^   r   ra   rj   r   r   s   @r   r   r   p  s         6 6 6 6 6 6, , ,   , , ,   # # # #A A A= = = = = $ $ $ $ $ $ $ $ $r   r   c              #   `   K   d}| D ]}|j         }||d fV  ||dz   |fV  |dz   } ||d fV  d S )Nr   r:   rq   )elementslengthlastrg   ps        r   _iter_elementsr     so      D  AtmQ1u

r   c                       e Zd Zd ZdS )r   c                 t    t          ||          | _        t          |           \  | _        | _        | _        d S r
   )r   _run_list_iterrO   r?   rR   rV   )r   r   r   s      r   r   z_ElementIterator.__init__  s0    ,Xv>>+/::(
DHdjjjr   N)r"   r#   r$   r   r(   r   r   r   r     s#        6 6 6 6 6r   r   c                        e Zd Zd Zd Zd ZdS )r   c                 P    t          j        |||||f          | _        || _        d S r
   )r   ZipRunIteratorzip_iterrZ   )r   
font_names
font_sizesboldsitalicsr   rZ   s          r   r   z$_FontStyleRunsRangeIterator.__init__  s+    .
JwX_/`aar   c           	   #      K   ddl m} | j                            ||          D ]O\  }}}|\  }}}}}	|                    ||t          |          t          |          |	| j                  }
|||
fV  Pd S Nr   r   r   )r   r   r   rP   r   boolrZ   )r   r?   rR   r   r   r   r   r   r   r   r   s              r   rP   z"_FontStyleRunsRangeIterator.ranges  s      "&-"6"6uc"B"B 	! 	!E3:@7Iy$9id4jjf_flpltuuBb.    	! 	!r   c                     ddl m} | j        |         \  }}}}}|                    ||t	          |          t	          |          || j                  S r   )r   r   r   r   r   rZ   )r   indexr   r   r   r   r   r   s           r   __getitem__z'_FontStyleRunsRangeIterator.__getitem__  sZ    6:mE6J3	9dFGyyIDJJtF||]djnjrysssr   N)r"   r#   r$   r   rP   r   r(   r   r   r   r     sF          ! ! !t t t t tr   r   c                       e Zd Zd Zd ZdS )_NoStyleRangeIteratorc              #      K   ||d fV  d S r
   r(   rk   s      r   rP   z_NoStyleRangeIterator.ranges  s      S$r   c                     d S r
   r(   )r   r   s     r   r   z!_NoStyleRangeIterator.__getitem__  s    tr   N)r"   r#   r$   rP   r   r(   r   r   r   r     s2              r   r   )r%   r   sysr   r   pyglet.textr   hasattrr   r   rQ   r   EventDispatcherr*   register_event_typer   r   r   RunIteratorr   r   r   r   r(   r   r   <module>r      s   HA AF 
			 



            WS"566P3;P  & N. N. N. N. N. N. N. N.bt t t t tu, t t tn	  $ $%5 6 6 6  $ $%5 6 6 6  $ $_ 5 5 5-? -? -? -? -?* -? -? -?`C$ C$ C$ C$ C$( C$ C$ C$L  6 6 6 6 6w* 6 6 6t t t t t t t t&        1022   r   