ó
ćNXc           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l m Z e a e j	 d k rg d   Z
 n$ e j d k r d   Z
 n	 d	   Z
 d
   Z d   Z d   Z e j	 d k rĺ e j j d d  Z e j d  rKe Z qKnf e j d k rKy7 d d l Z e j j j Z e j g e _ d   Z WqKe k
 rGd   Z qKXn  d   Z d   Z e j d k r~d d d  Z n d d d  Z d S(   s   
Utilities for working with terminals.

Authors:

* Brian E. Granger
* Fernando Perez
* Alexander Belchenko (e-mail: bialix AT ukr.net)
i˙˙˙˙Ni   (   t	   py3compatt   posixc           C   s   t  j d  d  S(   Nt   clear(   t   ost   system(    (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/terminal.pyt   _term_clear(   s    t   win32c           C   s   t  j d  d  S(   Nt   cls(   R   R   (    (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/terminal.pyR   +   s    c           C   s   d  S(   N(    (    (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/terminal.pyR   .   s    c         C   s   |  a  d S(   só  Control whether set_term_title is active or not.

    set_term_title() allows writing to the console titlebar.  In embedded
    widgets this can cause problems, so this call can be used to toggle it on
    or off as needed.

    The default state of the module is for the function to be disabled.

    Parameters
    ----------
      val : bool
        If True, set_term_title() actually writes to the terminal (using the
        appropriate platform-specific module).  If False, it is a no-op.
    N(   t   ignore_termtitle(   t   val(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/terminal.pyt   toggle_set_term_title3   s    c          O   s   d S(   s   Dummy no-op.N(    (   t   argst   kw(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/terminal.pyt   _set_term_titleF   s    c         C   s   t  j j d |   d S(   s3    Change virtual terminal title in xterm-workalikes s   ]0;%sN(   t   syst   stdoutt   write(   t   title(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/terminal.pyt   _set_term_title_xtermK   s    t   TERMt    t   xtermc         C   s   t  |   d S(   s9   Set terminal title using ctypes to access the Win32 APIs.N(   t   SetConsoleTitleW(   R   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/terminal.pyR   Z   s    c         C   sT   z0 t  j   } t j d  t j d |   } Wd t j |  X| rP t a n  d S(   s-   Set terminal title using the 'title' command.s   C:s   title N(   R    t   getcwdR   t   chdirR   t   TrueR   (   R   t   currt   ret(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/terminal.pyR   ^   s    c         C   s   t  r
 d St |   d S(   s@   Set terminal title using the necessary platform-dependent calls.N(   R   R   (   R   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/terminal.pyt   set_term_titlen   s    c           C   s   t  j d  t a d  S(   Ns8   This function is deprecated, use toggle_set_term_title()(   t   warningst   warnR   R   (    (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/terminal.pyt   freeze_term_titleu   s    iP   i   c         C   s×   y d d l  } Wn t k
 r* |  | f SX| j j j d  } | j d  } | j j j | |  } | rÉ t j d | j	  \ } } } }	 }
 } } } } } } | | d } | | d } | | f S|  | f Sd S(   sg  Return size of current terminal console.

        This function try to determine actual size of current working
        console window and return tuple (sizex, sizey) if success,
        or default size (defaultx, defaulty) otherwise.

        Dependencies: ctypes should be installed.

        Author: Alexander Belchenko (e-mail: bialix AT ukr.net)
        i˙˙˙˙Niő˙˙˙i   t   hhhhHhhhhhhi   (
   t   ctypest   ImportErrort   windllt   kernel32t   GetStdHandlet   create_string_buffert   GetConsoleScreenBufferInfot   structt   unpackt   raw(   t   defaultxt   defaultyR!   t   ht   csbit   rest   bufxt   bufyt   curxt   curyt   wattrt   leftt   topt   rightt   bottomt   maxxt   maxyt   sizext   sizey(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/terminal.pyt   get_terminal_size|   s    0
c         C   s
   |  | f S(   N(    (   R+   R,   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/terminal.pyR=      s    (   t   __doc__R   R(   R   R   R   R    R   R   t   nameR   t   platformR
   R   R   t   environt   getR   t
   startswithR!   R#   R$   R   t	   c_wchar_pt   argtypesR"   R   R   R=   (    (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/terminal.pyt   <module>
   s>   						