o
    º¼tf™ ã                   @   s>  d Z ddlmZ ddlZddlZddlZddlZddlmZ ddl	Z	ddl
mZ ddlZddlmZ ddlmZmZmZmZ ddlmZ dd	lmZmZmZ dd
lmZ ddl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dl(m)Z) ddl*m+Z+ dd„ Z,dd„ Z-G dd„ dedeeej.ƒfi ƒƒZ/dS )z0An abstract base class for console-type widgets.é    )ÚpartialN©Údedent)Úcategory)ÚQT6)ÚQtCoreÚQtGuiÚQtPrintSupportÚ	QtWidgets)ÚHtmlExporter)ÚMetaQObjectHasTraitsÚget_fontÚsuperQ)ÚLoggingConfigurable)ÚBoolÚEnumÚIntegerÚUnicodeé   )ÚQtAnsiCodeProcessor)ÚCompletionWidget)ÚCompletionHtml)ÚCompletionPlain)Ú
QtKillRing)Ú	columnizec                 C   s   t | ƒ}| d¡p| d¡S )zN Returns whether the specified unicode character is a letter or a number.
    ÚLÚN©r   Ú
startswith)ÚcharÚcat© r!   úa/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/qtconsole/console_widget.pyÚis_letter_or_number!   s   r#   c                 C   s   t | ƒ d¡S )z1Check whether a given char counts as white space.ÚZr   )r   r!   r!   r"   Úis_whitespace'   s   r%   c                       s¸  e Zd ZdZeddddZeddddZeddddZe	g d¢dd	d
dZ
eddddZe	ddgddddZe	g d¢ddddZeddddZedddZdd„ ZedddZeddddZeddddZedƒZdZdZe e¡Ze e¡Ze e¡Ze e¡Ze e j!¡Z"dZ#dZ$dZ%ej&j'ej&j(ej&j)ej&j*ej&j+ej&j,ej&j-ej&j.ej&j/ej&j0ej&j1ej&j2iZ3e4j5d ksÀej&j6e3ej&j7< e8e3 9¡ ƒej&j:ej&j;ej&j<ej&j=hB Z>dZ?dý‡ fd!d"„	Z@d#d$„ ZAd%d&„ ZBd'd(„ ZC‡ fd)d*„ZDd+d,„ ZEeddd-dZFed.dd/dZGd0d1„ ZHd2d3„ ZId4d5„ ZJdþd6d7„ZKd8d9„ ZLd:d;„ ZMd<d=„ ZNd>d?„ ZOdÿdAdB„ZPdCdD„ ZQd dEdF„ZRdGdH„ ZSdIdJ„ ZTdKdL„ ZUddMdN„ZVdOdP„ ZWeXeVeWƒZYdQdR„ ZZdýdSdT„Z[dUdV„ Z\eXeZe\ƒZ]dWdX„ Z^dYdZ„ Z_e j`jafd[d\„Zbdýd]d^„Zcd_d`„ Zddadb„ Zedcdd„ Zfdedf„ Zgdgdh„ Zhdidj„ Zidkdl„ Zjdmdn„ Zkdodp„ Zldqdr„ ZmeXelemƒZndsdt„ Zodudv„ Zpdwdx„ Zqdydz„ Zrd{d|„ Zsd}d~„ Ztdd€„ Zudd‚„ Zvddƒd„„Zwdd…d†„Zxdd‡dˆ„Zydd‰dŠ„Zzdd‹dŒ„Z{ddŽ„ Z|dd„ Z}d‘d’„ Z~dd“d”„Zd•d–„ Z€dd—d˜„Zd™dš„ Z‚d›dœ„ Zƒddž„ Z„dŸd „ Z…d¡d¢„ Z†d£d¤„ Z‡d¥d¦„ Zˆd§d¨„ Z‰d©dª„ ZŠd«d¬„ Z‹d­d®„ ZŒd¯d°„ Zd±d²„ ZŽd³d´„ Zdµd¶„ Zd·d¸„ Z‘d¹dº„ Z’dd»d¼„Z“d½d¾„ Z”d¿dÀ„ Z•eXdÁdÂ„ ƒZ–eXdÃdÄ„ ƒZ—dÅdÆ„ Z˜dÇdÈ„ Z™dÉdÊ„ ZšdËdÌ„ Z›dþdÍdÎ„ZœddÏdÐ„ZdýdÑdÒ„ZždÓdÔ„ ZŸdÕdÖ„ Z d×dØ„ Z¡dÙdÚ„ Z¢ddÛdÜ„Z£dÝdÞ„ Z¤dßdà„ Z¥dádâ„ Z¦dãdä„ Z§dådæ„ Z¨ddçdè„Z©dédê„ Zªdëdì„ Z«dídî„ Z¬ddïdð„Z­ddñdò„Z®dódô„ Z¯dõdö„ Z°		dd÷dø„Z±dùdú„ Z²dûdü„ Z³‡  Z´S (  ÚConsoleWidgetaÜ   An abstract base class for console-type widgets. This class has
        functionality for:

            * Maintaining a prompt and editing region
            * Providing the traditional Unix-style console keyboard shortcuts
            * Performing tab completion
            * Paging text
            * Handling ANSI escape codes

        ConsoleWidget also provides a number of utility methods that will be
        convenient to implementors of a console-style widget.
    Tz%Whether to process ANSI escape codes.)ÚconfigÚhelpiô  z
        The maximum number of lines of text before truncation. Specifying a
        non-positive number disables text truncation (not recommended).
        a  Whether to automatically execute on syntactically complete input.

        If False, Shift-Enter is required to submit each execution.
        Disabling this is mainly useful for non-Python kernels,
        where the completion check would be wrong.
        )ÚplainÚdroplistÚncursesr+   aP  
                    The type of completer to use. Valid values are:

                    'plain'   : Show the available completion as a text list
                                Below the editing area.
                    'droplist': Show the completion in a drop down list navigable
                                by the arrow keys, and from which you can select
                                completion by pressing Return.
                    'ncurses' : Show the completion as a text list which is navigable by
                                `tab` and arrow keys.
                    )r'   Údefault_valuer(   r   z”
        Set Height for completion.

        'droplist'
            Height in pixels.
        'ncurses'
            Maximum number of rows.
        r)   Úrichz±
        The type of underlying text widget to use. Valid values are 'plain',
        which specifies a QPlainTextEdit, and 'rich', which specifies a
        QTextEdit.
        )r,   r'   r(   )ÚinsideÚhsplitÚvsplitÚcustomÚnoner.   a\  
        The type of paging to use. Valid values are:

        'inside'
           The widget pages like a traditional terminal.
        'hsplit'
           When paging is requested, the widget is split horizontally. The top
           pane contains the console, and the bottom pane contains the paged text.
        'vsplit'
           Similar to 'hsplit', except that a vertical splitter is used.
        'custom'
           No action is taken by the widget beyond emitting a
           'custom_page_requested(str)' signal.
        'none'
           The text is written directly to the console.
        zVThe visibility of the scrollar. If False then the scrollbar will be
        invisible.zÖThe font family to use for the console.
        On OSX this defaults to Monaco, on Windows the default is
        Consolas with fallback of Courier, and on other platforms
        the default is Monospace.
        c                 C   s    t jdkrdS t jdkrdS dS )NÚwin32ZConsolasÚdarwinÚMonacoÚ	Monospace)ÚsysÚplatform©Úselfr!   r!   r"   Ú_font_family_default   s
   

z"ConsoleWidget._font_family_defaultz`The font size. If unconfigured, Qt will be entrusted
        with the size of the font.
        éQ   zrThe width of the console at start time in number
        of characters (will double with `hsplit` paging)
        é   zsThe height of the console at start time in number
        of characters (will double with `vsplit` paging)
        FNr4   c                    sø  t ƒ jd!i |¤Ž |r|  |¡ d| _d| _d| _tjjg| _	t
tjdƒr-| j	 tjj¡ t | ¡}| dddd¡ |  ¡ | _| jdv rmt ¡ | _| jdkrW| j tjj¡ n| j tjj¡ | j | j¡ | | j¡ n| | j¡ | jdv r“|  ¡ | _| jr| j ¡  | j | j¡ n| | j¡ | j ¡ | _tƒ | _ | j!dkrªt"| | j#ƒ| _$n| j!d	kr·t%| | j#ƒ| _$n
| j!d
krÁt&| ƒ| _$d| _'d| _(d| _)d| _*t+| jƒ| _,d| _-d| _.t/| jƒ| _0d| _1d| _2| j ¡ | _3d| _4d| _5d| _6d| _7g | _8t 9| j¡| _:| j: ;d¡ | j: <d¡ | j:j= >| j?¡ |  @¡  t Add¡}| Bd¡ tC DtCjDjE¡}| Fd¡r9tGjHdkr9d}| I|¡ | JtjjK¡ |jL >| jM¡ |  N|¡ || _Ot Add¡}| ItCjDjP¡ | JtjjK¡ |jL >| jQ¡ |  N|¡ || _Rt Add¡}| Bd¡ tC DtCjDjS¡}| Fd¡r—tGjHdkr—d}| I|¡ | JtjjK¡ |jL >| jT¡ |  N|¡ || _UtjAd| tCjDjVtjjKd| jWd| _X|  N| jX¡ tjAd| tCjDjYtjjKd| jZd| _[|  N| j[¡ tjAd| dtjjKd | j@d| _\|  N| j\¡ |  ]d¡ dS )"z¢ Create a ConsoleWidget.

        Parameters
        ----------
        parent : QWidget, optional [default None]
            The parent for this widget.
        Ngš™™™™™¹?ÚNativeGesturer   )r/   r0   r/   )r.   r/   r0   r+   r*   r)   z> FÚ é   éd   TÚPrintzCtrl+Pr4   zCtrl+Shift+PzSave as HTML/XMLz
Select AllzCtrl+AzCtrl+Shift+AzBigger Fontz#Increase the font size by one point)ZshortcutZshortcutContextZ	statusTipÚ	triggeredzSmaller Fontz#Decrease the font size by one pointzNormal FontzCtrl+0zRestore the Normal font sizer!   )^ÚsuperÚ__init__Z	setParentÚ_is_complete_msg_idÚ_is_complete_timeoutÚ_is_complete_max_timer   ÚQEventÚWheelÚ_pager_scroll_eventsÚhasattrÚappendr>   r
   ZQStackedLayoutZsetContentsMarginsÚ_create_controlÚ_controlÚpagingZ	QSplitterÚ	_splitterÚsetOrientationÚQtÚ
HorizontalÚVerticalZ	addWidgetÚ_create_page_controlÚ_page_controlÚhideÚ
textCursorÚ_append_before_prompt_cursorr   Ú_ansi_processorÚgui_completionr   Úgui_completion_heightÚ_completion_widgetr   r   Ú_continuation_promptÚ_continuation_prompt_htmlÚ
_executingÚ_filter_resizer   Ú_html_exporterÚ_input_buffer_executingÚ_input_buffer_pendingr   Ú
_kill_ringÚ_promptÚ_prompt_htmlÚ_prompt_cursorÚ_prompt_sepÚ_readingÚ_reading_callbackÚ
_tab_widthÚ_pending_insert_textZQTimerÚ_pending_text_flush_intervalÚsetIntervalZsetSingleShotÚtimeoutÚconnectÚ_on_flush_pending_stream_timerÚ
reset_fontZQActionÚ
setEnabledr   ÚQKeySequencerB   Úmatchesr7   r8   ÚsetShortcutZsetShortcutContextZWidgetWithChildrenShortcutrC   Úprint_Ú	addActionÚprint_actionZSaveÚexport_htmlÚexport_actionZ	SelectAllÚselect_all_smartÚselect_all_actionZZoomInÚ_increase_font_sizeZincrease_font_sizeZZoomOutÚ_decrease_font_sizeZdecrease_font_sizeZreset_font_sizeÚsetAcceptDrops)r:   ÚparentÚkwÚlayoutÚactionZprintkeyZ	selectall©Ú	__class__r!   r"   rE   â   sØ   












ÿ






ûûûzConsoleWidget.__init__c                 C   sP   |  ¡  ¡ r| tjj¡ | ¡  d S |  ¡  ¡ r&| tjj¡ | ¡  d S d S ©N)	ÚmimeDataÚhasUrlsÚsetDropActionr   rS   Z
LinkActionÚacceptÚhasTextÚ
CopyAction)r:   Úer!   r!   r"   ÚdragEnterEvent€  s   üzConsoleWidget.dragEnterEventc                 C   st   |  ¡  ¡ rd S |  ¡  ¡ r8| j | ¡ ¡}|  | ¡ ¡r+| t	j
j¡ | j |¡ n| t	j
j¡ | ¡  d S d S r‰   )rŠ   r‹   rŽ   rO   ÚcursorForPositionÚposÚ
_in_bufferÚpositionrŒ   r   rS   r   ÚsetTextCursorZIgnoreActionr   )r:   r   Úcursorr!   r!   r"   ÚdragMoveEventŒ  s   ùzConsoleWidget.dragMoveEventc                 C   s¦   |  ¡  ¡ r,|  ¡  | j ¡ }dd„ |  ¡  ¡ D ƒ}d dd„ |D ƒ¡}|  ||¡ d S |  ¡  ¡ rO| j 	| 
¡ ¡}|  | ¡ ¡rQ|  ¡  ¡ }|  ||¡ d S d S d S )Nc                 S   s   g | ]}|  ¡ ‘qS r!   )ZtoLocalFile)Ú.0Úurlr!   r!   r"   Ú
<listcomp>œ  s    z+ConsoleWidget.dropEvent.<locals>.<listcomp>z, c                 s   s$    | ]}d |  d d¡ d  V  qdS )ú'z'"'"'N)Úreplace)r™   Úfr!   r!   r"   Ú	<genexpr>  s   € ÿz*ConsoleWidget.dropEvent.<locals>.<genexpr>)rŠ   r‹   Ú_keep_cursor_in_bufferrO   rY   ÚurlsÚjoinÚ_insert_plain_text_into_bufferrŽ   r’   r“   r”   r•   Útext)r:   r   r—   Ú	filenamesr¤   r!   r!   r"   Ú	dropEvent˜  s   

ÿüzConsoleWidget.dropEventc           	         sÜ  |  ¡ }|tjjkrH| ¡ }|  | ¡ ¡r3|| jv r3t 	tjj| j| tj
j¡}tj ¡  ||¡ dS || jkr=|  |¡S || jkrG|  |¡S nŸt|ddƒrz|tjjkrz| ¡ tj
jkrz|| j ¡ krz| j | ¡ ¡}| j |¡ |  tjj¡ dS |tjjkr˜| j s˜d| _ tj ¡  ||¡ |  !¡  d| _ dS |tjj"kr´| j#r´|  | ¡ ¡r´| ¡ | j$v r´| %¡  n3|| j&v rÅ|| jkrÅ| j '¡  dS |tjj(krç| j )| ¡ ¡}t*rÜ| +¡  ,¡ }n| -¡ }tj. /||¡ t0ƒ  1||¡S )ze Reimplemented to ensure a console-like behavior in the underlying
            text widgets.
        TÚbuttonF)2Útyper   rI   ÚKeyPressÚkeyÚ_control_key_downÚ	modifiersÚ_ctrl_down_remapr   Ú	QKeyEventrS   Ú
NoModifierr
   ÚQApplicationÚinstanceÚ	sendEventrO   Ú_event_filter_console_keypressrW   Ú_event_filter_page_keypressÚgetattrZMouseButtonReleaser§   ZMiddleButtonÚviewportr’   r“   r–   ÚpasteÚ
QClipboardZ	SelectionZResizerb   Ú_adjust_scrollbarsZShortcutOverrideÚoverride_shortcutsÚ
_shortcutsr   rK   ZrepaintZ	MouseMoveÚanchorAtr   ZglobalPositionZtoPointZ	globalPosZQToolTipZshowTextrD   ÚeventFilter)	r:   ÚobjÚeventÚetyperª   Ú	new_eventr—   Úanchorr“   r‡   r!   r"   r½   ¦  s`   

þ



ÿÿþ



zConsoleWidget.eventFilterc                 C   s´   t  | j¡}| j ¡ | j ¡  ¡  d }|  ¡ }| t	j
j¡}|  ¡ | j | }|| t	j
j¡7 }| jdkr<|d | }| ¡ | j | }| jdkrP|d | }t t|ƒt|ƒ¡S )zc Reimplemented to suggest a size that is 80 characters wide and
            25 lines high.
        é   r/   r0   )r   ÚQFontMetricsÚfontrO   Z
frameWidthÚdocumentZdocumentMarginÚstyleZpixelMetricr
   ZQStyleZPM_SplitterWidthÚ_get_font_widthÚconsole_widthZPM_ScrollBarExtentrP   ÚheightÚconsole_heightr   ZQSizeÚint)r:   Úfont_metricsÚmarginrÇ   Z
splitwidthÚwidthrÊ   r!   r!   r"   ÚsizeHintí  s    ÿÿ

zConsoleWidget.sizeHintzŸWhether to include output from clients
        other than this one sharing the same kernel.

        Outputs are not displayed until enter is pressed.
        z	[remote] z‚Prefix to add to outputs coming from clients other than this one.

        Only relevant if include_other_output is True.
        c                 C   ó   | j  ¡  ¡ S )z> Returns whether text can be copied to the clipboard.
        )rO   rY   ÚhasSelectionr9   r!   r!   r"   Úcan_copy  ó   zConsoleWidget.can_copyc                 C   s.   | j  ¡ }| ¡ o|  | ¡ ¡o|  | ¡ ¡S )z; Returns whether text can be cut to the clipboard.
        )rO   rY   rÒ   r”   rÂ   r•   ©r:   r—   r!   r!   r"   Úcan_cut   s   
ÿþzConsoleWidget.can_cutc                 C   s(   | j  ¡ tjj@ rttj ¡  	¡ ƒS dS )z@ Returns whether text can be pasted from the clipboard.
        F)
rO   ÚtextInteractionFlagsr   rS   ÚTextEditableÚboolr
   r°   Ú	clipboardr¤   r9   r!   r!   r"   Ú	can_paste(  s   zConsoleWidget.can_pastec                 C   sB   | j r
| j ¡  dS |r| j}| j ¡  |  ¡  |r|| _dS dS )zÄ Clear the console.

        Parameters
        ----------
        keep_input : bool, optional (default True)
            If set, restores the old input buffer if a new prompt is written.
        N)ra   rO   ÚclearÚinput_bufferÚ_show_prompt)r:   Z
keep_inputrÝ   r!   r!   r"   rÜ   /  s   

ÿzConsoleWidget.clearc                 C   s   |   ¡  ¡  ¡  dS )z< Copy the currently selected text to the clipboard.
        N)r…   ZcurrentWidgetÚcopyr9   r!   r!   r"   rß   A  ó   zConsoleWidget.copyc                 C   s   t j ¡  |¡ dS )z+ Copy anchor text to the clipboard
        N)r
   r°   rÚ   ZsetText©r:   rÂ   r!   r!   r"   Úcopy_anchorF  rà   zConsoleWidget.copy_anchorc                 C   s&   |   ¡  |  ¡ r| j ¡  ¡  dS dS )zv Copy the currently selected text to the clipboard and delete it
            if it's inside the input buffer.
        N)rß   rÖ   rO   rY   ÚremoveSelectedTextr9   r!   r!   r"   ÚcutK  s   ÿzConsoleWidget.cutc                 C   sN   |d   dd¡| jkrd S |d   dd¡}|d   dd¡}|  |d	k|¡ d S )
NZparent_headerZmsg_idr   ÚcontentÚstatusÚcompleteÚindentr?   Ú
incomplete)ÚgetrF   Ú_trigger_is_complete_callback)r:   Úmsgræ   rè   r!   r!   r"   Ú_handle_is_complete_replyS  s
   z'ConsoleWidget._handle_is_complete_replyr?   c                 C   s$   | j d urd | _ |  ||¡ d S d S r‰   )rF   Ú_is_complete_callback)r:   rç   rè   r!   r!   r"   rë   Z  s   
þz+ConsoleWidget._trigger_is_complete_callbackc                 C   sL   | j d ur| jt ¡ k rd S |  ¡  t ¡ | j | _|| _| j |¡| _ d S r‰   )rF   rH   Útimerë   rG   rî   Zkernel_clientZis_complete)r:   ÚsourceÚcallbackr!   r!   r"   Ú_register_is_complete_callback_  s   
z,ConsoleWidget._register_is_complete_callbackc                 C   sb   |du r| j }n|s|| _ |r|  ||¡ dS |r(| jr(|  |t| j|ƒ¡ dS |  |dd¡ dS )a|   Executes source or the input buffer, possibly prompting for more
        input.

        Parameters
        ----------
        source : str, optional

            The source to execute. If not specified, the input buffer will be
            used. If specified and 'hidden' is False, the input buffer will be
            replaced with the source before execution.

        hidden : bool, optional (default False)

            If set, no output will be shown and the prompt will not be modified.
            In other words, it will be completely invisible to the user that
            an execution has occurred.

        interactive : bool, optional (default False)

            Whether the console is to treat the source as having been manually
            entered by the user. The effect of this parameter depends on the
            subclass implementation.

        Raises
        ------
        RuntimeError
            If incomplete input is given and 'hidden' is True. In this case,
            it is not possible to prompt for more input.

        Returns
        -------
        A boolean indicating whether the source was executed.
        NTr?   )rÝ   Ú_executeÚexecute_on_complete_inputrò   r   Ú
do_execute)r:   rð   ÚhiddenÚinteractiver!   r!   r"   Úexecutek  s   '
ÿzConsoleWidget.executec                 C   s†   |r|   d¡ | j| _d| _|  ¡  |  |d¡ d S |  ¡ }| ¡  z| d¡ |  	||¡ W | 
¡  n| 
¡  w | j tjj¡ d S )NÚ
TF)Ú_append_plain_textrÝ   rd   ra   Ú_finalize_input_requestró   Ú_get_end_cursorÚbeginEditBlockÚ
insertTextÚ_insert_continuation_promptÚendEditBlockrO   Ú
moveCursorr   ÚQTextCursorÚEnd)r:   rð   rç   rè   r—   r!   r!   r"   rõ      s   

zConsoleWidget.do_executec                 C   ó   | j  ¡  dS )z? Shows a dialog to export HTML/XML in various formats.
        N)rc   Zexportr9   r!   r!   r"   r|   º  rÔ   zConsoleWidget.export_htmlc                 C   sD   d| _ |  ¡  | j |  ¡  ¡ ¡ | j ¡  | j	¡ | j 
d¡ dS )z8
        Set the widget to a non-reading state.
        FN)rk   Ú_prompt_finishedrZ   ÚsetPositionrü   r•   rO   rÆ   ÚsetMaximumBlockCountÚbuffer_sizeÚsetUndoRedoEnabledr9   r!   r!   r"   rû   ¿  s   
ÿz%ConsoleWidget._finalize_input_requestc                 C   sH   | j r|s| jS |  ¡ }| | jtjj¡ | ¡  	¡ }| 
d| j d¡S )z· The text that the user has entered entered at the current prompt.

        If the console is currently executing, the text that is executing will
        always be returned.
        rù   )ra   rd   rü   r  Ú_prompt_posr   r  Ú
KeepAnchorÚ	selectionÚtoPlainTextr   r_   )r:   Úforcer—   rÝ   r!   r!   r"   Ú_get_input_bufferÔ  s   
zConsoleWidget._get_input_bufferc                 C   sf   | j r|| _dS |  ¡ }| ¡  | | jtjj¡ | 	¡  |  
|  ¡ |¡ | ¡  | j tjj¡ dS )zá Sets the text in the input buffer.

        If the console is currently executing, this call has no *immediate*
        effect. When the execution is finished, the input buffer will be updated
        appropriately.
        N)ra   re   rü   rý   r  r
  r   r  r  rã   r£   Ú_get_prompt_cursorr   rO   r  r  )r:   Ústringr—   r!   r!   r"   Ú_set_input_bufferæ  s   zConsoleWidget._set_input_bufferc                 C   rÑ   )z8 The base font being used by the ConsoleWidget.
        )rO   rÆ   ZdefaultFontr9   r!   r!   r"   Ú	_get_fontÿ  rÔ   zConsoleWidget._get_fontc                 C   s6   |d u r| j }t |¡}t|dƒr| d¡S | d¡S )NÚhorizontalAdvanceú )rÅ   r   rÄ   rL   r  rÏ   )r:   rÅ   rÍ   r!   r!   r"   rÈ     s   



zConsoleWidget._get_font_widthc                 C   sZ   | j  | j|  |¡ ¡ | j |¡ | j  ¡  |¡ | jr%| j ¡  |¡ | j	 
|¡ dS )zJ Sets the base font for the ConsoleWidget to the specified QFont.
        N)rO   ÚsetTabStopWidthÚ	tab_widthrÈ   r^   ZsetFontrÆ   ZsetDefaultFontrW   Úfont_changedÚemit)r:   rÅ   r!   r!   r"   Ú	_set_font  s   ÿzConsoleWidget._set_fontc                 C   sD   |dkr
t | ƒ| _n|dkrt| ƒ| _n	|dkrt| ƒ| _|| _dS )z$ Set gui completion widget.
        r+   r*   r)   N)r   r^   r   r   r\   )r:   r\   r!   r!   r"   Ú_set_completion_widget  s   

z$ConsoleWidget._set_completion_widgetc                 C   s   t  |¡ dS )z8 Open selected anchor in the default webbrowser
        N)Ú
webbrowserÚopenrá   r!   r!   r"   Úopen_anchor)  rÔ   zConsoleWidget.open_anchorc                 C   sz   | j  ¡ tjj@ r;|  ¡  | j  ¡ }tj 	¡  
|¡ ¡ }| ¡ |  ¡  }| d| ¡r1||d… }|  |t|ƒ¡ dS dS )a“   Paste the contents of the clipboard into the input region.

        Parameters
        ----------
        mode : QClipboard::Mode, optional [default QClipboard::Clipboard]

            Controls which part of the system clipboard is used. This can be
            used to access the selection clipboard in X11 and the Find buffer
            in Mac OS. By default, the regular clipboard is used.
        r  N)rO   r×   r   rS   rØ   r    rY   r
   r°   rÚ   r¤   Úrstripr•   Ú_get_line_start_posr   r£   r   )r:   Úmoder—   r¤   Zcursor_offsetr!   r!   r"   r·   .  s   
ïzConsoleWidget.pastec                 C   s6   |st  ¡ }t  |¡ ¡ t jjkrdS | j |¡ dS )zL Print the contents of the ConsoleWidget to the specified QPrinter.
        N)r	   ZQPrinterZQPrintDialogÚexec_ÚAcceptedrO   ry   )r:   Úprinterr!   r!   r"   ry   L  s
   zConsoleWidget.print_c                 C   s>   | j s|  ¡ }|  ¡  ¡ | ¡ k r|  |¡ |  |¡ dS dS )z6 Moves the prompt to the top of the viewport.
        N)ra   r  Ú_get_cursorÚblockNumberÚ_set_cursorÚ_set_top_cursor)r:   Zprompt_cursorr!   r!   r"   Úprompt_to_topU  s   
üzConsoleWidget.prompt_to_topc                 C   r  )za Redo the last operation. If there is no operation to redo, nothing
            happens.
        N)rO   Úredor9   r!   r!   r"   r*  ^  ó   zConsoleWidget.redoc                 C   sx   t jdkrd}n
t jdkrd}nd}t| j|ƒ}| jr"| | j¡ n| tj ¡  	¡  
¡ ¡ | tjj¡ |  |¡ dS )zJ Sets the font to the default fixed-width font for this platform.
        r3   ZCourierr4   r5   r6   N)r7   r8   r   Úfont_familyÚ	font_sizeÚsetPointSizer
   r°   r±   rÅ   Ú	pointSizeZsetStyleHintr   ÚQFontZ
TypeWriterr  )r:   ÚfallbackrÅ   r!   r!   r"   rt   d  s   

zConsoleWidget.reset_fontc                 C   s0   | j }t| ¡ | dƒ}| |¡ |  |¡ dS )zBChange the font size by the specified amount (in points).
        r   N)rÅ   Úmaxr/  r.  r  )r:   ÚdeltarÅ   Úsizer!   r!   r"   Úchange_font_sizex  s   
zConsoleWidget.change_font_sizec                 C   ó   |   d¡ d S )Nr   ©r5  r9   r!   r!   r"   r€   €  ó   z!ConsoleWidget._increase_font_sizec                 C   r6  )Néÿÿÿÿr7  r9   r!   r!   r"   r   ƒ  r8  z!ConsoleWidget._decrease_font_sizec                 C   s|   |   ¡ }| ¡ | ¡ f}| ¡  | |  ¡  ¡ ¡ |j|  ¡ tj	j
d | ¡ | ¡ f}||kr6|  ¡  dS | j |¡ dS )zK Select current cell, or, if already selected, the whole document.
        ©r!  N)r%  ÚselectionStartÚselectionEndÚclearSelectionr  r  r•   Ú_get_end_posr   r  r  Úselect_documentrO   r–   )r:   ÚcZ	sel_rangeZnew_sel_ranger!   r!   r"   r~   †  s   
ÿzConsoleWidget.select_all_smartc                 C   r  )z- Selects all the text in the buffer.
        N)rO   Z	selectAllr9   r!   r!   r"   r?  ˜  rÔ   zConsoleWidget.select_documentc                 C   s   | j S )zF The width (in terms of space characters) for tab characters.
        )rm   r9   r!   r!   r"   Ú_get_tab_width  s   zConsoleWidget._get_tab_widthc                 C   s   | j  ||  ¡  ¡ || _dS )zK Sets the width (in terms of space characters) for tab characters.
        N)rO   r  rÈ   rm   )r:   r  r!   r!   r"   Ú_set_tab_width¢  s   
zConsoleWidget._set_tab_widthc                 C   r  )za Undo the last operation. If there is no operation to undo, nothing
            happens.
        N)rO   Úundor9   r!   r!   r"   rC  «  r+  zConsoleWidget.undoc                 C   ó   t ‚)z§ Returns whether 'source' can be executed. When triggered by an
            Enter/Return key press, 'interactive' is True; otherwise, it is
            False.
        ©ÚNotImplementedError)r:   rð   r÷   r!   r!   r"   Ú_is_completeµ  s   zConsoleWidget._is_completec                 C   rD  )z@ Execute 'source'. If 'hidden', do not show any output.
        rE  )r:   rð   rö   r!   r!   r"   ró   ¼  ó   zConsoleWidget._executec                 C   ó   dS )ú= Called immediately after a new prompt is displayed.
        Nr!   r9   r!   r!   r"   Ú_prompt_started_hookÁ  rH  z"ConsoleWidget._prompt_started_hookc                 C   rI  )ú‡ Called immediately after a prompt is finished, i.e. when some input
            will be processed and a new prompt displayed.
        Nr!   r9   r!   r!   r"   Ú_prompt_finished_hookÆ  ó   z#ConsoleWidget._prompt_finished_hookc                 C   rI  )zj Called when the up key is pressed. Returns whether to continue
            processing the event.
        Tr!   ©r:   Zshift_modifierr!   r!   r"   Ú_up_pressedÌ  rN  zConsoleWidget._up_pressedc                 C   rI  )zl Called when the down key is pressed. Returns whether to continue
            processing the event.
        Tr!   rO  r!   r!   r"   Ú_down_pressedÒ  rN  zConsoleWidget._down_pressedc                 C   rI  )zk Called when the tab key is pressed. Returns whether to continue
            processing the event.
        Tr!   r9   r!   r!   r"   Ú_tab_pressedØ  rN  zConsoleWidget._tab_pressedc                 O   sr   | j  ¡ }|r| js| js|  ¡  d|_| | j¡ n|| jkr$|  ¡  | 	t
jj¡ |||g|¢R i |¤Ž}|S )zÅ A low-level method for appending content to the end of the buffer.

        If 'before_prompt' is enabled, the content will be inserted before the
        current prompt, if there is one.
        T)rO   rY   rk   ra   Ú_flush_pending_streamÚ_insert_moder  Ú_append_before_prompt_posÚ_insert_plain_textÚmovePositionr   r  r  )r:   ÚinsertÚinputÚbefore_promptÚargsÚkwargsr—   Úresultr!   r!   r"   Ú_append_customâ  s   

zConsoleWidget._append_customc                 C   ó   |   | j||¡ dS )zE Appends an new QTextBlock to the end of the console buffer.
        N)r^  Ú_insert_block)r:   Úblock_formatrZ  r!   r!   r"   Ú_append_block÷  rà   zConsoleWidget._append_blockc                 C   r_  )z8 Appends HTML at the end of the console buffer.
        N)r^  Ú_insert_html©r:   ÚhtmlrZ  r!   r!   r"   Ú_append_htmlü  rà   zConsoleWidget._append_htmlc                 C   s   |   | j||¡S )zB Appends HTML, then returns the plain text version of it.
        )r^  Ú _insert_html_fetching_plain_textrd  r!   r!   r"   Ú _append_html_fetching_plain_text  s   ÿz.ConsoleWidget._append_html_fetching_plain_textc                 C   r_  )z? Appends plain text, processing ANSI codes if enabled.
        N)r^  rV  )r:   r¤   rZ  r!   r!   r"   rú     rà   z ConsoleWidget._append_plain_textc                 C   r  )z4 If text completion is progress, cancel it.
        N)r^   Zcancel_completionr9   r!   r!   r"   Ú_cancel_completion  rÔ   z ConsoleWidget._cancel_completionc                 C   sÈ   |   ¡ }| j ¡ }| jr8d| _| tjj¡r7t |¡}| tjj	¡ | 
¡  ¡  ¡ }| |¡s0n| tjj¡sndS | tjj¡ | tjjtjj¡ | ¡  | j ¡ rb| j d¡ | j d¡ dS dS )zh Clears the "temporary text" buffer, i.e. all the text following
            the prompt region.
        FNT)r  r_   ÚlstripÚ_temp_buffer_filledrW  r   r  Ú	NextBlockÚselectZBlockUnderCursorr  r  r   ÚLeftr  r  rã   rO   ZisUndoRedoEnabledr	  )r:   r—   ÚpromptZtemp_cursorr¤   r!   r!   r"   Ú_clear_temporary_buffer  s,   


û€
ÿ
þz%ConsoleWidget._clear_temporary_bufferc                 C   sª   |   ¡  t|ƒdkr | | j ¡  ¡ tjj¡ | 	|d ¡ dS t|ƒdkrS| j ¡  ¡ }t
j |¡}|rF| |tjj¡ | 	|¡ | ¡ }| jj||t|ƒd dS dS )zL Performs completion with 'items' at the specified cursor location.
        r   r   )Zprefix_lengthN)ri  Úlenr  rO   rY   r•   r   r  r  rþ   ÚosÚpathÚcommonprefixr^   Z
show_items)r:   r—   ÚitemsÚcurrent_posÚprefixr!   r!   r"   Ú_complete_with_items0  s"   ÿ


ÿøz"ConsoleWidget._complete_with_itemsc                 C   sf   | j  ¡  ¡ }| ¡  |  d¡ | j||d | ¡  | |¡ | j  t	j
j¡ | j  |¡ d| _dS )z6fill the area below the active editting zone with textrù   )re  TN)rO   rY   r•   rý   rú   Ú_pager   r  r  r   r  r  r–   rk  )r:   r—   r¤   re  rv  r!   r!   r"   Ú_fill_temporary_bufferE  s   


z$ConsoleWidget._fill_temporary_bufferc                    s  t  ˆ¡}| dˆj¡ˆ_ˆj ˆ ¡ ¡ ˆj tj	j
¡ | dˆj¡ˆ_ˆj ˆ ¡ ¡ ˆj tj	j¡ | dˆj¡ˆ_ˆj ˆ ¡ ¡ ˆj tj	j¡ ˆj |¡‰ ˆ rq| ¡  | d‡ ‡fdd„¡ˆ_| d‡ ‡fdd„¡ˆ_| ¡  | ˆj¡ | ¡  | ˆj¡ | ˆj¡ |S )	zN Creates a context menu for the given QPoint (in widget coordinates).
        ÚCutÚCopyÚPastezCopy Link Addressc                      ó   ˆj ˆ dS ©N)rÂ   )râ   r!   ©rÂ   r:   r!   r"   Ú<lambda>k  ó    z2ConsoleWidget._context_menu_make.<locals>.<lambda>z	Open Linkc                      r~  r  )r  r!   r€  r!   r"   r  m  r‚  )r
   ZQMenurz   rä   Z
cut_actionru   rÖ   rx   r   rv   r{  rß   Zcopy_actionrÓ   r|  r·   Zpaste_actionrÛ   r}  rO   r¼   ZaddSeparatorZcopy_link_actionZopen_link_actionr   r}   r{   ©r:   r“   Zmenur!   r€  r"   Ú_context_menu_makeV  s2   
ÿÿz ConsoleWidget._context_menu_makec                 C   sB   t jdkr|o|tjj@ }t|ƒt|tjj@ ƒA S t|tjj@ ƒS )a7   Given a KeyboardModifiers flags object, return whether the Control
        key is down.

        Parameters
        ----------
        include_command : bool, optional (default True)
            Whether to treat the Command key as a (mutually exclusive) synonym
            for Control when in Mac OS.
        r4   )r7   r8   r   rS   ZControlModifierrÙ   ZMetaModifier)r:   r¬   Úinclude_commandZdownr!   r!   r"   r«   x  s   
zConsoleWidget._control_key_downc                 C   s   | j r|   ¡ }n| jdkrt ¡ }n| jdkr%t ¡ }| d¡ | d¡ | d¡ | | ¡ | 	¡  | ¡ |j
 | j¡ |j | j¡ |j | j¡ |j | j¡ | ¡  ¡ }|j ¡  |j | j¡ | jrltjj}ntjj}| tjjd¡ | tjj ¡ | !d¡ | "d¡ | #|¡ |S )z: Creates and connects the underlying text widget.
        r)   r-   FT)$Úcustom_controlÚkindr
   ÚQPlainTextEditÚ	QTextEditZsetAcceptRichTextZsetMouseTrackingr‚   ÚinstallEventFilterr¶   ZcustomContextMenuRequestedrr   Ú_custom_context_menu_requestedZcopyAvailableÚcopy_availableZredoAvailableÚredo_availableZundoAvailableÚundo_availablerÆ   ZdocumentLayoutZdocumentSizeChangedZ
disconnectr¹   Úscrollbar_visibilityr   rS   ÚScrollBarAlwaysOnÚScrollBarAlwaysOffÚsetAttributeÚWA_InputMethodEnabledZsetContextMenuPolicyZCustomContextMenuÚsetReadOnlyr	  ÚsetVerticalScrollBarPolicy)r:   Úcontrolr…   Úscrollbar_policyr!   r!   r"   rN   Š  s:   







ÿ




zConsoleWidget._create_controlc                 C   sŒ   | j r|   ¡ }n| jdkrt ¡ }n	| jdkrt ¡ }| | ¡ | ¡ }| | ¡ | d¡ | d¡ | j	r;t
jj}nt
jj}| |¡ |S )z< Creates and connects the underlying paging widget.
        r)   r-   TF)Úcustom_page_controlr‡  r
   rˆ  r‰  rŠ  r¶   r”  r	  r  r   rS   r  r‘  r•  )r:   r–  r¶   r—  r!   r!   r"   rV   ½  s    









z"ConsoleWidget._create_page_controlc                    s<  d}ˆj  ¡ ‰ ˆ  ¡ ‰| ¡ }ˆ | ¡ ¡}| ¡ tjj@ }| ¡ tjj	@ }t
jdko3ˆj| ¡ dd}|re|tjjkrAtjj}n$|tjjkrLtjj}n|tjjkrYd}tjj}n|tjjkred}tjj}|tjjtjjfv rÜd}ˆ ¡  ˆ ˆ¡rÚˆjrŽˆ d¡ dˆ_ˆjrŒˆ ¡  n©ˆjsÚˆ  tjjtjj¡ tˆ   ¡  !¡ ƒdk}ˆ "¡  #¡ ˆ $¡  #¡ k}	|s·|s·|	rÂ|sÂˆj%| d nuˆ &¡ }
‡ ‡‡fdd	„}ˆ 'ˆ (¡ d
|
… |¡ n[|rq|tjj)kríˆ *¡  d}nJ|tjj+kr4ˆ ˆ¡r0ˆ  ,¡  ˆ  tjj-tjj¡ ˆ  .¡ s%ˆ  tjj/tjj¡ ˆ  tjj0tjjtˆj1ƒ¡ ˆj2 3ˆ ¡ ˆ 4ˆ ¡ d}n|tjj5krCˆ 6¡  d}nô|tjj7kr]ˆj8rYˆj8 9¡ rYˆj8 :¡  d}nÚ|tjj;krªˆ ˆ¡r¦ˆ  ,¡  ˆ  #¡ }|ˆ $¡  #¡ krtˆj<ƒ}ntˆj1ƒ}ˆ  tjj=tjj¡ ˆ  tjj0tjj|¡ ˆj2 3ˆ ¡ ˆ 4ˆ ¡ d}n|tjj>kr¾ˆ ?¡  ˆj2 @¡  d}ny|tjjAtjjBfv rí|tjjAkrÖˆ Cˆ¡‰ nˆ Dˆ¡‰ ˆ  Eˆtjj¡ ˆj2 3ˆ ¡ d}nJ|tjjFkrStˆjGƒdkrˆjsˆjH Iˆ¡ n/tˆj(ddƒdkr8ˆj  ¡  JtKdƒ¡ t LtjMjNtjjtjjO¡}tPjQ R¡  Sˆj |¡ d}nÿt LtjMjNtjjBtjjO¡}tPjQ R¡  Sˆj |¡ d}nä|tjjkr`ˆ T¡  n×|tjjkroˆj  U¡  Vd¡ nÆ|r|tjjWkr‡ˆ 4ˆ Cˆ¡¡ d}n°|tjjXkršˆ 4ˆ Dˆ¡¡ d}n|tjj>krªˆj2 Y¡  d}n|tjjAkrÈˆ Cˆ¡‰ ˆ  Eˆtjj¡ ˆj2 3ˆ ¡ d}no|tjjFkræˆ Dˆ¡‰ ˆ  Eˆtjj¡ ˆj2 3ˆ ¡ d}nQ|tjjBkrñd}nF|tjjZkrˆj  [tjj¡ d}n3|tjj\krˆj  ]ˆ $¡ ¡ d}n ˆ ^¡  |r#tjj}ntjj_}|tjj`kr6ˆ *¡  d}n|tjjkr\|s\ˆjsJˆ a|¡sNd}néˆ $¡  #¡ }ˆ  #¡ |k}nÛ|tjjkr‚|s‚ˆjspˆ b|¡std}nÃˆ "¡  #¡ }ˆ  #¡ |k}nµ|tjjckrœˆjsšˆ d¡ r˜ˆjedd d}n›|tjjfkr­ˆjedd d}nŠ|tjjkró|sóˆ  #¡ ˆ  g¡ }}|ˆ $¡  #¡ kré|tˆj1ƒkréˆj j[tjjh|d ˆj j[tjji|d d}nNˆ ˆd ¡ }nD|tjjkr/|s/ˆˆ j¡ kr!ˆ jtjj/|d ˆ jtjj0|tˆj1ƒd ˆj  ]ˆ ¡ n
ˆj j[tjj0|d d}n|tjjkrŽˆ k¡ }ˆ l¡ }ˆ m¡ }| ¡ || ksU| g¡ tˆj1ƒkrY||7 }|rˆ ˆ¡r|  ¡ rxtn| o¡ | p¡ ƒ}ˆ  E|tjj_¡ ˆ  E|tjj¡ nˆ  E|¡ ˆ 4ˆ ¡ d}n©|tjjAkrìˆ  #¡ ˆ  g¡ }}ˆjsÐ|tˆj1ƒkrÐ|ˆ $¡  #¡ krÐˆ  q¡  ˆ  tjj=tjj¡ ˆ  r¡  ˆ  s¡  ˆ  t¡  d}ngˆ  u¡ }|ˆkrâˆ ˆd ¡ }nUˆ tv|ˆƒ¡ }nK|tjjBkr7ˆjs&ˆ ˆ¡r&ˆ  w¡ r&ˆ  .¡ s&ˆ  tjj/tjj¡ ˆ  tjj0tjjtˆj1ƒ¡ ˆ  r¡  d}nˆ  u¡ }ˆ |¡ p6ˆ ˆ¡ }|sf| xtjyjz¡rIˆ {¡  d}n| xtjyj|¡rXˆ }¡  d}n| xtjyj~¡rfˆ ¡  d}ˆj| ¡ ddsœ|tjj€tjjfv sœˆjrƒˆjrœ| ‚¡ dkr˜|sœ|tjjtjjfv rœˆ ?¡  |S )zj Filter key events for the underlying text widget to create a
            console-like interface.
        Fr4   T)r…  rù   r   )r÷   c                    sl   z ˆ   ¡  ˆ  ˆ¡ ˆ  d¡ ˆ ˆ ¡ |rˆ  |¡ W ˆ  ¡  nˆ  ¡  w ˆj tjj	¡ ˆj 
ˆ ¡ d S )Nrù   )rý   r  rþ   rÿ   r   rO   r  r   r  r  r–   )rç   rè   ©r—   r•   r:   r!   r"   rñ     s   



€z>ConsoleWidget._event_filter_console_keypress.<locals>.callbackN©r  r@   r   r:  r   )r!  Únr?   )ƒrO   rY   r•   rª   r«   r¬   r   rS   ÚAltModifierZShiftModifierr7   r8   ÚKey_LeftÚKey_HomeÚ	Key_RightÚKey_EndÚKey_UpÚKey_DownÚ
Key_ReturnÚ	Key_Enterri  r”   rk   rú   rl   ra   rW  r   r  r  r  rq  ÚselectedTextÚstriprü   r&  r  rø   Ú_get_input_buffer_cursor_posrò   r  ÚKey_GÚ_keyboard_quitÚKey_Kr=  Ú	EndOfLinerÒ   rl  ÚRightr_   rf   Zkill_cursorr'  ZKey_Lr)  ÚKey_OrW   Ú	isVisibleÚsetFocusZKey_Urg   ÚStartOfBlockZKey_Yr    ZyankÚKey_BackspaceZ
Key_DeleteÚ_get_word_start_cursorÚ_get_word_end_cursorr  ZKey_DrÝ   Zexit_requestedr  rþ   Úchrr®   rI   r©   r¯   r
   r°   r±   r²   Ú_scroll_to_endÚverticalScrollBarÚsetValueÚKey_BÚKey_FÚrotateÚKey_Greaterr  ÚKey_Lessr–   rë   Ú
MoveAnchorÚ
Key_EscaperP  rQ  ÚKey_TabrR  Ú_indentZKey_BacktabÚcolumnNumberÚPreviousBlockÚ
EndOfBlockÚ_get_line_end_posr   r%  Ú_get_leading_spacesr2  r;  r<  rý   rã   ÚdeletePreviousCharr   rÂ   ÚminZ
atBlockEndrw   rv   r|  rß   r{  rä   r}  r·   Ú
Key_PageUpÚKey_PageDownr¤   )r:   r¿   Zinterceptedrª   Ú	ctrl_downÚalt_downZ
shift_downZcmd_downZat_endZsingle_liner“   rñ   Ú
start_lineÚoffsetrÁ   Z
anchormodeÚprompt_lineÚend_lineÚlineÚcolÚ	start_posr@  ÚspacesZsel_maxrÂ   r!   r™  r"   r³   Õ  s,  

þ




€
ÿ

ÿÿ€
ÿ

ÿ
þ



ÿ
ÿ



þ
þ€


€

€ÿÿ
þÿ
ÿ


ÿ
ÿÿ
ÿ
þ
ÿÿÿÿz,ConsoleWidget._event_filter_console_keypressc                 C   sò  |  ¡ }|  | ¡ ¡}| ¡ tjj@ }|r$|tjjkr"| j ¡  dS dS |rH|tjj	kr6| j
 tjj¡ dS |tjjkrF| j
 tjj¡ dS dS |tjjtjjfv rt| jra| j
 ¡  | j ¡  dS |  ¡  | j¡ | j ¡  | j¡ dS |tjjtjjtjjfv ršt tjjtjj tjj!¡}t"j# $¡  %| j
|¡ dS |tjj&kr¹t tjjtjj'tjj!¡}t"j# $¡  %| j
|¡ dS |tjj(krØt tjjtjj)tjj!¡}t"j# $¡  %| j
|¡ dS |tjj*kr÷t tjjtjj+tjj!¡}t"j# $¡  %| j
|¡ dS dS )z_ Filter key events for the paging widget to create console-like
            interface.
        TF),rª   r«   r¬   r   rS   rœ  r­  rO   r¯  r»  rW   r  r   r  r  r¼  ÚStartZKey_Qr¾  rQ   rX   r…   ÚsetCurrentWidgetrÆ   r  r  r¤  r£  r¿  r®   rI   r©   rÉ  r¯   r
   r°   r±   r²   r±  rÈ  ZKey_Jr¢  rª  r¡  )r:   r¿   rª   rÊ  rË  rÁ   r!   r!   r"   r´   :  sn   
4Î+×

ýÿ
þ
þ
þ
þz)ConsoleWidget._event_filter_page_keypressc                 C   s2   | j  ¡ }| tjj¡ |  ¡  | tjj¡ dS )z_ Flush the pending stream output and change the
        prompt position appropriately.
        N)rO   rY   rW  r   r  r  rS  rÕ   r!   r!   r"   rs   {  s   
z,ConsoleWidget._on_flush_pending_stream_timerc                 C   sz   | j }g | _ | j ¡  ¡ }|dkr|  ||¡}d |¡}t ¡ }| j|  ¡ |dd | j	 
ttdt ¡ | d ƒƒ¡ dS )z) Flush out pending text into the widget. r   r?   T)ÚflushrA   iè  N)rn   rO   rÆ   ÚmaximumBlockCountÚ_get_last_lines_from_listr¢   rï   rV  rü   ro   rp   rÌ   r2  )r:   r¤   r  Útr!   r!   r"   rS  „  s   
ÿz#ConsoleWidget._flush_pending_streamc                 C   s
   | j  ¡ S )z6 Get a cursor at the current insert position.
        )rO   rY   r9   r!   r!   r"   r%  “  s   
zConsoleWidget._get_cursorc                 C   ó   | j  ¡ }| tjj¡ |S )zA Get a cursor at the last character of the current cell.
        )rO   rY   rW  r   r  r  rÕ   r!   r!   r"   rü   ˜  ó   
zConsoleWidget._get_end_cursorc                 C   ó   |   ¡  ¡ S )zE Get the position of the last character of the current cell.
        )rü   r•   r9   r!   r!   r"   r>  Ÿ  ó   zConsoleWidget._get_end_posc                 C   s\   | j  ¡ }| ¡ }||  ¡  ¡ kr| | j¡ |S | tjj	¡ | | 
¡ t| jƒ ¡ |S )zB Get a cursor at the first character of the current line.
        )rO   rY   r&  r  r  r
  rW  r   r  ÚStartOfLiner•   rq  r_   )r:   r—   rÌ  r!   r!   r"   Ú_get_line_start_cursor¤  s   
ý
ÿz$ConsoleWidget._get_line_start_cursorc                 C   rÜ  )zF Get the position of the first character of the current line.
        )rß  r•   r9   r!   r!   r"   r   ±  rÝ  z!ConsoleWidget._get_line_start_posc                 C   rÚ  )zA Get a cursor at the last character of the current line.
        )rO   rY   rW  r   r  r«  rÕ   r!   r!   r"   Ú_get_line_end_cursor¶  rÛ  z"ConsoleWidget._get_line_end_cursorc                 C   rÜ  )zE Get the position of the last character of the current line.
        )rà  r•   r9   r!   r!   r"   rÄ  ½  rÝ  zConsoleWidget._get_line_end_posc                 C   s.   |   ¡ }|du r
dS | j ¡ }| ¡ t|ƒ S )z“ Get the column of the cursor in the input buffer, excluding the
            contribution by the prompt, or -1 if there is no such column.
        Nr9  )Ú_get_input_buffer_cursor_promptrO   rY   rÁ  rq  )r:   ro  r—   r!   r!   r"   Ú_get_input_buffer_cursor_columnÂ  s
   
z-ConsoleWidget._get_input_buffer_cursor_columnc                 C   s:   |   ¡ }|du r
dS | j ¡ }| ¡  ¡ }|t|ƒd… S )z~ Get the text of the line of the input buffer that contains the
            cursor, or None if there is no such line.
        N)rá  rO   rY   Úblockr¤   rq  )r:   ro  r—   r¤   r!   r!   r"   Ú_get_input_buffer_cursor_lineÍ  s   
z+ConsoleWidget._get_input_buffer_cursor_linec                 C   s>   | j  ¡ }| | jtjj¡ | ¡  ¡ }t	| 
d| j d¡ƒS )z0Get the cursor position within the input buffer.rù   )rO   rY   r  r
  r   r  r  r  r  rq  r   r_   )r:   r—   rÝ   r!   r!   r"   r§  Ù  s   
z*ConsoleWidget._get_input_buffer_cursor_posc                 C   sF   | j rdS | j ¡ }| ¡ | jkr!| ¡ |  ¡  ¡ kr| jS | jS dS )zŽ Returns the (plain text) prompt for line of the input buffer that
            contains the cursor, or None if there is no such line.
        N)	ra   rO   rY   r•   r
  r&  r  rg   r_   rÕ   r!   r!   r"   rá  â  s   
z-ConsoleWidget._get_input_buffer_cursor_promptc                 C   sˆ   t |ƒ}||k r|r||r| d¡fS |fS |S d}||k r4| dd|¡}|dkr,d}n|d7 }||k s|r>||d… |fS ||d… S )zÀ Get the last specified number of lines of text (like `tail -n`).
        If return_count is True, returns a tuple of clipped text and the
        number of lines in the clipped text.
        rù   r   Nr9  r   )rq  ÚcountÚrfind)r:   r¤   Ú	num_linesÚreturn_countr“   Úir!   r!   r"   Ú_get_last_linesñ  s    ûzConsoleWidget._get_last_linesc                 C   sV   g }|}t |ƒD ]}| j||dd\}}| |¡ ||8 }|dkr# nq|ddd… S )z? Get the list of text clipped to last specified lines.
        T)rè  r   Nr9  )Úreversedrê  rM   )r:   Z	text_listrç  ÚretZlines_pendingr¤   Zlines_addedr!   r!   r"   rØ    s   
ÿ
ÿz'ConsoleWidget._get_last_lines_from_listc                 C   sh   |   ¡ }| ¡ }||  ¡  ¡ krt| jƒ}nt| jƒ}| tjj	¡ | 
¡ |d… }t|ƒt| ¡ ƒ S )z? Get the number of leading spaces of the current line.
        N)r%  r&  r  rq  rg   r_   rm  r   r  ÚLineUnderCursorr¥  rj  )r:   r—   rÌ  rÍ  r¤   r!   r!   r"   rÅ    s   
z!ConsoleWidget._get_leading_spacesc                 C   s   t | j ¡ d |  ¡ ƒS )z? Find the position in the text right after the prompt.
        r   )rÇ  ri   r•   r>  r9   r!   r!   r"   r
  &  s   zConsoleWidget._prompt_posc                 C   s   t | j ¡ |  ¡ ƒS )z@ Find the position in the text right before the prompt.
        )rÇ  rZ   r•   r>  r9   r!   r!   r"   rU  ,  s   
ÿz'ConsoleWidget._append_before_prompt_posc                 C   s   | j  ¡ }| | j¡ |S )zB Get a cursor at the prompt position of the current cell.
        )rO   rY   r  r
  rÕ   r!   r!   r"   r  3  s   
z ConsoleWidget._get_prompt_cursorc                 C   s(   | j  ¡ }| |¡ | |tjj¡ |S )z^ Get a cursor with text selected between the positions 'start' and
            'end'.
        )rO   rY   r  r   r  r  )r:   ÚstartÚendr—   r!   r!   r"   Ú_get_selection_cursor:  s   

z#ConsoleWidget._get_selection_cursorc                 C   s^  | j  ¡ }| j  ¡ }|  ¡ }|| jkr|S ||krZ| j  ¡ }| |¡ | tjj	¡ | tjj
¡ | ¡ }|| jkrQt| |¡ƒrQ|d8 }|| jkrQt| |¡ƒsA| |d ¡ |S |d8 }|| jkr‚||kr‚t| |¡ƒs‚|d8 }|| jkr‚||kr‚t| |¡ƒrn|| jkr¦||kr¦t| |¡ƒr¦|d8 }|| jkr¦||kr¦t| |¡ƒs’| |d ¡ |S )zÜ Find the start of the word to the left the given position. If a
            sequence of non-word characters precedes the first word, skip over
            them. (This emulates the behavior of bash, emacs, etc.)
        r   )rO   rÆ   rY   r   r
  r  rW  r   r  rÂ  rÃ  r•   r%   ÚcharacterAtr#   )r:   r•   rÆ   r—   Úline_start_posr!   r!   r"   r²  C  sR   





ÿ
ýÿì
ÿ
üÿ
ÿ
üÿz$ConsoleWidget._get_word_start_cursorc           	      C   sè  | j  ¡ }| j  ¡ }|  ¡ }|  ¡ }||kr|S ||krW| j  ¡ }| |¡ | tjj	¡ | 
¡ t| jƒ }||k rPt| |¡ƒrP|d7 }||k rPt| |¡ƒsA| |¡ |S t| |¡ƒr©d}|d }|  ¡ }||kr~t| |¡ƒsvd}n|d8 }||ksl|r©||k r¢||k r¢t| |¡ƒr¢|d7 }||k r¢||k r¢t| |¡ƒs| |¡ |S ||k rË||k rËt| |¡ƒsË|d7 }||k rË||k rËt| |¡ƒr¸||k rí||k rít| |¡ƒrí|d7 }||k rí||k rít| |¡ƒsÚ| |¡ |S )zÛ Find the end of the word to the right the given position. If a
            sequence of non-word characters precedes the first word, skip over
            them. (This emulates the behavior of bash, emacs, etc.)
        r   TF)rO   rÆ   rY   r>  rÄ  r  rW  r   r  rl  r•   rq  r_   r%   rñ  r   r#   )	r:   r•   rÆ   r—   Úend_posZline_end_posZis_indentation_whitespaceZback_posrò  r!   r!   r"   r³  s  s|   



ÿýÿ
(Úüÿüÿ
ÿüÿÿüÿ
z"ConsoleWidget._get_word_end_cursorc           	   	   C   s  |   ¡  ¡  d¡}|   ¡ }|   ¡ }| | ¡ ¡ | j |¡ |  ¡ }| j|| j  }| 	¡  t
|d ƒD ]E}| j |¡ | |  ¡ ¡ |rkt||  ¡ ƒ}|| j }| tjjtjjt||dkra|n| jƒ¡ | ¡  n| d| ¡ | tjj¡ q4| j |¡ dS )z? Indent/Dedent current line or current text selection.
        u   â€©r   r   r  N)r%  r¥  rå  r  r;  rO   r–   rÅ  rm   r=  Úranger   rÇ  rW  r   r  r¬  r  rã   rþ   ZDown)	r:   r   Znum_newlinesZsave_curÚcurrÓ  ÚstepÚ_Z	safe_stepr!   r!   r"   rÀ  ¶  s0   

ÿþ
zConsoleWidget._indentc                 C   s@   | j du r|  || j¡ n|  || j ¡| _|r| |¡ dS dS )zE Inserts new continuation prompt using the specified cursor.
        N)r`   rV  r_   rg  rþ   )r:   r—   rè   r!   r!   r"   rÿ   Ü  s   
ÿÿz)ConsoleWidget._insert_continuation_promptc                 C   s   |du rt  ¡ }| |¡ dS )zA Inserts an empty QTextBlock using the specified cursor.
        N)r   ZQTextBlockFormatZinsertBlock)r:   r—   ra  r!   r!   r"   r`  ç  s   zConsoleWidget._insert_blockc                 C   sj   |  ¡  | |¡ | tjjtjj¡ | ¡  ¡ dkr | 	¡  n| tjj
¡ | dt ¡ ¡ | ¡  dS )zq Inserts HTML using the specified cursor in such a way that future
            formatting is unaffected.
        r  N)rý   Z
insertHtmlrW  r   r  rn  r  r  r  rã   r¬  rþ   ZQTextCharFormatr   )r:   r—   re  r!   r!   r"   rc  î  s   

ÿ
zConsoleWidget._insert_htmlc                 C   s^   |  ¡  | ¡  | ¡ }|  ||¡ | ¡ }| |tjj¡ | ¡  	¡ }| |¡ | 
¡  |S )zc Inserts HTML using the specified cursor, then returns its plain text
            version.
        )rý   rã   r•   rc  r  r   r  r  r  r  r   )r:   r—   re  rî  rï  r¤   r!   r!   r"   rg    s   
z.ConsoleWidget._insert_html_fetching_plain_textc                 C   sF   | j  ¡ }| j  t | ¡ d | ¡ d ¡¡ ¡ }|  ¡ }|| dkS )z4Check if the viewport is at the end of the document.r   )	rO   r¶   r’   r   ZQPointrÏ   rÊ   r•   r>  )r:   r¶   Zend_scroll_posZend_doc_posr!   r!   r"   Ú_viewport_at_end  s   
ÿþzConsoleWidget._viewport_at_endc                 C   sF   | j  ¡  ¡ | j  ¡  ¡  }|| j  ¡  ¡ kr!| j  ¡  |¡ dS dS )z"Scroll to the end of the document.N)rO   r¶  ÚmaximumZpageStepÚvaluer·  )r:   Z
end_scrollr!   r!   r"   rµ    s   ÿÿzConsoleWidget._scroll_to_endc                 C   s4  |   ¡ }| j ¡  ¡ }| jr1|s1| j ¡ r1| ¡ |  ¡ kr1| j	 
|¡ |dkr/|  | j	|¡| _	dS | jr>| j ¡ s>| j ¡  |dkrH|  ||¡}| ¡  | jr†| j |¡D ]-}| jjD ]ã}|jdkrÍd}d}	|jdkrv| tjj¡ d}|jdkr¯|jdkrŠ| tjj¡ d}n%|jd	krž| tjjtjj¡ d}d}	n|jd
kr¯| tjjtjj¡ d}|rÌ|	r»| ¡ |  ¡  nd}
| !¡  |
dkrÌ| "d|
 ¡ q]|jdkrþ|j#dkrþ| "d¡ | $¡  |  %|¡ | &¡  | '¡  t(j)dkrý| tjj¡ | !¡  q]|jdkr| tjjtjj*¡ q]|jdkrt+j, -¡  .¡  q]|jdkr3| /¡ s2| tjj0tjj*¡ q]|jdkr@| tjj¡ q]|dur„| j 1¡ }t2|dƒrU|j3s~| ¡ }t |¡}| tjj¡ | ¡ | }t4|ƒ}t5||ƒ}| 6|| tjj¡ | "||¡ qVn| "|¡ | $¡  |r˜|  7¡  dS dS )zf Inserts plain text using the specified cursor, processing ANSI codes
            if enabled.
        r   NZeraseFÚscreenTrÐ  Úallrî  rï  r  ÚscrollÚpagerù   Úntzcarriage-returnÚbeepZ	backspaceÚnewlinerT  )8rø  rO   rÆ   r×  ra   ro   ZisActiver•   r>  rn   rM   rØ  rî  rê  rý   Ú
ansi_codesr[   Zsplit_stringÚactionsr†   Zarearm  r   r  ZDocumentZerase_torí  rW  rÞ  r  r«  r<  r;  rã   rþ   Úunitr   r(  ZjoinPreviousEditBlockrÆ  rr  Únamer½  r
   r°   r±   r   ZatBlockStartZPreviousCharacterZ
get_formatrL   rT  rq  rÇ  r  rµ  )r:   r—   r¤   rÖ  Zshould_autoscrollr  Z	substringZactÚremoveÚfillZnspaceÚformatr“   Zcursor2Zremainr›  Zswallowr!   r!   r"   rV  %  sº   
ÿÿ





þ
þ€


€þ
þ€€



€¸
Jÿz ConsoleWidget._insert_plain_textc                 C   s   |  d¡}|rF|d  d¡r| d¡ | ¡  | |d ¡ |dd… D ]}| jdu r2| | j¡ n|  || j¡| _| |¡ q$| ¡  dS dS )zÂ Inserts text into the input buffer using the specified cursor (which
            must be in the input buffer), ensuring that continuation prompts are
            inserted as necessary.
        Tr9  rù   r?   r   r   N)	Ú
splitlinesÚendswithrM   rý   rþ   r`   r_   rg  r   )r:   r—   r¤   ÚlinesrÐ  r!   r!   r"   r£   ‘  s    


ÿÿñz,ConsoleWidget._insert_plain_text_into_bufferc                 C   s   ||   |¡kS )zV
        Returns whether the specified position is inside the editing region.
        )Ú_move_position_in_buffer)r:   r•   r!   r!   r"   r”   ¨  r+  zConsoleWidget._in_bufferc                 C   s‚   | j  ¡ }| |¡ | ¡ }|  ¡  ¡ }||kr"|| jkr|S | jS ||kr>| tjj	¡ | 
¡ t| jƒ }||kr<|S |S | jS )z5
        Return the next position in buffer.
        )rO   rY   r  r&  r  r
  rW  r   r  r°  r•   rq  r_   )r:   r•   r—   rÐ  rÎ  Z
prompt_posr!   r!   r"   r  ®  s   


z&ConsoleWidget._move_position_in_bufferc                 C   sÈ   | j  ¡ }| ¡ }|| jk r7| |¡ | ¡ }|  ¡  ¡ }||kr(| | j¡ n| tj	j
¡ | j  |¡ dS | ¡ }|  |¡}|  |¡}||krO||krOdS | |¡ | |tj	j¡ | j  |¡ dS )zq Ensures that the cursor is inside the editing region. Returns
            whether the cursor was moved.
        TF)rO   rY   r<  r
  r  r&  r  rW  r   r  r  r–   r;  r  r  )r:   r—   ÚendposrÐ  rÎ  ÚstartposZ
new_endposZnew_startposr!   r!   r"   r    Â  s(   





z$ConsoleWidget._keep_cursor_in_bufferc                 C   s$   | j r|  ¡  |  ¡  dS d| _dS )z? Cancels the current editing task ala Ctrl-G in Emacs.
        r?   N)rk  ri  rp  rÝ   r9   r!   r!   r"   r©  â  s   
zConsoleWidget._keyboard_quitc                 C   s  t  | j¡ ¡ }| j ¡  ¡ | }| jdkrxt d| |¡rx| jdkr+| j	 
|¡ dS | j ¡  d¡ | j ¡  | j ¡ }|rF|  ||¡ n|  ||¡ | j t jj¡ | j ¡  | j ¡ ¡ | jrn| j ¡  | j ¡  dS |  ¡  | j¡ dS |r|  |¡ dS |  |¡ dS )zþ Displays text using the pager if it exceeds the height of the
        viewport.

        Parameters
        ----------
        html : bool, optional (default False)
            If set, the text will be interpreted as HTML instead of plain text.
        r2   z(?:[^
]*
){%i}r1   r   N)r   rÄ   rÅ   rÊ   rO   r¶   rP   ÚreÚmatchÚcustom_page_requestedr  rÆ   r  rW   rÜ   rY   rc  rV  r  r  rÔ  Úresizer4  rQ   Úshowr¯  r…   rÕ  rf  rú   )r:   r¤   re  Úline_heightZminlinesr—   r!   r!   r"   ry  ë  s,   	
ÿ



zConsoleWidget._pagec                 C   sl   | j du r	tdƒ‚|dkr| j  tjj¡ n|dkr#| j  tjj¡ n|dkr+tdƒ‚td| ƒ‚|| _dS )z§
        Change the pager to `paging` style.

        Parameters
        ----------
        paging : string
            Either "hsplit", "vsplit", or "inside"
        NzRcan only switch if --paging=hsplit or
                    --paging=vsplit is used.r/   r0   r.   zCswitching to 'inside' paging not
                    supported yet.zunknown paging method '%s')	rQ   rF  rR   r   rS   rT   rU   Ú
ValueErrorrP   )r:   rP   r!   r!   r"   Ú_set_paging	  s   
	
zConsoleWidget._set_pagingc                 C   s   | j  d¡ |  ¡  dS )rL  TN)rO   r”  rM  r9   r!   r!   r"   r  '	  s   zConsoleWidget._prompt_finishedc                 C   sv   | j  ¡  d¡ | j  d¡ | j  d¡ | j  tjjd¡ | j	s#d| _
|  ¡  | jr1| j| _d| _| j  tjj¡ dS )rJ  r   TFr?   N)rO   rÆ   r  r	  r”  r’  r   rS   r“  rk   ra   rK  re   rÝ   r  r   r  r  r9   r!   r!   r"   Ú_prompt_started.	  s   zConsoleWidget._prompt_startedc                    s°   ˆj rtdƒ‚ˆ sˆ ¡ stdƒ‚dˆ_ |rˆjddd d| ¡ vr,ˆj|ddd nˆj|dd ˆ d	u rNd	ˆ_ˆj rEtj ¡  ˆj s=ˆj	dd
 
d¡S ‡ ‡fdd„ˆ_d	S )a2   Reads one line of input from the user.

        Parameters
        ----------
        prompt : str, optional
            The prompt to print before reading the line.

        callback : callable, optional
            A callback to execute with the read line. If not specified, input is
            read *synchronously* and this method does not return until it has
            been read.

        Returns
        -------
        If a callback is specified, returns nothing. Otherwise, returns the
        input string with the trailing newline stripped.
        z.Cannot read a line. Widget is already reading.z>Cannot synchronously read a line if the widget is not visible!TzUWarning: QtConsole does not support password mode, the text you type will be visible.)r  ZipdbF)r  Ú	separatorNrš  rù   c                      s   ˆ ˆj dd d¡ƒS )NTrš  rù   )r  r  r!   ©rñ   r:   r!   r"   r  q	  s   z)ConsoleWidget._readline.<locals>.<lambda>)rk   ÚRuntimeErrorr®  rÞ   Úlowerrl   r   ÚQCoreApplicationÚprocessEventsr  r  )r:   ro  rñ   Úpasswordr!   r  r"   Ú	_readlineF	  s&   ÿ
ÿzConsoleWidget._readlinec                 C   s   |r|| _ dS || _d| _ dS )a…   Sets the continuation prompt.

        Parameters
        ----------
        prompt : str
            The prompt to show when more input is needed.

        html : bool, optional (default False)
            If set, the prompt will be inserted as formatted HTML. Otherwise,
            the prompt will be treated as plain text, though ANSI color codes
            will be handled.
        N)r`   r_   )r:   ro  re  r!   r!   r"   Ú_set_continuation_promptt	  s   

z&ConsoleWidget._set_continuation_promptc                 C   s   | j  |¡ dS )z7 Convenience method to set the current cursor.
        N)rO   r–   rÕ   r!   r!   r"   r'  ‡	  s   zConsoleWidget._set_cursorc                 C   sH   | j  ¡ }| | ¡ ¡ | j  ¡ }| j  |¡ | j  ¡  | j  |¡ dS )zJ Scrolls the viewport so that the specified cursor is at the top.
        N)rO   r¶  r·  rù  rY   r–   ZensureCursorVisible)r:   r—   Ú	scrollbarZoriginal_cursorr!   r!   r"   r(  Œ	  s   


zConsoleWidget._set_top_cursorc                 C   sP  |   ¡  tjdkrtj d¡stj ¡  ntj ¡  |  	¡ }| 
¡ dkr'd}nd}| j | 
¡ d ¡ |rQ| 
¡ dkrQ| tjjtjj¡ | ¡  ¡ dkrQ|  ¡  |rY|  | j¡ |du rp| jdu ri|  | j¡ n|  | j¡ n|r||  |¡| _|| _n|  |¡ || _d| _|   ¡  | j |  ¡ d ¡ |r¢| j | j 
¡ d ¡ |  ¡  dS )	a   Writes a new prompt at the end of the buffer.

        Parameters
        ----------
        prompt : str, optional
            The prompt to show. If not specified, the previous prompt is used.

        html : bool, optional (default False)
            Only relevant when a prompt is specified. If set, the prompt will
            be inserted as formatted HTML. Otherwise, the prompt will be treated
            as plain text, though ANSI color codes will be handled.

        newline : bool, optional (default True)
            If set, a new line will be written before showing the prompt if
            there is not already a newline at the end of the buffer.

        separator : bool, optional (default True)
            If set, a separator will be written before the prompt.
        r4   ZQTCONSOLE_TESTINGr   FTr   rù   N)rS  r7   r8   rr  Úenvironrê   r   r  r  rü   r•   rZ   r  rW  r   r  rn  r  r  r  rb  rú   rj   rh   rg   rf  rh  ri   r>  r  )r:   ro  re  r  r  r—   Zmove_forwardr!   r!   r"   rÞ   –	  sH   

€

ÿ

ÿzConsoleWidget._show_promptc                 C   sÊ   | j  ¡ }| j  ¡ }| j  ¡  ¡ }t| j tjƒr+td| 	¡ d ƒ}|| j  
¡  ¡  }n| ¡  ¡ }|}|| ¡  }| dt|ƒ¡ | t|ƒ¡ |dk ra| ¡ | ¡ krc| t| ¡ | ƒ¡ dS dS dS )zD Expands the vertical scrollbar beyond the range set by Qt.
        r   r   N)rO   rÆ   r¶  r¶   rÊ   Ú
isinstancer
   rˆ  r2  Z	lineCountZfontMetricsZlineSpacingr4  rù  ZsetRangeÚroundZsetPageStepZ
blockCountr×  r·  rú  )r:   rÆ   r!  Zviewport_heightrù  rö  Údiffr!   r!   r"   r¹   ê	  s   

ÿz ConsoleWidget._adjust_scrollbarsc                 C   s    |   |¡}| | j |¡¡ dS )zK Shows a context menu at the given QPoint (in widget coordinates).
        N)r„  r"  rO   ZmapToGlobalrƒ  r!   r!   r"   r‹  
  s   
z,ConsoleWidget._custom_context_menu_requestedr‰   )T)Fr?   )NFF)F)NF)r?   )r?   NF)NFTT)µÚ__name__Ú
__module__Ú__qualname__Ú__doc__r   r  r   r  rô   r   r\   r]   r‡  rP   r  r   r,  r;   r-  rÉ   rË   rº   r†  r˜  r   ZSignalrÙ   rŒ  r  rŽ  Úobjectr  r   r0  r  rO   rW   rQ   rS   r¸  r  r¹  rŸ  ZKey_Arž  ZKey_Pr¡  ZKey_Nr¢  ZKey_Hr±  r­   r7   r8   r   ZKey_EÚsetÚkeysZKey_Cr¨  r­  ZKey_Vr»   rk  rE   r‘   r˜   r¦   r½   rÐ   Zinclude_other_outputZother_output_prefixrÓ   rÖ   rÛ   rÜ   rß   râ   rä   rí   rë   rò   rø   rõ   r|   rû   r  r  ÚpropertyrÝ   r  rÈ   r  rÅ   r  r  r¸   Z	Clipboardr·   ry   r)  r*  rt   r5  r€   r   r~   r?  rA  rB  r  rC  rG  ró   rK  rM  rP  rQ  rR  r^  rb  rf  rh  rú   ri  rp  rx  rz  r„  r«   rN   rV   r³   r´   rs   rS  r%  rü   r>  rß  r   rà  rÄ  râ  rä  r§  rá  rê  rØ  rÅ  r
  rU  r  rð  r²  r³  rÀ  rÿ   r`  rc  rg  rø  rµ  rV  r£   r”   r  r    r©  ry  r  r  r  r  r   r'  r(  rÞ   r¹   r‹  Ú__classcell__r!   r!   r‡   r"   r&   /   s~   ÿÿÿ
þÿÿþÿÿÿÿÿ



û

ÿÿ Gÿÿ

5

	

		


"3  gA		

	0
C&
	l 	%.
ÿTr&   ZNewBase)0r)  Ú	functoolsr   rr  Zos.pathr  r7   Útextwrapr   rï   Úunicodedatar   r  Zqtpyr   r   r   r	   r
   Zqtconsole.rich_textr   Zqtconsole.utilr   r   r   Ztraitlets.config.configurabler   Z	traitletsr   r   r   r   Zansi_code_processorr   Zcompletion_widgetr   Zcompletion_htmlr   Zcompletion_plainr   Z	kill_ringr   Úutilr   r#   r%   ZQWidgetr&   r!   r!   r!   r"   Ú<module>   s2    &