Your IP : 3.145.70.108


Current Path : /opt/alt/python36/lib64/python3.6/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/__pycache__/editor.cpython-36.opt-1.pyc

3

� f��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Tddl
mZddlj
ZddljZddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlm Z dZ!dej"�Z#e$jdkZ%dd�Z&Gdd�de'�Z(dd�Z)dd�Z*Gdd�de'�Z+dd�Z,dd d!d"�Z-d#d$�Z.d%d&�Z/d'd(�Z0e1d)k�r�dd*l2m3Z3e3d+d,d-d.�dd/l4m5Z5e5e0�dS)0�N)�*)�	Scrollbar)�idleConf)�configdialog)�grep)�help)�
help_about)�macosx)�MultiCallCreator)�pyparse)�query)�replace)�search)�window�z (%s)�darwincCsbtj\}}}}}d||f}|d|f7}|dkrB|d|f7}n|dkr^|d|d|f7}|S)zYFormat sys.version_info to produce the Sphinx version string used to install the chm docsz%s%sz%s�	candidatezrc%s�finalr)�sys�version_info)�major�minor�micro�level�serial�release�r�3/opt/alt/python36/lib64/python3.6/idlelib/editor.py�_sphinx_version!src@s�eZdZddlmZddlmZmZddlm	Z	ddl
mZmZddl
mZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlm Z ddl!m"Z"e#j$�Z%dZ&d�dd�Z'dd�Z(dd�Z)dd�Z*dd�Z+d�dd�Z,d�d�d�d�d�d�d�gZ-d,d-�Z.d.d/�Z/d0d1�Z0d2d3�Z1dZ2d4d5�Z3d�gZ4d8d9�Z5d:d;�Z6d<d=�Z7d>d?�Z8d�d@dA�Z9�ddBdC�Z:�ddDdE�Z;�ddFdG�Z<dHdI�Z=dJdK�Z>dLdM�Z?�ddNdO�Z@�ddPdQ�ZAdRdS�ZBdTdU�ZCdVdW�ZDdXdY�ZEdZd[�ZFd\d]�ZGd^d_�ZHd`da�ZIdbdc�ZJddde�ZKdfdg�ZL�ddhdi�ZM�ddjdk�ZN�ddldm�ZOdndo�ZPdpdq�ZQdrds�ZRdtdu�ZSdvdw�ZTdxdy�ZUdzd{�ZVd|d}�ZWeXjYeXjZd~Z[dd��Z\d�d��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d��Zb�dd�d��Zcd�d��Zdd�d��Zed�d��Zfd�d��Zgd�d��Zhd�d��Zid�d��Zjd�d��Zk�d	d�d��Zld�d��Zm�d
d�d��Znd�d��Zod�d��Zpd�d��Zqd�d��Zrd�d��Zsd�d��Ztd�d��Zud�d��Zvd�d��Zwd�d�iZxd�d��Zy�dd�d��Zz�dd�d��Z{d�d��Z|�d
d�dÄZ}�dd�dńZ~d�dDŽZd�dɄZ�d�d˄Z�d�d̈́Z��dd�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�dS(�EditorWindowr)�
Percolator)�ColorDelegator�color_config)�
UndoDelegator)�	IOBinding�encoding)�mainmenu)�MultiStatusBar)�AutoComplete)�
AutoExpand)�Calltip)�CodeContext)�FormatParagraph)�
ParenMatch)�Rstrip)�Squeezer)�
ZoomHeightNcCsnddlm}tjdk�rtjjtjdd�}tj	j
d�rvddtjdd�}tjjd	�r^d
}q�d}tjj||dd�}nVtj	dd�dkr�tjjtjdd
t
��}	tjj|	�r�|	}ntj	dkr�tjjtjd�}tjj|�}tjj|��r|t_tj	dk�rdtjt_ndtjdd�t_||_|�p*|j}||_t|�|_tj||jd�|_}
|�rl|j|_|j|j_ni|_i|j_tjjtjd�|_d|_t|
�|_ }t!|dd�|_"}tj#ddddd�|_$dddd|j$d tj#ddd!dd�d"�}
t%t&�|f|
�|_'}|j'|j_(|j)�|j*�|jj+d#|j,�|jj-d$|j.�t/j0��rp|j-d$|j.�|j-d%|j1�|j-d&|j1�n|j-d'|j1�|j-d(|j2�|j-d)|j2�|j-d*|j2�|j-d+|j3�|j-d,|j4�|j-d-|j5�|j-d.|j6�|j-d/|j7�|j-d0|j8�|j-d1|j9�|j-d2|j:�|j-d3|j;�|j-d4d5d6��|j-d7|j<�|j-d8|j=�|j-d9|j>�|j-d:|j?�|j-d;|j@�|j-d<|jA�|j-d=|jB�|j-d>|jC�|j-d?|jD�|j-d@|jE�|j-dA|jF�|j-dB|jG�|j-dC|jH�|j-dD|jI�|j-dE|jJ�|j-dF|jK�|j-dG|jL�|j-dH|jM�|j-dI|jN�|j-dJ|jOd��|j-dK|jOdL��|j-dM|jP�|j-dN|jQ�|j-dO|jR�|�r�||j|<|�r�||jS|<|j-dP|jT�|j-dQ|jjU�|j-dR|jV�|j-dS|jW�|j-dT|jX�|jY�|jZ|dU<|j[t\t]dV�|j^|dW<tj_|jdd�|dX<|j[t`tadLdY�|j[tbtadLdY�|jc�tj#ddZd[d\d�}||_dd]|_e|je|_f|jg�d^|_hd}|_i|jj|�|_k}|jl�|_m}|jn|�|jo|_o|jp|_p|jq|jr�|js|�|_t}|ju|jv�d^|_w|jxd^�d|_y|�rjtjjz|��rZtjj|��rZ|j{|��rjdb|_w|j||�}|jx|�n|j}|�db|_w|j~�|jr�|j�|j��|j�j�dc�}|�r�|j�dd�}|dk�r�d~}|dk�r�|j��|dL}||_�tj�|j��t�j�|_�t�j�|_�t�j�|_�|j�dedf�|j�dgdhdidj�|j�dkdl�|j�dmdn�|j�dodndpdq�|j�|�}|j-de|j��|j-dg|j��|j-dr|j��|j-ds|j�|�j��|j-dt|j�|�j��|j�|�}|j-du|j��|j-do|j��||�}|j-dv|j��|j-dw|j��|j-dx|j�|�j��|j�|�}|j-dk|j��|j-dm|j��|j-dy|j��|j-dz|j�|�j��|j-d{|j�|�j��|j�|�}|j-d||j��dS)Nr)�
ScriptBindingZDocz
index.html�linuxzpython-docs-z%s.%s.%s�z/var/www/html/python/z/var/www/html/python/index.htmlz/usr/share/doc/�winzPython%s.chmrz0Resources/English.lproj/Documentation/index.htmlzfile://zhttps://docs.python.org/%d.%d/�)�menuzrecent-files.lst��vbar)�name�mainr�width�int)�type�text�ZnoneZ
wordprocessor�height)r9ZpadxZwrapZhighlightthicknessr;Ztabstyler@ZWM_DELETE_WINDOWz<<close-window>>z<Control-Button-1>z<2>z<3>z<MouseWheel>z
<Button-4>z
<Button-5>z<<cut>>z<<copy>>z	<<paste>>z<<center-insert>>z<<help>>z<<python-docs>>z<<about-idle>>z<<open-config-dialog>>z<<open-module>>z<<do-nothing>>cSsdS)N�breakr)�eventrrr�<lambda>�sz'EditorWindow.__init__.<locals>.<lambda>z<<select-all>>z<<remove-selection>>z<<find>>z<<find-again>>z<<find-in-files>>z<<find-selection>>z<<replace>>z
<<goto-line>>z<<smart-backspace>>z<<newline-and-indent>>z<<smart-indent>>z<<indent-region>>z<<dedent-region>>z<<comment-region>>z<<uncomment-region>>z<<tabify-region>>z<<untabify-region>>z<<toggle-tabs>>z<<change-indentwidth>>z<Left>z<Right>�z<<del-word-left>>z<<del-word-right>>z<<beginning-of-line>>z<<open-new-window>>z<<close-all-windows>>z<<open-class-browser>>z<<open-path-browser>>z<<open-turtle-demo>>�command)�side�fillZyscrollcommand�font)rFrG�expand�Indentz
use-spaces�boolrF�2���@KLTr�endz<<autocomplete>>z	<Key-Tab>z<<try-open-completions>>z<KeyRelease-period>z<KeyRelease-slash>z<KeyRelease-backslash>z<<try-open-calltip>>z<KeyRelease-parenleft>z<<refresh-calltip>>z<KeyRelease-parenright>z<<paren-closed>>z<KeyRelease-bracketright>z<KeyRelease-braceright>z<<force-open-completions>>z<<expand-word>>z<<format-paragraph>>z<<flash-paren>>z<<check-module>>z<<run-module>>z
<<do-rstrip>>z<<force-open-calltip>>z<<zoom-height>>z<<toggle-code-context>>z<<squeeze-current-text>>)rLrMrN���)�Zidlelib.runscriptr1r�help_url�os�path�joinr�base_prefix�platform�countr�isdirr�isfile�normpath�flist�root�Menu�menubarrZListedToplevel�top�vars�tkinter_varsZinversedict�
instance_dictrZuserdir�recent_files_path�prompt_last_line�Frame�
text_framerr8�	GetOptionr;r
ZTextr>Zfocused_widget�
createmenubar�apply_bindingsZprotocol�close�bind�close_eventr	ZisAquaTk�right_menu_event�mousescroll�cut�copy�paste�center_insert_event�help_dialog�python_docs�about_dialog�
config_dialog�open_module_event�
select_all�remove_selection�
find_event�find_again_event�find_in_files_event�find_selection_event�
replace_event�goto_line_event�smart_backspace_event�newline_and_indent_event�smart_indent_event�indent_region_event�dedent_region_event�comment_region_event�uncomment_region_event�tabify_region_event�untabify_region_event�toggle_tabs_event�change_indentwidth_event�move_at_edge_if_selection�
del_word_left�del_word_right�
home_callback�dict�new_callbackZclose_all_callback�open_module_browser�open_path_browser�open_turtle_demo�set_status_bar�handle_yview�pack�RIGHT�Y�set�GetFontZLEFTZBOTHZTOPZ	focus_set�usetabs�tabwidth�indentwidth�set_notabs_indentwidth�context_use_ps1�num_context_linesr �perr#�undo�insertfilter�undo_block_start�undo_block_stopZset_saved_change_hook�saved_change_hookr$�ioZset_filename_change_hook�filename_change_hookZ	good_load�set_indentation_params�color�exists�loadfile�ispythonsourceZset_filename�ResetColorizer�update_recent_files_list�load_extensions�menudict�get�index�
add_separator�	wmenu_endZregister_callback�postwindowsmenu�tkMessageBox�askyesno�tkSimpleDialog�
askinteger�	showerror�	event_addr(Zautocomplete_eventZtry_open_completions_eventZforce_open_completions_eventr)Zexpand_word_eventr,Zformat_paragraph_eventr-Zflash_paren_eventZparen_closed_eventZcheck_module_eventZrun_module_eventr.Z	do_rstripr*Ztry_open_calltip_eventZrefresh_calltip_eventZforce_open_calltip_eventr0Zzoom_height_eventr+Ztoggle_code_context_eventr/Zsqueeze_current_text_event)�selfr[�filename�keyr\r1ZdochomeZpyverZbasepathZchmfiler_rfr8Ztext_optionsr>Z	usespacesr�r�r��	is_py_srcr6rOZautocompleteZ
parenmatchZ
scriptbindingZctipZsqueezerrrr�__init__As�






















zEditorWindow.__init__cCsnt|t�r`y|j|j�}WnDtk
r^y|j|j�}Wntk
rX|jd�}YnXYnXtjdd|�S)z3Return filename as BMP unicode so diplayable in Tk.z	iso8859-1u[𐀀-􏿿]u�)�
isinstance�bytes�decode�filesystemencoding�UnicodeDecodeErrorr%�re�sub)r�r�rrr�_filename_to_unicodeDs
z!EditorWindow._filename_to_unicodecCs|jj�\}}|jj|�dS)NrA)r�Zdefaultfilenamer[�new)r�rB�dirname�basenamerrrr�SszEditorWindow.new_callbackcCs�|jd@dkr|jdkrdS|jjd�rd|jjddd�rd|jjddd�rdt|jjd�jd�d	�}n:|jjdd�}x*tt	|��D]}||dkr�Pq�Wt	|�}t|jjd�jd�d	�}||kr�d}d
t
|�d}|jd	@dkr�|jjddd�n�|jjd��s|jjdd�n@|jj|jjd�d|jjd���rD|jjdd�n|jjdd�|jj|�}|jjd�}|jj|d|��r�||}}|jjddd�|jj
d||�|jjd|�|jjd�dS)N�rZHomeZiomarkz<=zinsert lineendzinsert linestart�.rD� �	�insertzinsert linestart+�c�selz1.0rOz	sel.firstZ	my_anchor�<zsel.last�>rA)r�r�)�stateZkeysymr>r��comparer<�splitr��range�len�str�
tag_remove�mark_set�tag_add�see)r�rBZinsertpt�lineZlineat�dest�first�lastrrrr�Xs@
zEditorWindow.home_callbackcCs�|j|j�|_t|jdddd�}tjdkr<|jjddtd�|jjdd	td�|jjd
dtd�|jjt	t
d�|jt	t
d�|jjd
|j
�|jjd
dd�|jj|j
�dS)NrDZgrey75)r@ZborderwidthZ
backgroundrZ	_padding1z    )rF�columnzCol: ?r�zLn: ?)rFrGz<<set-line-and-column>>z<KeyRelease>z<ButtonRelease>)r'r_�
status_barrerrV�	set_labelr�r�ZBOTTOM�Xr>rk�set_line_and_columnr�Z
after_idle)r��seprrrr��s
zEditorWindow.set_status_barcCs>|jjt�jd�\}}|jjdd|�|jjdd|�dS)Nr�r�zCol: %sr�zLn: %s)r>r�ZINSERTr�r�r�)r�rBr�r�rrrr��sz EditorWindow.set_line_and_column�file�_File�edit�_Edit�format�F_ormat�run�_Run�options�_Optionsr�_Windowr�_HelpcCs�|j}i|_}xD|jD]:\}}t|�\}}t||dd�||<}|j|||d�qWtj�r�t|ddd�|d<}|jd|d�|j�t|jdd�|_	|jd	j
d
dd|j	d�|jd
jt�|_
|j�dS)Nr)r9�tearoff)�labelr6�	underlineZappleZapplicationZIDLE)r�r6)r�r�r3zRecent Files)r�r�r6r)r^r��
menu_specs�prepstrr]Zadd_cascader	Z
isCarbonTk�
fill_menus�recent_files_menuZinsert_cascader��END�base_helpmenu_length�reset_help_menu_entries)r�Zmbarr�r9r�r�r6rrrrh�s"

zEditorWindow.createmenubarcCsJ|jd}|jd�}|dkr d}||jkr<|j|jd|�tj|�dS)NrrOrDrP)r�r�r��deleterZadd_windows_to_menu)r�r6rOrrrr��s


zEditorWindow.postwindowsmenucGsR|dkr<t|d�}t|jd�|�|jd�}d}|df}|jj|f|��dS)zHandle scrollbar.ZmovetorrOz@0,0Zscroll�unitsrA)�float�round�	getlinenor>�yview)r�rB�argsZfraction�linesrrrr��szEditorWindow.handle_yviewcCs@tj|jdktj|jdki}||jr*dnd}|jj|d�dS)a�Handle scrollwheel event.

        For wheel up, event.delta = 120*n on Windows, -1*n on darwin,
        where n can be > 1 if one scrolls fast.  Flicking the wheel
        generates up to maybe 20 events with n up to 10 or more 1.
        Macs use wheel down (delta = 1*n) to scroll up, so positive
        delta means to scroll up on both systems.

        X-11 sends Control-Button-4 event instead.
        rr�r?rrA���)Z	EventTypeZ
MouseWheelZdeltaZButtonZnumr=r>Zyview_scroll)r�rBZuprrrrrn�s
zEditorWindow.mousescrollc	
Cs�|jjdd|j|jf�|js(|j�|j}||_tjdd�dk}|rX|jj	dd�xX|j
D]N}y|\}}}Wntk
r�w`YnX|dkr�q`t||��}|j
||d�q`W|j|j|j�|r�|jj	dd�d	S)
Nr�z@%d,%dr3r4Zarrow)Zcursor)r�ZibeamrA)r>r��x�y�rmenu�
make_rmenurBrrV�config�rmenu_specs�
ValueError�getattrZentryconfigureZtk_popupZx_rootZy_root)	r�rBrZiswin�itemr��	eventnameZverify_stater�rrrrm�s*zEditorWindow.right_menu_event�Close�<<close-window>>cCsjt|jdd�}xP|jD]F}|d|d}}|dk	rT|j|fdd�}|j||d�q|j�qW||_dS)Nr)r�rDcSs|j|�dS)N)�event_generate)r>rrrrrEsz(EditorWindow.make_rmenu.<locals>.command)r�rE)r]r>r�add_commandr�r)r�rrr�rrErrrr�szEditorWindow.make_rmenucCs|j�S)N)�rmenu_check_copy)r�rrr�rmenu_check_cutszEditorWindow.rmenu_check_cutcCs6y|jjd�}Wntk
r$dSX|r.dSdSdS)Nz	sel.first�disabled�normal)r>r��TclError)r�Zindxrrrrs
zEditorWindow.rmenu_check_copycCs6y|jjjd|jd�Wntk
r,dSXdSdS)Nztk::GetSelectionZ	CLIPBOARDrr)r>�tk�callr)r�rrr�rmenu_check_pastes
zEditorWindow.rmenu_check_pastecCstj|j�dS)zHandle Help 'About IDLE' event.rA)rZAboutDialogr_)r�rBrrrruszEditorWindow.about_dialogcCstj|jd�dS)z&Handle Options 'Configure IDLE' event.ZSettingsrA)rZConfigDialogr_)r�rBrrrrv$szEditorWindow.config_dialogcCs"|jr|j}n|j}tj|�dS)zHandle Help 'IDLE Help' event.rA)r\r_rZ
show_idlehelp)r�rB�parentrrrrs*s

zEditorWindow.help_dialogcCsntjdd�dkr^ytj|j�Wqjtk
rZ}ztjdt|�|j	d�WYdd}~XqjXnt
j|j�dS)Nr3r4zDocument Start Failure)�title�messagerrA)rrVrR�	startfilerQ�OSErrorr�r�r�r>�
webbrowser�open)r�rB�whyrrrrt4s$zEditorWindow.python_docscCs|jjd�dS)Nz<<Cut>>rA)r>r)r�rBrrrro?szEditorWindow.cutcCs |jjd�sdS|jjd�dS)Nr�z<<Copy>>rA)r>Z
tag_rangesr)r�rBrrrrpCszEditorWindow.copycCs|jjd�|jjd�dS)Nz	<<Paste>>r�rA)r>rr�)r�rBrrrrqJszEditorWindow.pastecCs.|jjddd�|jjdd�|jjd�dS)Nr�z1.0zend-1cr�rA)r>r�r�r�)r�rBrrrrxOszEditorWindow.select_allcCs |jjddd�|jjd�dS)Nr�z1.0rOr�rA)r>r�r�)r�rBrrrryUszEditorWindow.remove_selectioncs*|jj�|jj�d�����fdd�}|S)z�Cursor move begins at start or end of selection

        When a left/right cursor key is pressed create and return to Tkinter a
        function which causes a cursor move from the associated edge of the
        selection.

        �sel.first+1c�sel.last-1ccsB|jd@dkr>y�d��d���Wntk
r<YnXdS)Nr?rz	sel.firstr�)r�r)rB)�
edge_index�edges_table�self_text_index�self_text_mark_setrr�move_at_edgeesz<EditorWindow.move_at_edge_if_selection.<locals>.move_at_edge)r'r()r>r�r�)r�r)r-r)r)r*r+r,rr�Zs
z&EditorWindow.move_at_edge_if_selectioncCs|jjd�dS)Nz
<Meta-Delete>rA)r>r)r�rBrrrr�nszEditorWindow.del_word_leftcCs|jjd�dS)Nz<Meta-d>rA)r>r)r�rBrrrr�rszEditorWindow.del_word_rightcCstj|j�dS)NrA)r�findr>)r�rBrrrrzvszEditorWindow.find_eventcCstj|j�dS)NrA)rZ
find_againr>)r�rBrrrr{zszEditorWindow.find_again_eventcCstj|j�dS)NrA)rZfind_selectionr>)r�rBrrrr}~sz!EditorWindow.find_selection_eventcCstj|j|j|j�dS)NrA)rr>r�r[)r�rBrrrr|�sz EditorWindow.find_in_files_eventcCstj|j�dS)NrA)r
r>)r�rBrrrr~�szEditorWindow.replace_eventcCsT|j}tjdd|d�}|dkr"dS|dkr6|j�dS|jdd|�|jd�dS)NZGotozGo to line number:)rrArr�z%d.0)r>r�r��bellr�r�)r�rBr>�linenorrrr�s

zEditorWindow.goto_line_eventc
Cspy|jjdd�j�}Wntk
r.d}YnXtj|jdd|�j}|dk	rl|jr`|jj|�n|j	j
|�|S)z�Get module name from user and open it.

        Return module path or None for calls by open_module_browser
        when latter is not invoked in named editor window.
        z	sel.firstzsel.lastr7zOpen ModulezAEnter the name of a Python module
to search on sys.path and open:N)r>r��striprrZ
ModuleName�resultr[r%r�r�)r�r9Z	file_pathrrr�open_module�s
zEditorWindow.open_modulecCs|j�dS)NrA)r3)r�rBrrrrw�szEditorWindow.open_module_eventcCsJ|jj}|jjdko|s,|j�}|dkr,dSddlm}|j|j|�dS)NZPyShellEditorWindowrAr)�browser)	r�r��	__class__�__name__r3�idlelibr4Z
ModuleBrowserr\)r�rBr�r4rrrr��sz EditorWindow.open_module_browsercCsddlm}|j|j�dS)Nr)�pathbrowserrA)r7r8ZPathBrowserr\)r�rBr8rrrr��szEditorWindow.open_path_browsercCs&ddl}tjddg}|j|dd�dS)Nrz-cz,from turtledemo.__main__ import main; main()F)�shellrA)�
subprocessr�
executable�Popen)r�rBr:�cmdrrrr��szEditorWindow.open_turtle_democCsN|dk	rJ|dkrJ|jjdd|�|jjddd�|jjddd�|j�dS)Nrr�z%d.0r�z1.0rOz
insert +1l)r>r�r�r��center)r�r0rrr�gotoline�s
zEditorWindow.gotolinecCsb|stjj|�rdStjjtjj|��\}}tjj|�dkrBdS|jjdd�}|jd�o`d|kS)	NT�.py�.pywz1.0z1.0 lineendz#!�python)r@rA)	rRrSrX�splitextr��normcaser>r��
startswith)r�r��baseZextr�rrrr��szEditorWindow.ispythonsourcecCs|jr|jj|�d|_dS)N)r[Zunregister_maybe_terminate)r�rrr�
close_hook�szEditorWindow.close_hookcCs
||_dS)N)rG)r�rGrrr�set_close_hook�szEditorWindow.set_close_hookcCs2|jr|jj|�|j�|jj|�|j�dS)N)r[Zfilename_changed_editr�r_Zupdate_windowlist_registryr�)r�rrrr��s
z!EditorWindow.filename_change_hookcCsV|jr
dS|j|jj�r"|j�|_|jrR|jj|j�|jj|j�|jj|j�dS)N)	r�r�r�r�r!r��removefilterr�r�)r�rrr�
_addcolorizer�s
zEditorWindow._addcolorizercCs,|js
dS|jj�|jj|j�d|_dS)N)r�Zremovecolorsr�rI)r�rrr�_rmcolorizer�s

zEditorWindow._rmcolorizercCs |j�|j�tj|j�dS)zUpdate the color themeN)rKrJrr"r>)r�rrrr��szEditorWindow.ResetColorizer�_cCsp|jd|�|j|�}|r6||jkr6|jd|d|�d|j|�krR|jd|�n|jd|d�|j|�dS)NZERRORz
 wordstart�
r�z+1c)r�r��
IDENTCHARSr�r�)r�r>�pos�charrrr�colorize_syntax_errors
z"EditorWindow.colorize_syntax_errorcCstj|jdd�|jd<dS)z.Update the text widgets' font if it is changedr:rrHN)rr�r\r>)r�rrr�	ResetFontszEditorWindow.ResetFontcCs�tj�|j_}x&|j�D]\}}|jj|f|��qWxF|j�D]:}tj|�}|rBx&|j�D]\}}|jj|f|��q^WqBWdS)z/Remove the keybindings before they are changed.N)	r�GetCurrentKeySetr&�default_keydefs�itemsr>Zevent_delete�get_standard_extension_names�GetExtensionBindings)r��keydefsrB�keylist�
extensionName�xkeydefsrrr�RemoveKeybindingss
zEditorWindow.RemoveKeybindingsc
CsVtj�|j_}|j�x(|j�D]}tj|�}|r"|j|�q"Wi}xR|jjD]F}i||d<x4|dD](}|rj|d||dt|d�d<qjWqPWx�|j	D]�}|j	|}|j
t�}|dkr�q�|d7}x�td|�D]r}	|j
|	�dkr�|j|	d�}
|
r�|j|	d�}d}||k�r.|||k�r.|||}|r�t||�}
|j|	|
d�q�Wq�WdS)	z-Update the keybindings after they are changedrrDNrE�acceleratorr�r7)r])rrSr&rTrirVrW�menudefsr�r�r�r�r�r=Z	entrycget�get_acceleratorZentryconfig)
r�rXrZr[Z
menuEventDictr6rZmenubarItemrOr�ZaccelZitemNamerBrrr�ApplyKeybindings#s<
(



zEditorWindow.ApplyKeybindingscCs|jstjddddd�|_dS)zCUpdate the indentwidth if changed and not using tabs in this windowr:rJz
num-spacesr<)r=N)r�rrgr�)r�rrrr�Gs
z#EditorWindow.set_notabs_indentwidthcCs�tj�}|jd}|jt�}||jkr8|j|jd|�|rr|j�x,|D]$}|j|d�}|j	|d|d�qJW||jd<dS)z3Update the additional help entries on the Help menurrDr)r�rEN)
rZGetAllExtraHelpSourcesListr�r�r�r�rr��"_EditorWindow__extra_help_callbackr)r�Z	help_listZhelpmenuZhelpmenu_length�entryr=rrrr�Ns



z$EditorWindow.reset_help_menu_entriescs|f�fdd�	}|S)zCCreate a callback with the helpfile value frozen at definition timecs�|jd�stjj|�}tjdd�dkrrytj|�Wq|tk
rn}ztj	dt
|��jd�WYdd}~Xq|Xn
tj
|�dS)N�www�httpr3r4zDocument Start Failure)r r!r)rcrd)rErRrSrZrrVr"r#r�r�r�r>r$r%)�helpfiler&)r�rr�display_extra_helpas
$z>EditorWindow.__extra_help_callback.<locals>.display_extra_helpr)r�rerfr)r�rZ__extra_help_callback_sz"EditorWindow.__extra_help_callbackcs�g}tjj|j�r8t|jdddd��}|j�}WdQRX|rjtjj|�d}||kr^|j|�|jd|�g�x4|D],}d|ks�tjj|dd��rt�j	|�qtW�fd
d�|D�}d}|dt
|��}y,t|jd
ddd��}|j|�WdQRXWn\tk
�rR}z>t
|jdd��sBd|j_tjdd|jt|��|jd�WYdd}~XnXxt|jjD]h}|j}	|	jdt�xNt|�D]B\}
}|j�}|j|�}|j|�}
|	j||
d||
dd��q~W�q^WdS)z/Load and update the recent files list and menus�r�utf_8r
)r%�errorsNrMr�rDcsg|]}|�kr|�qSrr)�.0rS)�	bad_pathsrr�
<listcomp>sz9EditorWindow.update_recent_files_list.<locals>.<listcomp>Z1234567890ABCDEFGHIJK�w�recentfilelist_error_displayedFTzIDLE Warningz|Cannot update File menu Recent Files list. Your operating system says:
%s
Select OK and IDLE will continue without updating.)r r!rr�)r�rEr�rP)rRrSr�rcr%�	readlines�abspath�remover��appendr��
writelinesr#rr\ror��showwarningr�r�r>r_rbr�rr��	enumerate�rstrip�#_EditorWindow__recent_file_callbackr)r��new_fileZrf_listZrf_list_filerSZulcharsZrf_file�err�instancer6�i�	file_nameZ
ufile_name�callbackr)rlrr�nsL



z%EditorWindow.update_recent_files_listcs|f�fdd�	}|S)Ncs�jj|d�dS)N)ZeditFile)r�r%)Z
fn_closure)r�rr�open_recent_file�sz=EditorWindow.__recent_file_callback.<locals>.open_recent_filer)r�r}rr)r�rZ__recent_file_callback�sz#EditorWindow.__recent_file_callbackcCs�|j�}|j�}|r*|r*|d|t}n|r4|}n|r>|}nd}|pL|pL|}|j�sfd|}d|}|jj|�|jj|�dS)Nz - �Untitledz*%s*z*%s)�short_title�
long_title�_py_version�	get_savedr_Zwm_titleZwm_iconname)r�ZshortZlongr Ziconrrrr��szEditorWindow.saved_change_hookcCs
|jj�S)N)r�r�)r�rrrr��szEditorWindow.get_savedcCs|jj|�dS)N)r��	set_saved)r��flagrrrr��szEditorWindow.set_savedcCs|jj�dS)N)r��
reset_undo)r�rrrr��szEditorWindow.reset_undocCs(|jj}|rtjj|�}nd}|j|�S)Nr�)r�r�rRrSr�r�)r�r�rrrr��s
zEditorWindow.short_titlecCs|j|jjpd�S)Nr7)r�r�r�)r�rrrr��szEditorWindow.long_titlecCs|j�dS)NrA)r>)r�rBrrrrr�sz EditorWindow.center_insert_eventr�cCsH|j}|j�\}}|j|�}||}td||d�}|jt|��dS)NrDr5)r>�getwindowlinesr�maxrr)r��markr>r_�botr0r@Znewtoprrrr>�s
zEditorWindow.centercCsN|j}|jd�}|jd�}||krF|j�dkrFt|d�}||d}||fS)Nz@0,0z@0,65535rDr@)r>rZwinfo_heightr<)r�r>r_r�r@rrrr��s

zEditorWindow.getwindowlinescCs|j}tt|j|���S)N)r>r<rr�)r�r�r>rrrr�szEditorWindow.getlinenocCs(|jj�}tjd|�}ttt|j���S)zReturn (width, height, x, y)z(\d+)x(\d+)\+(-?\d+)\+(-?\d+))r_Zwm_geometryr��match�list�mapr<�groups)r�Zgeom�mrrr�get_geometry�s
zEditorWindow.get_geometrycCs|j�dS)NrA)rj)r�rBrrrrl�szEditorWindow.close_eventcCsH|jrD|j�s:|jj�dkr&|jj�|jj�|jj�|jj�SdS)Nr)r�r�r_r�Z	deiconify�lowerZlift�	maybesave)r�rrrr��s


zEditorWindow.maybesavecCs |j�}t|�dkr|j�|S)NZcancel)r�r��_close)r�Zreplyrrrrj�szEditorWindow.closecCs�|jjr|j|jjd�tj|j�|j�|jj�d|_d|_|j	rZ|j	jd�d|_	d|_
d|_|jj�d|_|j
j�|jr�|j�dS)N)ryF)r�r�r�rZunregister_callbackr��unload_extensionsrjr�r�r>rar�r_ZdestroyrG)r�rrrr��s"


zEditorWindow._closecCsi|_|j�dS)N)�
extensions�load_standard_extensions)r�rrrr�szEditorWindow.load_extensionscCs4x(t|jj��D]}t|d�r|j�qWi|_dS)Nrj)r�r��values�hasattrrj)r��insrrrr�s
zEditorWindow.unload_extensionscCsHxB|j�D]6}y|j|�Wq
tdt|��tj�Yq
Xq
WdS)NzFailed to load extension)rV�load_extension�print�repr�	traceback�	print_exc)r�r9rrrr�sz%EditorWindow.load_standard_extensionscCstjdd�S)NT)Zeditor_only)rZ
GetExtensions)r�rrrrV"sz)EditorWindow.get_standard_extension_namesZZzDummyZzzdummyc	CsF|jj||�}y>ytjd|td�}Wn"ttfk
rHtj|�}YnXWn tk
rltd|��YnXt||�}t	j
|�}t|d�r�|j|j
|�||�}||j|<|�rB|j|�x�|D]|}|jdd�}x |dd�dkr�|dd�}q�Wx"|dd�d	k�r|dd�}q�W|d
}t||�r�|jj|t||��q�WdS)
Nr�)�packagez
Failed to import extension: r^�-rLrDr�r�Z_eventrPrP)�extfilesr��	importlib�
import_module�__package__�ImportError�	TypeErrorr�rrrWr�r�r^r�rir
r>rk)	r�r9Zfname�mod�clsrXr�ZveventZ
methodnamerrrr�)s4







zEditorWindow.load_extensioncCsJ|dkr|jj}|j}||_x(|j�D]\}}|r&|j|f|��q&WdS)N)r&rTr>rXrUr�)r�rXr>rBrYrrrriEszEditorWindow.apply_bindingsc	Cs�|dkr|jj}|dkr |jj}|j}|j}x�|D]�\}}|j|�}|sJq2x�|D]�}|sb|j�qP|\}	}
|	dd�dk}|r�|	dd�}	t|	�\}}	t||
�}
||
fdd�}|r�|j	|
t
�}|j|	|||
|d�qP|j|	|||
d�qPWq2WdS)zAdd appropriate entries to the menus and submenus

        Menus that are absent or None in self.menudict are ignored.
        NrD�!cSs|j|�dS)N)r)r>rrrrrEgsz(EditorWindow.fill_menus.<locals>.command)r�r�rEr]Zvariable)r�r�rEr])
r&r^rTr�r>r�r�r�r_�get_var_objZ
BooleanVarZadd_checkbuttonr)r�r^rXr�r>ZmnameZ	entrylistr6rbr�rZcheckbuttonr�r]rE�varrrrr�Ns8




zEditorWindow.fill_menuscCs&|j|�}|r|j�}|St|��dS)N)r�r��	NameError)r�r9r��valuerrr�getvarss

zEditorWindow.getvarcCs(|j||�}|r|j|�nt|��dS)N)r�r�r�)r�r9r��vartyper�rrr�setvar{szEditorWindow.setvarcCs.|jj|�}|r*|r*||j�|j|<}|S)N)rar�r>)r�r9r�r�rrrr��s
zEditorWindow.get_var_objcCs,|jr$|jjd|�p"d|jj|�kSdSdS)NZTODO�STRINGrD)r�r>�
tag_prevrangeZ	tag_names)r�Z
text_indexrrr�is_char_in_string�szEditorWindow.is_char_in_stringcCs:y |jjd�}|jjd�}||fStk
r4dSXdS)Nz	sel.firstzsel.last)NN)r>r�r)r�r�r�rrr�get_selection_indices�sz"EditorWindow.get_selection_indicescCs|jdpt}t|�S)N�tabs)r>�TK_TABWIDTH_DEFAULTr<)r�Zcurrentrrr�get_tk_tabwidth�szEditorWindow.get_tk_tabwidthcCsB|j}|j�|kr>|jjdd|dd|jd|�}|j|d�dS)NrHZmeasurez
-displayof�n)r�)r>r�rrZmasterZ	configure)r�Znewtabwidthr>Zpixelsrrr�set_tk_tabwidth�s
zEditorWindow.set_tk_tabwidthTcCsP|r@|r@|j�}d|ko"dknr.||_|j|jkr@d|_|j|j�dS)Nr5rF)�guess_indentr�r�r�r�)r�r�Zguessr|rrrr��sz#EditorWindow.set_indentation_paramsc
CsB|j}|j�\}}|r6|r6|j||�|jd|�dS|jdd�}|dkrp|jddd�rd|jd�n|j�dS|d
d	kr�|jd�dS|j}t|j	|��}|d|j
|j
}d
}	xH||jkr�P|dd�}|	d}	t|j	|��}||kp�|dd	kr�Pq�W|j�|jd|	d�||k�r6|j
dd||�|j�dS)Nr�rAzinsert linestartr7r�z1.0z	insert-1crDz 	rz
insert-%dcr�rPrPrP)r>r�rr�r�r�r/r�r��
expandtabsr�rdr�r�r�)
r�rBr>r�r��charsr�ZhaveZwantZ
ncharsdeletedrrrr��sB


z"EditorWindow.smart_backspace_eventc

Cs�|j}|j�\}}|j�z�|rV|rVt|�t|�kr>|j|�S|j||�|jd|�|jdd�}t||j	�\}}|t
|�kr�|j||j�n>|j
r�d}n&t
|j|j	��}|j}	d|	||	}|jd|�|jd�dS|j�XdS)Nr�zinsert linestartr�r�rA)r>r�r��
index2liner�rr�r��
classifywsr�r��reindent_tor�r�r�r�r�r�)
r�rBr>r�r��prefix�raw�	effectiveZpadr�rrrr��s,

zEditorWindow.smart_indent_eventcCs�|j}|j�\}}|j��z�|r>|r>|j||�|jd|�|jdd�}dt|�}}x ||krx||dkrx|d}qZW||kr�|jdd�dS|d|�}d}x2|r�|ddkr�||jkr�|dd
�}|d}q�W|r�|jd|d�x|jd�dk�r|jd�q�W|jdd�t	|j
d��}	tj|j
|j�}
|j�s�xj|jD]`}t|	|d�}t|�d	}
|j|
d�}|
j|�|
j|j|j|
��}|dk	�s�|dk�rDP�qDW|
j|�p�d�n@|jd
d�}|�r�|d}
nd}
|j|
d�}|
j|�|
jd�|
j�}|tjk�r�|tjk�rnn|tjk�r6|jd|�nT|tjk�rR|j|
j��n8|tjk�r�|
j �dk�rz|jd|�n|j|
j!��ndS|
j"�}|jd|�|
j#��r�|j$|�n|�r�|
j%��r�|j&|�dS|j'd�|j(�XdS)Nr�zinsert linestartrz 	rDrMrAzinsert - %d charsz.0Zconsolez1.0rPrP))r>r�r�rr�r�r�r�rdr�r�rZParserr�r�r�r�r�r�Zset_codeZfind_good_parse_start�_build_char_in_string_funcZset_lor�Zget_continuation_typeZC_NONEZC_STRING_FIRST_LINEZC_STRING_NEXT_LINESZ	C_BRACKETr�Zcompute_bracket_indentZC_BACKSLASHZget_num_lines_in_stmtZcompute_backslash_indentZget_base_indent_stringZis_block_openerr�Zis_block_closerr�r�r�)r�rBr>r�r�r�r|r��indentZlnor
�contextZstartatZstartatindexZrawtextZbodrgr�rrrr�s�






z%EditorWindow.newline_and_indent_eventcCs||jfdd�}|S)NcSs||d|�S)Nz+%dcr)�offsetZ_startindexZ_icisrrr�inner}sz6EditorWindow._build_char_in_string_func.<locals>.inner)r�)r�Z
startindexr�rrrr�|sz'EditorWindow._build_char_in_string_funcc
Csz|j�\}}}}xTtt|��D]D}||}|rt||j�\}}	|	|j}	|j|	�||d�||<qW|j||||�dS)NrA)�
get_regionr�r�r�r�r��_make_blanks�
set_region)
r�rB�head�tailr�rrOr�r�r�rrrr��s
z EditorWindow.indent_region_eventc
Cs�|j�\}}}}xZtt|��D]J}||}|rt||j�\}}	t|	|jd�}	|j|	�||d�||<qW|j||||�dS)NrrA)	r�r�r�r�r�r�r�r�r�)
r�rBr�r�r�rrOr�r�r�rrrr��sz EditorWindow.dedent_region_eventcCsR|j�\}}}}x,tt|�d�D]}||}d|||<q"W|j||||�dS)NrDz##rA)r�r�r�r�)r�rBr�r�r�rrOr�rrrr��sz!EditorWindow.comment_region_eventcCs�|j�\}}}}xdtt|��D]T}||}|s0q|dd�dkrN|dd�}n|dd�dkrj|dd�}|||<qW|j||||�dS)Nr5z##rD�#rA)r�r�r�r�)r�rBr�r�r�rrOr�rrrr��sz#EditorWindow.uncomment_region_eventc
Cs�|j�\}}}}|j�}|dkr$dSx\tt|��D]L}||}|r2t||�\}	}
t|
|�\}}d|d|||	d�||<q2W|j||||�dS)Nr�r�rA)r��_asktabwidthr�r�r��divmodr�)
r�rBr�r�r�rr�rOr�r�r��ntabs�nspacesrrrr��s$z EditorWindow.tabify_region_eventcCs`|j�\}}}}|j�}|dkr$dSx&tt|��D]}||j|�||<q2W|j||||�dS)NrA)r�r�r�r�r�r�)r�rBr�r�r�rr�rOrrrr��sz"EditorWindow.untabify_region_eventcCsF|jddd
|jdd|jdd	|jd
�rB|j|_d|_dS)NzToggle tabsz
Turn tabs �on�offz?
Indent width �will be�
remains atz 8.z!
 Note: a tab is always 8 columns)rrrA)r�r�)r�r�)r�r�r>r�)r�rBrrrr��s

zEditorWindow.toggle_tabs_eventcCs:|jdd|j|jddd�}|r6||jkr6|jr6||_dS)NzIndent widthz6New indent width (2-16)
(Always use 8 when using tabs)r5�)r�initialvalue�minvalue�maxvaluerA)r�r>r�r�)r�rBr�rrrr��sz%EditorWindow.change_indentwidth_eventcCsn|j}|j�\}}|r8|r8|j|d�}|j|d�}n|jd�}|jd�}|j||�}|jd�}||||fS)Nz
 linestartz-1c lineend +1czinsert linestartzinsert lineend +1crM)r>r�r�r�r�)r�r>r�r�r�r�r�rrrrr��s


zEditorWindow.get_regioncCsx|j}dj|�}||kr$|j�dS|jddd�|jd|�|j�|j||�|j||�|j�|j	d|d�dS)NrMr�z1.0rOr�)
r>rTr/r�r�r�rr�r�r�)r�r�r�r�rr>�newcharsrrrr��s
zEditorWindow.set_regioncCs2|jr&t||j�\}}d|d|Sd|SdS)Nr�r�)r�r�r�)r�r�r�r�rrrr�szEditorWindow._make_blankscCsJ|j}|j�|jddd�r(|jdd�|r>|jd|j|��|j�dS)Nzinsert linestartz!=r�)r>r�r�rr�r�r�)r�r�r>rrrr�
szEditorWindow.reindent_tocCs|jdd|j|jddd�S)Nz	Tab widthzColumns per tab? (2-16)r5r�)rr�r�r�)r�r>r�)r�rrrr�szEditorWindow._asktabwidthcCsPt|j|j�j�\}}|r@|r@t||j�\}}t||j�\}}nd}}||S)Nr)�IndentSearcherr>r�r�r�)r��openerZindentedr�ZindentsmallZindentlargerrrr�$szEditorWindow.guess_indent)NNNN)N)r�r�)r�r�)r�r�)r�r�)r�r�)rr�)rr�)rrN)N)N)N)N)N)N)N)N)N)N)r�)r�)N)NN)N)N)T)�r6�
__module__�__qualname__Zidlelib.percolatorr Zidlelib.colorizerr!r"Zidlelib.undor#Zidlelib.iomenur$r%r7r&Zidlelib.statusbarr'Zidlelib.autocompleter(Zidlelib.autoexpandr)Zidlelib.calltipr*Zidlelib.codecontextr+Zidlelib.paragraphr,Zidlelib.parenmatchr-Zidlelib.rstripr.Zidlelib.squeezerr/Zidlelib.zoomheightr0r�getfilesystemencodingr�rQr�r�r�r�r�r�r�rhr�r�rnrrmrrrrrrurvrsrtrorprqrxryr�r�r�rzr{r}r|r~rr3rwr�r�r�r?r�rGrHr�rJrKr��stringZ
ascii_lettersZdigitsrNrQrRr\r`r�r�rar�rxr�r�r�r�r�r�rrr>r�rr�rlr�rjr�r�r�r�rVr�r�rir�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�rrrrr-s

+




		$.	
		%	,#j
	

	rcCstt|��S)N)r<r)r�rrrr�.sr�cCs\d}}xJ|D]B}|dkr,|d}|d}q|dkrN|d}||d|}qPqW||fS)Nrr�rDr�r)�sr�r�r�Zchrrrr�6s

r�c@s8eZdZdd�Zdd�Zejejdfdd�Zd
d�Z	dS)r�cCs(||_||_d|_|_d|_|_dS)Nr)r>r�r|�finished�blkopenline�indentedline)r�r>r�rrrr�KszIndentSearcher.__init__cCsL|jr
dS|jd}|_t|�d}|jj|dd�r:dS|jj||d�S)Nr7rDz.0z>=rOz lineend+1c)r�r|r�r>r�r�)r�r|r�rrr�readlineQszIndentSearcher.readline�class�def�for�if�try�whilec		Cs>|jrn2||kr ||kr ||_n||kr:|jr:||_d|_dS)NrD)r�r�r�)	r�r=�token�startrOr��INDENT�NAMEZOPENERSrrr�
tokeneaterZszIndentSearcher.tokeneatercCsltj}|jt_zHy(tj|j�}x|D]}|j|�q$WWntjtfk
rRYnXWd|t_X|j|j	fS)N)
�tokenize�tabsizer��generate_tokensr�r��
TokenError�SyntaxErrorr�r�)r�Zsave_tabsize�tokensr�rrrr�fs

zIndentSearcher.runN)r�r�r�r�r�r�)
r6r�r�r�r�r�r�r�r�r�rrrrr�Ds
	r�cCs6|jd�}|dkr.|d|�||dd�}||fS)NrLrrD)r.)r�r|rrrr�xs
r��[�]�/)ZbracketleftZbracketrightZslashcCs�|j|�}|s tj�r$|dkr$dS|d}tjddd�|�}tjd	d
d�|�}tjdd|�}tjdd
|�}tjdd|�}tjdd|�}tjdd|�}tjdd|�}tjdd|�}|S)N�<<open-module>>�
<<goto-line>>�<<change-indentwidth>>r7rz-[a-z]\bcSs|j�j�S)N)�group�upper)r�rrrrC�sz!get_accelerator.<locals>.<lambda>z\b\w+\bcSstj|j�|j��S)N)�keynamesr�r�)r�rrrrC�szKey-ZCancelz
Ctrl-BreakzControl-zCtrl-r��+z><r�r�r�>r�r�r�)r�r	Z	isCocoaTkr�r�)rXrrYr�rrrr_�s"
r_cCs4|j}|jddd�|jddd�|jddd�dS)	NZtcl_wordBreakAfterza brr�Z
tcl_wordcharsz\wZtcl_nonwordcharsz\W)rr)r\rrrr�
fixwordbreaks�srcCs�|}t|�tjdd�r&tjd}nd}tj|d�t||d�}|j}d|d<x,td�D] }|jdd|t	|�d�qZWdS)	NrD)r\r��
r@�r�z  rM)
rr�argvr	ZsetupApprr>r�r�r�)rr\r�r�r>r|rrr�_editor_window�sr�__main__)r:zidlelib.idle_test.test_editorr5F)�	verbosity�exit)r�)6Z
importlib.abcr��importlib.utilrRrVr�r�r�r$ZtkinterZtkinter.ttkrZtkinter.simpledialogZsimpledialogr�Ztkinter.messageboxZ
messageboxr�Zidlelib.configrr7rrrrr	Zidlelib.multicallr
rrr
rrr�Zpython_versionr�rrr�objectrr�r�r�r�rr_rrr6Zunittestr:Zidlelib.idle_test.htestr�rrrr�<module>sn



4
	


?>