
_y]c           @  sA  d  Z  d d l m Z d d l m Z d d l Z d d l Z d d l Z d d l m	 Z	 d d l
 m Z m Z d d l m Z d d l m Z d d	 l m Z d d
 l m Z m Z m Z m Z m Z m Z d d l m Z d d l m Z d d l m Z d d l  m! Z! d e! f d     YZ" d e e f d     YZ# d S(   s"   Frontend widget for the Qt Consolei(   t   print_function(   t
   namedtupleN(   t   qt(   t   QtCoret   QtGui(   t	   py3compat(   t   import_item(   t   BaseFrontendMixin(   t   Anyt   Boolt   Instancet   Unicodet   DottedObjectNamet   defaulti   (   t   BracketMatcher(   t   CallTipWidget(   t   HistoryConsoleWidget(   t   PygmentsHighlightert   FrontendHighlighterc           B  sG   e  Z d  Z d d  Z d   Z d   Z d   Z d   Z d   Z	 RS(   sA    A PygmentsHighlighter that understands and ignores prompts.
    c         C  s   t  t |   j | j j   d | d |  _ | |  _ t |  _ t	 j
 d t	 j | j   |  _ t	 j
 d t	 j | j   |  _ d  S(   Nt   lexeri    s!   ^(%s)?([ \t]*>>> |^[ \t]*\.\.\. )s0   ^(%s)?([ \t]*In \[\d+\]: |[ \t]*\ \ \ \.\.\.+: )(   t   superR   t   __init__t   _controlt   documentt   _current_offsett	   _frontendt   Falset   highlighting_ont   ret   compilet   escapet   other_output_prefixt   _classic_prompt_ret   _ipy_prompt_re(   t   selft   frontendR   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR      s    %			c         C  sN   | s | j    r | S|  j j |  } | rF | t | j d   S| Sd S(   s,   Handle inputs that start with '>>> ' syntax.i    N(   t   isspaceR    t   matcht   lent   group(   R"   t   linet   m(    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   transform_classic_prompt*   s    c         C  sN   | s | j    r | S|  j j |  } | rF | t | j d   S| Sd S(   s7   Handle inputs that start classic IPython prompt syntax.i    N(   R$   R!   R%   R&   R'   (   R"   R(   R)   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   transform_ipy_prompt5   s    c         C  s   t  |  d  s |  j r d S|  j   } |  j j |  } |  j |  } t |  t |  } | d k r | |  _ t t	 |   j
 |  n  d S(   sL    Highlight a block of text. Reimplemented to highlight selectively.
        R   Ni    (   t   hasattrR   t   currentBlockR   t   _get_block_plain_textR+   R&   R   R   R   t   highlightBlock(   R"   t   stringt   current_blockt   without_promptt   diff(    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR/   @   s    	c         C  s5   |  j  } t |  _  t t |   j |  | |  _  d S(   sG    Reimplemented to temporarily enable highlighting if disabled.
        N(   R   t   TrueR   R   t   rehighlightBlock(   R"   t   blockt   old(    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR5   T   s    		c         C  s-   | |  j  7} t t |   j | | |  d S(   s1    Reimplemented to highlight selectively.
        N(   R   R   R   t	   setFormat(   R"   t   startt   countt   format(    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR8   \   s    N(
   t   __name__t
   __module__t   __doc__t   NoneR   R*   R+   R/   R5   R8   (    (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR      s   				t   FrontendWidgetc           B  s  e  Z d  Z e d e  Z e   Z e e  Z	 e e  Z
 e j   Z e e  Z e j e  Z e j   Z e e d e d d Z e e d e d d Z e e d e d d Z e d e d d  Z d   Z d   Z e   Z d	   Z e j e  Z e j e  Z e j e  Z e  d
 d d g  Z! e  d d d d g  Z" e  d d d g  Z# e Z$ e% e& d e Z' e$ d  Z( d   Z) d   Z* d   Z+ d   Z, d   Z- d   Z. d   Z/ d   Z0 d   Z1 d   Z2 d   Z3 d   Z4 d   Z5 d    Z6 d!   Z7 e d"  Z8 d#   Z9 e d$  Z: d%   Z; d&   Z< d'   Z= d(   Z> d)   Z? d*   Z@ d+   ZA d,   ZB e d-  ZC e d.  ZD d/   ZE d0   ZF d1   ZG d2   ZH d3   ZI d4   ZJ d5   ZK d6   ZL d7   ZM d8   ZN d9   ZO d:   ZP d;   ZQ eR d<  d=    ZS RS(>   s0    A Qt frontend for a generic Python kernel.
    t   configt   helps9   Whether to draw information calltips on open-parentheses.s9   Whether to clear the console when the kernel is restarteds;   Whether to ask for user confirmation when restarting kernels    The pygments lexer class to use.c         C  s   t  |  } |   |  _ d  S(   N(   R   R   (   R"   t   nameR7   t   newt   lexer_class(    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _lexer_class_changed   s    c         C  s   t  j r d Sd Sd  S(   Ns   pygments.lexers.Python3Lexers   pygments.lexers.PythonLexer(   R   t   PY3(   R"   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _lexer_class_default   s    	c         C  s   t  |  j  } |   S(   N(   R   RE   (   R"   RE   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _lexer_default   s    t   _CallTipRequestt   idt   post   _CompletionRequestt   codet   _ExecutionRequestt   kindt
   allow_nonec         O  s  t  t |   j | |   t j t j k rk d d  l } | j d k  rk |  j j	 d | j
  t |  _ qk n  t |  j  |  _ t |  j  |  _ t j d d   |  _ t |  _ t |  d |  j |  _ d  |  _ d  |  _ i  |  _ i  |  j d <i  |  _ t |  _ d	 |  _  |  j! d
  |  j j" |  j#  |  j$ j% |  j j"  |  j } t& j' j( t& j' j) Bt& j' j* B} | j+ t  | j, t j- |   | j. t& j' j/  | j0 j% |  j1  |  j2 j% | j+  |  j3 |  |  j j4   } | j5 j% |  j6  | |  _7 t |  _8 d  S(   Nii   i    i   s+   PySide %s < 1.0.7 found; disabling calltipss   Copy (Raw Text)R   t   executei   s   ... (   i   i    i   (9   R   R@   R   R   t   QT_APIt   QT_API_PYSIDEt   PySidet   __version_info__t   logt   warningt   __version__R   t   enable_calltipsR   R   t   _bracket_matcherR   t   _call_tip_widgetR   t   QActionR?   t   _copy_raw_actiont   _hiddenR   R   t   _highlightert   _kernel_managert   _kernel_clientt   _request_infot   _callback_dictR4   t   _display_bannert	   tab_widtht   _set_continuation_promptt   setFontt   fontt   font_changedt   connectR   t   Qtt   CTRLt   SHIFTt   Key_Ct
   setEnabledt   setShortcutt   QKeySequencet   setShortcutContextt   WidgetWithChildrenShortcutt	   triggeredt   copy_rawt   copy_availablet	   addActionR   t   contentsChanget   _document_contents_changet   _local_kernelt   _pending_clearoutput(   R"   t   local_kernelt   argst   kwRU   t   actiont   keyR   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR      sD    
								 	c         C  s  |  j  d k	 r. |  j  j   r. |  j  j   n |  j j   r |  j j   j   j   } | r| j   } t	 |  j
 j |  } t	 |  j
 j |  } d j |  } y | d d k } Wn t k
 r t } n X| r | d  } n  t j j   j |  qn |  j j d  d S(   sN    Copy the currently selected text to the clipboard, removing prompts.
        s   
is%   frontend widget : unknown copy targetN(   t   _page_controlR?   t   hasFocust   copyR   t
   textCursort	   selectiont   toPlainTextt
   splitlinest   mapR`   R*   R+   t   joint
   IndexErrorR   R   t   QApplicationt	   clipboardt   setTextRW   t   debug(   R"   t   textt   linest   was_newline(    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR      s"    
c         C  sX   |  j  j | |  } |  j | d  |  j d | <| |  _ | sT |  j j |  n  d S(   s    Execute 'source'. If 'hidden', do not show any output.

        See parent class :meth:`execute` docstring for full details.
        t   userRR   N(   t   kernel_clientRR   RO   Rc   R_   t	   executingt   emit(   R"   t   sourcet   hiddent   msg_id(    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _execute   s
    	c         C  s   |  j  s t |  j _ n  d S(   s=    Called immediately after a new prompt is displayed.
        N(   t   _readingR4   R`   R   (   R"   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _prompt_started_hook
  s    	c         C  s   |  j  s t |  j _ n  d S(   s    Called immediately after a prompt is finished, i.e. when some input
            will be processed and a new prompt displayed.
        N(   R   R   R`   R   (   R"   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _prompt_finished_hook  s    	c         C  sn   |  j    } | d k r t St | |  j    j    } | oS |  j   j   d k } | ri |  j   n  | S(   sk    Called when the tab key is pressed. Returns whether to continue
            processing the event.
        t    N(	   t   _get_input_buffer_cursor_lineR?   R   t   boolt   _get_input_buffer_cursor_columnt   stript   _get_cursort   selectedTextt	   _complete(   R"   R   t   non_ws_beforet   complete(    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _tab_pressed  s    c         C  sq   t  t |   j |  } xR | j   D]D } | j   j t j j  t j j	 k r% | j
 | |  j  Pq% q% W| S(   s6    Reimplemented to add an action for raw copy.
        (   R   R@   t   _context_menu_maket   actionst   shortcutt   matchesR   Rr   t   Pastet
   ExactMatcht   insertActionR^   (   R"   RL   t   menut   before_action(    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR   ,  s    c         C  s   |  j  r |  j   n  d  S(   N(   t
   _executingt   interrupt_kernel(   R"   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   request_interrupt_kernel7  s    	c         C  s   d } |  j  | d t d  S(   Ns,   Are you sure you want to restart the kernel?t   now(   t   restart_kernelR   (   R"   t   message(    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   request_restart_kernel;  s    c         C  sG  | j    } |  j | j   d t rs | t j j k rP |  j rP |  j   t	 S| t j j
 k r1|  j   t	 Sn | j   t j j @s1| t j j k r1|  j   } |  j j   } | d k r.| j   r.|  j   |  } | j d  r+| j   r+| j t j j t j j d  | j   t	 Sq.q1n  t t |   j |  S(   sG    Reimplemented for execution interruption and smart backspace.
        t   include_commandi   s       i   (   R   t   _control_key_downt	   modifiersR   R   Rl   Ro   R   R   R4   t
   Key_PeriodR   t   AltModifiert   Key_BackspaceR   R   R   t   hasSelectionR   t   endswithR   t   movePositionR   t   QTextCursort   Leftt
   KeepAnchort   removeSelectedTextR   R@   t   _event_filter_console_keypress(   R"   t   eventR   t   colt   cursorR   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR   ?  s(    


c         C  sH   |  j  |  rD | d j d t  } | r7 t |  _ qD |  j   n  d S(   s   Handle clear output messages.t   contentt   waitN(   t   include_outputt   getR4   R|   t   clear_output(   R"   t   msgR   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _handle_clear_outputb  s
    c         C  se   t  t j    } |  j j d d t d i | | 6} | |  j | <|  j | d  |  j d | <d S(   sL  Silently execute `expr` in the kernel and call `callback` with reply

        the `expr` is evaluated silently in the kernel (without) output in
        the frontend. Call `callback` with the
        `repr <http://docs.python.org/library/functions.html#repr> `_ as first argument

        Parameters
        ----------
        expr : string
            valid string to be executed by the kernel.
        callback : function
            function accepting one argument, as a string. The string will be
            the `repr` of the result of evaluating `expr`

        The `callback` is called with the `repr()` of the result of `expr` as
        first argument. To get the object, do `eval()` on the passed value.

        See Also
        --------
        _handle_exec_callback : private method, deal with calling callback with reply

        R   t   silentt   user_expressionst   silent_exec_callbackRR   N(	   t   strt   uuidt   uuid1R   RR   R4   Rd   RO   Rc   (   R"   t   exprt   callbackt
   local_uuidR   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _silent_exec_callbackk  s
    c         C  s^   | d j  d  } | s d Sx: | D]2 } | |  j k r$ |  j j |  | |  q$ q$ Wd S(   s  Execute `callback` corresponding to `msg` reply, after ``_silent_exec_callback``

        Parameters
        ----------
        msg : raw message send by the kernel containing an `user_expressions`
                and having a 'silent_exec_callback' kind.

        Notes
        -----
        This function will look for a `callback` associated with the
        corresponding message id. Association has been made by
        `_silent_exec_callback`. `callback` is then called with the `repr()`
        of the value of corresponding `user_expressions` as argument.
        `callback` is then removed from the known list so that any message
        coming again with the same id won't trigger it.
        R   R   N(   R   Rd   t   pop(   R"   R   t   user_expt
   expression(    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _handle_exec_callback  s    c         C  s  |  j  j d | j d d   | d d } |  j d j |  } t |  _ | r| j d k r|  j r|  j j	 j
   |  j r |  j j   n  | d } | d } | d	 k r |  j |  n | d
 k r |  j |  n  |  j |  |  j j |  |  j d j |  ni | rW| j d k rW|  j rW|  j |  |  j d j |  n& | r}|  j r}t d | j   n  d S(   s-    Handles replies for code execution.
        s   execute_reply: %sR   R   t   parent_headerR   RR   R   t   statust   okt   abortedR   s   Unknown handler for %sN(   RW   R   R   Rc   R   R   RP   R_   R   t   iopub_channelt   flusht
   ansi_codest   _ansi_processort	   reset_sgrt   _process_execute_okt   _process_execute_abortt"   _show_interpreter_prompt_for_replyt   executedR   R   R   t   RuntimeError(   R"   R   R   t   infoR   R   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _handle_execute_reply  s,    		

c         C  s   |  j  |  d S(   s     Handle error messages.
        N(   t   _process_execute_error(   R"   R   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _handle_error  s    c           s     j  j d | j d d     j r7 t d   n    j j j     f d   }   j r{   j  j d  t	   _ n    j
 | d d d | d	 | d d	 d
 S(   s(    Handle requests for raw_input.
        s	   input: %sR   R   s.   Request for raw input during hidden execution.c           s     j      j j |   d  S(   N(   t   _finalize_input_requestR   t   input(   R(   (   R"   (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR     s    
s9   Got second input request, assuming first was interrupted.t   promptR   t   passwordN(   RW   R   R   R_   R   R   R   R   R   R   t	   _readline(   R"   R   R   (    (   R"   s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _handle_input_request  s    		c         C  s-   | r d n d } |  j  d | d t d  S(   Ns   Kernel died, restartings   Kernel restartings   <br>%s<hr><br>t   before_prompt(   t   _append_htmlR   (   R"   t   diedR   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _kernel_restarted_message  s    c         C  sM   |  j  j d |  |  j r/ |  j j |  n |  j d t  |  j   d S(   sA   Handle the kernel's death (if we do not own the kernel).
        s   kernel died: %sR   N(   RW   RX   t   custom_restartt   custom_restart_kernel_diedR   R   R4   t   reset(   R"   t   since_last_heartbeat(    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _handle_kernel_died  s
    	c         C  s.   |  j  j d  |  j d |  |  j   d S(   so   Notice that the autorestarter restarted the kernel.

        There's nothing to do but show a message.
        s   kernel restartedR   N(   RW   RX   R   R   (   R"   R   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _handle_kernel_restarted  s    c         C  s   |  j  j d | j d d   |  j   } |  j j d  } | r | j | d d k r | j | j   k r | d } | j d  d k r | j d	 t  r |  j	 j
 |  q n  d
 S(   s   Handle replies for call tips.s	   oinfo: %sR   R   t   call_tipR   R   R   R   t   foundN(   RW   R   R   R   Rc   RK   RL   t   positionR   R\   t   show_inspect_data(   R"   t   repR   R   R   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _handle_inspect_reply  s    
'c         C  sd   |  j  j d | j d d   |  j |  r` |  j   | d d } |  j | d d t n  d S(   s%    Handle display hook output.
        s   execute_result: %sR   R   t   datas   
R   N(   RW   R   R   R   t   flush_clearoutputt   _append_plain_textR4   (   R"   R   R   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _handle_execute_result  s
    
c         C  sT   |  j  j d | j d d   |  j |  rP |  j   |  j | d d  n  d S(   s+    Handle stdout, stderr, and stdin.
        s
   stream: %sR   R   R   N(   RW   R   R   R   R  t   append_stream(   R"   R   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _handle_stream  s    
c         C  s   |  j  j d | j d d   | j d i   j d t  } |  j r |  j |  r | rp |  j d t  q |  j r |  j j	 |   q |  j
   j   } t j j |  | d t j j t j j  } | t j j k r |  j j	 |   q n  d S(   s=    Handle shutdown signal, only if from other console.
        s   shutdown: %sR   R   t   restartR   s8   Kernel has been shutdown permanently. Close the Console?N(   RW   R   R   R   R_   t	   from_hereR   R{   t   exit_requestedR   t   windowt   windowTitleR   t   QMessageBoxt   questiont   Yest   No(   R"   R   R  t   titlet   reply(    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _handle_shutdown_reply  s    	c         C  sc   | d j  d d  } | d k rA |  j r_ |  j d t  q_ n | d k rP n | d k r_ n  d S(	   s   Handle status messageR   t   execution_stateR   t   startingR   t   idlet   busyN(   R   R   R   R4   (   R"   R   t   state(    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _handle_status/  s    	c         C  s   |  j  d t  d S(   s    Called when the KernelManager channels have started listening or
            when the frontend is assigned an already listening KernelManager.
        t   clearN(   R   R4   (   R"   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _started_channels=  s    c         C  s   |  j  j   d S(   s    Copy the currently selected text to the clipboard without attempting
            to remove prompts or otherwise alter the text.
        N(   R   R   (   R"   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyRv   G  s    c         C  sU   |  j  r" t |  _ |  j j   n/ |  j rD t |  _ |  j j   n |  j d  d S(   s    Attempts to interrupt the running kernel.
        
        Also unsets _reading flag, to avoid runtime errors
        if raw_input is called again.
        s+   Cannot interrupt a kernel I did not start.
N(   t   custom_interruptR   R   t   custom_interrupt_requestedR   t   kernel_managerR   R	  (   R"   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR   M  s    				c         C  s   |  j  r" t |  _  i  |  j d <n  t |  _ t |  j _ | r |  j j   |  j r |  j	 |  j
  |  j r |  j	 |  j  q q n  |  j   d S(   s   Resets the widget to its initial state if ``clear`` parameter
        is True, otherwise
        prints a visual indication of the fact that the kernel restarted, but
        does not clear the traces from previous usage of the kernel before it
        was restarted.  With ``clear=True``, it is similar to ``%clear``, but
        also re-writes the banner and aborts execution if necessary.
        RR   N(   R   R   Rc   R   R`   R   R   R  Re   R	  t   bannert   kernel_bannert   _show_interpreter_prompt(   R"   R  (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR   \  s    					c         C  s  |  j  r |  j j   d S|  j r |  j j j   |  j r t j	 j
 t j	 j B} t j	 j |  d | |  } | t j	 j
 k } n t } | r y |  j j d |  Wn* t k
 r } |  j d | d t q X|  j d d t q|  j j j   n |  j d d t d S(   s1    Attempts to restart the running kernel.
        Ns   Restart kernel?R   s   Error restarting kernel: %s
R   s!   <br>Restarting kernel...
<hr><br>s(   Cannot restart a Kernel I did not start
(   R   t   custom_restart_requestedR   R#  R   t
   hb_channelt   pauset   confirm_restartR   R  R  R  R  R4   R   R   R	  R   t   unpause(   R"   R   R   t   buttonst   resultt
   do_restartt   e(    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR   u  s0    				

c         C  s&   | j  d  } |  j | d t d S(   s"   Appends text to the output stream.i   R   N(   t
   expandtabsR	  R4   (   R"   R   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR    s    c         C  s#   |  j  r t |  _  |  j   n  d S(   s(   If a clearoutput is pending, execute it.N(   R|   R   R   (   R"   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR    s    		c         C  sJ   |  j  j   } | j   | j | j | j  | j d  | j   d S(   s"   Clears the current line of output.R   N(   R   R   t   beginEditBlockR   t   StartOfLineR   t
   insertTextt   endEditBlock(   R"   R   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR     s
    
c         C  sQ   |  j    } | j t j j  | j   j | j    d k rM |  j   n  d S(   s   Trigger call tip automatically on open parenthesis
        
        Call tips can be requested explcitly with `_call_tip`.
        t   (N(	   R   R   R   R   R   R   t   characterAtR  t	   _call_tip(   R"   R   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _auto_call_tip  s    !c         C  sz   |  j  s |  j j j   r! t S|  j   } |  j } |  j j | |  } |  j   j	   } |  j
 | |  |  j d <t S(   sA   Shows a call tip, if appropriate, at the current cursor location.R  (   RZ   R   t   shell_channelt   is_aliveR   t   _get_input_buffer_cursor_post   input_buffert   inspectR   R  RJ   Rc   R4   (   R"   t
   cursor_posRN   R   RL   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR7    s    	c         C  sV   |  j  } |  j   } |  j j d | d |  } |  j | | |  } | |  j d <d S(   s=    Performs completion at the current cursor location.
        RN   R>  R   N(   R<  R;  R   R   RM   Rc   (   R"   RN   R>  R   R   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR     s
    	c         C  s   |  j  d  d S(   s;    Process a reply for an aborted execution request.
        s   ERROR: execution aborted
N(   R	  (   R"   R   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR     s    c         C  sz   | d } | d d k rV | d d k p7 | d d k } | |  _  |  j j |   n  d j | d  } |  j |  d	 S(
   sM    Process a reply for an execution request that resulted in an error.
        R   t   enamet
   SystemExitt   evalues   -kR4   R   t	   tracebackN(   t   _keep_kernel_on_exitR  R   R   R	  (   R"   R   R   t
   keepkernelRB  (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR     s    
 	c         C  s[   | d j  d g   } x> | D]6 } |  j |  s d } t | t | d   q q Wd S(   s=    Process a reply for a successful execution request.
        R   t   payloads,   Warning: received unknown payload of type %sR   N(   R   t   _process_execute_payloadt   printt   repr(   R"   R   RE  t   itemRX   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR     s
    c         C  s   t  S(   s    Process a single payload item from the list of payload items in an
            execution reply. Returns whether the payload was handled.
        (   R   (   R"   RI  (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyRF     s    c         C  s   |  j  d  d S(   s-    Shows a prompt for the interpreter.
        s   >>> N(   t   _show_prompt(   R"   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR&    s    c         C  s   |  j    d S(   sN    Shows a prompt for the interpreter given an 'execute_reply' message.
        N(   R&  (   R"   R   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR     s    c         C  sB   | | 7} |  j  j   } | |  j   j   k r> |  j   n  d S(   sh    Called whenever the document's content changes. Display a call tip
            if appropriate.
        N(   R   R   R   R  R8  (   R"   R  t   removedt   addedR   (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyRz     s    
R$  c         C  s   d } | t  j t  j f S(   s-    Returns the standard Python banner.
        sV   Python %s on %s
Type "help", "copyright", "credits" or "license" for more information.(   t   syst   versiont   platform(   R"   R$  (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   _banner_default!  s    (T   R<   R=   R>   R   R4   R$  R%  R	   R   Re   R!  R   t   SignalR"  R   t   floatR   R'  RZ   t   clear_on_kernel_restartR*  R   RE   RF   RH   R   R   RI   t   objectR   R   R  R   RJ   RM   RO   R{   R
   R   R`   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R  R
  R  R  R  R   Rv   R   R   R   R  R  R   R8  R7  R   R   R   R   RF  R&  R   Rz   R   RP  (    (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyR@   c   s   									8									#			 		%			
								
		2						
								($   R>   t
   __future__R    t   collectionsR   RM  R   R   t	   qtconsoleR   t   qtconsole.qtR   R   t   ipython_genutilsR   t   ipython_genutils.importstringR   t   qtconsole.base_frontend_mixinR   t	   traitletsR   R	   R
   R   R   R   t   bracket_matcherR   t   call_tip_widgetR   t   history_console_widgetR   t   pygments_highlighterR   R   R@   (    (    (    s8   lib/python2.7/site-packages/qtconsole/frontend_widget.pyt   <module>   s"   .I