a
    ñ»j’w  ã                   @   sš   d dl m  mZ d dl mZ d dlmZ ddlmZ G dd„ deƒZ	G dd	„ d	eƒZ
G d
d„ deƒZG dd„ deƒZG dd„ dee	e
ejƒZdd„ ZdS )é    N)ÚPoint)Úlogé   )Úbasemodec                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚIncrementalSearchPromptModec                 C   s   d S ©N© ©ÚselfZrlobjr   r   ú=E:\soccer\ml_env\Lib\site-packages\pyreadline3/modes/emacs.pyÚ__init__   s    z$IncrementalSearchPromptMode.__init__c                 C   sÆ  t dƒ | ¡ }g }g }| j ¡ D ]2\}}|| jkr@| |¡ q"|| jkr"| |¡ q"t d||f ƒ |jdkr®| jd d… | _t	| jƒdkrž|  
| j¡| _n|  ¡  d| _nð|jdv �r|  ¡  | j| _| jd d… | _t	| jjƒ| j_|jdk�r| j | j¡ d	S |j�rnŒ||v �r<| jj| _
d
| _|  
| j¡| _nb||v �rf| jj| _
d| _|  
| j¡| _n8|jdk�rž|jdk�rž|  j|j7  _|  
| j¡| _n | j| jj| jf | _| j | j¡ d S )NÚ$_process_incremental_search_keyeventz!IncrementalSearchPromptMode %s %sÚ	backspaceéÿÿÿÿr   Ú ©ÚreturnÚescaper   Túreverse-i-search%d`%s': úforward-i-search%d`%s': F)r   ÚtupleÚkey_dispatchÚitemsÚreverse_search_historyÚappendÚforward_search_historyÚkey_nameÚsubsearch_queryÚlenÚsubsearch_funÚlineÚ_bellÚsubsearch_oldpromptÚpromptÚprocess_keyevent_queueÚ_historyÚhistoryÚhistory_cursorÚl_bufferÚset_lineÚsubsearch_old_lineÚsubsearch_promptÚcontrolÚmetaÚchar)r
   ÚkeyinfoÚkeytupleZ	revtuplesZ	fwdtuplesZktupleÚfuncr   r   r   r      sT    






þz@IncrementalSearchPromptMode._process_incremental_search_keyeventc                 C   s²   t dƒ d| _|| _| j ¡ | _| j}| | j¡ | j	| _
| j| jkrf| j| jkrf| jdt…  ¡ | _| j| jkrzd| _nd| _| j| jjdf | _	| jr¨|  |¡| _nd| _dS )úInitialize search promptZinit_incremental_searchr   r   r   r   N)r   r   r   r(   Úget_line_textr*   r$   r   r   r#   r"   Úprevious_funcr   r   r   r+   r%   r'   r    )r
   Z	searchfunZ
init_eventÚqueuer   r   r   Ú_init_incremental_searchH   s&    
ÿ
þz4IncrementalSearchPromptMode._init_incremental_searchN)Ú__name__Ú
__module__Ú__qualname__r   r   r6   r   r   r   r   r      s   1r   c                   @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )ÚSearchPromptModec                 C   s   d S r   r   r	   r   r   r   r   h   s    zSearchPromptMode.__init__c                 C   s  |  ¡ }td||f ƒ | j}|jdkr:| jd d… | _n¶|jdv rÂ| jrn| jdkrb| | j¡}n| | j¡}|  ¡  | j	| _
| jd d… | _t| jjƒ| j_|jdkr²| j| _n| j |¡ dS |jrÊn&|jdkrð|jdkrð|  j|j7  _n | j	d | j | _
d S )NzSearchPromptMode %s %sr   r   r   r   Fú:)r   r   r%   r   Únon_inc_queryÚnon_inc_directionr   r   r!   Únon_inc_oldpromptr#   r$   r   r&   r'   Únon_inc_oldliner(   r)   r,   r-   r.   )r
   r/   r0   r&   Úresr   r   r   Ú(_process_non_incremental_search_keyeventk   s.    




z9SearchPromptMode._process_non_incremental_search_keyeventc                 C   sL   || _ d| _| j| _| j ¡ | _| j ¡  | jd | _| j}| 	| j
¡ d S )Nr   r;   )r=   r<   r#   r>   r(   Úcopyr?   Z
reset_liner$   r   rA   )r
   Ú	directionr5   r   r   r   Ú_init_non_i_searchŠ   s    
z#SearchPromptMode._init_non_i_searchc                 C   s
   |   d¡S )z­Search backward starting at the current line and moving up
        through the history as necessary using a non-incremental search for
        a string supplied by the user.r   ©rD   ©r
   Úer   r   r   Ú&non_incremental_reverse_search_history”   s    z7SearchPromptMode.non_incremental_reverse_search_historyc                 C   s
   |   d¡S )z²Search forward starting at the current line and moving down
        through the the history as necessary using a non-incremental search
        for a string supplied by the user.r   rE   rF   r   r   r   Ú&non_incremental_forward_search_historyš   s    z7SearchPromptMode.non_incremental_forward_search_historyN)r7   r8   r9   r   rA   rD   rH   rI   r   r   r   r   r:   g   s
   
r:   c                   @   s   e Zd ZdS )ÚLeaveModeTryNextN)r7   r8   r9   r   r   r   r   rJ   ¡   s   rJ   c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚDigitArgumentModec                 C   s   d S r   r   r	   r   r   r   r   ¦   s    zDigitArgumentMode.__init__c                 C   s¸   t d| ƒ | ¡ }t d||f ƒ |jdv rJ| j| _| jd d… | _dS |jrRnV|jdv rœ|jdkrœ|jdkrœt d| j	|jf ƒ | j	d	 t
|jƒ | _	n| j| _t‚d
| j	 | _d S )NzDigitArgumentMode.keyinfo %sz DigitArgumentMode.keytuple %s %s)r   r   TÚ
0123456789Fz	arg %s %sé
   ú
(arg: %s) )r   r   r   Ú_digit_argument_oldpromptr#   r$   r.   r,   r-   ÚargumentÚintrJ   )r
   r/   r0   r   r   r   Ú _process_digit_argument_keyevent©   s(    
ÿþýz2DigitArgumentMode._process_digit_argument_keyeventc                 C   s”   | j }| j ¡ }| j| _| j}| j}| | j¡ |jdkrBd| _	n|jdv rXt
|jƒ| _	td| j	t| j	ƒf ƒ d| j	 | _td| j	|jf ƒ dS )r2   ú-r   rL   z<%s> %srN   zarg-init %s %sN)Úconsoler(   r3   r#   rO   r$   r   rR   r.   rP   rQ   r   Útype)r
   r/   Úcr    r5   r   r   r   Ú_init_digit_argument¿   s    


z&DigitArgumentMode._init_digit_argumentN)r7   r8   r9   r   rR   rW   r   r   r   r   rK   ¥   s   rK   c                   @   sÌ  e Zd Z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„ 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#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ ZeZd6d7„ Zd8d9„ Z d:d;„ Z!d<d=„ Z"d>d?„ Z#d@dA„ Z$dBdC„ Z%dDdE„ Z&dFdG„ Z'dHdI„ Z(dJdK„ Z)dLdM„ Z*dNdO„ Z+dPdQ„ Z,dRdS„ Z-dTdU„ Z.dVdW„ Z/dXdY„ Z0dZd[„ Z1d\d]„ Z2d^d_„ Z3d`da„ Z4dbdc„ Z5ddde„ Z6dfdg„ Z7dhdi„ Z8djdk„ Z9dldm„ Z:dndo„ Z;dpS )qÚ	EmacsModeÚemacsc                 C   sb   t j | |¡ t | |¡ t | |¡ t | |¡ dd„ | _d | _d| _d| _	d| _
| jg| _d S )Nc                 S   s   d S r   r   )ÚxÚyr   r   r   Ú<lambda>Û   ó    z$EmacsMode.__init__.<locals>.<lambda>z>>> F)r   ÚBaseModer   r   r:   rK   Ú_keylogr4   r#   Ú_insert_verbatimÚ	next_metaÚ_process_keyeventr$   r	   r   r   r   r   Ö   s    
zEmacsMode.__init__c                 C   s   dS )Nz<EmacsMode>r   )r
   r   r   r   Ú__repr__ã   s    zEmacsMode.__repr__c                 C   s
   || _ dS )zElogfun should be function that takes disp_fun and line_buffer object N)r_   )r
   Zlogfunr   r   r   Úadd_key_loggeræ   s    zEmacsMode.add_key_loggerc                 C   s\   z| j d |ƒ}W n, ty>   | j d d… | _ |  |¡}Y n0 |rX|  | j ¡ ¡ dS dS )Nr   TF)r$   rJ   Úprocess_keyeventZadd_historyr(   rB   )r
   r/   Úrr   r   r   re   ê   s    zEmacsMode.process_keyeventc                 C   sø   t d| ƒ dd„ }| jr&d| _d|_| ¡ }| jrN|  |¡ d| _d| _dS || jv rŠ| jt	 
| j¡f}t d| ƒ t	 
| j¡dkrŠt‚|jsœ|jsœ|jr¢|}n| j}| j ||¡}t d||f ƒ d	}|rî||ƒ}|  || j¡ | j ¡  || _|S )
zreturn True when line is finalz_process_keyevent <%s>c                 S   s   d S r   r   )rG   r   r   r   Únopú   s    z(EmacsMode._process_keyevent.<locals>.nopFTr   zexit_dispatch:<%s, %s>zreadline from keyboard:<%s,%s>N)r   ra   r-   r   r`   Úinsert_textrP   Zexit_dispatchr(   ÚlineobjÚ	EndOfLineÚEOFErrorr   r,   Úself_insertr   Úgetr_   Z	push_undor4   )r
   r/   rg   r0   ZparsÚdefaultZdispatch_funcrf   r   r   r   rb   õ   s8    


zEmacsMode._process_keyeventc                 C   s$   | j  | j¡ tj| j_|  ¡  dS )zJMove back through the history list, fetching the previous
        command.N)r%   Úprevious_historyr(   ri   rj   ÚpointÚfinalizerF   r   r   r   ro     s    
zEmacsMode.previous_historyc                 C   s   | j  | j¡ |  ¡  dS )zIMove forward through the history list, fetching the next
        command.N)r%   Únext_historyr(   rq   rF   r   r   r   rr   &  s    zEmacsMode.next_historyc                 C   s   | j  ¡  |  ¡  dS )z&Move to the first line in the history.N)r%   Úbeginning_of_historyrq   rF   r   r   r   rs   ,  s    
zEmacsMode.beginning_of_historyc                 C   s   | j  | j¡ |  ¡  dS )zUMove to the end of the input history, i.e., the line currently
        being entered.N)r%   Úend_of_historyr(   rq   rF   r   r   r   rt   1  s    zEmacsMode.end_of_historyc                 C   s$   t dƒ |  | jj|¡ |  ¡  dS )zƒSearch backward starting at the current line and moving up
        through the history as necessary. This is an incremental search.Zrev_search_historyN)r   r6   r%   r   rq   rF   r   r   r   r   7  s    z EmacsMode.reverse_search_historyc                 C   s$   t dƒ |  | jj|¡ |  ¡  dS )z�Search forward starting at the current line and moving down
        through the the history as necessary. This is an incremental
        search.Zfwd_search_historyN)r   r6   r%   r   rq   rF   r   r   r   r   >  s    z EmacsMode.forward_search_historyc                 C   s^   | j r,t| j| j jƒr,t| j| j jƒ| j_nd| j_| j | j¡}|| _|j| j_|  	¡  dS )zËSearch forward through the history for the string of characters
        between the start of the current line and the point. This is a
        non-incremental search. By default, this command is unbound.N)
r4   Úhasattrr%   r7   ÚgetattrÚlastcommandÚhistory_search_forwardr(   rp   rq   ©r
   rG   Úqr   r   r   rx   F  s    
ÿ

z EmacsMode.history_search_forwardc                 C   s^   | j r,t| j| j jƒr,t| j| j jƒ| j_nd| j_| j | j¡}|| _|j| j_|  	¡  dS )zÌSearch backward through the history for the string of characters
        between the start of the current line and the point. This is a
        non-incremental search. By default, this command is unbound.N)
r4   ru   r%   r7   rv   rw   Úhistory_search_backwardr(   rp   rq   ry   r   r   r   r{   U  s    
ÿ

z!EmacsMode.history_search_backwardc                 C   s   |   ¡  dS )aR  Insert the first argument to the previous command (usually the
        second word on the previous line) at point. With an argument n,
        insert the nth word from the previous command (the words in the
        previous command begin with word 0). A negative argument inserts the
        nth word from the end of the previous command.N©rq   rF   r   r   r   Úyank_nth_argd  s    zEmacsMode.yank_nth_argc                 C   s   |   ¡  dS )a  Insert last argument to the previous command (the last word of
        the previous history entry). With an argument, behave exactly like
        yank-nth-arg. Successive calls to yank-last-arg move back through
        the history list, inserting the last argument of each line in turn.Nr|   rF   r   r   r   Úyank_last_argl  s    zEmacsMode.yank_last_argc                 C   s   |   ¡  dS )zÅDelete the character under the cursor, unless the cursor is at
        the end of the line, in which case the character behind the cursor
        is deleted. By default, this is not bound to a key.Nr|   rF   r   r   r   Úforward_backward_delete_chars  s    z&EmacsMode.forward_backward_delete_charc                 C   s   d| _ |  ¡  dS )zuAdd the next character typed to the line verbatim. This is how to
        insert key sequences like C-q, for example.TN)r`   rq   rF   r   r   r   Úquoted_inserty  s    zEmacsMode.quoted_insertc                 C   s@   t | jjt| jjƒƒ}d| j|| j   }|  |¡ |  ¡  dS )zInsert a tab character.ú N)Úminr(   rp   r   Zline_bufferZtabstoprh   rq   )r
   rG   ÚcursorÚwsr   r   r   Ú
tab_insert  s    
zEmacsMode.tab_insertc                 C   s   | j  ¡  |  ¡  dS )a  Drag the character before the cursor forward over the character
        at the cursor, moving the cursor forward as well. If the insertion
        point is at the end of the line, then this transposes the last two
        characters of the line. Negative arguments have no effect.N)r(   Útranspose_charsrq   rF   r   r   r   r†   †  s    
zEmacsMode.transpose_charsc                 C   s   | j  ¡  |  ¡  dS )zÌDrag the word before point past the word after point, moving
        point past that word as well. If the insertion point is at the end
        of the line, this transposes the last two words on the line.N)r(   Útranspose_wordsrq   rF   r   r   r   r‡   Ž  s    
zEmacsMode.transpose_wordsc                 C   s   |   ¡  dS )a*  Toggle overwrite mode. With an explicit positive numeric
        argument, switches to overwrite mode. With an explicit non-positive
        numeric argument, switches to insert mode. This command affects only
        emacs mode; vi mode does overwrite differently. Each call to
        readline() starts in insert mode. In overwrite mode, characters
        bound to self-insert replace the text at point rather than pushing
        the text to the right. Characters bound to backward-delete-char
        replace the character before point with a space.Nr|   rF   r   r   r   Úoverwrite_mode•  s    	zEmacsMode.overwrite_modec                 C   s   | j  ¡  |  ¡  dS )z0Kill the text from point to the end of the line.N)r(   Ú	kill_linerq   rF   r   r   r   r‰      s    
zEmacsMode.kill_linec                 C   s   | j  ¡  |  ¡  dS )z+Kill backward to the beginning of the line.N)r(   Úbackward_kill_linerq   rF   r   r   r   rŠ   ¥  s    
zEmacsMode.backward_kill_linec                 C   s   | j  ¡  |  ¡  dS )zKKill backward from the cursor to the beginning of the current
        line.N)r(   Úunix_line_discardrq   rF   r   r   r   r‹   ª  s    
zEmacsMode.unix_line_discardc                 C   s   | j  ¡  |  ¡  dS )zgKill all characters on the current line, no matter where point
        is. By default, this is unbound.N)r(   Úkill_whole_linerq   rF   r   r   r   rŒ   ±  s    
zEmacsMode.kill_whole_linec                 C   s   | j  ¡  |  ¡  dS )zŸKill from point to the end of the current word, or if between
        words, to the end of the next word. Word boundaries are the same as
        forward-word.N)r(   Ú	kill_wordrq   rF   r   r   r   r�   ·  s    
zEmacsMode.kill_wordc                 C   s   | j  ¡  |  ¡  dS )zRKill the word behind point. Word boundaries are the same as
        backward-word.N)r(   Úbackward_kill_wordrq   rF   r   r   r   rŽ   À  s    
zEmacsMode.backward_kill_wordc                 C   s   | j  ¡  |  ¡  dS )ztKill the word behind point, using white space as a word
        boundary. The killed text is saved on the kill-ring.N)r(   Úunix_word_ruboutrq   rF   r   r   r   r�   Æ  s    
zEmacsMode.unix_word_ruboutc                 C   s   |   ¡  dS )zQKill the text in the current region. By default, this command is
        unbound.Nr|   rF   r   r   r   Úkill_regionÌ  s    zEmacsMode.kill_regionc                 C   s   |   ¡  dS )z|Copy the text in the region to the kill buffer, so it can be
        yanked right away. By default, this command is unbound.Nr|   rF   r   r   r   Úcopy_region_as_killÑ  s    zEmacsMode.copy_region_as_killc                 C   s   |   ¡  dS )z–Copy the word before point to the kill buffer. The word
        boundaries are the same as backward-word. By default, this command
        is unbound.Nr|   rF   r   r   r   Úcopy_backward_wordÖ  s    zEmacsMode.copy_backward_wordc                 C   s   |   ¡  dS )z˜Copy the word following point to the kill buffer. The word
        boundaries are the same as forward-word. By default, this command is
        unbound.Nr|   rF   r   r   r   Úcopy_forward_wordÜ  s    zEmacsMode.copy_forward_wordc                 C   s   | j  ¡  |  ¡  dS )z7Yank the top of the kill ring into the buffer at point.N)r(   Úyankrq   rF   r   r   r   r”   â  s    
zEmacsMode.yankc                 C   s   | j  ¡  |  ¡  dS )zrRotate the kill-ring, and yank the new top. You can only do this
        if the prior command is yank or yank-pop.N)r(   Úyank_poprq   rF   r   r   r   r•   ç  s    
zEmacsMode.yank_popc                 C   s   |   ¡  dS )zéDeletes the character under the cursor if not at the beginning or
        end of the line (like delete-char). If at the end of the line,
        behaves identically to possible-completions. This command is unbound
        by default.Nr|   rF   r   r   r   Údelete_char_or_listí  s    zEmacsMode.delete_char_or_listc                 C   s   |   ¡  dS )zJBegin saving the characters typed into the current keyboard
        macro.Nr|   rF   r   r   r   Ústart_kbd_macroô  s    zEmacsMode.start_kbd_macroc                 C   s   |   ¡  dS )zaStop saving the characters typed into the current keyboard macro
        and save the definition.Nr|   rF   r   r   r   Úend_kbd_macroù  s    zEmacsMode.end_kbd_macroc                 C   s   |   ¡  dS )z}Re-execute the last keyboard macro defined, by making the
        characters in the macro appear as if typed at the keyboard.Nr|   rF   r   r   r   Úcall_last_kbd_macroþ  s    zEmacsMode.call_last_kbd_macroc                 C   s   |   ¡  dS )zsRead in the contents of the inputrc file, and incorporate any
        bindings or variable assignments found there.Nr|   rF   r   r   r   Úre_read_init_file  s    zEmacsMode.re_read_init_filec                 C   s   |   ¡  |  ¡  dS )zmAbort the current editing command and ring the terminals bell
        (subject to the setting of bell-style).N)r!   rq   rF   r   r   r   Úabort  s    zEmacsMode.abortc                 C   s   |   ¡  dS )zyIf the metafied character x is lowercase, run the command that is
        bound to the corresponding uppercase character.Nr|   rF   r   r   r   Údo_uppercase_version  s    zEmacsMode.do_uppercase_versionc                 C   s   d| _ |  ¡  dS )z|Metafy the next character typed. This is for keyboards without a
        meta key. Typing ESC f is equivalent to typing M-f.TN)ra   rq   rF   r   r   r   Úprefix_meta  s    zEmacsMode.prefix_metac                 C   s   | j  ¡  |  ¡  dS )z6Incremental undo, separately remembered for each line.N)r(   Zpop_undorq   rF   r   r   r   Úundo  s    
zEmacsMode.undoc                 C   s   |   ¡  dS )z~Undo all changes made to this line. This is like executing the
        undo command enough times to get back to the beginning.Nr|   rF   r   r   r   Úrevert_line  s    zEmacsMode.revert_linec                 C   s   |   ¡  dS )z,Perform tilde expansion on the current word.Nr|   rF   r   r   r   Útilde_expand#  s    zEmacsMode.tilde_expandc                 C   s   | j  ¡  |  ¡  dS )zgSet the mark to the point. If a numeric argument is supplied, the
        mark is set to that position.N)r(   Úset_markrq   rF   r   r   r   r¡   '  s    
zEmacsMode.set_markc                 C   s   |   ¡  dS )z™Swap the point with the mark. The current cursor position is set
        to the saved position, and the old cursor position is saved as the
        mark.Nr|   rF   r   r   r   Úexchange_point_and_mark-  s    z!EmacsMode.exchange_point_and_markc                 C   s   |   ¡  dS )zŒA character is read and point is moved to the next occurrence of
        that character. A negative count searches for previous occurrences.Nr|   rF   r   r   r   Úcharacter_search3  s    zEmacsMode.character_searchc                 C   s   |   ¡  dS )zšA character is read and point is moved to the previous occurrence
        of that character. A negative count searches for subsequent
        occurrences.Nr|   rF   r   r   r   Úcharacter_search_backward8  s    z#EmacsMode.character_search_backwardc                 C   s   |   ¡  dS )añ  Without a numeric argument, the value of the comment-begin
        variable is inserted at the beginning of the current line. If a
        numeric argument is supplied, this command acts as a toggle: if the
        characters at the beginning of the line do not match the value of
        comment-begin, the value is inserted, otherwise the characters in
        comment-begin are deleted from the beginning of the line. In either
        case, the line is accepted as if a newline had been typed.Nr|   rF   r   r   r   Úinsert_comment>  s    zEmacsMode.insert_commentc                 C   s   |   ¡  dS )a  Print all of the settable variables and their values to the
        Readline output stream. If a numeric argument is supplied, the
        output is formatted in such a way that it can be made part of an
        inputrc file. This command is unbound by default.Nr|   rF   r   r   r   Údump_variablesH  s    zEmacsMode.dump_variablesc                 C   s   |   ¡  dS )a  Print all of the Readline key sequences bound to macros and the
        strings they output. If a numeric argument is supplied, the output
        is formatted in such a way that it can be made part of an inputrc
        file. This command is unbound by default.Nr|   rF   r   r   r   Údump_macrosO  s    zEmacsMode.dump_macrosc                 C   s   |   |¡ dS )zuAdd this digit to the argument already accumulating, or start a
        new argument. M-- starts a negative argument.N)rW   rF   r   r   r   Údigit_argumentV  s    zEmacsMode.digit_argumentc                 C   s   dS )aõ  This is another way to specify an argument. If this command is
        followed by one or more digits, optionally with a leading minus
        sign, those digits define the argument. If the command is followed
        by digits, executing universal-argument again ends the numeric
        argument, but is otherwise ignored. As a special case, if this
        command is immediately followed by a character that is neither a
        digit or minus sign, the argument count for the next command is
        multiplied by four. The argument count is initially one, so
        executing this function the first time makes the argument count
        four, a second time makes the argument count sixteen, and so on. By
        default, this is not bound to a key.Nr   rF   r   r   r   Úuniversal_argument\  s    zEmacsMode.universal_argumentc                 C   s
  |   d¡ |   d¡ |  d| j¡ |  d| j¡ |  d| j¡ |  d| j¡ |  d| j¡ |  d| j¡ |  d	| j¡ |  d
| j¡ |  d| j¡ |  d| j¡ |  d| j¡ |  d| j¡ |  d| j	¡ |  d| j
¡ |  d| j
¡ |  d| j¡ |  d| j¡ |  d| j¡ |  d| j¡ |  d| j¡ |  d| j¡ |  d| j¡ |  d| j¡ |  d| j¡ |  d| j	¡ |  d| j¡ |  d| j¡ |  d| j¡ |  d| j¡ |  d| j¡ |  d | j¡ |  d!| j¡ |  d| j¡ |  d"| j¡ |  d#| j¡ |  d$| j¡ |  d%| j¡ |  d&| j¡ |  d'| j¡ |  d(| j¡ |  d)| j¡ |  d*| j ¡ |  d+| j!¡ |  d,| j"¡ |  d-| j#¡ |  d.| j$¡ |  d/| j¡ |  d0| j%¡ |  d1| j&¡ |  d2| j'¡ |  d3| j(¡ |  d4| j)¡ |  d5| j*¡ |  d6| j¡ |  d7| j¡ |  d8| j¡ |  d9| j¡ |  d:| j¡ |  d;| j¡ |  d<| j¡ |  d=| j¡ |  d>| j¡ |  d?| j¡ |  d@| j¡ |  dA| j¡ |  dB| j¡ |  dC| j¡ |  dD| j¡ t+dEƒ t,dFdGƒD ]}|  dH| | j-¡ �qÞ|  dI| j-¡ dJS )KzLWhen in vi command mode, this causes a switch to emacs editing
        mode.z	Control-dz	Control-zÚspacezShift-spacezControl-spaceÚReturnÚLeftz	Control-bÚRightz	Control-fz	Control-hZ	BackSpacezControl-BackSpaceZHomeZEndÚDeleteZClearzAlt-fzAlt-bz	Control-lz	Control-pZUpz	Control-nZDownz	Control-az	Control-ezAlt-<zAlt->z	Control-rz	Control-szControl-Shift-rzAlt-pzAlt-nz	Control-_ÚEscapezMeta-dzControl-Deletez	Control-wz	Control-vzAlt-vz	Control-yz	Control-kz	Control-mz	Control-qzControl-Shift-vzControl-RightzControl-LeftzShift-Rightz
Shift-LeftzShift-Control-RightzShift-Control-Leftz
Shift-Homez	Shift-EndZnumpad0Znumpad1Znumpad2Znumpad3Znumpad4Znumpad5Znumpad6Znumpad7Znumpad8Znumpad9ÚaddÚsubtractÚmultiplyÚdivideZ
vk_decimalzRUNNING INIT EMACSr   rM   zalt-%dzalt--N).Z_bind_exit_keyZ	_bind_keyrl   Zaccept_lineZbackward_charZforward_charZbackward_delete_charZbackward_delete_wordZbeginning_of_lineÚend_of_lineZdelete_charZclear_screenZforward_wordZbackward_wordro   r{   rr   rx   rs   rt   r   r   rH   rI   rž   rŒ   r�   Zforward_delete_wordr�   ZpasteZipython_paster”   r‰   r¡   Zcopy_region_to_clipboardZpaste_mulitline_codeZforward_word_endZforward_char_extend_selectionZbackward_char_extend_selectionZ!forward_word_end_extend_selectionZbackward_word_extend_selectionZ"beginning_of_line_extend_selectionZend_of_line_extend_selectionr   Úranger¨   )r
   rG   Úir   r   r   Úinit_editing_modek  s”    

zEmacsMode.init_editing_modeN)<r7   r8   r9   Úmoder   rc   rd   re   rb   ro   rr   rs   rt   r   r   rx   r{   r}   r~   r   r€   r…   r†   r‡   rˆ   r‰   rŠ   r‹   rŒ   r�   Zforward_kill_wordrŽ   r�   r�   r‘   r’   r“   r”   r•   r–   r—   r˜   r™   rš   r›   rœ   r�   rž   rŸ   r    r¡   r¢   r£   r¤   r¥   r¦   r§   r¨   r©   r·   r   r   r   r   rX   Ñ   sr   *
rX   c                 C   sx   | sdS | d }| D ]^}t t|ƒƒD ]L}|d|d …  ¡ |d|d …  ¡ kr$|d|… }|dkrl  dS  qq$q|S )zGGiven a list of pathnames, returns the longest common leading componentr   r   Nr   )rµ   r   Úlower)ÚmÚprefixÚitemr¶   r   r   r   ÚcommonprefixÀ  s    (r½   )Zpyreadline3.lineeditor.lineobjZ
lineeditorri   r   Zpyreadline3.loggerr   r   r   Úobjectr   r:   Ú	ExceptionrJ   rK   r^   rX   r½   r   r   r   r   Ú<module>   s   T:,

ÿ   r