
    \
j"                         d Z ddlZddlZ G d dej        j        j                  Zd Z G d d          Z G d d	e          Z	 G d
 de          Z
 G d dej        j                  ZdS )z;Base class for structured (hierarchical) document formats.
    Nc                   ,     e Zd Zd fd	Zd Zd Z xZS )ImageElementNc                 n   |                                 | _        |d u r|j        p|| _        |d u r|j        p|| _        i | _        | j        |j        z  |j        z  }t          d| j        |z
            }t          d|           }t          t          |           
                    ||| j                   d S )Nr   )get_textureimagewidthheightvertex_listsanchor_ymaxminsuperr   __init__)selfr   r   r	   r   ascentdescent	__class__s          X/DATA/AppData/hermes/venv/lib/python3.11/site-packages/pyglet/text/formats/structured.pyr   zImageElement.__init__-   s    &&((
d]2u{;e
n5?;%,.?Qh.//a(##lD!!**67DJGGGGG    c                 j   t           j                            | j                                        |j                  }|}|| j        z   }|| j        z   }|| j        z   | j        z   }|j	        
                    dt           j        j        |d||||||||ffdd| j        j        f          }	|	| j        |<   d S )N   v2i)c3B)   r   r   r   r   r   r   r   r   r   r   r   t3f)pygletgraphicsTextureGroupr   r   	top_groupr   r   r	   batchaddglGL_QUADS
tex_coordsr
   )
r   layoutxygroupx1y1x2y2vertex_lists
             r   placezImageElement.place8   s    ,,TZ-C-C-E-EvGWXX^_t|+l&&q&)*<eRRRR45(DJ)*, , %0&!!!r   c                 T    | j         |                                          | j         |= d S N)r
   delete)r   r%   s     r   removezImageElement.removeD   s-    &!((***f%%%r   )NN)__name__
__module____qualname__r   r.   r2   __classcell__)r   s   @r   r   r   ,   sa        	H 	H 	H 	H 	H 	H
0 
0 
0& & & & & & &r   r   c                     d| cxk     rdk     sn t          d          d}d}d}t          t          |                    D ]6}t          | ||         z            }|||         |z  z  }| ||         |z  z  } 7|S )Nr   i  z#Argument must be between 1 and 3999)i  i  i  i  d   Z   2   (   
   	      r      )MCMDCDCXCLXLXIXVIVI )
ValueErrorrangelenint)inputintsnumsresulticounts         r   _int_to_romanrX   I   s    ut>???JDKDF3t99 ! !ET!W$%%$q'E/!a5 Mr   c                   $    e Zd Zd ZddZddZdS )ListBuilderc                     |j                             d          pd}|j                             d          }|rt          |          }ng }|                    |dz              |dz   |d<   d|d<   ||d<   dS )zBegin a list.

        :Parameters:
            `decoder` : `StructuredTextDecoder`
                Decoder.
            `style` : dict
                Style dictionary that applies over the entire list.

        margin_leftr   	tab_stopsr:   iindentN)current_stylegetlistappend)r   decoderstyleleft_marginr]   s        r   beginzListBuilder.beginX   s     +//>>C!)--k::	 	YIIIr)****R/mh&kr   Nc                     |                      |          }|r|                    |           |                    d           dS )aX  Begin a list item.

        :Parameters:
            `decoder` : `StructuredTextDecoder`
                Decoder.
            `style` : dict
                Style dictionary that applies over the list item.
            `value` : str
                Optional value of the list item.  The meaning is list-type
                dependent.

        	N)get_markadd_text)r   rc   rd   valuemarks        r   itemzListBuilder.itemm   sK     }}U## 	#T"""r   c                     dS )zGet the mark text for the next list item.

        :Parameters:
            `value` : str
                Optional value of the list item.  The meaning is list-type
                dependent.

        :rtype: str
        rM    r   rk   s     r   ri   zListBuilder.get_mark   s	     rr   r0   )r3   r4   r5   rf   rm   ri   ro   r   r   rZ   rZ   W   sK        ' ' '*   $
 
 
 
 
 
r   rZ   c                       e Zd Zd Zd ZdS )UnorderedListBuilderc                     || _         dS )zCreate an unordered list with constant mark text.

        :Parameters:
            `mark` : str
                Mark to prepend to each list item.

        Nrl   )r   rl   s     r   r   zUnorderedListBuilder.__init__   s     			r   c                     | j         S r0   rt   rp   s     r   ri   zUnorderedListBuilder.get_mark   s
    yr   N)r3   r4   r5   r   ri   ro   r   r   rr   rr      s2              r   rr   c                   :    e Zd Z ej        d          Zd Zd ZdS )OrderedListBuilderz(.*?)([1aAiI])(.*)c                     || _         | j                            |                                          \  | _        | _        | _        | j        dv sJ dS )a  Create an ordered list with sequentially numbered mark text.

        The format is composed of an optional prefix text, a numbering
        scheme character followed by suffix text. Valid numbering schemes
        are:

        ``1``
            Decimal Arabic
        ``a``
            Lowercase alphanumeric
        ``A``
            Uppercase alphanumeric
        ``i``
            Lowercase Roman
        ``I``
            Uppercase Roman

        Prefix text may typically be ``(`` or ``[`` and suffix text is
        typically ``.``, ``)`` or empty, but either can be any string.

        :Parameters:
            `start` : int
                First list item number.
            `format` : str
                Format style, for example ``"1."``.

        1aAiIN)
next_value	format_rematchgroupsprefix	numberingsuffix)r   startformats      r   r   zOrderedListBuilder.__init__   sR    8  37>3G3G3O3O3V3V3X3X0T^T[~((((((r   c                    || j         }|dz   | _         | j        dv rP	 d|dz
           }n# t          $ r d}Y nw xY w| j        dk    r|                                }| j        || j        S | j        dv rT	 t          |          }n# t          $ r d}Y nw xY w| j        dk    r|                                }| j        || j        S d| j        || j        fz  S )	Nr?   aAabcdefghijklmnopqrstuvwxyz?AiIrV   z%s%d%s)rz   r   rN   upperr~   r   rX   lower)r   rk   rl   s      r   ri   zOrderedListBuilder.get_mark   s   =OE!)>T!!3EAI>   ~$$zz||#{{DD$++>>^t##$U++   ~$$zz||#{{DD$++>>t{E4;???s   * 997B BBN)r3   r4   r5   recompiler{   r   ri   ro   r   r   rw   rw      sJ        
/00I) ) )B@ @ @ @ @r   rw   c                   4    e Zd ZddZd Zd Zd Zd Zd ZdS )	StructuredTextDecoderNc                    d| _         i | _        i | _        g | _        g | _        t
          j        j                                        | _        |t
          j	        
                    d          }|                     ||           | j        S )Nr   rM   )len_textr_   
next_stylestack
list_stackr   textdocumentFormattedDocumentresourceFileLocationdecode_structuredr   r   locations      r   decodezStructuredTextDecoder.decode   sw    
,>>@@33B77HtX...}r   c                      t          d          )Nabstract)NotImplementedErrorr   s      r   r   z'StructuredTextDecoder.decode_structured   s    !*---r   c                    i }|                                 D ]}| j                            |          ||<    | j                            ||f           | j                            |           | j                            |           d S r0   )keysr_   r`   r   rb   updater   )r   keystyles
old_stylesnames        r   
push_stylez StructuredTextDecoder.push_style   s    
KKMM 	< 	<D#155d;;Jt
3
+,,,!!&)))v&&&&&r   c                     | j         D ]\  }}||k    r nd S 	 | j                                         \  }}| j                            |           | j                            |           ||k    rd S Yr0   )r   popr   r   r_   )r   r   r|   _r   s        r   	pop_stylezStructuredTextDecoder.pop_style   s    
 	 	HE1e||  F	 $
 0 0E:O"":...%%j111||	r   c                     | j                             | j        || j                   | j                                         | xj        t          |          z  c_        d S r0   )r   insert_textr   r   clearrP   )r   r   s     r   rj   zStructuredTextDecoder.add_text   sN    !!$-tGGGT"r   c                     | j                             | j        || j                   | j                                         | xj        dz  c_        d S )Nr?   )r   insert_elementr   r   r   )r   elements     r   add_elementz!StructuredTextDecoder.add_element  sH    $$T]GT_MMMr   r0   )	r3   r4   r5   r   r   r   r   rj   r   ro   r   r   r   r      ss        
 
 
 
. . .' ' '   # # #
    r   r   )__doc__r   r   r   r   InlineElementr   rX   rZ   rr   rw   DocumentDecoderr   ro   r   r   <module>r      s$  H  
			 & & & & &6;'5 & & &:  2 2 2 2 2 2 2 2j    ;   9@ 9@ 9@ 9@ 9@ 9@ 9@ 9@x0 0 0 0 0FK7 0 0 0 0 0r   