
)Oc        #   @   s  d  d k  Z  d  d k Z d  d k Z d  d k l Z l Z l Z l Z e i i	 i
 Z
 e i i	 i Z e d e d e d e d e d e d e d	 e d
 e d e d e d e d e d e d e d e  Z e e d <d   Z d e f d     YZ d e f d     YZ d e f d     YZ e  i d  Z d d d d d d  d! Z d" d# d$ Z d% Z d& e   d' e   d( e   Z e  i e  Z d)   Z e d*  Z e d+  Z d,   Z  d-   Z! d.   Z" d/   Z# d0 e i i$ i% f d1     YZ& d2 e f d3     YZ' d4   Z( d S(5   iN(   t   log2vist   WRTLt   RTLt   ONt   imaget   pt   wt   fastt   bt   it   ut   at   plaint   fontt   colort   sizet   nwt   st   stt    c         C   s  |  d d j o |  d }  n t  |   d j o[ t |  d |  d d  } t |  d |  d d  } t |  d |  d	 d  } d
 } net  |   d j op t |  d |  d d  } t |  d |  d d  } t |  d |  d	 d  } t |  d |  d d  } n t  |   d j oO t |  d d  d } t |  d d  d } t |  d d  d } d
 } n t  |   d j o` t |  d d  d } t |  d d  d } t |  d d  d } t |  d d  d } n t d   | | | | f S(   s  
    This function converts a hexcode into a color/alpha tuple. Leading
    # marks are ignored. Colors can be rgb or rgba, with each element having
    either one or two digits. (So the strings can be 3, 4, 6, or 8 digits long,
    not including the optional #.) A missing alpha is interpreted as 255,
    fully opaque.

    For example, color('#123a') returns (17, 34, 51, 170), while
    color('c0c0c0') returns (192, 192, 192, 255).
    i    t   #i   i   i   i   i   i   i   i   i   i   i   s:   Argument to color() must be 3, 4, 6, or 8 hex digits long.(   t   lent   intt	   Exception(   R   t   rt   gR   R   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR   5   s0    

t	   TextStylec           B   sY   e  Z d  Z d	 d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z RS(
   s_   
    This is used to represent the style of text that will be displayed
    on the screen.
    c         C   s   | d  j	 o t |   i t |   nR d |  _ d |  _ t |  _ t |  _ t |  _ t |  _	 d  |  _
 d  |  _ d  |  _ d  |  _ h  |  _ h  |  _ d  S(   NR   i    (   t   Nonet   varst   updateR   R   t   Falset   boldt   italict	   underlinet   strikethroughR   t   black_colort	   hyperlinkt   ft   wcachet   scache(   t   selft   source(    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   __init__c   s    											c         C   s1   t  |  i |  i |  i |  i |  i d  |  _ d  S(   Ni    (   t   get_fontR   R   R   R    R!   R%   (   R(   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR   z   s    c         C   s   |  i  S(   N(   R%   (   R(   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR+   }   s    c         C   s   |  i  i   S(   N(   R%   t
   get_ascent(   R(   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR,      s    c         C   sM   |  i  i | d   } | d  j o' |  i i |  d } | |  i  | <n | S(   Ni    (   R&   t   getR   R%   R   (   R(   t   textt   rv(    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt	   get_width   s
    c         C   s)   |  i  |  |  i i   |  i i   f S(   N(   R0   R%   R,   t   get_descent(   R(   R.   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   sizes   s    c
         C   s\  | o$ |  i  p | } |  i p | } n | | | | | f }
 |	 o |
 |  i j o |  i |
 Sn | o. t |  i |  i |  i |  i |  i |  } n
 |  i	 } t
 | t  ou | i | | | |  } |  i oO | i   \ } } t | d d  } | i d | d | | f  i |  qn | \ } } } } | | | d f } | i | | |  } t i i i |  } |  i oO | i   \ } } t | d d  } | i d | d | | f  i |  n | d j o* t i i i | | d d d | d  n t i i i |  |	 o+ t i i o | | i   f |  i |
 <n | | i   f S(   Ni
   i   i    i   i   i   (   R   R#   R'   R+   R   R   R   R    R!   R%   t
   isinstancet	   ImageFontt   renderR"   t   get_sizet   maxt
   subsurfacet   fillt   renpyt   displayt   pgrendert   copy_surfacet   modulet   linmapt   mutated_surfacet   gamet   less_memory(   R(   R.   t	   antialiasR   R#   t
   use_colorst   timet   att   expandt	   use_cachet   keyR   R/   t   swt   sht   sohR   R   R   R   t   surf(    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR5      s:    .	
.
**c         C   s
   t  |  S(   N(   R   (   R(   R.   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   length   s    N(   t   __name__t
   __module__t   __doc__R   R*   R   R+   R,   R0   R2   R5   RN   (    (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR   ]   s   						.t   WidgetStylec           B   sM   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   s+   
    Represents the style of a widget.
    c         C   s}   | i  d  d |  _ | i   |  _ | |  _ | |  _ t i i i | | |  i | |  } | i	   \ |  _
 } d  |  _ d  S(   Nt    i   (   R2   t   heightR,   t   ascentt   widgett   owidthR:   R;   R5   R6   t   widthR   R$   (   R(   t   tsRV   RX   RE   RM   t   _(    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR*      s    		$c         C   s   d  S(   N(    (   R(   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR      s    c         C   s   |  i  S(   N(   RU   (   R(   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR,      s    c         C   s   |  i  S(   N(   RX   (   R(   RV   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR0      s    c         C   s   |  i  |  i f S(   N(   RX   RT   (   R(   RV   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR2      s    c
   
      C   s\   | o; t  i i i | |  i |  i | |  |  i |  i f f Sn d  |  i |  i f f Sd  S(   N(   R:   R;   R5   RW   RT   RX   R   (
   R(   RV   RC   R   R#   t
   foregroundR   RF   RG   RH   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR5      s    ;c         C   s   d S(   Ni   (    (   R(   R.   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyRN      s    (
   RO   RP   RQ   R*   R   R,   R0   R2   R5   RN   (    (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyRR      s   						t   SpacerStylec           B   s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c         C   s   d  S(   N(    (   R(   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR      s    c         C   s   d S(   Ni    (   i    i    (    (   R(   t   ignored(    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR2      s    c         C   s   d S(   Ni    (    (   R(   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR,      s    c         C   s   d S(   Ni    (    (   R(   R.   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR0      s    c         C   s   d S(   Ni    (    (   R(   R.   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyRN      s    (   RO   RP   R   R2   R,   R0   RN   (    (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR\      s
   				u   (?x)
      (?P<space>[ ​])
    | \{(?P<tag>[^{}]+)\}
    | (?P<untag>\{\{)
    | (?P<newline>\n)
    | (?P<word>[^ \n\{]+)
    u(   \!\"\%\)\,\-\.\:\;\?\]‐’”‰′″u   ℃−、。々〉》」』】u   〕〗ぁぃぅぇぉっゃゅu   ょゎ゛゜ゝゞァィゥェu   ォッャュョヮヵヶーヽu   ヾ！＂％）），－．：u   ；？］｝｝｡｣ﾞﾟu   \"\#\$\(\@\[¢£¥§‘“♯u   〈《「『【〒〔〖＃＄u   （（＠［｛｛｢￠￡￥u    \'\w!-z|~ɏ０-９＠-Ｊａ-ｚut   (?x)
  (?P<space>[ \t​])
| \{(?P<tag>[^{}]+)\}
| (?P<untag>\{\{)
| (?P<newline>\n)
| (?P<word>([%(ea_not_after)s]*uN   ([^ \n\{​%(ea_not_before)s%(ea_not_after)s%(ea_western)s]|[%(ea_western)s]+)u=   [%(ea_not_before)s]*)|[%(ea_not_after)s]|[%(ea_not_before)s])c         c   s+  | d
 j p | i d j o
 t } n. | i d j o
 t } n t d | i   x | i |   D] } | i d  o d | i d  f Vqd | i d  o d | i d  f Vqd | i d  o d | i d  f Vqd | i d  o	 d Vqd | i d	  o d	 | i d	  f Vqd qd Wd
 S(   s>  
    This functions is used to tokenize text. It's called when laying
    out a Text widget, and is given the string that is the text of the
    widget, and the style associated with the widget.

    It's expected to yield some number of pairs. In each pair, the
    first element is the kind of token found, and the second element
    is the text corresponding to that token. The following token
    types are defined:

    "newline" -- A newline, which when encountered starts a new line.

    "word" -- A word of text. A line will never be broken inside of
    a word.

    "space" -- A space. Spaces are always placed on the current line,
    and will never be placed as the start of a line.
    
    "tag" -- A text tag. If encountered, the second element should be
    the name of the tag, without any enclosing braces.
    t   westernt	   eastasians   Language %r is unknown.t   spacet   wordt   tagt   untagt   {t   newlineN(   s   wordRd   (   R   t   languaget   western_text_regexpt   eastasian_text_regexpR   t   finditert   group(   R   t   stylet   regexpt   m(    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   text_tokenizer$  s"    

 	c         C   s   t  |  t  o |  g }  n g  } x |  D] } t  | t  o& t i i | |  } | i |  q* t  | t i i i  o | i d | f g  q* t	 d t
 |    q* W| S(   s   
    This tokenizes the input into a list of lists of tokens, where
    each token is a pair giving the type of token and the text of the
    token.
    RV   s$   Couldn't figure out how to tokenize (   R3   t
   basestringR:   t   configRn   t   appendR;   t   coret   DisplayableR   t   repr(   t   lRk   t   pausesR/   R   t   sl(    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   input_tokenizerP  s     c   
      C   s:  d } d } d } t i i } x |  D] \ } } } | | j	 oN | o7 | o t | t  \ } }	 n | | i |  7} n | } | } q% | oT | d j oG | | 7} | o t | t  \ } }	 n | | i |  7} d } q% | | 7} q% W| o7 | o t | t  \ } }	 n | | i |  7} n | S(   s:   
    Returns the width of the given list of triples. 
    i    R   R`   N(   R   R:   Rp   t   rtlR    R   R0   (
   t   triplest   justifyR/   t   curtst   curRy   t   typeRY   R	   t   dir(    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   layout_widthk  s2     


c         C   s  g  } g  } g  } | | i  } | i } t } x |  D] }	 |	 \ }
 } } |
 d j o: | i |  | i t  g  } | | i } t } q5 n |
 d j o+ | o | o q5 n | i |	  q5 q5 t } t | |	 g |  | j o4 | i |  | i t  |	 g } | | i } q5 | i |	  q5 W| i |  | i t  x< | d  D]0 } | o# | d d d j o | i   qVqVW| | f S(   s   
    Breaks the text up into rows. 

    @param triples: The text to be laid out. This is a list of
    (type, text/widgetstyle, data) triples.

    @param width: The width we want to layout to.

    @param style: The style of the text widget.
    Re   R`   ii    (   t   first_indentR{   t   TrueRq   t   rest_indentR   R   t   pop(   Rz   RX   Rk   t   linest   linet
   lines_lastt   targetR{   t   after_newlinet   tripleR~   RY   R	   Ru   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   greedy_text_layout  sF    	 	 c         C   s)  g  } g  } | } | | }	 |	 | }
 x|  D]} | \ } } } | d j o" | p q- n | i  |  q- q- t | | g |  } | | j p | d j o | d 8} | d j oK | o# | d d d j o | i   n |	 t | |  8}	 |	 | }
 n | }
 | i  |  | } | d j o
 g  } q| g } q- | i  |  | |
 j oR | d 8} | d j o |	 | 8}	 |	 | }
 n | }
 | i  |  g  } | } q- q- W| i  |  xe | D]] } | o# | d d d j o | i   n | o& | d d d j o | i d  qqW| S(   NR`   Re   i   i    i(   Rq   R   R   (   Rz   RX   Rk   t   softt   nR{   R   R   R   t   totalt   linesoftR   R~   RY   R	   t   lwRu   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   subtitle_text_layout_core  sZ    

 



 c      
   C   sA  | i  } | i } t | t  o t | |  } n g  g } xD |  D]< } | d d j o | i g   qF n | d i |  qF Wg  } g  } x| D]}  d }	 g  }
 x |	 t |   j  o t |  |	 g |  } | | j p |  |	 d d j o |
 i |  |	  n8 x4 |  |	 d D]$ } |
 i d |  |	 d | f  qW|	 d 7}	 q W|
 }  t |  |  } d } x) | | t | |  j o | d 7} qrWxM t	 oE t
 |  | | | | | |  } t |  | j o Pn | d 7} qW| i |  x+ t t |  d  D] } | i t  qW| i t	  q W| | f S(   Ni    Re   iRa   i   i   (   R{   t   subtitle_widthR3   t   floatR   Rq   R   R   t   minR   R   t   extendt   rangeR   (   Rz   RX   Rk   R{   t	   softwidtht   parst   tupR   R   t   xt
   newtriplest   triplewidtht   chart	   sumwidthsR	   R/   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   subtitle_text_layout)  sR    			  " "
 c         C   s8   | i  d j o t |  | |  Sn t |  | |  Sd  S(   Nt   subtitle(   t   layoutR   R   (   Rz   RX   Rk   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   text_layout`  s    t   Textc           B   s   e  Z d  Z d d d d d d d d d	 d
 d d d g Z d Z d   Z d   Z e e d e e d d  Z	 d   Z
 d   Z e e d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z e d  Z d    Z RS(!   sG   
    A displayable that can format and display text on the screen.
    t   laidoutt   laidout_lineheightst   laidout_linewidthst   laidout_widtht   laidout_heightt   laidout_startt   laidout_lengtht   laidout_hyperlinkst   laidout_lines_lastRX   t   tokenst   childrent	   child_posi   c         C   s8   | d j o d  |  _ n | d j o d  |  _ n d  S(   Ni    i   (   R   t	   activatedt   slow_done_time(   R(   t   version(    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   after_upgradet  s    c         C   s   |  i    d  S(   N(   R   (   R(   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   after_setstatez  s    i    t   defaultc   	      K   s   t  t |   i d | |  | |  _ | |  _ t |  _ d |  _ | |  _	 | p | d j o t
 |  _ n
 t |  _ | |  _ | |  _ | |  _ d |  _ d |  _ g  |  _ d |  _ g  |  _ d |  _ |  i d t  d S(   sa  
        @param text: The text that will be displayed on the screen.

        @param slow: If True, the text will be slowly typed onto the screen.

        @param style: A style that will be applied to the text.

        @param properties: Additional properties that are applied to the text.

        @param pause: If not None, then we display up to the pauseth pause (0-numbered.)

        @param slow_done: A callback that occurs when slow text is done.

        @param slow_offset: The offset into the text to start the slow text.

        @param tokenized: True if the text is already tokenized.

        Rk   it   redrawN(   t   superR   R*   R.   t   pauseR   t   keep_pausingR   t   pause_lengtht	   tokenizedR   t   slowt
   slow_paramt	   slow_donet
   slow_startR   R   R   R   t   pause_lengthsRX   R   (	   R(   R.   R   R   R   R   R   Rk   t
   properties(    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR*   }  s&    															c         C   s   | |  _  |  i   d S(   sF   
        Changes the text display by this object to new_text.
        N(   R.   R   (   R(   t   new_text(    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   set_text  s    	c         C   s   | |  _  |  i   d S(   s?   
        Changes the style assocated with this object.
        N(   Rk   R   (   R(   Rk   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt	   set_style  s    	c      	   C   sH  d |  _ g  |  _ |  i o |  i } n d } t i i p d Sn | o3 |  i p t | |  i  |  _	 q~ |  i |  _	 n g  } d } t
 |  _ t
 |  _ t
 |  _ d |  _ g  |  _ x|  i	 d D]} | \ } } | d j ov| d j o@ | i d  | i d  |  i d	 7_ |  i i d  q qZ| i d
  oX | i d d | d f  | i d  |  i d	 7_ |  i i t | d   q qZ| d j o t |  _ qZ| d j o) t
 |  _ | d	 7} d |  _ g  |  _ qZ| d j o# |  i d	 7_ |  i i d  qZ| i d  o- |  i d	 7_ |  i i t | d   qZn | i |  q W| |  i	 d <|  i d j	 oY|  i } g  } x6|  i	 d D]'} | i |  | \ } } | d j o | d j o | d	 8} n | d j o | i   n | o qn | d j o t |  _ Pq| d j o8 | d j o |  i t O_ d |  _ Pq| d	 8} q| d  d j oB | d j o' |  i t O_ t | d  |  _ Pq| d	 8} qqqW| |  i	 d <n |  i p t
 |  _ t
 |  _ n g  |  _ g  }	 x|  i	 D] }
 g  } t |
  } x | D] \ } } | d j o | i d  oo t i d |  } | p t d |   n t i i | i  d	   } | i d | f  |  i i |  q9| d j o |  i i |  n | i | | f  q9W|	 i |  qW|	 |  _	 | o t i! i" i# |  d  n d S(   se   
        This is called after this widget has been updated by
        set_text or set_style.
        u    Ni    Rb   R   R   Re   s   
i   s   p=s   w=i   R   R   s   image=s
   image=(.*)s!   Image tag %s could not be parsed.RV   (   s   tagR   (   s   newlines   
(   s   newlines   
($   R   R   R   R.   R:   Rk   t   styles_builtR   Rx   R   R   t   no_waitt   no_wait_oncet   no_wait_doneRv   R   Rq   t
   startswithR   R   R   R   R   R   R   R   t   itert   ret   matchR   t   easyt   displayableRj   R;   R5   R   (   R(   R   t
   retokenizeR.   t
   new_tokenst   fastsR	   R~   R   t	   newtokenst   tlt   ntlt   tlitert   kindRm   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR     s    		

					 	
	"	 		
		
  	c   	      C   s  |  i  d j	 oT |  i d j	 oD | |  i  |  i j o t Sqd t i i i |  i  |  i |  n |  i oE |  i	 i
 o8 t i i i | d  o t |  _ t i i i    n |  i o t Sn xO |  i D]D \ } } } | i | | | | | |  } | d j	 o | Sq q W|  i   o t i i i | d  o t i i oz t |  _ d |  _ t i i i |  d  t i i |  i t i i i  } t |  _ d |  _ t i i i |  d  | Sn d S(   sD   
        Space, Enter, or Click ends slow, if it's enabled.
        t   dismisst   button_selecti    N(   R   R   R   R   R:   RA   t	   interfacet   timeoutR   Rk   t   slow_abortableR;   t   behaviort	   map_eventR   Rr   t   IgnoreEventR   R   t   eventt
   is_focusedRp   t   hyperlink_callbackR   R   R5   R   R   t   focust   argument(	   R(   t   evR   t   yR   t   childt   xot   yoR/   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR   c  s2     %0	

  		"		c         C   s%   |  i  d  j o |  i   n |  i S(   N(   R   R   R   R   (   R(   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   visit  s    c         C   s  |  i  o |  i | j o d Sn |  i d j o |  i   n | |  _ g  } t   g } |  i i | d _ |  i i | d _ |  i i	 | d _	 |  i i
 | d _
 |  i i | d _ |  i i | d _ d | d _ d | d _ d | d _ | d i   g  |  _ g  } x |  i D] } | i |  qWt |  } x| D]\ } }	 | d j o! | i d | d d f  qEni| d j o|	 i d  o, | i   | p t d |	   qEqEn |	 d j o qEn|	 d	 j o qEn|	 i d
  o qEn|	 d j o! | i d | d d f  qEn|	 i d  ot i d |	  }
 |
 p t d |	   n |
 i d  } t i i |  } | i } t |  i  } t i i  i! | j o, |  i" o | i# d  q| i# d  n | i# d  | i t    | i | d _ | i | d _ | i	 | d _	 | i
 | d _
 | i | d _ | i | d _ | i | d _ | i | d _ | | d _ | d i   |  i i |  | i# |  qEn | i t | d   |	 d j o t$ | d _	 | d i   nJ|	 d j o t$ | d _
 | d i   n|	 d j o t$ | d _ | d i   n|	 d j o t$ | d _ | d i   n|	 d j o9 t% | d _	 t% | d _
 t% | d _ | d i   n|	 d d j o t& t i' i |	 d  } | i | d _ | i | d _ | i	 | d _	 | i
 | d _
 | i | d _ | i | d _ | i | d _ | i | d _ | d i   n|	 i d  oU t i d |	  }
 |
 p t d |	   n |
 i d  | d _ | d i   n_|	 i d  o t i d |	  }
 |
 p t d  |	   n |
 i d  d! j o& | d i t( |
 i d"   7_ nY |
 i d  d# j o& | d i t( |
 i d"   8_ n t( |
 i d"   | d _ | d i   n| |	 i d$  o[ t i d% |	  }
 |
 p t d& |	   n t |
 i d   | d _ | d i   n t d' |	   | d j o qEqn{ | d( j o! | i d( | d |	 f  qEnM | d) j o | i d) | d |	 f  n" | d* j o n t d+ |   | d* j o3 t) | d |	 | |  } | i d) | |	 f  qEqEWt |  d j o t d,  n t i i* | | |  i  \ } } g  |  _  g  |  _+ g  |  _, d |  _- d |  _. |  i i/ |  _0 d |  _1 | |  _2 x3 | D]+ } | p | i d) | d d- f  qqW|  i i3 } x| D]} g  } d } d } x| D]\ } } }	 | d j o |  i- |  _. q#	n y |  i- t |	  7_- Wn |  i- | i4 |	  7_- n X| | j	 o4 | d j	 o | i | | f  n | } |	 } n | |	 7} | oK | d( j o> | o | i | | f  d } n | i t5   d f  q#	q#	W| o | i | | f  n t i i6 o g  } t7 } xP | D]H \ } }	 t8 | t  o t9 |	 |  \ }	 } n | i | |	 f  ql
W| t: j p | t; j o | i<   n | } n d } d } xl | D]d \ } }	 t |  d j o |	 d j o
 d- }	 n | i= |	  \ } } | | 7} t> | |  } q
W|  i  i |  |  i, i |  |  i+ i |  t> | |  i0  |  _0 |  i1 | |  i i? 7_1 |  i- d 7_- q	Wd S(.   s   
        This lays out the text of this widget. It sets self.laidout,
        self.laidout_lineheights, self.laidout_width, and
        self.laidout_height.
        NiRe   R   Rb   t   /s*   Closing tag %s does not match an open tag.R   R   s   w=R   t   starts   a=s   a=(.*)s%   Hyperlink tag %s could not be parsed.i   t	   activate_t   hover_t   idle_R   R	   R
   R   R   i    t   =R   s	   font=(.*)s    Font tag %s could not be parsed.R   s   size=(\+|-|)(\d+)s    Size tag %s could not be parsed.t   +i   t   -R   s   color=(\#?[a-fA-F0-9]+)s!   Color tag %s could not be parsed.s=   Text tag %s was not recognized. Case and spacing matter here.R`   Ra   RV   s   Unknown text token kind %s.s+   A tag was left open at the end of the text.RS   (@   R   RX   R   R   R   R   Rk   R   R   R   R    R!   R"   R   R#   R$   R   R   R   Rq   R   R   R   R   R   Rj   R:   Rp   t   hyperlink_stylert   prefixR   R;   R   R   R   t
   set_prefixR   R   t   getattrt   storeR   RR   R   R   R   R   R   t	   min_widthR   R   R   R{   RN   R\   Ry   R   R3   R    R   R   t   reverseR2   R7   t   line_spacing(   R(   RX   RE   Rz   t   tslR   Ru   t   tiR   R	   Rm   R   t   hlst
   old_prefixt   linkRk   t   wstylet   linetriplesR   R{   R   t   oldtsR}   RY   t   rtl_linet   line_directionRT   R   t   h(    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR     s   			
  
	
&&!							 "  


 
  

c         C   s   d } x |  i  D] } x | D] \ } } | d j o | t |  7} q | d j o | t |  7} q | d j o | t |  7} q | d j o | d 7} q | d j o | d j o
 d } q q Wq W| S(	   s   
        Returns a simple length of the text in the first segment of
        the tokens. Doesn't use the same algorithm as get_laidout_length,
        so isn't suitable for slow_start.
        i    Re   Ra   R`   RV   i   Rb   R   (   R   R   (   R(   R/   R   R~   R.   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   get_simple_length  s     
  c         C   s   |  i  p t i Sn |  i S(   s  
        The (reasonably arbitrary) length this text field was laidout
        to. This can only be called after the text field was drawn
        (that is, after it has been on the screen for an interaction
        with the user. Otherwise, it returns sys.maxint.
        (   R   t   syst   maxintR   (   R(   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   get_laidout_length  s    
c   $      C   s  d } |  i  i } |  i  i } |  i  i } |  i  i } |  i  i } |  i  i } xt |  i |  i	 |  i
 |  i  D]\ } } } } | o# | o |  i | | } | } n d } | | |  i | } | } d } d } xG | D]? \ } } t | i   |  } t | t  o | d 7} q q Wx| D]\ } } t | t  o/ | | } | | 7} | | 8} | d 8} q*n | | i |  8} t } | d j  o2 t } t | t t f  o | |  } qt Sn | i | | | | | | |	 | | 	 \ }  \ }! }" | o | i |  \ }! }" n | | | i   }# |  o" | i |  | | |# | f  n | o; | i d j	 o+ | i |  | i | | | | |! |"  n t | t t f  p" |
 i | | | |# | f  n | |! } | d j o t Sq*q*W| d 8} | | | } qp Wt S(   s  
        Renders the text to r at the offsets. Color is the base color,
        and user_colors controls if the user can override those colors.

        Returns True if all characters were rendered, or False if a
        length restriction stopped some from being rendered.
        i    i   N(   Rk   R   R   RC   R   t
   text_alignR{   t   zipR   R   R   R   R   R7   R,   R3   R\   RN   R   R   t   strt   unicodeR5   R2   t   blitR$   R   t	   add_focusRq   ($   R(   R   R   R   R   R#   t   user_colorsRN   RE   RF   R   R  RG   R   t   indentR   RC   R   R	  R{   R   t   line_heightt
   line_widtht   lastt   empty_spaceR   t
   max_ascentt   spacersRY   R.   R`   RH   RM   RJ   RK   t   actual_y(    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   render_pass  sj    	" 
  



3"+"

c         C   s   |  i  p d Sn t |  _  |  i o |  i   d |  _ n | |  _ |  i o t i i i	 |  i  n |  i
 o  t |  _ t i i i	 d  n d S(   sN   
        Called to call slow_done, and also to update slow_done_time.
        Ni    (   R   R   R   R   R   R   R:   RA   R   R   R   R   R   (   R(   R   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   call_slow_donef  s    
	

	

	c         C   s  |  i  oy |  i i } |  i o$ | d  j o t i i i } qD n | t	 j o t i i i } n | o | |  i i
 9} q n t i i o
 d  } n |  i i } |  i i } | d  j o
 g  } n t | t  p | g } n d } d }	 d }
 d } xP | D]H \ } } t | |  } t |	 |  }	 t |
 |  }
 t | |  } qWxf | D]^ \ } } } } t | | |  } t |	 | |  }	 t |
 | |  }
 t | | |  } qXW|  i | | |
 |  |  i  o4 | o- t |  i |  i  } | t | |  } n t i } |  i |  t i i i |  i | |
 |  i |	 |  } xV | D]N \ } } |  i | | | | |	 |  i i |  i i t  | | | g  t  d  q[WxX | D]P \ } } } } |  i | | | | | |	 | | | t  | | | g  t  |  qWg  |  _! |  i | | |	 |  i i" |  i i# t	 | | | |  i! t	 d  o |  i  o |  i |  qrn |  i  o t i i i$ |  d  n | S(   Ni    (%   R   Rk   t   slow_cpsR   R   R:   RA   t   preferencest   text_cpsR   t   slow_cps_multipliert   less_updatest   drop_shadowt   outlinesR3   t   listR   R7   R   R   R   R   R  R  R  R;   R5   t   RenderR   R   R  t   drop_shadow_colorR   R   R   R#   R   (   R(   RX   RT   R   RF   t   speedt   dslistR   t   mindsxt   mindsyt   maxdsxt   maxdsyt   dsxt   dsyRG   R   R   RN   R/   t   dsxot   dsyo(    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR5   |  sj    



  	. F B	B

c         C   sT   d  |  _ t i i i |  d  t i i o$ t i i |  i t i i	 i
  Sn d  S(   Ni    (   R   R   R:   R;   R5   R   Rp   t   hyperlink_focusR   R   R   (   R(   R   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR     s    	c         C   sD   d  |  _ t i i i |  d  t i i o t i i d   n d  S(   Ni    (   R   R   R:   R;   R5   R   Rp   R.  (   R(   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   unfocus  s    	(   RO   RP   RQ   t   nosavet   __version__R   R   R   R   R*   R   R   R   R   R   R   R   R  R  R  R  R5   R   R/  (    (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR   h  s2   						5			(		 X			U		Jt   ParameterizedTextc           B   s,   e  Z d  Z d d  Z d   Z d   Z RS(   s   
    This can be used as an image. When used, this image is expected to
    have a single parameter, a string which is rendered as the image.
    R   c         K   s   | |  _  | |  _ d  S(   N(   Rk   R   (   R(   Rk   R   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR*     s    	c         C   se   t  |  d j o t d d i |    n | d } t i i |  } t | d |  i |  i S(   Ni   s%   '%s' takes a single string parameter.RS   i    Rk   (	   R   R   t   joinR:   t   pythont   py_evalR   Rk   R   (   R(   t   namet
   parameterst   paramt   string(    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   parameterize  s    
c         C   s   d  S(   N(    (   R(   t   callback(    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   predict  s    (   RO   RP   RQ   R*   R:  R<  (    (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyR2    s   	c      	   C   sR  t  i i |  d   } g  } x | D] \ } } | d j o q" n | i d  d j o | | i d   } n | o` | d d j oO | p d | Sn | d | d j o d | | d f Sn | i   q" n | t j o d	 | Sn t | o | i |  q" q" W| o8 d
 d i g  } | D] } | d | d q*~  Sn d  S(   NRb   R   ii    R   s4   Close text tag '%s' does not match an open text tag.i   s6   Close text tag '%s' does not match open text tag '%s'.s   Text tag '%s' is not known.s?   One or more text tags were left open at the end of the string: s   , t   '(	   R:   Rp   Rn   R   t   findR   t	   text_tagsRq   R3  (   R   R   t	   tag_stackR~   R.   t   _[1]R	   (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pyt   check_text_tags  s,     
8()   R   R:   R  t
   _renpybidiR    R   R   R   R;   R   R+   R4   t   dictR   R   R?  R   t   objectR   RR   R\   t   compileRg   t   ea_not_beforet   ea_not_aftert
   ea_westernt   globalsRh   Rn   R   Rx   R   R   R   R   R   Rr   Rs   R   R2  RB  (    (    (    s:   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\text.pys   <module>   sb   "	
	(c*			,-	F	K	7	   q