
    d                        d Z dZddl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	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l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 de_        dZdZ ejB                  ejD                  ejF                  ejH                  ejJ                  ejL                  ejN                  fZ( G d dejR                  ejT                        Z+dZ, G d d      Z-dZ. G d dej^                        Z0y)zShell is an interactive text control in which a user types in
commands to be sent to the interpreter.  This particular shell is
based on wxPython's wxStyledTextCtrl.

Sponsored by Orbtech - Your source for Python programming expertise.z(Patrick K. O'Brien <pobrien@orbtech.com>    N)stc)PY3)
cmp_to_key   )Buffer)
dispatcher)
editwindow)frame)PseudoFileIn)PseudoFileOut)PseudoFileErr)VERSION)magic)lscdpwdsxz<-- T   c            
           e Zd ZdZdZdddej                  ej                  ej                  ddddf
dZ	d Z
d Zd	 Zd
 ZddZd Zy)
ShellFramez%Frame containing the shell component.zShell FrameNPyShellc                    t         j                  j                  | ||||||       t         j                  j                  | |	|
       |t        j
                  k(  r| j                  d       dt        z  }| j                  |j                  dd             t        || d|||| j                  | j                  d|| _        | j                  | j                  _        | j                  j                          | j!                          y)zCreate ShellFrame instance.)i  i  z&PyShell %s - The Flakiest Python Shell
, r   )parentid	introTextlocalsInterpClassstartupScriptexecStartupScriptN)r
   Frame__init__ShellFrameMixinwxDefaultSizeSetSizer   SetStatusTextreplaceShellr!   r"   shellsetStatusTextSetFocusLoadSettings)selfr   r   titlepossizestyler   r    configdataDirargskwdsintros                 -/usr/lib/python3/dist-packages/wx/py/shell.pyr$   zShellFrame.__init__,   s     	T62uc4G&&tVW=2>>!LL$87B5==t45 !	 #'2"(k)-););-1-C-C* %)	*
 $(#5#5

 

    c                     | j                   j                  r#|j                         r|j                  d       yy| j	                          | j                   j                          | j                          y)zEvent handler for closing.TN)r,   waitingCanVetoVetoSaveSettingsdestroyDestroyr0   events     r:   OnClosezShellFrame.OnCloseH   sR     ::}}

4   JJ LLNr;   c                    d}dt         z  dz   dz   dz   dt        j                  z  z   dt        j                  j	                         d   z  z   d	t
        j                  z  z   d
dj                  t
        j                  dd       z  z   }t        j                  | ||t
        j                  t
        j                  z        }|j                          |j                          y)zDisplay an About window.zAbout PyShellzPyShell %s

z)Yet another Python shell, only flakier.

z"Half-baked by Patrick K. O'Brien,
z&the other half is still in the oven.

zPlatform: %s
zPython Version: %s
r   zwxPython Version: %s
z	(%s)
r   r   N)r   sysplatformversionsplitr&   VERSION_STRINGjoinPlatformInfoMessageDialogOKICON_INFORMATION	ShowModalrB   )r0   rD   r1   textdialogs        r:   OnAboutzShellFrame.OnAboutS   s    ')<=56 ::  #,,.	/
 &(9(9(;A(>>? ("*;*;;< TYYrqr':;;= !!$e"$%%"*=*="=?r;   c                 D    t         j                  j                  | |       y)zShow a help dialog.N)r
   r%   OnHelprC   s     r:   rV   zShellFrame.OnHelpd   s    $$T51r;   c                     | j                   ot        j                  j                  |        t        j                  j                  | | j                          | j
                  j                  | j                          y y N)r5   r
   r%   r/   r#   r,   r0   s    r:   r/   zShellFrame.LoadSettingsi   sS    ;;"!!..t4KK$$T4;;7JJ##DKK0 #r;   c                    | j                   ~t        j                  j                  |        | j                  s|rPt        j
                  j                  | | j                          | j                  j                  | j                          y y y rX   )r5   r
   r%   r@   autoSaveSettingsr#   r,   )r0   forces     r:   r@   zShellFrame.SaveSettingso   sc    ;;"!!..t4$$((t{{;

''4 ). #r;   c                 v    | j                   -| j                  d       | j                   j                          y y )NT)r\   )r5   r@   FlushrY   s    r:   DoSaveSettingszShellFrame.DoSaveSettingsv   s2    ;;"D)KK #r;   F)__name__
__module____qualname____doc__namer&   DefaultPositionr'   DEFAULT_FRAME_STYLEr$   rE   rT   rV   r/   r@   r_    r;   r:   r   r   '   sV    /D"r''bnn--d!d	8	"2
15 r;   r   a  * Key bindings:
Home              Go to the beginning of the command or line.
Shift+Home        Select to the beginning of the command or line.
Shift+End         Select to the end of the line.
End               Go to the end of the line.
Ctrl+C            Copy selected text, removing prompts.
Ctrl+Shift+C      Copy selected text, retaining prompts.
Alt+C             Copy to the clipboard, including prefixed prompts.
Ctrl+X            Cut selected text.
Ctrl+V            Paste from clipboard.
Ctrl+Shift+V      Paste and run multiple commands from clipboard.
Ctrl+Up Arrow     Retrieve Previous History item.
Alt+P             Retrieve Previous History item.
Ctrl+Down Arrow   Retrieve Next History item.
Alt+N             Retrieve Next History item.
Shift+Up Arrow    Insert Previous History item.
Shift+Down Arrow  Insert Next History item.
F8                Command-completion of History item.
                  (Type a few characters of a previous command and press F8.)
Ctrl+Enter        Insert new line into multiline command.
Ctrl+]            Increase font size.
Ctrl+[            Decrease font size.
Ctrl+=            Default font size.
Ctrl-Space        Show Auto Completion.
Ctrl-Alt-Space    Show Call Tip.
Shift+Enter       Complete Text from History.
Ctrl+F            Search
F3                Search next
Ctrl+H            "hide" lines containing selection / "unhide"
F12               on/off "free-edit" mode
c                   2    e Zd ZdZdZd Zd Zd Zd Zd Z	y)	ShellFacadezSimplified interface to all shell-related functionality.

    This is a semi-transparent facade, in that all attributes of other
    are accessible, even though only some are visible to the user.zShell Interfacec                 8    | j                   }||d<   t        |d<   y)zCreate a ShellFacade instance.otherhelpTextN)__dict__	HELP_TEXT)r0   rl   ds      r:   r$   zShellFacade.__init__   s    MM'
!*r;   c                 :    | j                  | j                         y)z;Display some useful information about how to use the shell.N)writerm   rY   s    r:   helpzShellFacade.help   s    

4==!r;   c                 p    t        | j                  |      rt        | j                  |      S t        |      rX   )hasattrrl   getattrAttributeError)r0   re   s     r:   __getattr__zShellFacade.__getattr__   s,    4::t$4::t,, &&r;   c                     || j                   v r|| j                   |<   y t        | j                  |      rt        | j                  ||       y t	        |      rX   )rn   ru   rl   setattrrw   )r0   re   values      r:   __setattr__zShellFacade.__setattr__   sE    4== "'DMM$TZZ&DJJe, &&r;   c                 .    g d}|j                          |S )z8Return list of magic attributes to extend introspection.)aboutaskautoCallTipautoCompleteautoCompleteAutoHideautoCompleteCaseInsensitiveautoCompleteIncludeDoubleautoCompleteIncludeMagicautoCompleteIncludeSinglecallTipInsertclearpausepromptquitredirectStderrredirectStdinredirectStdoutrunrunfilewrapzoom)sort)r0   lists     r:   _getAttributeNameszShellFacade._getAttributeNames   s    . 			r;   N)
ra   rb   rc   rd   re   r$   rs   rx   r|   r   rh   r;   r:   rj   rj      s(    F
 D""''r;   rj   zi
Author: %r
Py Version: %s
Python Version: %s
wxPython Version: %s
wxPython PlatformInfo: %s
Platform: %sc            
          e Zd ZdZd Zdej                  ej                  ej                  ddddddf
dZ	d Z
d Zd	 Zd
 ZdEdZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdFdZdGdZ d Z!dHdZ"d  Z#d! Z$d" Z%d# Z&d$ Z'd% Z(dEd&Z)dId'Z*d( Z+d) Z,dJd*Z-d+ Z.dKd,Z/dLd-Z0d. Z1d/ Z2d0 Z3dFd1Z4dFd2Z5dFd3Z6d4 Z7d5 Z8d6 Z9d7 Z:d8 Z;d9 Z<d: Z=d; Z>d< Z?d= Z@d> ZAdFd?ZBdKd@ZCdA ZDdB ZEdC ZFdD ZGy)Mr+   zShell based on StyledTextCtrl.r    NTc           
          t         j                  j                   |||||        j                          |ddl}|j
                  }t        j                   _        t        j                   _        t        j                   _	        |ddl
m} n|}t         j                   j                         _        d j                  _        d j                  _         ||| j$                   j                  t'         j(                        t+         j,                        d| _        t1                _         j.                  j5                          _        d _        d _        d _        d _        g  _         d _!        d _"         jG                  dtH        jJ                         d _&         jO                  tP        jR                   jT                          jO                  tP        jV                   jX                          jO                  tP        jZ                   j\                         |rtP        j^                   _/        tP        j`                   _0        tP        jb                   _1        tP        jd                   _2        tP        jf                   _3        tP        jh                   _4        tP        jj                   _5        ntQ        jl                          _/        tQ        jl                          _0        tQ        jl                          _1        tQ        jl                          _2        tQ        jl                          _3        tQ        jl                          _4        tQ        jl                          _5         jO                  tP        jn                   fd	 j^                  
        jO                  tP        jn                   fd j`                  
        jO                  tP        jn                   fdtp        jr                  
        jO                  tP        jn                   fd jb                  
        jO                  tP        jn                   fdtp        jt                  
        jO                  tP        jn                   fd jd                  
        jO                  tP        jn                   fd jf                  
        jO                  tP        jn                   fd jh                  
        jO                  tP        jn                   fd jj                  
        jO                  tP        jv                   fd j^                  
        jO                  tP        jv                   fd jf                  
        jO                  tP        jv                   fd j`                  
        jO                  tP        jv                   fdtp        jr                  
        jO                  tP        jv                   fd jb                  
        jO                  tP        jv                   fdtp        jt                  
        jO                  tP        jv                   fd jh                  
        jO                  tP        jv                   fd jj                  
       d _<         jO                  tP        jz                   j|                          j                  |        j                           j                          |
r3|	t        j                  j                  d      }	 j                  |	       n j                          tQ        j                   j                  d       y)zCreate Shell instance.Nr   r   )Interpreterr   F)r   rawinstdinstdoutstderrr   c                 $    j                         S rX   )Cutevtr0   s    r:   <lambda>z Shell.__init__.<locals>.<lambda>I  s    488: r;   )r   c                 $    j                         S rX   )Copyr   s    r:   r   z Shell.__init__.<locals>.<lambda>J      499; r;   c                 $    j                         S rX   )CopyWithPromptsr   s    r:   r   z Shell.__init__.<locals>.<lambda>K  s    4+?+?+A r;   c                 $    j                         S rX   )Paster   s    r:   r   z Shell.__init__.<locals>.<lambda>L      4::< r;   c                 $    j                         S rX   )PasteAndRunr   s    r:   r   z Shell.__init__.<locals>.<lambda>M  s    4+;+;+= r;   c                 $    j                         S rX   )	SelectAllr   s    r:   r   z Shell.__init__.<locals>.<lambda>N  s    4>>+; r;   c                 $    j                         S rX   )Clearr   s    r:   r   z Shell.__init__.<locals>.<lambda>O  r   r;   c                 $    j                         S rX   )Undor   s    r:   r   z Shell.__init__.<locals>.<lambda>P  r   r;   c                 $    j                         S rX   )Redor   s    r:   r   z Shell.__init__.<locals>.<lambda>Q  r   r;   c                 B    | j                  j                               S rX   EnableCanCutr   s    r:   r   z Shell.__init__.<locals>.<lambda>S      

4;;=0I r;   c                 B    | j                  j                               S rX   r   r   s    r:   r   z Shell.__init__.<locals>.<lambda>T  r   r;   c                 B    | j                  j                               S rX   r   CanCopyr   s    r:   r   z Shell.__init__.<locals>.<lambda>U      

4<<>0J r;   c                 B    | j                  j                               S rX   r   r   s    r:   r   z Shell.__init__.<locals>.<lambda>V  r   r;   c                 B    | j                  j                               S rX   r   CanPaster   s    r:   r   z Shell.__init__.<locals>.<lambda>W      

4==?0K r;   c                 B    | j                  j                               S rX   r   r   s    r:   r   z Shell.__init__.<locals>.<lambda>X  r   r;   c                 B    | j                  j                               S rX   )r   CanUndor   s    r:   r   z Shell.__init__.<locals>.<lambda>Y  r   r;   c                 B    | j                  j                               S rX   )r   CanRedor   s    r:   r   z Shell.__init__.<locals>.<lambda>Z  r   r;   PYTHONSTARTUP)Ir	   
EditWindowr$   r   __main__rn   rG   r   r   r   interpreterr   r   readline	readlinesreaderinput	isreading	raw_inputr   writeOutr   writeErrinterpr   buffergetAutoCompleteKeysautoCompleteKeyspromptPosStartpromptPosEndmore
lastUpdatehistoryhistoryIndexnoteModeMarkerDefiner   STC_MARK_ROUNDRECT	searchTxtBindr&   EVT_CHAROnCharEVT_KEY_DOWN	OnKeyDownEVT_CONTEXT_MENUOnContextMenuID_CUTID_COPYID_PASTEID_SELECTALLID_CLEARID_UNDOID_REDONewIdRefEVT_MENUr
   ID_COPY_PLUSID_PASTE_PLUSEVT_UPDATE_UIr=   EVT_IDLEOnIdle	showIntrosetBuiltinKeywordssetLocalShellosenvirongetr"   r   	CallAfterScrollToLine)r0   r   r   r2   r3   r4   r   r   r    r!   r"   
useStockIdr7   r8   r   r   s   `               r:   r$   zShell.__init__   s    	&&tVRdEJ		>&&F YY
jjjj 0%K #4==$..A % "
 $( *0(,(,)6t}})E)6t}})E	1
 ,01 h !% ? ? A   	   !C223 			"++t{{+		"//4>>2 			"%%t'9'9: ))DK::DLKKDM "DKKDM::DL::DL++-DK;;=DLKKMDM "DKKMDM;;=DL;;=DL 			"++5$++	F		"++64<<	H		"++AeFXFX	Y		"++7DMM	J		"++=%BUBU	V		"++;@Q@Q	R		"++7DMM	J		"++64<<	H		"++64<<	H		"""$Idkk	Z		"""$Idmm	\		"""$Jt||	\		"""$JuOaOa	b		"""$KPTP]P]	^		"""$KPUPcPc	d		"""$Jt||	\		"""$Jt||	\ 		"++t{{+ 	y! 	! 	 $ "

 ?""=1KKM
T&&*r;   c                 L    g | _         d| _        t        j                  d       y )Nr   zShell.clearHistorysignal)r   r   r   sendrY   s    r:   clearHistoryzShell.clearHistoryy  s    34r;   c                     | ` y rX   )r   rY   s    r:   rA   zShell.destroy  s    Kr;   c                 $    | j                          y)zSet focus to the shell.N)r.   rY   s    r:   setFocuszShell.setFocus      r;   c                 f    | j                   rt        j                  d       |j                          y)z Free the CPU to do other things.g?N)r=   timesleepSkiprC   s     r:   r   zShell.OnIdle  s    <<JJt

r;   c                 B   |r| j                  |       	 | j                  j                  rf|r>|j                  t        j
                        s| j                  t        j
                         | j                  | j                  j                         yy# t        $ r Y yw xY w)z'Display introductory text in the shell.N)rr   r   r   endswithr   lineseprw   r0   rR   s     r:   r   zShell.showIntro  st    JJt	{{$$bjj 9JJrzz*

4;;001 %  		s   A;B 	BBc                     ddl m} dx|_        x|_        |_        t
        |_        t        |_        t        |_        t        |_        y)zwCreate pseudo keywords as part of builtins.

        This sets "close", "exit" and "quit" to a helpful string.
        r   )builtins3Click on the close button to leave the application.N)		six.movesr  closeexitr   r   r   r   r   )r0   r  s     r:   r   zShell.setBuiltinKeywords  s>    
 	'A	B 	Br;   c                 &    | j                  d       y)zQuit the application.r  Nrr   rY   s    r:   r   z
Shell.quit  s     	

HIr;   c                 J    t        |       | j                  j                  d<   y)z;Add 'shell' to locals as reference to ShellFacade instance.)rl   r,   N)rj   r   r   rY   s    r:   r   zShell.setLocalShell  s    &1&=7#r;   c                 $   |r}t         j                  j                  |      r^d|z   }t        r)| j	                  d|z         | j	                  d|z         n| j	                  d|d|d       || j
                  _        y| j	                  d       y)	z9Execute the user's PYTHONSTARTUP script if they have one.zStartup script executed: z	print(%r)z,with open(%r, "r") as f:
    exec(f.read())
zprint(z); execfile()r   N)r   pathisfiler   pushr   r!   )r0   r!   rR   s      r:   r"   zShell.execStartupScript  sw    RWW^^M:.>D		+,-		 14AC D 		t]KL(5DKK%IIbMr;   c                    t         t        t        t        j                  j                         d   t        j                  t        t        j                        t        j                  fz  }| j                  |j                                y)zDisplay information about Py.r   N)DISPLAY_TEXT
__author__r   rG   rI   rJ   r&   rK   strrM   rH   rr   stripr  s     r:   r~   zShell.about  s[     	W				Q	!2!2C4H		 	

4::< r;   c                 V   | j                   r|j                          y| j                         sy|j                         }| j	                         }| j
                  }|t        j                  t        j                  fv ry|| j                  v rw| j                         r| j                          | j                  ||      t        |      z   }| j                  t        |             | j                  r| j!                  |       yy|t#        d      k(  r| j                         r| j                          | j%                  d       | j                  ||      dz   }| j                  d       | j'                  || j	                         | j)                         k(         y|j                          y)z|Keypress event handler.

        Only receives an event if OnKeyDown calls event.Skip() for the
        corresponding event.N(r   )r   r  CanEdit
GetKeyCodeGetCurrentPosr   r&   
WXK_RETURNWXK_NUMPAD_ENTERr   AutoCompActiveAutoCompCancelGetTextRangechrrr   r   autoCompleteShowordReplaceSelectionautoCallTipShowGetTextLength)r0   rD   keycurrposstopposcommands         r:   r   zShell.OnChar  s^    ==JJL ||~ $$&##2==""5"566D))) ""$##%''9CHDGJJs3x   %%g. !CH_ ""$##% !!"%''9C?GJJsO  $*<*<*>$BTBTBV*VW JJLr;   c                 &   |j                         }| j                         r|j                          y|j                         }|j	                         }|j                         }|j                         }| j                         }| j                         }| j                         | j                         k7  }	|s|r|r|t        d      t        d      fv rz| j                         }
| j                  |
      }|dz  r| j                  |
      }| j                  |
d       | j!                         }|
dz  }
|
}|
|k  r3| j#                  |
      dk(  r|
dz  }
|
|k  r| j#                  |
      dk(  r| j%                  |
dz
        }| j'                  ||
dz
         | j)                  ||       y| j+                         \  }}|dz  }| j-                  |      }| j-                  |      }|| j-                  | j.                        k(  r|dz  }| j                  |      }| j1                  |d       | j3                  |dz   |       | j5                  |       |t6        j8                  k(  r| j:                  r| j                  | j!                         dz
        t=        t?        t@        jB                              z   | _        | jE                  | j!                                | jG                  | j.                         | jI                          | jK                  d       | jM                  d       | jO                  d       n3| jK                  d       | jM                  d	       | jO                  d       | j:                   | _        y| j:                  r|j                          y|sY|sW|sU|sS|t6        jP                  t6        jR                  fv r1| jU                         r| jW                          | jY                          y|r3|t6        jP                  t6        jR                  fv r| j[                          y|s|ri|t6        jP                  t6        jR                  fv rG| jU                         r| jW                          ||k(  r| jY                          y| j]                          y|s|r|r|j                          y|t6        j^                  k(  r2| jU                         r|j                          y| ja                          y|t6        jb                  k(  r|s|r|r| ja                          y|s|r4|t        d
      t6        jd                  fv rtg        jh                  d       y|s|r4|t        d      t6        jj                  fv rtg        jh                  d       y|s|r4|t        d      t6        jl                  fv rtg        jh                  d       y|s|r|t        d      t        d      fv s|r$|t6        jn                  k(  r| jq                          y|s|r:|s8|t        d      t        d      t6        jr                  fv r| ju                          y|s|r:|r8|t        d      t        d      t6        jr                  fv r| jw                          y|r:|s8|t        d      t        d      t6        jr                  fv r| jy                          y|s|rn|t6        jz                  k(  r[| j.                  }||kD  r7| j5                  |       |	s6|s3| j}                  |       | j                          y|j                          yyy|t6        jz                  k(  r| j.                  }||kD  r| j                         \  }}| j                         }|dd	 t@        jB                  t@        j                  t@        j                  fv rC| j5                  |d	z   |z
         |	sM|sJ| j}                  |d	z   |z
         | j                          y|j                          y|j                          yyy|	r|t        vr| j                         sy|s|r|s|t        d      t        d      fv s|r&|s$|t6        jr                  k(  r| j                          y|s|r%|t6        j                  k(  r| j                  |       y|s|r+|r)|t        d      t        d      fv r| j                          y|s|r|s|t6        j                  k(  s|r+|t        d      t        d      fv r| j                  d       y|s|r|s|t6        j                  k(  s|r+|t        d      t        d      fv r| j                  d       y|s|r8|r6|t6        j                  k(  r#| j                         r| j                  d       y|s|r8|r6|t6        j                  k(  r#| j                         r| j                  d       y|t6        j                  k(  r| j                          y|t6        jb                  k(  rD|	r!| j                         r|j                          y|| j.                  kD  r|j                          yy|t6        j                  t6        jn                  fv r"| j                         r|j                          yy|t6        jr                  k(  ry|r|t        d      t        d      fv ry|r|t        d      t        d       fv ry|t        v r|j                          y| j                         sy|j                          y)!zKey down event handler.NFfr   r   blacki  red   ]FontIncreaser  [FontDecrease=FontDefaultXxCcVvPp)stepNnr   LlTt)Pr(  r,  r  ControlDownRawControlDownAltDown	ShiftDownr)  r4  GetSelectionStartGetSelectionEndr1  GetCurrentLine	MarkerGetPositionFromLineMarkerDeleteGetLineCountGetLineVisibleGetLineEndPosition	ShowLinesSetSelectionGetSelectionLineFromPositionr   	MarkerAdd	HideLinesSetCurrentPosr&   WXK_F12r   lenr#  rG   ps1GotoLineGotoPosr   SetCaretForegroundSetCaretWidthSetCaretPeriodr*  r+  CallTipActiveCallTipCancelprocessLineOnShowCompHistoryinsertLineBreak
WXK_ESCAPEclearCommandWXK_BACKWXK_NUMPAD_ADDr   r  WXK_NUMPAD_SUBTRACTWXK_NUMPAD_DIVIDE
WXK_DELETEr   
WXK_INSERTr   r   CopyWithPromptsPrefixedWXK_HOME	SetAnchorEnsureCaretVisible
GetCurLineps2ps3NAVKEYSr'  r   	WXK_SPACEOnCallTipAutoCompleteManuallyr   WXK_UPOnHistoryReplaceWXK_DOWNOnHistoryInsertWXK_F8OnHistorySearchWXK_TAB)r0   rD   r5  controlDownrawControlDownaltDown	shiftDownr6  endpos	selectinglimstartPmaxlili0endPstartLendLhomeline_strline_lenr2   s                         r:   r   zShell.OnKeyDown  s      JJL '')--/--/OO%	$$&##%**,0D0D0FF	kySSXsSVxDX=X$$&Br"A4x..r2!!"a())+ah4#6#6r#:a#?!GB h4#6#6r#:a#?..r!t4sBqD)!!641++-KF4!GD**62F((.D t,,T->->??	v&ANN61%NN6!8D)("**}} (($*;*;*=a*?As377|$% ! d//12T../''0""1%##C(''.""1%##A& $-DM==JJL  ;	'2==""5"566!!#""$ 32=="2E2E"FF""$ H[H[8\1\!!#""$&   "$$& JJL BMM!!!#

!!# BKK^{	 S2CTCT8U1UOO>2 S2CYCY8Z1ZOO>2 S2CWCW8X1XOO=1 ##c(CH9M2M3"--#7HHJ YSXs3x??IIK SXs3x??  " [SXs3x??((* 1C$$D~""4( NN4(++-

	 *3y BKK$$D~&*oo&7#(&&(BQ<CGGCGGCGG#<<&&s1uX~6$Ys1uX~6//1JJL

 .79 3g-dlln iCCPSHVYZ]V^K_D_{sbmm7KJJL 1D..y9 ss3xQTUXQYFZ?Z iC299DTS3s8(<!<!!r!* iC2;;DVS3s8(<!<!!r!* )ryy@PVZVbVbVd  b ) )r{{@RX\XdXdXf  b ) BII  " BKKT\\^

4,,,

 - RZZ//||~

  BMM! SSXs3x$88  SSXs3x$88  G^JJL  JJLr;   c                   
 | j                   dd }dj                  |      }ddl}|j                  d|      }g }|D ]"  }t	        |      dkD  s|j                  |       $ t        t	        |            D cg c]  }||   |d| vs||    }}d 
|j                  t        
fd             | j                  d	       dj                  |      }| j                         dz
  }	t        | j                  |	            j                         r.|	dz  }	t        | j                  |	            j                         r.| j                  | j                         |	z
  dz
  |       yc c}w )
z<Show possible autocompletion Words from already typed words.N r   z[ \.\[\]=}(\)\,0-9\"]r   c                     | |kD  | |k  z
  S rX   rh   )abs     r:   _cmpz%Shell.OnShowCompHistory.<locals>._cmp  s    !eA&'r;   c                 N     | j                         |j                               S rX   )lower)r  r  r  s     r:   r   z)Shell.OnShowCompHistory.<locals>.<lambda>  s    QWWY	0J r;   )r5  T)r   rL   rerJ   ri  appendranger   r   AutoCompSetIgnoreCaser)  r/  	GetCharAtisalnumAutoCompShow)r0   hisjoinedr  newlistthlistiunlist
stringlistcposr  s             @r:   rs  zShell.OnShowCompHistory  sQ    ll1o 3 ((3V<  	"AAw{q!	" &+3v;%7W6!9FSUTUJ;V&)WW	(
#JKL 	""4( XXf%

 !!#a'4>>4()113AID 4>>4()113 	$,,.5q8*E+ Xs   7E#E#c                     | j                   }| j                         }| j                  ||       | j                  d       d| _        y)z'Delete the current, unexecuted command.r   FN)r   r4  rb  r2  r   )r0   startposr  s      r:   rv  zShell.clearCommand%  s@    $$##%(F+b!	r;   c                 F    | j                          | j                  |       y)z?Replace with the previous/next command from the history buffer.N)rv  replaceFromHistory)r0   rM  s     r:   r  zShell.OnHistoryReplace-  s    %r;   c                    t        t        j                        }| j                  d       | j                  |z   }d|cxk  rt        | j                        k  r
n n|| _        d|cxk  rt        | j                        dz
  k  rQn y| j                  | j                     }|j                  dt        j                  |z         }| j                  |       yy)z7Replace selection with command from the history buffer.r   r   r   r   r   N)
r#  rG   r  r2  r   ri  r   r*   r   r  )r0   rM  r  newindexr8  s        r:   r  zShell.replaceFromHistory2  s    #''lb!$$t+.S.. (D/C-a//ll4#4#45GoodBJJ,<=G!!'* 0r;   c                     | j                         sy| j                         }| j                  |       | j                         }| j                  ||       y)z9Insert the previous/next command from the history buffer.N)r'  r)  r  rb  )r0   rM  r  r  s       r:   r  zShell.OnHistoryInsert>  sH    ||~%%'%##%&(+r;   c                    | j                         sy| j                         }| j                         |z
  }| j                  d      }|dkD  r|d|  }|sy| j                  dk  s%| j                  t        | j                        dz
  k\  rt        t        | j                              }nIt        t        t        | j                                    }|| j                  dz   d |d| j                   z   }|D ]j  }| j                  |   }|dt        |       |k(  s$| j                  |t        |      d        | j                         }| j                  ||       || _         y y)zASearch up the history buffer for the text in front of the cursor.NFrstripr   r   r   r   )r'  r)  r4  
getCommandr   ri  r   r  r   r2  rb  )	r0   r  numCharsAfterCursor
searchTextsearchOrderr   r  r8  r  s	            r:   r  zShell.OnHistorySearchG  sT   ||~%%'"002X=__E_2
"#$9&9%9:J #T\\!21!44DLL 12KeC-./BT..q012R8J9J9J5KKK 		All1oG'J(J6%%gc*o.>&?@++-!!&(3$%!		r;   c                     t        |       y)zDisplay status information.N)printr  s     r:   r-   zShell.setStatusTextf  s    
 	dr;   c                     | j                         r7| j                  t        j                         d| _        | j                          yy)zInsert a new line break.TN)r'  rr   r   r  r   r   rY   s    r:   rt  zShell.insertLineBreakm  s0    <<>JJrzz"DIKKM r;   c                    | j                         }| j                  }| j                         }t        t        j
                        }| j                         r| j                  |       d| j                  _	        | j                  ||      }|j                  t        j                  |z         }|D cg c]  }|j                          }}dj                  |      }| j                   j"                  r5|sd}|| j                   _        | j'                  t        j                         y| j)                  |       t+        j,                  d| j.                         y| j1                  d      r2| j3                         }| j5                          | j'                  |       y| j                  |       | j7                  |       yc c}w )z5Process the line of text at which the user hit Enter.Fr   r   r  N)r)  r   r4  r#  rG   r  r'  rg  r   r   r.  rJ   r   r  r  rL   r   r   r   rr   r  r&   	CallLaterr  r  getMultilineCommandrv  r  )r0   theposr  r  r  r8  lineslines           r:   rr  zShell.processLinet  sW    ##%$$##%#''l <<>v&$DKK''&9GMM"**s"23E/45tT[[]5E5ii&G{{$$ #G$+!

2::&		'"Q 7 78 e,224!!#

7# ""6*v&/ 6s   1F?c                    t        t        j                        }t        |      }t        t        j                        }t        |      }| j                         d   }| j                         }|d| |k(  r<|dkD  r7|dz  }| j                  |       | j                         d   }|d| |k(  r|dkD  r7|d| |k(  r*| j                         }| j                  |       | j                         |z   }|dz  }| j                  |       | j                         d   d| |k(  rN|| j                  k  r?|dz  }| j                  |       | j                         d   d| |k(  r|| j                  k  r?| j                         }	| j                  ||	      }
|
j                  t        j                  |z   d      }
|
j                         }
|
j                  dt        j                  |z         }
nd}
|r|
j                         }
|
S )znExtract a multi-line command from the editor.

        The command may not necessarily be valid Python syntax.r   Nr   r   r   )r#  rG   rj  ri  r  r  rZ  rk  r)  	LineCountr.  r*   r   r  r  )r0   r  rj  ps1sizer  ps2sizerR   r  r  r7  r8  s              r:   r  zShell.getMultilineCommand  s    #''lc(#''lc( #""$8Gn#qAIDMM$??$Q'D 8Gn#q >S &&(DMM$))+g5HAIDMM$//#A&x0C7D4>><Q	d# //#A&x0C7D4>><Q ((*G''':Goobjj3&6=Gnn&GoodBJJ,<=GGnn&Gr;   c                     |s| j                         d   }| j                  |      }||k(  rd}|r|j                         }|S )z~Extract a command from text which may include a shell prompt.

        The command may not necessarily be valid Python syntax.r   r   )r  lstripPromptr  )r0   rR   r  r8  s       r:   r  zShell.getCommand  sH     ??$Q'D##D)d?Gnn&Gr;   c                     t        t        j                        }t        |      }t        t        j                        }t        |      }|d| |k(  r||d }|S |d| |k(  r||d }|S )z%Return text without a leading prompt.N)r#  rG   rj  ri  r  )r0   rR   rj  r  r  r  s         r:   r  zShell.lstripPrompt  sn    #''lc(#''lc(>S >D  (7^s">Dr;   c                    |s| j                  t        j                         t        rt	        |      }t        j                         }d| _        d| _        | j                  j                  |      | _        d| _        d| _        ~| j                  s| j                  |j                                |s| j                          yy)z.Send command to the interpreter for execution.TNF)rr   r   r  	USE_MAGICr   r&   
BusyCursorr=   r   r   r  r   
addHistoryr  r   )r0   r8  silentbusys       r:   r  z
Shell.push  s    JJrzz" 'NG}}KK$$W-	yyOOGNN,-KKM r;   c                     d| _         |dk7  r_t        | j                        dk(  s|| j                  d   k7  r4| j                  j                  d|       t	        j
                  d|       yyy)z#Add command to the command history.r   r   r   zShell.addHistory)r  r8  N)r   ri  r   insertr   r  )r0   r8  s     r:   r  zShell.addHistory  sc      b=!#w$,,q/'ALL7+OO#5wG (B r;   c                 v   | j                  |      }| j                  |       | j                          | j                  r{| j                  dk(  rt        j
                         | _        t        j
                         | j                  z
  t        kD  r*| j                          t        j
                         | _        yyy)zRDisplay text in the shell.

        Replace line endings with OS-specific endings.N)fixLineEndingsAddTextr  r=   r   r  PRINT_UPDATE_MAX_TIMEUpdater  s     r:   rr   zShell.write  s     ""4(T!<<$ $		yy{4??*-BB $		 C r;   c                    |j                  d      }t        t        |            D ]  }||   j                  d      }t        t        |            D ]6  }t        j                  j                  ||   j                  d            ||<   8 t        j                  j                  |      ||<    t        j                  j                  |      }|S )z>Return text with line endings replaced by OS-specific endings.z
r   )rJ   r  ri  r   r  rL   )r0   rR   r  rQ  chunksrH  s         r:   r  zShell.fixLineEndings  s    

6"s5z" 	/A1X^^D)F3v;' CJJOOF1IOOD,ABq	Czzv.E!H		/
 zzu%r;   c                    | j                   j                  }d}|rt        t        j                        }n?| j
                  rt        t        j                        }nt        t        j                        }| j                         d   }|dkD  r$|rd}n| j                  t        j                         | j
                  s| j                         | _        |s| j                  |       | j
                  s%| j                         | _        | j                          | j
                  r | j!                         }| j#                  |      }| j#                  |dz
        t%        |      d }|j'                         }|j)                         }	g }
|D ]%  }|j+                         r|
j-                  |       % n dj/                  |
      }
|dk(  r!|j'                  d      j'                  d      }n+|dt%        |      t%        |	      z
   }|d	   d
k(  r	|
dv r|dz  }| j                  |       | j1                          | j3                  d       y)zyDisplay proper prompt for the context: ps1, ps2 or ps3.

        If this is a continuation line, autoindent as necessary.Fr   r   TNr   r   r  r   :)ifelseelifforwhilewithdefclasstryexceptfinally    )r   r   r#  rG   r  r   r  rj  r  rr   r   r  r)  r   r   EmptyUndoBufferrZ  GetLineri  r$  lstripr  r  rL   r  ScrollToColumn)r0   r   skipr   r2   line_numcurrentLinepreviousLinepstripr  
first_wordr  indents                r:   r   zShell.prompt  s    KK))	\FYY\F\Foo"7

2::&yy"&"4"4"6DJJvyy $ 2 2 4D  "99((*HX.Khqj1#f+,?L%%'F&&(F J 99;%%a(	
 ,J|#))$/55d;#$Dc,&7F&CE":s? #K KEMFJJv!Ar;   c                 <   d}| j                   }d|_        | j                          	 |j                  s1t	        j
                         j                  d       |j                  s1|j                  }d|_        d|_        t        |      }|S # d|_        d|_        w xY w)z!Replacement for stdin.readline().r   T)onlyIfNeededF)r   r   r   r   r&   GetAppYieldr#  )r0   r   r   s      r:   r   zShell.readlineQ  s    	%ll		!!t!4 llLLEFL$FE
 FL$Fs   <B $B Bc                 n    g }|dd dgk7  r)|j                  | j                                |dd dgk7  r)|S )z"Replacement for stdin.readlines().r   Nr   )r  r   )r0   r  s     r:   r   zShell.readlinesa  s@    BCjTF"LL) BCjTF"r;   c                 H    |r| j                  |       | j                         S )z"Return string based on user input.)rr   r   )r0   r   s     r:   r   zShell.raw_inputh  s    JJv}}r;   c                    t        j                  d|dd      }	 |j                         t         j                  k(  r"|j	                         }||j                          S 	 |j                          y# |j                          w xY w)z.Get response from the user using a dialog box.NzInput Dialog (Raw)r   )r&   TextEntryDialogrQ   ID_OKGetValuerB   )r0   r   rS   rR   s       r:   r   z	Shell.askn  sp    ##D&$8">	!RXX-(NN	 . NN NNs   2A/ /Bc                 &    | j                  d       y)z0Halt execution pending a response from the user.zPress enter to continue:N)r   rY   s    r:   r   zShell.pausez  s    +,r;   c                 $    | j                          y)zDelete all text from the shell.N)ClearAllrY   s    r:   r   zShell.clear~  r	  r;   c                     | j                         }| j                  |       |j                         }|r| j                          |r| j	                  |       | j                  |       y)zExecute command as if it was typed in directly.
        >>> shell.run('print("this")')
        >>> print("this")
        this
        >>>
        N)r4  rg  r  r   rr   r  )r0   r8  r   verboser  s        r:   r   z	Shell.run  sQ     ##%6".."4;;=DJJw'		'r;   c                     | j                          t        |      5 }|D ]3  }|dd dk(  r| j                  |dd        | j                  |dd       5 	 ddd       y# 1 sw Y   yxY w)zJExecute all commands in file as if they were typed into the
        shell.N   zshell.F)r   r  T)r   openr   )r0   filenamefile_r8  s       r:   r   zShell.runfile  sr     	(^ 	Bu  B2A;(*HHWUEHBHHWUDHAB	B 	B 	Bs   9AA(c                 6   | j                  | j                         | j                  | j                         | j                  j                  || j                  | j                  | j                        }|r$dj                  |      }| j                  ||       yy)z#Display auto-completion popup list.)includeMagicincludeSingleincludeDoubler  N)AutoCompSetAutoHider   r  r   r   getAutoCompleteListr   r   r   rL   r  )r0   r8  offsetr   optionss        r:   r0  zShell.autoCompleteShow  s      !:!:;""4#C#CD{{..w!%!>!>"&"@"@"&"@"@ / B hhtnGfg. r;   c                    | j                         r| j                          | j                  j                  |      \  }}}|rt	        j
                  d| |       | j                  s|sy| j                         }|rD|rB| j                  r6| j                  |dz          | j                         }| j                  ||       |rD|t        |      dz   z
  }	|| j                  |      z
  }
t        |	|
      }	| j                  |	|       yy)z6Display argument spec and docstring in a popup window.zShell.calltip)r  sendercalltipNr  r   )rp  rq  r   
getCallTipr   r  r   r)  r   rr   rb  ri  	GetColumnmaxCallTipShow)r0   r8  insertcalltipforceCallTipre   argspectipr  r  tipposfallbacks              r:   r3  zShell.autoCallTipShow  s     #{{55g>wOO?4M%%'}););JJw}%'')Fh/TQ/F$.."::H *FVS) r;   c                 R   | j                         r| j                          | j                         }| j                  }|}d}||k\  r+| j	                  |      t        d      k(  r|}n|dz  }||k\  r+|dk7  r1| j                  |dz   |      }|dz  }|s:| j                  }| j                  ||      }| j                  |t        |             y|}d}||kD  r6t        | j	                  |            j                         r|}n|dz  }||kD  r6|dk(  r|}| j                  ||      }	|	j                  d      }
|
dk7  rl| j                         s[| j                  |	d|
dz    | j	                  |dz
        t        d      k(  xr! | j                         | j                         k(  d       yyyy)z#AutoComplete and Calltips manually.r   .r   r&  NT)r,  r-  r)  r   r  r1  r.  r0  ri  r/  isspacefindrp  r3  r4  )r0   r  r6  r7  r  pointavailpos
textbehind
textbeforebegposctipsctindexs              r:   r  z#Shell.OnCallTipAutoCompleteManually  s    !$$&##go~~d#sCy0 $AID	 go B**MA,=wGJQM++!..wF
%%j#z2BC %Wn4>>$/088:!%AID	 Wn
 R<!F))67;**c*b=););)=((|!)<w{3s3x? H--/43E3E3GG *>=/ r;   c                 &    | j                  |       y)zReplacement for stdout.Nr  r  s     r:   r   zShell.writeOut      

4r;   c                 &    | j                  |       y)zReplacement for stderr.Nr  r  s     r:   r   zShell.writeErr  r1  r;   c                 ^    |r| j                   t        _        y| j                  t        _        y)z<If redirect is true then sys.stdin will come from the shell.N)r   rG   r   r0   redirects     r:   r   zShell.redirectStdin  s    CI

CIr;   c                 p    |rt        | j                        t        _        y| j                  t        _        y)z9If redirect is true then sys.stdout will go to the shell.N)r   r   rG   r   r4  s     r:   r   zShell.redirectStdout       &t}}5CJCJr;   c                 p    |rt        | j                        t        _        y| j                  t        _        y)z9If redirect is true then sys.stderr will go to the shell.N)r   r   rG   r   r4  s     r:   r   zShell.redirectStderr  r7  r;   c                     | j                         | j                         k7  r;| j                         | j                  k\  r| j                         | j                  k\  ryy)z/Return true if text is selected and can be cut.TF)rX  rY  r   rY   s    r:   r   zShell.CanCut  sP    !!#t';';'==))+t/@/@@'')T->->>r;   c                 d    | j                         r t        j                  j                  |       ryy)z&Return true if a paste should succeed.TF)r'  r	   r   r   rY   s    r:   r   zShell.CanPaste  s$    <<>j33<<TBr;   c                     | j                         | j                         k7  r<| j                         | j                  k\  r| j                         | j                  k\  ryy| j                         | j                  k\  S )z&Return true if editing should succeed.TF)rX  rY  r   r)  rY   s    r:   r'  zShell.CanEdit  sj    !!#t';';'==%%'4+<+<<++-1B1BB%%'4+<+<<<r;   c                 
   | j                         rs| j                         rb| j                         r| j                          | j	                         r| j                          | j                          | j                  d       yyy)z/Remove selection and place it on the clipboard.r   N)r   r   r,  r-  rp  rq  r   r2  rY   s    r:   r   z	Shell.Cut(  sa    ;;=T\\^""$##%!!#""$IIK!!"% ,=r;   c                    | j                         rt        t        j                        }t        t        j                        }| j                         }|j                  t        j                  |z   t        j                        }|j                  t        j                  |z   t        j                        }| j                  |      }t        j                  |      }| j                  |       yy)z-Copy selection and place it on the clipboard.rR   N)r   r#  rG   rj  r  GetSelectedTextr*   r   r  r  r&   TextDataObject_clip)r0   rj  r  r8  datas        r:   r   z
Shell.Copy2  s    <<>cgg,Ccgg,C**,Goobjj3&6

CGoobjj3&6

CG''W'5G$$W-DJJt r;   c                     | j                         r7| j                         }t        j                  |      }| j	                  |       yy)zACopy selection, including prompts, and place it on the clipboard.N)r   r?  r&   r@  rA  )r0   r8  rB  s      r:   r   zShell.CopyWithPrompts>  s:    <<>**,G$$W-DJJt r;   c                     | j                         rm| j                         }d}||j                  t        j                  t        j                  |z         z   }t        j                  |      }| j                  |       yy)zcCopy selection, including prompts prefixed with four
        spaces, and place it on the clipboard.r  N)r   r?  r*   r   r  r&   r@  rA  )r0   r8  spacesrB  s       r:   r}  zShell.CopyWithPromptsPrefixedE  sj     <<>**,GFwrzz/1zzF/B D DG$$W-DJJt r;   c                 6   t         j                  j                         r{t         j                  j                  d       t         j                  j	                  |       t         j                  j                          t         j                  j                          y y )NF)r&   TheClipboardOpenUsePrimarySelectionSetDatar^   Close)r0   rB  s     r:   rA  zShell._clipP  s[    ??!OO//6OO##D)OO!!#OO!!#	 "r;   c                 R   | j                         rt        j                  j                         rvt	        t
        j                        }t        j                  j                  t        j                  t        j                              rt        j                         }t        j                  j                  |      r| j                  d       |j                         }|j                         }| j                  |      }| j!                  |      }|j#                  t$        j&                  |z   d      }|j#                  t$        j&                  d      }|j#                  dt$        j&                  |z         }| j)                  |       t        j                  j+                          yyy)z*Replace selection with clipboard contents.r   r>  r   N)r   r&   rG  rH  r#  rG   r  IsSupported
DataFormatDF_UNICODETEXTr@  GetDatar2  GetTextr  r  r  r*   r   r  rr   rK  )r0   r  rB  r8  s       r:   r   zShell.PasteW  s   ==?r335cgg,C**2==9J9J+KL((*??**40))"-"llnG%nn.G"11':G"//W/=G%oobjj3.>EG%oobjj$?G%oodBJJ4DEGJJw'OO!!#  6?r;   c                    d}t         j                  j                         rt         j                  j                  t        j                  t         j
                              rCt        j                         }t         j                  j                  |      r|j                         }t         j                  j                          |r| j                  |       yy)z8Replace selection with clipboard contents, run commands.r   N)r&   rG  rH  rM  rN  rO  r@  rP  rQ  rK  Execute)r0   rR   rB  s      r:   r   zShell.PasteAndRunj  s    ??!**2==9J9J+KL((*??**40<<>DOO!!#LL r;   c                 ,   t        t        j                        }t        t        j                        }| j	                         }| j                  |       | j                  }| j                  ||       | j                  d       |j                         }| j                  |      }| j                  |      }|j                  t        j                  |z   d      }|j                  t        j                  |z   d      }|j                  t        j                  d      }|j                  d      }g }d}|D ]  }	|	j!                         |j!                         k(  rd}	|	j                         }
|	j!                         dk7  r2|
|	k(  r-|
dd dvr&|
dd dk7  r|
dd d	k7  r|r|j#                  |       |	}{|dz  }||	z  } |j#                  |       |D ]F  }|j                  dt        j                  |z         }| j%                  |       | j'                          H y)
z-Replace selection with text and run commands.r   r   Nr>  )r  r  r  r     r  )r#  rG   rj  r  r4  rg  r   rb  r2  r  r  r  r*   r   r  rJ   r$  r  rr   rr  )r0   rR   rj  r  r  r  r  commandsr8  r  r  s              r:   rS  zShell.Executew  s   #''l#''l##%6"$$(F+b!{{}""4(  &||BJJ,d3||BJJ,d3||BJJ-

4  	 Dzz|syy{* [[]Fzz|r!fn2AJo52AJ(*2AJ)+OOG, 44)	 * 	  	GoodBJJ,<=GJJw	r;   c                 &    | j                  |       y)z"Sets whether text is word wrapped.N)SetWrapMode)r0   r   s     r:   r   z
Shell.wrap  s    r;   c                 &    | j                  |       y)zSet the zoom level.

        This number of points is added to the size of all fonts.  It
        may be positive to magnify or negative to reduce.N)SetZoom)r0   pointss     r:   r   z
Shell.zoom  s    
 	Vr;   c                    |j                  dd      | _        |j                  dd      | _        |j                  dd      | _        |j                  dd      | _        |j                  dd      | _        |j                  dd      | _        | j                  |j                  dd             |j                  d	d      | _        | j                  | j                         |j                  d
d      }|dk7  r| j                  |       y y )NOptions/AutoCompleteT Options/AutoCompleteIncludeMagic!Options/AutoCompleteIncludeSingle!Options/AutoCompleteIncludeDoubleOptions/AutoCallTipOptions/CallTipInsertView/WrapModeView/ShowLineNumbersView/Zoom/Shelli)ReadBoolr   r   r   r   r   r   rX  lineNumberssetDisplayLineNumbersReadIntrZ  )r0   r5   r   s      r:   r/   zShell.LoadSettings  s    OO2D9 	 OO>E 	% OO?F 	& OO?F 	& "??+@$G#__-DdK$?@!??+A4H""D$4$45~~/53;LL r;   c                    |j                  d| j                         |j                  d| j                         |j                  d| j                         |j                  d| j                         |j                  d| j
                         |j                  d| j                         |j                  d| j                                |j                  d| j                         |j                  d	| j                                y )
Nr]  r^  r_  r`  ra  rb  rc  rd  re  )	WriteBoolr   r   r   r   r   r   GetWrapModerg  WriteIntGetZoom)r0   r5   s     r:   r@   zShell.SaveSettings  s    /1B1BC;66	8<77	9<77	9.0@0@A0$2D2DE$*:*:*<=/1A1AB)4<<>:r;   c                 v   t        j                         }|j                  | j                  d       |j                  | j                  d       |j                          |j                  | j                  d       |j                  | j                  d       |j                  t        j                  d       |j                  | j                  d       |j                  t        j                  d       |j                  | j                  d       |j                          |j                  | j                  d	       |S )
z
            Create and return a context menu for the shell.
            This is used instead of the scintilla default menu
            in order to correctly respect our immutable buffer.
        r   r   r   r   zCopy With Promptsr   zPaste And Runr   z
Select All)r&   MenuAppendr   r   AppendSeparatorr   r   r
   r   r   r   r   r   )r0   menus     r:   GetContextMenuzShell.GetContextMenu  s     wwyDLL&)DLL&)DKK'DLL&)E&&(;<DMM7+E''9DMM7+D%%|4r;   c                 F    | j                         }| j                  |       y rX   )rt  	PopupMenu)r0   r   rs  s      r:   r   zShell.OnContextMenu  s    ""$tr;   )r   )T)NTr`   )zPlease enter your response:)TT)r   )TF)Hra   rb   rc   rd   re   r&   rf   r'   CLIP_CHILDRENr$   r  rA   r  r   r   r   r   r   r"   r~   r   r   rs  rv  r  r  r  r  r-   rt  rr  r  r  r  r  r  rr   r  r   r   r   r   r   r   r   r   r   r0  r3  r  r   r   r   r   r   r   r   r'  r   r   r   r}  rA  r   r   rS  r   r   r/   r@   rt  r   rh   r;   r:   r+   r+      s}   (D"$"*<*<nnB,<,<d#t 	L+^5
J>
!+\yx*FZ&

+,>('T#J*	H,	7r 
-
B/*,-`#%%	=&
	$$&
+\*;0r;   r+   )1rd   r"  r&   r   sixr   keywordr   rG   r  	functoolsr   r   r   r   r   r	   r
   pseudor   r   r   rI   r   r   r  r   r   r   r   r  r  r  WXK_ENDWXK_LEFT	WXK_RIGHTr  r  
WXK_PAGEUPWXK_PAGEDOWNr  r#   r%   r   ro   rj   r!  r   r+   rh   r;   r:   <module>r     s   H 8
 	    	 
          ! !    

	 ::r{{BLL99bkk2=="//CR e33 R n	B: :|JJ!! Jr;   