
    R                     :    d Z ddlmZ dZ G d de      Zd Zd Zy)	zo
Layout dimensions are used to give the minimum, maximum and preferred
dimensions for containers and controls.
    )unicode_literals)LayoutDimensionsum_layout_dimensionsmax_layout_dimensionsc                   4    e Zd ZdZddZed        Zd Zd Zy)r   a  
    Specified dimension (width/height) of a user control or window.

    The layout engine tries to honor the preferred size. If that is not
    possible, because the terminal is larger or smaller, it tries to keep in
    between min and max.

    :param min: Minimum size.
    :param max: Maximum size.
    :param weight: For a VSplit/HSplit, the actual size will be determined
                   by taking the proportion of weights from all the children.
                   E.g. When there are two children, one width a weight of 1,
                   and the other with a weight of 2. The second will always be
                   twice as big as the first, if the min/max values allow it.
    :param preferred: Preferred size.
    Nc                 b   t        |t              r|dkD  sJ |d u| _        |d u| _        |d u| _        |d}|d}||}|| _        || _        || _        || _        | j                  | j
                  k  r| j
                  | _        | j                  | j                  kD  r| j                  | _        y y )Nr   l       73Me')	
isinstanceintmin_specifiedmax_specifiedpreferred_specifiedminmax	preferredweight)selfr   r   r   r   s        2lib/third_party/prompt_toolkit/layout/dimension.py__init__zLayoutDimension.__init__   s    &#&6A:55 _ _#,D#8 ;C;CI" >>DHH$!XXDN>>DHH$!XXDN %    c                      | |||      S )z|
        Return a :class:`.LayoutDimension` with an exact size. (min, max and
        preferred set to ``amount``).
        r   r   r    )clsamounts     r   exactzLayoutDimension.exact9   s     v6V<<r   c           	      p    d| j                   d| j                  d| j                  d| j                  d	S )NzLayoutDimension(min=z, max=z, preferred=z	, weight=))r   r   r   r   )r   s    r   __repr__zLayoutDimension.__repr__A   s%    HHdhh= 	=r   c                     t        | |g      S )N)r   )r   others     r   __add__zLayoutDimension.__add__E   s    $dE]33r   )NN   N)	__name__
__module____qualname____doc__r   classmethodr   r   r!   r   r   r   r   r      s*     &4 = ==4r   r   c                 B   t        | D cg c]  }|j                  |j                   c}      }t        | D cg c]  }|j                  |j                   c}      }t        | D cg c]  }|j                   c}      }t	        |||      S c c}w c c}w c c}w )z<
    Sum a list of :class:`.LayoutDimension` instances.
    r   )sumr   r   r   r   )
dimensionsdr   r   r   s        r   r   r   I   s     j>jAEE,=quuj>
?C
j>jAEE,=quuj>
?C*5*QQ[[*56IsyAA	 ?>5   BBBB*Bc                 B   t        | D cg c]  }|j                  |j                   c}      }t        | D cg c]  }|j                   |j                    c}      }t        | D cg c]  }|j                   c}      }t        |||      S c c}w c c}w c c}w )zL
    Take the maximum of a list of :class:`.LayoutDimension` instances.
    r   )r   r   r   r   )r*   r+   min_max_r   s        r   r   r   T   s     z?z!QUU->z?@Dz?z!QUU->z?@D*5*QQ[[*56ItCC	 @?5r,   N)r&   
__future__r   __all__objectr   r   r   r   r   r   <module>r3      s/    (84f 84vBDr   