Your IP : 18.222.98.91


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



���];�@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)Nz%s%sz%s�	candidatezrc%s�finalr)�sys�version_info)�major�minor�micro�level�serial�release�r�1/opt/alt/python35/lib64/python3.5/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)Nrz�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��wrapZnoneZhighlightthicknessr�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)rarbrc���)�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_bindings�protocol�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 rn�filename�keyroZdochomeZpyverZbasepathZchmfilertrzrMZtext_optionsrRZ	usespacesr�r�r��	is_py_srcrKrerrrr!gs<						
		









	
		
	
	%	
	





	zEditorWindow.__init__cCs�t|t�rty|j|j�}WnLtk
rsy|j|j�}Wn!tk
rn|jd�}YnXYnXtjdd|�S)Nz	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)NrV)r�Zdefaultfilenamern�new)r rWr1�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�.rY� �	�insertzinsert linestart+�c�selz1.0rez	sel.firstZ	my_anchor�<zsel.last�>rV)r�r�)�stateZkeysymrRr��comparerQ�splitr��range�len�str�
tag_remove�mark_set�tag_add�see)r rWZinsertpt�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)NrUrYZborderwidthZ
backgroundZgrey75rJZ	_padding1z    r[�columnzCol: ?r�zLn: ?r\z<<set-line-and-column>>z<KeyRelease>z<ButtonRelease>)rFrt�
status_barryrri�	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 rWr�r�rrrr��s!z EditorWindow.set_line_and_column�file�_File�edit�_Edit�format�F_ormat�run�_Run�options�_Optionsrd�_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)rsr��
menu_specs�prepstrrrZadd_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)NrdrerYrf)r�r�r��deleterZadd_windows_to_menu)r rKrerrrr��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_rmenurWrri�config�rmenu_specs�
ValueError�getattrZentryconfigureZtk_popupZx_rootZy_root)	r rWrZiswin�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)NrrrYcSs|j|�dS)N)�event_generate)rRrrrrrZ�sz(EditorWindow.make_rmenu.<locals>.commandrrZ)rrrRr�add_commandr�r)r rrrrrZrrrr�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	CLIPBOARDr!r")rR�tk�callr#)r rrr�rmenu_check_paste�s
 
	zEditorWindow.rmenu_check_pastecCstj|jd�dS)Nz
About IDLE)r
ZAboutDialogrt)r rWrrrr��szEditorWindow.about_dialogcCstj|jd�dS)NZSettings)rZConfigDialogrt)r rWrrrr�szEditorWindow.config_dialogcCs/|jr|j}n	|j}tj|�dS)N)rortrZ
show_idlehelp)r rWrrrrr�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�messagerrV)rrir-�	startfilerg�OSErrorr�r�r�rR�
webbrowser�open)r rW�whyrrrr�s,zEditorWindow.python_docscCs|jjd�dS)Nz<<Cut>>rV)rRr)r rWrrrr�szEditorWindow.cutcCs*|jjd�sdS|jjd�dS)Nr�z<<Copy>>rV)rRZ
tag_rangesr)r rWrrrr�szEditorWindow.copycCs$|jjd�|jjd�dS)Nz	<<Paste>>r�rV)rRrr�)r rWrrrr�&szEditorWindow.pastecCs=|jjddd�|jjdd�|jjd�dS)Nr�z1.0zend-1cr�rV)rRr�r�r�)r rWrrrr�+szEditorWindow.select_allcCs*|jjddd�|jjd�dS)Nr�z1.0rer�)rRr�r�)r rWrrrr�1szEditorWindow.remove_selectioncs=|jj�|jj�d�����fdd�}|S)N�sel.first+1c�sel.last-1ccsK|jd@dkrGy�d��d���Wntk
rFYnXdS)NrSrz	sel.firstr�)r�r#)rW)�
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 r0r4r)r0r1r2r3rr�5s
z&EditorWindow.move_at_edge_if_selectioncCs|jjd�dS)Nz
<Meta-Delete>rV)rRr)r rWrrrr�IszEditorWindow.del_word_leftcCs|jjd�dS)Nz<Meta-d>rV)rRr)r rWrrrr�MszEditorWindow.del_word_rightcCstj|j�dS)NrV)r�findrR)r rWrrrr�QszEditorWindow.find_eventcCstj|j�dS)NrV)rZ
find_againrR)r rWrrrr�UszEditorWindow.find_again_eventcCstj|j�dS)NrV)rZfind_selectionrR)r rWrrrr�Ysz!EditorWindow.find_selection_eventcCs tj|j|j|j�dS)NrV)rZgreprRr�rn)r rWrrrr�]sz EditorWindow.find_in_files_eventcCstj|j�dS)NrV)r�replacerR)r rWrrrr�aszEditorWindow.replace_eventcCsp|j}tjddd|�}|dkr1dS|dkrK|j�dS|jdd|�|jd�dS)NZGotozGo to line number:rrVrr�z%d.0)rRr�r��bellr�r�)r rWrR�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_filenamerqrnr,r�r�)r rWrL�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�idlelibrFrn)r rWr��head�tail�base�extrFrrrr��szEditorWindow.open_class_browsercCs$ddlm}|j|j�dS)Nr)�PathBrowser)rIrNrn)r rWrNrrrr��szEditorWindow.open_path_browsercCs5ddl}tjddg}|j|dd�dS)Nrz-cz,from turtledemo.__main__ import main; main()�shellF)�
subprocessr�
executable�Popen)r rWrP�cmdrrrr��s
	zEditorWindow.open_turtle_democCsi|dk	re|dkre|jjdd|�|jjddd�|jjddd�|j�dS)Nrr�z%d.0r�z1.0rez
insert +1l)rRr�r�r��center)r r8rrr�gotoline�s
zEditorWindow.gotolinecCs�|stjj|�rdStjjtjj|��\}}tjj|�dkr]dS|jjdd�}|jd�o�d|kS)	NT�.py�.pywz1.0z1.0 lineendz#!�python)rVrW)	r-r.rkrHr��normcaserRr��
startswith)r r�rLrMr�rrrr��s$zEditorWindow.ispythonsourcecCs&|jr"|jj|�d|_dS)N)rnZunregister_maybe_terminate)r rrr�
close_hook�s	zEditorWindow.close_hookcCs
||_dS)N)r[)r r[rrr�set_close_hook�szEditorWindow.set_close_hookcCsA|jr|jj|�|j�|jj|�|j�dS)N)rnZfilename_changed_editr�rtZupdate_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)N)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)N�ERRORz
 wordstart�
r�z+1c)r�r��
IDENTCHARSr�r�)r rR�pos�charrrr�colorize_syntax_error�sz"EditorWindow.colorize_syntax_errorcCs#tj|jdd�|jd<dS)NrNr=r])r	r�rorR)r rrr�	ResetFont�szEditorWindow.ResetFontcCs�tj�|j_}x-|j�D]\}}|jj||�q#WxY|j�D]K}tj|�}|rSx-|j�D]\}}|jj||�q{WqSWdS)N)	r	�GetCurrentKeySetrD�default_keydefs�itemsrRZevent_delete�get_standard_extension_names�GetExtensionBindings)r �keydefsrW�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)NrrYrZ�acceleratorrr9)r	rhrDrir}rkrl�menudefsr
r�r�r
r�rPZ	entrycget�get_acceleratorZentryconfig)
r rmrorpZ
menuEventDictrKrZmenubarItemrer�ZaccelZitemNamerWrrr�ApplyKeybindingss<
,

zEditorWindow.ApplyKeybindingscCs+|js'tjddddd�|_dS)NrNr_z
num-spacesrPrQ)r�r	r{r�)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)NrrYrrrZ)
r	ZGetAllExtraHelpSourcesListr�r�r
rrr��"_EditorWindow__extra_help_callbackr)r Z	help_listZhelpmenuZhelpmenu_length�entryrSrrrr6s


z$EditorWindow.reset_help_menu_entriescs|�fdd�}|S)Ncs�|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)rxry)rZr-r.rmrrir)r*r�r�r�rRr+r,)�helpfiler-)r rr�display_extra_helpIs,z>EditorWindow.__extra_help_callback.<locals>.display_extra_helpr)r rzr{r)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�fd
d�|D�}d}|dt
|��}y9t|jd
dddd��}|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)N�rrC�utf_8�errorsr6rbr�rYcs"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�rZrrf)r-r.r�rxr,�	readlinesr0�remover��appendr��
writelinesr*rror�r��showwarningr�r�rRrtrwr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_savedrtZwm_titleZwm_iconname)r Zshort�longr'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}|r'tjj|�}nd}|j|�S)Nr�)r�r�r-r.r�r�)r r�rrrr��s
zEditorWindow.short_titlecCs|j|jjpd�S)Nr9)r�r�r�)r rrrr��szEditorWindow.long_titlecCs|j�dS)N)rT)r rWrrrr��sz EditorWindow.center_insert_eventr�cCsb|j}|j�\}}|j|�}||}td||d�}|jt|��dS)NrYr#)rR�getwindowlines�	getlineno�maxr��float)r �markrRrt�botr8rUZnewtoprrrrT�s	
zEditorWindow.centercCsm|j}|jd�}|jd�}||krc|j�dkrct|d�}||d}||fS)Nz@0,0z@0,65535rYrU)rRr�Zwinfo_heightrQ)r rRrtr�rUrrrr��s	zEditorWindow.getwindowlinescCs"|j}tt|j|���S)N)rRrQr�r�)r r�rRrrrr��s	zEditorWindow.getlinenocCs:|jj�}tjd|�}ttt|j���S)Nz(\d+)x(\d+)\+(-?\d+)\+(-?\d+))rtZwm_geometryr��match�list�maprQ�groups)r r9�mrrr�get_geometry�szEditorWindow.get_geometrycCs|j�dS)N)r)r rWrrrr��szEditorWindow.close_eventcCsb|jr^|j�sQ|jj�dkr7|jj�|jj�|jj�|jj�SdS)Nr")r�r�rtr�r7�lowerr8�	maybesave)r rrrr��s	


zEditorWindow.maybesavecCs,|j�}t|�dkr(|j�|S)N�cancel)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_extensionsrr�r�rRrvr�rtr4r[)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)rk�load_extension�print�repr�	traceback�	print_exc)r rLrrrr�sz%EditorWindow.load_standard_extensionscCstjdd�S)NZeditor_onlyT)r	Z
GetExtensions)r rrrrksz)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: rs�-r`rYr�r�Z_eventrfrf)r<�
import_module�__package__r?�	TypeErrorr�rr	rlr�rrsr�r}r6rRr3)r rL�mod�clsrmr�ZveventZ
methodnamerrrr�s2





zEditorWindow.load_extensioncCsa|dkr|jj}|j}||_x0|j�D]"\}}|r7|j||�q7WdS)N)rDrirRrmrjr�)r rmrRrWrnrrrr}&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)
NrY�!cSs|j|�dS)N)r)rRrrrrrZHsz(EditorWindow.fill_menus.<locals>.commandrrrZrr�variable)
rDrsrir�rRr�r�r
rt�get_var_objZ
BooleanVarZadd_checkbuttonr)r rsrmr�rRZmnameZ	entrylistrKrwrrZcheckbuttonrrrrZ�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)rvr�rR)r rLr�r�rrrr�cs
zEditorWindow.get_var_objcCs<|jr4|jjd|�p3d|jj|�kSdSdS)NZTODO�STRINGrY)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 �currentrrr�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|j
|j
}|jrtj
jd
�d}	nd}	d}
x]||	kr1P|dd�}|
d}
t|j	|��}||ks||dd	kr$Pq$W|j�|jd|
d�||kr�|jdd
||�|j�dS)Nr�rVzinsert linestartr9r�z1.0z	insert-1crYz 	rbrz
insert-%dcr�rfrfrfrf)rRr�rr�r�r�r7r�r��
expandtabsr�r�rrpr�r�r�r�)r rWrRr�r��charsr�ZhaveZwant�last_line_of_promptZ
ncharsdeletedrrrr��sH	

		


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�rV)rRr�r��
index2liner�rr�r��
classifywsr�r��reindent_tor�r�r�r�r�r�)
r rWrRr�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|d
dkr4||	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
jkrz|t
jkr�n�|t
jkr|jd|�no|t
jkr,|j|j ��nJ|t
j!krv|j"�dkr`|jd|�qv|j|j#��ndS|j$�}|jd|�|j%�r�|j&|�n|r�|j'�r�|j(|�dSWd|j)d�|j*�XdS)Nr�zinsert linestartrz 	rYrbrVzinsert - %d charsz.0Zconsolez1.0rfrfrf)+rRr�r�rr�r�r�r�rrpr�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_indentZget_base_indent_stringZis_block_openerr�Zis_block_closerr�r�r�)r rWrRr�r�r�r�r��indentr��lnor�contextZstartatZstartatindexZrawtextZbodr|r�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)NrV)�
get_regionr�r�r�r�r��_make_blanks�
set_region)
r rWrJrKr��linesrdr�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)NrrV)	r�r�r�r�r�r�r�r�r�)
r rWrJrKr�r�rdr�r�r�rrrr�ss
%z EditorWindow.dedent_region_eventcCsk|j�\}}}}x6tt|�d�D]}||}d|||<q/W|j||||�dS)NrYz##)r�r�r�r�)r rWrJrKr�r�rdr�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##rY�#)r�r�r�r�)r rWrJrKr�r�rdr�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 rWrJrKr�r�r�rdr�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 rWrJrKr�r�r�rdrrrr��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 columnsrrrV)r�r�)r�r�)r�r�rRr�)r rWrrrr��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)rr:�minvaluer#�maxvalue�rV)r�rRr�r�)r rWr�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 +1crb)rRr�r�r�r�)r rRr�r�rJrKr�r�rrrr��s	zEditorWindow.get_regioncCs�|j}dj|�}||kr2|j�dS|jddd�|jd|�|j�|j||�|j||�|j�|j	d|d�dS)Nrbr�z1.0rer�)
rRr/r7r�r�r�rr�r�r�)r rJrKr�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)rr:r�r#r�r�)r�rRr�)r rrrr��s		zEditorWindow._asktabwidthcCsrt|j|j�j�\}}|r`|r`t||j�\}}t||j�\}}n
d}}||S)Nr)�IndentSearcherrRr�rr�)r ZopenerZindentedr�ZindentsmallZindentlargerrrr�s!
zEditorWindow.guess_indent)r�r�)r�r�)r�r�)rr)rr)rdr)rr)rrN)�r:r;r<Zidlelib.Percolatorr>Zidlelib.ColorDelegatorr?r@Zidlelib.UndoDelegatorrAZidlelib.IOBindingrBrCrIrD�tkinterrEZidlelib.MultiStatusBarrFr�getfilesystemencodingr�rgr!r�r�r�r�r�r	r|r�rr�rrr rr&r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rUr�r[r\r�r^r_r��string�
ascii_letters�digitsrcrfrgrqrur�rrvr�r�r�r�r�r�r�r�r�rTr�r�r�r�r�rr�r�r�r�rkr�r}rr�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�rYr�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)Nr9rYz.0z>=rez 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)NrY)r�r�r�)	r rP�token�startrer��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�tokensrrrrrKs	
	
zIndentSearcher.runN)r�r�r�rrr)
r:r;r<r!r�rrrrrrrrrr�)s
	r�cCsG|jd�}|dkr=|d|�||dd�}||fS)Nr`rrY)r5)r�r�rrrr
]s"r
Zbracketleft�[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>>r9rz-[a-z]\bcSs|j�j�S)N)�group�upper)r�rrrrXvsz!get_accelerator.<locals>.<lambda>z\b\w+\bcSstj|j�|j��S)N)�keynamesr�r)r�rrrrXwszKey-ZCancelz
Ctrl-BreakzControl-zCtrl-r�r,z><r�r�r�>rrr)r�r
Z	isCocoaTkr�r�)rmrrnr�rrrrtls"	
rtcCsF|j}|jddd�|jddd�|jddd�dS)	NZtcl_wordBreakAfterza brr�Z
tcl_wordcharsz[a-zA-Z0-9_]Ztcl_nonwordcharsz
[^a-zA-Z0-9_])r$r%)ror$rrr�
fixwordbreaks�s	rcCsx|}t|�tjdd�r3tjd}nd}tj|d�td|d|�}|jjd|j�dS)NrYror�z<<close-all-windows>>)	rr�argvr
ZsetupAppr=rRr3r�)rror�r�rrr�_editor_window�s
r�__main__zidlelib.idle_test.test_editor�	verbosityr#�exitF)r)7r<Z
importlib.abc�importlib.utilr-rir�r�rr�Ztkinter.simpledialogZsimpledialogr�Ztkinter.messageboxZ
messageboxr�r�r+Zidlelib.MultiCallrrIrrrrrZidlelib.configHandlerr	r
rrr
rr�Zpython_versionr�r�objectrZ
helpDialogr=r�r��tokenizerr�r
rrtrrr:ZunittestrNZidlelib.idle_test.htestrrrrr�<module>sf
-	������
4
	

?>