AlkantarClanX12

Your IP : 3.145.7.187


Current Path : /proc/self/root/opt/alt/python35/lib64/python3.5/idlelib/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python35/lib64/python3.5/idlelib/__pycache__/EditorWindow.cpython-35.pyc



��Yf;�@s}ddlZddlZddlZddlZddlZddlZddlZddlZddlTddl	j
Zddlj
ZddlZddlZddlmZddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZmZmZddlmZddlmZd
Z dej!�Z"dd�Z#Gdd�de$�Z%e%�Z&Gdd�de$�Z'dd�Z(dd�Z)ddl*Z*e*Z+[*Gdd�de$�Z,dd�Z-dddd d!d"iZ.d#d$�Z/d%d&�Z0d'd(�Z1e2d)kryddl3Z3e3j4d*d+d,d-d.�dd/l5m6Z6e6e1�dS)0�N)�*)�MultiCallCreator)�
WindowList)�SearchDialog)�
GrepDialog)�
ReplaceDialog)�PyParse)�idleConf)�aboutDialog�textView�configDialog)�
macosxSupport)�help�z (%s)cCs�tj\}}}}}d||f}|d|f7}|dkrY|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�9/opt/alt/python35/lib64/python3.5/idlelib/EditorWindow.py�_sphinx_versionsrc@sReZdZdd�Zddd�Zdd�Zdd	�Zdd
d�ZdS)�
HelpDialogcCsd|_d|_dS)N)�parent�dlg)�selfrrr�__init__-s	zHelpDialog.__init__NcCsUddl}|jdtdd�|jdkr>|j|�|rQ|j|�dS)z� Display the help dialog.

            parent - parent widget for the help window

            near - a Toplevel widget (e.g. EditorWindow or PyShell)
                   to use as a reference for placing the help window
        rNz�EditorWindow.HelpDialog is no longer used by Idle.
It will be removed in 3.6 or later.
It has been replaced by private help.HelpWindow
�
stacklevel�)�warnings�warn�DeprecationWarningr�show_dialog�
nearwindow)r r�near�wrrr�display1s	

zHelpDialog.displaycCsr||_tjjtjjtjjt��d�}tj|d|dd�|_	}|j
d|jd�dS)Nzhelp.txtZHelpZmodalFz	<Destroy>�+)r�os�path�join�abspath�dirname�__file__rZ	view_filer�bind�destroy)r r�fnrrrrr'Cs	-"zHelpDialog.show_dialogcCs\|j}|j�d|j�df}|j�|jd|�|j�|j�dS)N�
z=+%d+%d)rZwinfo_rootxZwinfo_rootyZwithdrawZgeometry�	deiconify�lift)r r)r�geomrrrr(Is	 

zHelpDialog.nearwindowcCsd|_d|_dS)N)rr)r Zevrrrr4Ts	zHelpDialog.destroy)�__name__�
__module__�__qualname__r!r+r'r(r4rrrrr+s
rc@s�eZdZddlmZddlmZmZddlm	Z	ddl
mZmZddl
mZddlmZddlmZej�Zd	Zd	d	d	d	d
d�Zdd
�Zdd�Zdd�Zdd�Zd	dd�Zd�d�d�d�d�d�d�gZd$d%�Zd&d'�Zd	Z d(d)�Z!d�gZ"d,d-�Z#d.d/�Z$d0d1�Z%d2d3�Z&d	d4d5�Z'd	d6d7�Z(d	d8d9�Z)d	d:d;�Z*d<d=�Z+d>d?�Z,d@dA�Z-d	dBdC�Z.d	dDdE�Z/dFdG�Z0dHdI�Z1dJdK�Z2dLdM�Z3dNdO�Z4dPdQ�Z5dRdS�Z6dTdU�Z7dVdW�Z8d	dXdY�Z9d	dZd[�Z:d	d\d]�Z;d	d^d_�Z<d`da�Z=dbdc�Z>ddde�Z?dfdg�Z@dhdi�ZAdjdk�ZBdldm�ZCdndo�ZDeEjFeEjGdpZHdqdr�ZIdsdt�ZJdudv�ZKdwdx�ZLdydz�ZMd{d|�ZNd}d~�ZOd	dd��ZPd�d��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZVd�d��ZWd�d��ZXd�d�d��ZYd�d��ZZd�d�d��Z[d�d��Z\d�d��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d��Zbd�d��Zcd�d��Zdd�d��Zed	d�d��Zfd	d	d�d��Zgd�d��Zhd	d�d��Zid	d�d��Zjd�d��Zkd�d��Zld�d��Zmd�d��Znd�d�d��Zod�d��Zpd�d��Zqd�d��Zrd�d��Zsd�d��Ztd�d��Zud�d��Zvd�d��Zwd�d��Zxd�d��Zyd�d��Zzd�d��Z{d�d��Z|d�d��Z}d�d��Z~d�d��Zd�d��Z�d�d��Z�d	S)��EditorWindowr)�
Percolator)�ColorDelegator�color_config)�
UndoDelegator)�	IOBinding�encoding)�Bindings)�Toplevel)�MultiStatusBarNcCs�	tjdkr|tjjtjdd�}tjjd�r�ddtj	dd�}tjj
d�rrd}qd	}tjj||dd�}n}tjdd�d
kr�tjjtjddt��}tjj|�r|}n'tjdkrtjjtjd
�}tjj
|�}tjj|�rb|t_tjdkr|dtjt_ndtj	dd�t_||_|p�|j}||_ytjWntk
r�dt_YnXt|�|_tj|d|j�|_}	|r|j|_|j|j_ni|_i|j_tjjtj�d�|_t|	�|_}
t |
dd�|_!}tj"ddddd�|_#ddddddd d!d|j#d"tj"ddd"dd�i}t$d#kr�d$|d%<t%t&�|
|�|_'}
|j'|j_(|j)�|j*�|jj+d&|j,�|jj-d'|j.�t/j0�r�|
j-d'|j.�|
j-d(|j1�|
j-d)|j1�n|
j-d*|j1�|
j-d+|j2�|
j-d,|j3�|
j-d-|j4�|
j-d.|j5�|
j-d/|j6�|
j-d0|j7�|
j-d1|j8�|
j-d2|j9�|
j-d3|j:�|
j-d4d5d6��|
j-d7|j;�|
j-d8|j<�|
j-d9|j=�|
j-d:|j>�|
j-d;|j?�|
j-d<|j@�|
j-d=|jA�|
j-d>|jB�|
j-d?|jC�|
j-d@|jD�|
j-dA|jE�|
j-dB|jF�|
j-dC|jG�|
j-dD|jH�|
j-dE|jI�|
j-dF|jJ�|
j-dG|jK�|
j-dH|jL�|
j-dI|jM�|
j-dJ|jNd!��|
j-dK|jNdL��|
j-dM|jO�|
j-dN|jP�|
j-dO|jQ�|r�||j|<|rn||jR|<|
j-dP|jS�|
j-dQ|jjT�|
j-dR|jU�|
j-dS|jV�|
j-dT|jW�|jX�|
jY|dU<|jZdVt[dWt\�|j]|
dX<tj^|jdd�|
dY<|
jZdVt_dWt`dZdL�|
jZdVtadWt`dZdL�|
jb�tj"dd[d\dd]�}||_cd^|_d|jd|_e|jf�d_|_gdf|_h|ji|
�|_j}|jk�|_l}|jm|�|jn|
_n|jo|
_o|jp|jq�|jr|�|_s}|jt|ju�d_|_v|jwd_�d|_x|r�tjjy|�r�tjj
|�r�|jz|�r�dc|_v|j{|�}|jw|�n|j||�dc|_v|j}�|jq�|j~�|j�|j�j�dd�}|rs	|j�de�}|dkr:	dg}|d!krZ	|j��|dL}||_�tj�|j��t�j�|_�t�j�|_�t�j�|_�dS)hNZDocz
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.chm�darwinz0Resources/English.lproj/Documentation/index.htmlzfile://zhttps://docs.python.org/%d.%d/r#z>>> �menuzrecent-files.lst�name�vbar�mainr=�width�type�int�textZpadx�ZwrapZnoneZhighlightthicknessr�heightg!@Z
wordprocessorZtabstyleZWM_DELETE_WINDOWz<<close-window>>z<Control-Button-1>z<2>z<3>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�expand�Indentz
use-spaces�boolrF�2���@KLT�windows�end)r`rarb���)�r=�help_urlr-r.r/r�base_prefix�platform�countr�isdirr�isfile�normpath�flist�root�ps1�AttributeError�Menu�menubarrZListedToplevel�top�vars�tkinter_varsZinversedict�
instance_dictr	Z
GetUserCfgDir�recent_files_path�Frame�
text_frameZ	ScrollbarrM�	GetOptionrOZ	TkVersionrZTextrRZfocused_widget�
createmenubar�apply_bindingsZprotocol�closer3�close_eventr
ZisAquaTk�right_menu_event�cut�copy�paste�center_insert_event�help_dialog�python_docs�about_dialog�
config_dialog�open_module�
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_class_browser�open_path_browser�open_turtle_demo�set_status_bar�yview�pack�RIGHT�Y�set�GetFontZLEFTZBOTHZTOPZ	focus_set�usetabs�tabwidth�indentwidth�set_notabs_indentwidth�context_use_ps1�num_context_linesr>�perrA�undo�insertfilter�undo_block_start�undo_block_stopZset_saved_change_hook�saved_change_hookrB�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)r rm�filename�keyrnZdochomeZpyverZbasepathZchmfilersryrMZtext_optionsrRZ	usespacesr�r�r��	is_py_srcrKrdrrrr!gs<						
		









	
		
	
	%	
	





	zEditorWindow.__init__cCs�t|t�rty|j|j�}WnLtk
rsy|j|j�}Wn!tk
rn|jd�}YnXYnXtjdd|�S)z3Return filename as BMP unicode so diplayable in Tk.z	iso8859-1u[𐀀-􏿿]u�)�
isinstance�bytes�decode�filesystemencoding�UnicodeDecodeErrorrC�re�sub)r r�rrr�_filename_to_unicode@s

z!EditorWindow._filename_to_unicodecCs)|jj�\}}|jj|�dS)NrU)r�Zdefaultfilenamerm�new)r rVr1�basenamerrrr�OszEditorWindow.new_callbackcCss|jd@dkr&|jdkr&dS|jjd�r�|jjddd�r�|jjddd�r�t|jjd�jd�d	�}nO|jjdd�}x7tt	|��D]}||dkr�Pq�Wt	|�}t|jjd�jd�d	�}||krd}d
t
|�d}|jd	@dkrV|jjddd�n�|jjd�s~|jjdd�nY|jj|jjd�d|jjd��r�|jjdd�n|jjdd�|jj|�}|jjd�}|jj|d|�r ||}}|jjddd�|jj
d||�|jjd|�|jjd�dS)N�rZHomeZiomarkz<=zinsert lineendzinsert linestart�.rX� �	�insertzinsert linestart+�c�selz1.0rdz	sel.firstZ	my_anchor�<zsel.last�>rU)r�r�)�stateZkeysymrRr��comparerQ�splitr��range�len�str�
tag_remove�mark_set�tag_add�see)r rVZinsertpt�lineZlineat�dest�first�lastrrrr�Ts@"(%
zEditorWindow.home_callbackcCs|j|j�|_t|jdddddd�}tjdkr^|jjddd	t�|jjd
dd	t�|jjdd
d	t�|jjd	t	dt
�|jd	t	dt
�|jjd|j
�|jjddd�|jj|j
�dS)NrTrXZborderwidthZ
backgroundZgrey75rJZ	_padding1z    rZ�columnzCol: ?r�zLn: ?r[z<<set-line-and-column>>z<KeyRelease>z<ButtonRelease>)rFrs�
status_barrxrrh�	set_labelr�r�ZBOTTOM�XrRr3�set_line_and_column�	event_addZ
after_idle)r �seprrrr�s!
zEditorWindow.set_status_barcCsS|jjt�jd�\}}|jjdd|�|jjdd|�dS)Nr�r�zCol: %sr�zLn: %s)rRr�ZINSERTr�r�r�)r rVr�r�rrrr��s!z EditorWindow.set_line_and_column�file�_File�edit�_Edit�format�F_ormat�run�_Run�options�_Optionsrc�_Windowr�_HelpcCs2|j}i|_}xe|jD]Z\}}t|�\}}t|d|dd�||<}|jd|d|d|�q Wtj�r�t|dddd�|d<}|jdd	d|�|j�t|jdd�|_	|jd
j
dddddd|j	�|jd
jt�|_
|j�dS)NrL�tearoffr�labelrK�	underlineZappleZapplicationZIDLEr�rHzRecent Filesr)rrr��
menu_specs�prepstrrqZadd_cascader
Z
isCarbonTk�
fill_menus�recent_files_menuZinsert_cascader��END�base_helpmenu_length�reset_help_menu_entries)r Zmbarr�rLrrrKrrrr{�s"	
  

zEditorWindow.createmenubarcCse|jd}|jd�}|dkr.d}||jkrT|j|jd|�tj|�dS)NrcrdrXre)r�r�r��deleterZadd_windows_to_menu)r rKrdrrrr��s
zEditorWindow.postwindowsmenuc	
Cs |jjdd|j|jf�|js6|j�|j}||_tjdd�dk}|rz|jj	dd�xp|j
D]e}y|\}}}Wntk
r�w�YnX|dkr�q�t||��}|j
|d|�q�W|j|j|j�|r|jj	dd�dS)	Nr�z@%d,%drHrIZcursorZarrowr�Zibeam)rRr��x�y�rmenu�
make_rmenurVrrh�config�rmenu_specs�
ValueError�getattrZentryconfigureZtk_popupZx_rootZy_root)	r rVrZiswin�itemr�	eventnameZverify_stater�rrrr�s(#	
		
zEditorWindow.right_menu_event�Close�<<close-window>>cCs�t|jdd�}xj|jD]_}|d|d}}|dk	rt|j|dd�}|jd|d|�q|j�qW||_dS)NrrrXcSs|j|�dS)N)�event_generate)rRrrrrrY�sz(EditorWindow.make_rmenu.<locals>.commandrrY)rqrRr�add_commandr�r)r rrrrrYrrrr�szEditorWindow.make_rmenucCs
|j�S)N)�rmenu_check_copy)r rrr�rmenu_check_cut�szEditorWindow.rmenu_check_cutcCsAy|jjd�}Wntk
r.dSYnX|r9dSdSdS)Nz	sel.first�disabled�normal)rRr��TclError)r Zindxrrrr�s

	zEditorWindow.rmenu_check_copycCsAy |jjjd|jd�Wntk
r8dSYnXdSdS)Nztk::GetSelectionZ	CLIPBOARDrr )rR�tk�callr!)r rrr�rmenu_check_paste�s
 
	zEditorWindow.rmenu_check_pastecCstj|jd�dS)zHandle Help 'About IDLE' event.z
About IDLEN)r
ZAboutDialogrs)r rVrrrr��szEditorWindow.about_dialogcCstj|jd�dS)z&Handle Options 'Configure IDLE' event.ZSettingsN)rZConfigDialogrs)r rVrrrr�szEditorWindow.config_dialogcCs/|jr|j}n	|j}tj|�dS)zHandle Help 'IDLE Help' event.N)rnrsrZ
show_idlehelp)r rVrrrrr�s		zEditorWindow.help_dialogcCs�tjdd�dkr}ytj|j�Wq�tk
ry}z*tjdddt|�d|j	�WYdd}~Xq�Xnt
j|j�dS)NrHrI�titlezDocument Start Failure�messagerrU)rrhr-�	startfilerf�OSErrorr�r�r�rR�
webbrowser�open)r rV�whyrrrr�s,zEditorWindow.python_docscCs|jjd�dS)Nz<<Cut>>rU)rRr)r rVrrrr�szEditorWindow.cutcCs*|jjd�sdS|jjd�dS)Nr�z<<Copy>>rU)rRZ
tag_rangesr)r rVrrrr�szEditorWindow.copycCs$|jjd�|jjd�dS)Nz	<<Paste>>r�rU)rRrr�)r rVrrrr�&szEditorWindow.pastecCs=|jjddd�|jjdd�|jjd�dS)Nr�z1.0zend-1cr�rU)rRr�r�r�)r rVrrrr�+szEditorWindow.select_allcCs*|jjddd�|jjd�dS)Nr�z1.0rdr�)rRr�r�)r rVrrrr�1szEditorWindow.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-1ccsK|jd@dkrGy�d��d���Wntk
rFYnXdS)NrSrz	sel.firstr�)r�r!)rV)�
edge_index�edges_table�self_text_index�self_text_mark_setrr�move_at_edge@s

z<EditorWindow.move_at_edge_if_selection.<locals>.move_at_edge)r,r-)rRr�r�)r r.r2r)r.r/r0r1rr�5s
z&EditorWindow.move_at_edge_if_selectioncCs|jjd�dS)Nz
<Meta-Delete>rU)rRr)r rVrrrr�IszEditorWindow.del_word_leftcCs|jjd�dS)Nz<Meta-d>rU)rRr)r rVrrrr�MszEditorWindow.del_word_rightcCstj|j�dS)NrU)r�findrR)r rVrrrr�QszEditorWindow.find_eventcCstj|j�dS)NrU)rZ
find_againrR)r rVrrrr�UszEditorWindow.find_again_eventcCstj|j�dS)NrU)rZfind_selectionrR)r rVrrrr�Ysz!EditorWindow.find_selection_eventcCs tj|j|j|j�dS)NrU)rZgreprRr�rm)r rVrrrr�]sz EditorWindow.find_in_files_eventcCstj|j�dS)NrU)r�replacerR)r rVrrrr�aszEditorWindow.replace_eventcCsp|j}tjddd|�}|dkr1dS|dkrK|j�dS|jdd|�|jd�dS)NZGotozGo to line number:rrUrr�z%d.0)rRr�r��bellr�r�)r rVrR�linenorrrr�es		
zEditorWindow.goto_line_eventc!Cs�y|jjdd�}Wntk
r3d}Yn
X|j�}tjddd|jd|�}|rs|j�}|s}dSytjj|�}WnNt	t
fk
r�}z(tjdt
|�d|j�dSWYdd}~XnX|dkr
tjdd	d|j�dSt|jtjj�sBtjdd
d|j�dSy|jj|�}Wn/tk
r�tjddd|j�dSYnX|jr�|jj|�n|jj|�|S)Nz	sel.firstzsel.last�ZModulezAEnter the name of a Python module
to search on sys.path and open:r�initialvaluezImport errorzmodule not foundznot a source-based modulez$loader does not support get_filename)rRr�r!�stripr�Z	askstring�	importlib�util�	find_specr�ImportErrorr�r�r�r��loader�abc�SourceLoader�get_filenamerprmr*r�r�)r rVrL�spec�msgZ	file_pathrrrr�qsH
	


	
		zEditorWindow.open_modulecCs�|jj}|jjdko!|s@|j�}|dkr@dStjj|�\}}tjj|�\}}ddl	m
}|j
|j||g�dS)NZPyShellEditorWindowr)�ClassBrowser)r�r��	__class__r:r�r-r.r��splitext�idlelibrDrm)r rVr��head�tail�base�extrDrrrr��szEditorWindow.open_class_browsercCs$ddlm}|j|j�dS)Nr)�PathBrowser)rGrLrm)r rVrLrrrr��szEditorWindow.open_path_browsercCs5ddl}tjddg}|j|dd�dS)Nrz-cz,from turtledemo.__main__ import main; main()�shellF)�
subprocessr�
executable�Popen)r rVrN�cmdrrrr��s
	zEditorWindow.open_turtle_democCsi|dk	re|dkre|jjdd|�|jjddd�|jjddd�|j�dS)Nrr�z%d.0r�z1.0rdz
insert +1l)rRr�r�r��center)r r6rrr�gotoline�s
zEditorWindow.gotolinecCs�|stjj|�rdStjjtjj|��\}}tjj|�dkr]dS|jjdd�}|jd�o�d|kS)	NT�.py�.pywz1.0z1.0 lineendz#!�python)rTrU)	r-r.rjrFr��normcaserRr��
startswith)r r�rJrKr�rrrr��s$zEditorWindow.ispythonsourcecCs&|jr"|jj|�d|_dS)N)rmZunregister_maybe_terminate)r rrr�
close_hook�s	zEditorWindow.close_hookcCs
||_dS)N)rY)r rYrrr�set_close_hook�szEditorWindow.set_close_hookcCsA|jr|jj|�|j�|jj|�|j�dS)N)rmZfilename_changed_editr�rsZupdate_windowlist_registryr�)r rrrr��s
	
z!EditorWindow.filename_change_hookcCsw|jr
dS|j|jj�r1|j�|_|jrs|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�r[)r rrr�_rmcolorizer�s
	
zEditorWindow._rmcolorizercCs(|j�|j�tj|j�dS)zUpdate the color themeN)r]r\r=r@rR)r rrrr��s

zEditorWindow.ResetColorizer�_cCs�|jd|�|j|�}|rK||jkrK|jd|d|�d|j|�krs|jd|�n|jd|d�|j|�dS)NZERRORz
 wordstart�
r�z+1c)r�r��
IDENTCHARSr�r�)r rR�pos�charrrr�colorize_syntax_error�sz"EditorWindow.colorize_syntax_errorcCs#tj|jdd�|jd<dS)z.Update the text widgets' font if it is changedrNr=r\N)r	r�rnrR)r rrr�	ResetFont�szEditorWindow.ResetFontcCs�tj�|j_}x-|j�D]\}}|jj||�q#WxY|j�D]K}tj|�}|rSx-|j�D]\}}|jj||�q{WqSWdS)z/Remove the keybindings before they are changed.N)	r	�GetCurrentKeySetrD�default_keydefs�itemsrRZevent_delete�get_standard_extension_names�GetExtensionBindings)r �keydefsrV�keylist�
extensionName�xkeydefsrrr�RemoveKeybindings�szEditorWindow.RemoveKeybindingsc
Cs�tj�|j_}|j�x6|j�D](}tj|�}|r-|j|�q-Wi}xa|jjD]S}i||d<x<|dD]0}|r�|d||dt|d�d<q�WqlWx�|j	D]�}|j	|}|j
t�}|dkr�q�|d7}x�td|�D]�}	|j
|	�dkr|j|	d�}
|
r|j|	d�}d}||kr�|||kr�|||}|rt||�}
|j|	d|
�qWq�WdS)z-Update the keybindings after they are changedrrXNrY�acceleratorrr7)r	rerDrfr|rhri�menudefsrr�r�rr�rPZ	entrycget�get_acceleratorZentryconfig)
r rjrlrmZ
menuEventDictrKrZmenubarItemrdr�ZaccelZitemNamerVrrr�ApplyKeybindingss<
,

zEditorWindow.ApplyKeybindingscCs+|js'tjddddd�|_dS)zCUpdate the indentwidth if changed and not using tabs in this windowrNr^z
num-spacesrPrQN)r�r	rzr�)r rrrr�/s	z#EditorWindow.set_notabs_indentwidthcCs�tj�}|jd}|jt�}||jkrN|j|jd|�|r�|j�x;|D]3}|j|d�}|j	d|dd|�qeW||jd<dS)z3Update the additional help entries on the Help menurrXrrrYN)
r	ZGetAllExtraHelpSourcesListr�r�rrrr��"_EditorWindow__extra_help_callbackr)r Z	help_listZhelpmenuZhelpmenu_length�entryrQrrrr
6s


z$EditorWindow.reset_help_menu_entriescs|�fdd�}|S)zCCreate a callback with the helpfile value frozen at definition timecs�|jd	�s!tjj|�}tjdd�dkr�ytj|�Wq�tk
r�}z*tj	dddt
|�d�j�WYdd}~Xq�Xn
tj
|�dS)
N�www�httprHrIr%zDocument Start Failurer&r)rurv)rXr-r.rlrrhr'r(r�r�r�rRr)r*)�helpfiler+)r rr�display_extra_helpIs,z>EditorWindow.__extra_help_callback.<locals>.display_extra_helpr)r rwrxr)r rZ__extra_help_callbackGsz"EditorWindow.__extra_help_callbackcsmg}tjj|j�rOt|jddddd��}|j�}WdQRX|r�tjj|�d}||kr�|j|�|jd|�g�xD|D]<}d	|ks�tjj|dd��r��j	|�q�W�fdd�|D�}d
}|dt
|��}y9t|jddddd��}|j|�WdQRXWnxtk
r�}zXt
|jdd�s�d|j_tjdddd|jt|��d|j�WYdd}~XnXx�|jjD]�}|j}	|	jdt�xlt|�D]^\}
}|j�}|j|�}|j|�}
|	jd||
d|d|
dd�qWq�WdS)z/Load and update the recent files list and menus�rrC�utf_8�errorsr4Nr_r�rXcs"g|]}|�kr|�qSrr)�.0r.)�	bad_pathsrr�
<listcomp>gs	z9EditorWindow.update_recent_files_list.<locals>.<listcomp>Z1234567890ABCDEFGHIJKr*�recentfilelist_error_displayedFTr%zIDLE Warningr&z|Cannot update File menu Recent Files list. Your operating system says:
%s
Select OK and IDLE will continue without updating.rrr�rYrre)r-r.r�rwr*�	readlinesr0�remover��appendr��
writelinesr(rrnr�r��showwarningr�r�rRrsrvr
rr�	enumerate�rstrip�#_EditorWindow__recent_file_callbackr)r �new_fileZrf_listZrf_list_filer.ZulcharsZrf_file�err�instancerK�i�	file_nameZ
ufile_name�callbackr)r~rr�VsL

)	z%EditorWindow.update_recent_files_listcs|�fdd�}|S)Ncs�jjd|�dS)NZeditFile)r�r*)Z
fn_closure)r rr�open_recent_file�sz=EditorWindow.__recent_file_callback.<locals>.open_recent_filer)r r�r�r)r rZ__recent_file_callback�sz#EditorWindow.__recent_file_callbackcCs�|j�}|j�}|r9|r9|d|t}n$|rH|}n|rW|}nd}|pl|pl|}|j�s�d|}d|}|jj|�|jj|�dS)Nz - �Untitledz*%s*z*%s)�short_title�
long_title�_py_version�	get_savedrsZwm_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 Zflagrrrr��szEditorWindow.set_savedcCs|jj�dS)N)r��
reset_undo)r rrrr��szEditorWindow.reset_undocCs:|jj}|r'tjj|�}nd}|j|�S)Nr�)r�r�r-r.r�r�)r r�rrrr��s
zEditorWindow.short_titlecCs|j|jjpd�S)Nr7)r�r�r�)r rrrr��szEditorWindow.long_titlecCs|j�dS)N)rR)r rVrrrr��sz EditorWindow.center_insert_eventr�cCsb|j}|j�\}}|j|�}||}td||d�}|jt|��dS)NrXr#)rR�getwindowlines�	getlineno�maxr��float)r �markrRrs�botr6rTZnewtoprrrrR�s	
zEditorWindow.centercCsm|j}|jd�}|jd�}||krc|j�dkrct|d�}||d}||fS)Nz@0,0z@0,65535rXrT)rRr�Zwinfo_heightrQ)r rRrsr�rTrrrr��s	zEditorWindow.getwindowlinescCs"|j}tt|j|���S)N)rRrQr�r�)r r�rRrrrr��s	zEditorWindow.getlinenocCs:|jj�}tjd|�}ttt|j���S)zReturn (width, height, x, y)z(\d+)x(\d+)\+(-?\d+)\+(-?\d+))rsZwm_geometryr��match�list�maprQ�groups)r r9�mrrr�get_geometry�szEditorWindow.get_geometrycCs|j�dS)N)r})r rVrrrr~�szEditorWindow.close_eventcCsb|jr^|j�sQ|jj�dkr7|jj�|jj�|jj�|jj�SdS)Nr )r�r�rsr�r7�lowerr8�	maybesave)r rrrr��s	


zEditorWindow.maybesavecCs,|j�}t|�dkr(|j�|S)NZcancel)r�r��_close)r Zreplyrrrr}�s
zEditorWindow.closecCs�|jjr"|jd|jj�tj|j�|j�|jj�d|_d|_|j	r}|j	jd�d|_	d|_
d|_|jj�d|_|j
j�|jr�|j�dS)Nr�F)r�r�r�rZunregister_callbackr��unload_extensionsr}r�r�rRrur�rsr4rY)r rrrr��s"

						
	
	zEditorWindow._closecCsi|_|j�dS)N)�
extensions�load_standard_extensions)r rrrr��s	zEditorWindow.load_extensionscCsFx6t|jj��D]}t|d�r|j�qWi|_dS)Nr})r�r��values�hasattrr})r �insrrrr��szEditorWindow.unload_extensionscCsTxM|j�D]?}y|j|�Wq
tdt|��tj�Yq
Xq
WdS)NzFailed to load extension)rh�load_extension�print�repr�	traceback�	print_exc)r rLrrrr�sz%EditorWindow.load_standard_extensionscCstjdd�S)NZeditor_onlyT)r	Z
GetExtensions)r rrrrhsz)EditorWindow.get_standard_extension_namescCs�yKytjd|dt�}Wn'ttfk
rItj|�}YnXWn"tk
rotd|��YnXt||�}tj|�}t	|d�r�|j
|j|�||�}||j|<|r�|j
|�x�|D]�}|jdd�}x*|dd�dkr'|dd�}q�Wx*|dd�d	krT|dd�}q+W|d
}t	||�r�|jj|t||��q�WdS)
Nr��packagez
Failed to import extension: rp�-r^rXr�r�Z_eventrere)r:�
import_module�__package__r=�	TypeErrorr�rr	rir�r	rpr�r|r4rRr3)r rL�mod�clsrjr�ZveventZ
methodnamerrrr�s2





zEditorWindow.load_extensioncCsa|dkr|jj}|j}||_x0|j�D]"\}}|r7|j||�q7WdS)N)rDrfrRrjrgr�)r rjrRrVrkrrrr|&s		zEditorWindow.apply_bindingsc
Csi|dkr|jj}|dkr0|jj}|j}|j}x |D]\}}|j|�}|smqIx�|D]�}|s�|j�qt|\}	}
|	dd�dk}|r�|	dd�}	t|	�\}}	t||
�}
||
dd�}|r;|j	|
t
�}|jd|	d|d|d	|
d
|�qt|jd|	d|d|d	|
�qtWqIWdS)zAdd appropriate entries to the menus and submenus

        Menus that are absent or None in self.menudict are ignored.
        NrX�!cSs|j|�dS)N)r)rRrrrrrYHsz(EditorWindow.fill_menus.<locals>.commandrrrYroZvariable)
rDrprfr�rRr�r�rrq�get_var_objZ
BooleanVarZadd_checkbuttonr)r rprjr�rRZmnameZ	entrylistrKrtrrZcheckbuttonrrorY�varrrrr	/s8		


zEditorWindow.fill_menuscCs5|j|�}|r%|j�}|St|��dS)N)r�r��	NameError)r rLr��valuerrr�getvarTs
zEditorWindow.getvarcCs8|j||�}|r(|j|�nt|��dS)N)r�r�r�)r rLr��vartyper�rrr�setvar\szEditorWindow.setvarcCs=|jj|�}|r9|r9||j�|j|<}|S)N)rur�rR)r rLr�r�rrrr�cs
zEditorWindow.get_var_objcCs<|jr4|jjd|�p3d|jj|�kSdSdS)NZTODO�STRINGrX)r�rR�
tag_prevrangeZ	tag_names)r Z
text_indexrrr�is_char_in_stringss	zEditorWindow.is_char_in_stringcCsOy2|jjd�}|jjd�}||fSWntk
rJdSYnXdS)Nz	sel.firstzsel.last)NN)rRr�r!)r r�r�rrr�get_selection_indicess
z"EditorWindow.get_selection_indicescCs|jdpt}t|�S)N�tabs)rR�TK_TABWIDTH_DEFAULTrQ)r Zcurrentrrr�get_tk_tabwidth�szEditorWindow.get_tk_tabwidthcCs[|j}|j�|krW|jjdd|dd|jd|�}|jd|�dS)Nr\Zmeasurez
-displayof�nr�)rRr�r"r#ZmasterZ	configure)r ZnewtabwidthrRZpixelsrrr�set_tk_tabwidth�s		
zEditorWindow.set_tk_tabwidthTcCsl|rX|rX|j�}d|ko/dknr=||_|j|jkrXd|_|j|j�dS)Nr#rF)�guess_indentr�r�r�r�)r r�Zguessr�rrrr��s		z#EditorWindow.set_indentation_paramscCs�|j}|j�\}}|rK|rK|j||�|jd|�dS|jdd�}|dkr�|jddd�r�|jd�n
|j�dS|dd	kr�|jd�dS|j}t|j	|��}|d
ks�t
�|d|j|j}|jr't
jjd�d}	nd}	d
}
x]||	krCP|dd�}|
d}
t|j	|��}||ks�|dd	kr6Pq6W|j�|jd|
d�||kr�|jdd
||�|j�dS)Nr�rUzinsert linestartr7r�z1.0z	insert-1crXz 	rr_z
insert-%dcr�rererere)rRr�rr�r�r�r5r�r��
expandtabs�AssertionErrorr�r�rror�r�r�r�)r rVrRr�r��charsr�ZhaveZwant�last_line_of_promptZ
ncharsdeletedrrrr��sJ	

		


z"EditorWindow.smart_backspace_eventc

CsE|j}|j�\}}|j�z|ry|ryt|�t|�krY|j|�S|j||�|jd|�|jdd�}t||j	�\}}|t
|�kr�|j||j�nU|j
r�d}n3t
|j|j	��}|j}	d|	||	}|jd|�|jd�dSWd|j�XdS)Nr�zinsert linestartr�r�rU)rRr�r��
index2liner�rr�r��
classifywsr�r��reindent_tor�r�r�r�r�r�)
r rVrRr�r��prefix�raw�	effectiveZpadr�rrrr��s,	

			
zEditorWindow.smart_indent_eventcCs|j}|j�\}}|j�z�|rT|rT|j||�|jd|�|jdd�}dt|�}}x*||kr�||dkr�|d}q|W||kr�|jdd�dS|d|�}d}tj	j
d�d
}	x@|r4|ddkr4||	kr4|dd�}|d}q�W|rO|jd|d�x&|jd�dkrw|jd�qRW|jdd�t|jd��}
t
j|j|j�}|jsax�|jD]}t|
|d�}
t|
�d	}|j|d�}|j|�|j|j|j|��}|dk	sF|
dkr�Pq�W|j|pZd�nW|jd
d�}|r�|d}nd}|j|d�}|j|�|jd�|j�}|t
jkr�|t
jkr�n�|t
jkr|jd|�n�|t
jkr,|j|j ��nc|t
j!krv|j"�dkr`|jd|�q�|j|j#��nds�t$d|f��dS|j%�}|jd|�|j&�r�|j'|�n|r�|j(�r�|j)|�dSWd|j*d�|j+�XdS)Nr�zinsert linestartrz 	rXr_rUzinsert - %d charsz.0Zconsolez1.0zbogus continuation type %rrerere),rRr�r�rr�r�r�r�rror�r�r�rZParserr�r�r�r�r�r�Zset_strZfind_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_indentr�Zget_base_indent_stringZis_block_openerr�Zis_block_closerr�r�r�)r rVrRr�r�r�r�r��indentr�Zlnor�contextZstartatZstartatindexZrawtextZbodryr�rrrr��s�	
%	





z%EditorWindow.newline_and_indent_eventcCs||jdd�}|S)NcSs||d|�S)Nz+%dcr)�offsetZ_startindexZ_icisrrr�innercsz6EditorWindow._build_char_in_string_func.<locals>.inner)r�)r Z
startindexr�rrrr�bsz'EditorWindow._build_char_in_string_funcc
Cs�|j�\}}}}xptt|��D]\}||}|r+t||j�\}}	|	|j}	|j|	�||d�||<q+W|j||||�dS)NrU)�
get_regionr�r�r�r�r��_make_blanks�
set_region)
r rVrHrIr��linesrar�r�r�rrrr�hs

%z EditorWindow.indent_region_eventc
Cs�|j�\}}}}xytt|��D]e}||}|r+t||j�\}}	t|	|jd�}	|j|	�||d�||<q+W|j||||�dS)NrrU)	r�r�r�r�r�r�r�r�r�)
r rVrHrIr�r�rar�r�r�rrrr�ss
%z EditorWindow.dedent_region_eventcCsk|j�\}}}}x6tt|�d�D]}||}d|||<q/W|j||||�dS)NrXz##)r�r�r�r�)r rVrHrIr�r�rar�rrrr�~s

z!EditorWindow.comment_region_eventcCs�|j�\}}}}x�tt|��D]r}||}|sDq+|dd�dkrm|dd�}n&|dd�dkr�|dd�}|||<q+W|j||||�dS)Nr#z##rX�#)r�r�r�r�)r rVrHrIr�r�rar�rrrr��s
z#EditorWindow.uncomment_region_eventc
Cs�|j�\}}}}|j�}|dkr4dSxxtt|��D]d}||}|rGt||�\}	}
t|
|�\}}d|d|||	d�||<qGW|j||||�dS)Nr�r�)r��_asktabwidthr�r�r��divmodr�)
r rVrHrIr�r�r�rar�r�r��ntabs�nspacesrrrr��s
(z EditorWindow.tabify_region_eventcCs�|j�\}}}}|j�}|dkr4dSx1tt|��D]}||j|�||<qGW|j||||�dS)N)r�r�r�r�r�r�)r rVrHrIr�r�r�rarrrr��sz"EditorWindow.untabify_region_eventcCsW|jddd
|jdd|jdd	d
|j�rS|j|_d|_dS)NzToggle tabsz
Turn tabs �on�offz?
Indent width �will be�
remains atz 8.z!
 Note: a tab is always 8 columnsrrrU)r�r�)r�r�)r�r�rRr�)r rVrrrr��s!
	zEditorWindow.toggle_tabs_eventcCs\|jddd|jd|jdddd�}|rX||jkrX|jrX||_d	S)
NzIndent widthz6New indent width (2-16)
(Always use 8 when using tabs)rr8�minvaluer#�maxvalue�rU)r�rRr�r�)r rVr�rrrr��s				z%EditorWindow.change_indentwidth_eventcCs�|j}|j�\}}|rP|rP|j|d�}|j|d�}n|jd�}|jd�}|j||�}|jd�}||||fS)Nz
 linestartz-1c lineend +1czinsert linestartzinsert lineend +1cr_)rRr�r�r�r�)r rRr�r�rHrIr�r�rrrr��s	zEditorWindow.get_regioncCs�|j}dj|�}||kr2|j�dS|jddd�|jd|�|j�|j||�|j||�|j�|j	d|d�dS)Nr_r�z1.0rdr�)
rRr/r5r�r�r�rr�r�r�)r rHrIr�r�rR�newcharsrrrr��s	


zEditorWindow.set_regioncCs=|jr1t||j�\}}d|d|Sd|SdS)Nr�r�)r�r�r�)r r�r�r�rrrr��s	zEditorWindow._make_blankscCse|j}|j�|jddd�r8|jdd�|rW|jd|j|��|j�dS)Nzinsert linestartz!=r�)rRr�r�rr�r�r�)r r�rRrrrr��s	
zEditorWindow.reindent_tocCs.|jddd|jd|jdddd�S)	Nz	Tab widthzColumns per tab? (2-16)rr8r�r#r�r�)r�rRr�)r rrrr��s		zEditorWindow._asktabwidthcCsrt|j|j�j�\}}|r`|r`t||j�\}}t||j�\}}n
d}}||S)Nr)�IndentSearcherrRr�r�r�)r ZopenerZindentedr�ZindentsmallZindentlargerrrr�s!
zEditorWindow.guess_indent)r�r�)r�r�)r�r�)r�r�)rr)rcr)rr)rrN)�r:r;r<Zidlelib.Percolatorr>Zidlelib.ColorDelegatorr?r@Zidlelib.UndoDelegatorrAZidlelib.IOBindingrBrCrGrD�tkinterrEZidlelib.MultiStatusBarrFr�getfilesystemencodingr�rfr!r�r�r�r�r�rr{r�rrrrrrr$r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rSr�rYrZr�r\r]r��stringZ
ascii_lettersZdigitsr`rcrdrnrrr�r
rsr�r�r�r�r�r�r�r�r�rRr�r�r�r~r�r}r�r�r�r�rhr�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�rrrrr=[s��+	
		+	$.	
		%	0#k


	r=cCstt|��S)N)rQr�)r�rrrr�sr�cCstd}}x]|D]U}|dkr:|d}|d}q|dkre|d}||d|}qPqW||fS)Nrr�rXr�r)�sr�r�r�Zchrrrr�s




r�c@sOeZdZdd�Zdd�Zejejddd�Zd
d�Z	dS)r�cCs6||_||_d|_|_d|_|_dS)Nr)rRr�r��finished�blkopenline�indentedline)r rRr�rrrr!0s		zIndentSearcher.__init__cCsd|jr
dS|jd}|_t|�d}|jj|dd�rMdS|jj||d�S)Nr7rXz.0z>=rdz lineend+1c)r�r�r�rRr�r�)r r�r�rrr�readline6s	zIndentSearcher.readline�class�def�for�if�try�whilec		Cs[|jrnK||kr0||kr0||_n'||krW|jrW||_d|_dS)NrX)r�r�r�)	r rP�token�startrdr��INDENT�NAMEZOPENERSrrr�
tokeneater?s		zIndentSearcher.tokeneatercCs�tj}|jt_zVy4tj|j�}x|D]}|j|�q4WWntjtfk
riYnXWd|t_X|j|j	fS)N)
�	_tokenize�tabsizer��generate_tokensr�r��
TokenError�SyntaxErrorr�r�)r Zsave_tabsize�tokensr�rrrr�Ks	
	
zIndentSearcher.runN)r�r�r�r�r�r�)
r:r;r<r!r�r�r�r�r�r�rrrrr�)s
	r�cCsG|jd�}|dkr=|d|�||dd�}||fS)Nr^rrX)r3)r�r�rrrr]s"rZbracketleft�[Zbracketright�]Zslash�/cCs	|j|�}|s.tj�r2|dkr2dS|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�rrrrWvsz!get_accelerator.<locals>.<lambda>z\b\w+\bcSstj|j�|j��S)N)�keynamesr�r
)r�rrrrWwszKey-ZCancelz
Ctrl-BreakzControl-zCtrl-r�r,z><r�r�r�>rr	r)r�r
Z	isCocoaTkr�r�)rjrrkr�rrrrqls"	
rqcCsF|j}|jddd�|jddd�|jddd�dS)	NZtcl_wordBreakAfterza brr�Z
tcl_wordcharsz[a-zA-Z0-9_]Ztcl_nonwordcharsz
[^a-zA-Z0-9_])r"r#)rnr"rrr�
fixwordbreaks�s	r
cCsx|}t|�tjdd�r3tjd}nd}tj|d�td|d|�}|jjd|j�dS)NrXrnr�z<<close-all-windows>>)	r
r�argvr
ZsetupAppr=rRr3r~)rrnr�r�rrr�_editor_window�s
r�__main__zidlelib.idle_test.test_editor�	verbosityr#�exitF)r�)7r:Z
importlib.abc�importlib.utilr-rhr�r�rr�Ztkinter.simpledialogZsimpledialogr�Ztkinter.messageboxZ
messageboxr�r�r)Zidlelib.MultiCallrrGrrrrrZidlelib.configHandlerr	r
rrr
rr�Zpython_versionr�r�objectrZ
helpDialogr=r�r��tokenizer�r�rrrqr
rr:ZunittestrNZidlelib.idle_test.htestr�rrrr�<module>sf
-	������
4