
    .hh                    T   S SK rS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
r
S SK7  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SK J!r!  S SK"J#r#  S SKJ$r$  S SK%J&r&  Sr'S\RP                  " 5       -  r)\R                  S:H  r*S r+ " S S5      r,S r-\R\                  " S5      r/S r0 " S S 5      r1S! r2S"S#S$S%.r3S& r4S' r5S( r6\7S):X  a  S S*K8J9r9  \9" S+S,S-S.9  S S/K:J;r;  \;" \65        gg)0    N)*)Font)	Scrollbar)simpledialog)
messagebox)idleConf)configdialog)grep)help)
help_about)macosx)MultiCallCreator)pyparse)query)replace)search)wheel_event)py_extensions)window)_get_dochome   z (%s)darwinc                      [         R                  u  pp#nU  U 3nXR -  nUS:X  a
  USU 3-  nU$ US:w  a  XSS    U 3-  nU$ )zYFormat sys.version_info to produce the Sphinx version string used to install the chm docs	candidatercfinalr   )sysversion_info)majorminormicrolevelserialreleases         7/opt/python-3.13.8/usr/lib/python3.13/idlelib/editor.py_sphinx_versionr&   '   so    ),)9)9&E%wGGRx=  N 
'	AhZx((N    c                      \ rS rSrSSKJr  SSKJrJr  SSK	J
r
  SSKJrJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJrJrJrJ r   SSK!J"r"  SSK#J$r$  \%RL                  " 5       r'Sr(Sr)Sr*Sr+SyS jr,SzS jr-S r.S r/S r0S r1SzS jr2 / SQr3S r4S r5S r6S r7S r8Sr9S  r:S!/r;S" r<S# r=S$ r>S% r?SzS& jr@SzS' jrASzS( jrBSzS) jrCS* rDS+ rES, rFSzS- jrGSzS. jrHS/ rIS0 rJS1 rKS2 rLS3 rMS4 rNS5 rOS6 rPS7 rQS8 rRS9 rSSzS: jrTSzS; jrUSzS< jrVS= rWS> rXS? rYS@ rZSA r[SB r\SC r]SD r^\_R                  \_R                  -   SE-   rbSF rcSG rdSH reSI rfSJ rgSK rhSL riSM rjSzSN jrkSO rlSP rmSQ rnSR roSS rpST rqSU rrSV rsS{SW jrtSX ruS{SY jrvSZ rwS[ rxS\ ryS] rzS^ r{S_ r|S` r}Sa r~Sb rScSd0rSe rSzSf jrS|Sg jrSh rSzSi jrSzSj jrSk rSl rSm rSn rS}So jrSp rSq rSr rSs rSt rSu rSv rSzSw jrSxrg)~EditorWindow4   r   )
Percolator)ColorDelegatorcolor_config)UndoDelegator)	IOBindingencoding)mainmenu)MultiStatusBar)AutoComplete)
AutoExpand)Calltip)CodeContext)LineNumbers)FormatParagraphFormatRegionIndentsRstrip)
ParenMatch)
ZoomHeightNTc                 x   SSK Jn  [        R                  c  [	        5       [        l        Xl        U=(       d    UR                  nX@l        [        U5      U l        [        R                  " X@R                  S9=U l        nU(       a-  UR                  U l        UR                  U R                  l        O0 U l        0 U R                  l        [         R"                  =(       a.    [$        R&                  R)                  [         R"                  S5      U l        SU l        [/        U5      =U l        n[3        USS9=U l        n[         R6                  " SS	S
SS9n	SSSSU	S[         R6                  " SS	SSS9S.n
[9        [:        5      " U40 U
D6=U l        nU R<                  U R                  l        U RA                  5         U RC                  5         U R                  RE                  SU RF                  5        U R                  RI                  SU RJ                  5        [L        RN                  " 5       (       aU  URI                  SU RJ                  5        URI                  SU RP                  5        URI                  SU RP                  5        OURI                  SU RP                  5        URI                  S[R        5        URT                  S:X  a,  URI                  S[R        5        URI                  S[R        5        URI                  SU RV                  5        URI                  SU RX                  5        URI                  SU RZ                  5        URI                  SU R\                  5        URI                  S U R^                  5        URI                  S!U R`                  5        URI                  S"U Rb                  5        URI                  S#U Rd                  5        URI                  S$U Rf                  5        URI                  S%U Rh                  5        URI                  S&S' 5        URI                  S(U Rj                  5        URI                  S)U Rl                  5        URI                  S*U Rn                  5        URI                  S+U Rp                  5        URI                  S,U Rr                  5        URI                  S-U Rt                  5        URI                  S.U Rv                  5        URI                  S/U Rx                  5        URI                  S0U Rz                  5        URI                  S1U R|                  5        URI                  S2U R~                  5        U R                  U 5      =U lA        nURI                  S3UR                  5        URI                  S4UR                  5        URI                  S5UR                  5        URI                  S6UR                  5        URI                  S7UR                  5        URI                  S8UR                  5        U R                  U 5      nURI                  S9UR                  5        URI                  S:UR                  5        URI                  S;U R                  S5      5        URI                  S<U R                  S=5      5        URI                  S>U R                  5        URI                  S?U R                  5        URI                  S@U R                  5        U(       a  X1R                  U '   U(       a  XR                  U'   URI                  SAU R                  5        URI                  SBU R
                  R                  5        URI                  SCU R                  5        URI                  SDU R                  5        URI                  SEU R                  5        U R                  5         UR                  [        [        S=SF9  UR                  S=S=SG9  UR                  S=S=SG9  U R                  USH'   UR                  S=SI[        SJ9  UR                  USK'   [         R                  " U R                  SS	5      USL'   UR                  S=S=[        SJ9  UR                  5         U R                  5         [         R6                  " SSMSNSOS9nU(       + U lb        SPU lc        U R                  U ld        U R                  5         [        [         SQ5      (       d  U R<                  SR   [         lg        U R                  5         SSU li        U R                  U5      =U lk        nU R                  5       =U lm        nUR                  U5        UR                  Ulo        UR                  Ulp        UR                  U R                  5        U R                  U 5      =U lt        nUR                  U R                  5        STU lw        U R                  ST5        S U ly        S U lz        S U l{        U(       a  [$        R&                  R                  U5      (       ad  [$        R&                  R                  U5      (       d@  UR                  U5      (       a)  SUU lw        U R                  U5      nU R                  U5        OUGR                  U5        SUU lw        U GR                  5         U R                  5         U GR                  5         U GR                  5         U GR                  GR                  SV5      nU(       a\  UGR                  SW5      nUc  SXnUS:  a  UGR                  5         US=-   nUU l        [        GR                  " U GR                  5        G[        GR                  U l        G[        GR                  U l        G[        GR                  U l        UGR!                  SYSZ5        UGR!                  S[S\S]S^5        UGR!                  S_S`5        UGR!                  SaSb5        UGR!                  ScSbSdSe5        U GR#                  X GR$                  5      nURI                  SYUGR&                  5        URI                  S[UGR(                  5        URI                  SfUGR*                  5        URI                  SgU GR-                  U 5      GR.                  5        URI                  ShU GR1                  U 5      GR2                  5        U GR5                  U 5      nURI                  SiUGR6                  5        URI                  ScUGR8                  5        U" U 5      nURI                  SjUGR:                  5        URI                  SkUGR<                  5        URI                  SlUGR>                  5        URI                  SmU GRA                  U 5      GRB                  5        U GRE                  U 5      =U l        nURI                  S_UGRH                  5        URI                  SaUGRJ                  5        URI                  SnUGRL                  5        URI                  SoU GRO                  U 5      GRP                  5        U GRR                  (       a?  U GRU                  U 5      U lz        URI                  SpU R                  GRV                  5        OU GRY                  SqSrSs5        U GRZ                  (       ab  U GR]                  U 5      U l{        [         R6                  " SS	StSOS9(       a  U GR_                  5         URI                  SuU GR^                  5        g U GRY                  SqSvSs5        g )wNr   )ScriptBinding)menuzrecent-files.lst vbar)namemainr)   widthinttypetext   nonewordprocessorheight)rC   padxwraphighlightthicknessrE   tabstylerM   WM_DELETE_WINDOW<<close-window>>z<Control-Button-1>z<2>z<3>z<MouseWheel>x11z
<Button-4>z
<Button-5>z<Configure>z<<cut>>z<<copy>>z	<<paste>>z<<center-insert>>z<<help>>z<<python-docs>>z<<about-idle>>z<<open-config-dialog>><<open-module>>z<<do-nothing>>c                     gNbreak )events    r%   <lambda>'EditorWindow.__init__.<locals>.<lambda>   s    'r'   z<<select-all>>z<<remove-selection>>z<<find>>z<<find-again>>z<<find-in-files>>z<<find-selection>>z<<replace>><<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>><<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>>)sidefillexpand)weightcommand   )rowcolumnstickyyscrollcommandfontIndentz
use-spacesboolr   blink_off_timeinsertofftime)2   i  i@KL FTr   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<<run-custom>>z<<do-rstrip>>z<<force-open-calltip>>z<<zoom-height>>z<<toggle-code-context>>optionsz*ode*ontextdisabledzline-numbers-defaultz<<toggle-line-numbers>>*ine*umbers)idlelib.runscriptr?   r)   help_urlr   flistrootMenumenubarr   ListedTopleveltopvarstkinter_varsinversedictinstance_dictr   userdirospathjoinrecent_files_pathprompt_last_lineFrame
text_framer   rB   	GetOptionr   TextrI   focused_widgetcreatemenubarapply_bindingsprotocolclosebindclose_eventr   isAquaTkright_menu_eventr   _windowingsystemhandle_winconfig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_eventr9   fregionindent_region_eventdedent_region_eventcomment_region_eventuncomment_region_eventtabify_region_eventuntabify_region_eventr:   toggle_tabs_eventchange_indentwidth_eventmove_at_edge_if_selectiondel_word_leftdel_word_righthome_callbackdictnew_callbackclose_all_callbackopen_module_browseropen_path_browseropen_turtle_demoset_status_barpackLEFTBOTHrowconfigurecolumnconfigurehandle_yviewgridNSEWsetGetFont	focus_set	set_widthusetabstabwidthindentwidthset_notabs_indentwidthhasattrrm   update_cursor_blinknum_context_linesr+   perr.   undoinsertfilterundo_block_startundo_block_stopset_saved_change_hooksaved_change_hookr/   ioset_filename_change_hookfilename_change_hook	good_loadset_indentation_paramscolorcode_contextline_numbersexistsisdirloadfileispythonsourceset_filenameResetColorizerupdate_recent_files_listload_extensionsmenudictgetindexadd_separator	wmenu_endregister_callbackpostwindowsmenur   
askintegerr   askyesno	showerror	event_addr3   user_input_insert_tagsautocomplete_eventtry_open_completions_eventforce_open_completions_eventr4   expand_word_eventr8   format_paragraph_eventr<   flash_paren_eventparen_closed_eventcheck_module_eventrun_module_eventrun_custom_eventr;   	do_rstripr5   ctiptry_open_calltip_eventrefresh_calltip_eventforce_open_calltip_eventr=   zoom_height_eventallow_code_contextr6   toggle_code_context_eventupdate_menu_stateallow_line_numbersr7   toggle_line_numbers_event)selfrw   filenamekeyrx   r?   r|   r   rB   rE   text_optionsrI   r   indents	usespacesr   r   r   	is_py_srcr@   rp   autocomplete
parenmatchscriptbindingr   s                            r%   __init__EditorWindow.__init__K   s   3  ($0NL!
!uzz	Dz..t,,GG3 %

D &+%6%6DHH" "D%'DHH"!)!1!1 "6bggll  "476 !#',Sz1*$Zf==	D""6>7O&'+",,uF	 ,D1*MMM	D"&)),djj9($*:*:;??II($*:*:; II*4+@+@AIIeT223 IIeD112		.+.  E)IIlK0IIlK0		-!6!67		)TXX&		*dii(		+tzz*		%t'?'?@		*d../		#T%5%56		"D$5$56		*D,>,>?		#T%;%;<		"$9:		"DOO4		($*?*?@		*doo.		"D$9$9:		%t'?'?@		&(A(AB		-!3!34		/4#7#78		'(B(BC		*4+H+HI		$T%<%<=!%!2!24!88w		%w'B'BC		%w'B'BC		&(D(DE		('*H*HI		%w'B'BC		')F)FG,,t$		#W%>%>?		*G,L,LM		(D::1=>		)T;;A>?		%t'9'9:		&(;(;<		)4+=+=>&)d#"&

3II+T->->?II-tzz/L/LMII.0H0HIII-t/E/EFII,d.C.CDTQ7!,""1Q"/++Y		a$	/!%''		6>JV		a$	/ &&vx'3&B	$}   ==##% x!122&*ii&@H#  " "2..3--//	D $ 5 5#33""4#9#9:~~d++"
##D$=$=>##E*
  ww~~h''h0G0G;;x((%)DN $ 3 3H =I//	:)!% %%'}}  ***U#C{ax""$Ag DN$$T%9%9: '11"++#-- 	);713H+-E	G-/GH,.GH)+D24M	O
 ((/J/JK		$l&E&EF		,99	;		.;;	=		#T__T%:%L%LM		(&&t,CC	E__T*
		#Z%A%AB		$j&C&CD%d+		$m&F&FG		"M$B$BC		"M$B$BC		/4;;t#4#>#>?<<--	D		($*E*EF		')C)CD		*D,I,IJ		#T__T%:%L%LM""" $ 0 0 6DII/''AAC ""9mZH""" $ 0 0 6D!!&."8vG..0II/1O1OP""9mZHr'   c                 $    U R                  5         g N)r   r	  rZ   s     r%   r   EditorWindow.handle_winconfigI  s    r'   c           	      :   U R                   n[        [        UR                  R                  UR                  S5      UR                  S5      /5      5      nUR                  5       SU-  -
  n[        XR                  S5      S9R                  S5      nX4-  U l	        g )NborderrN   re   rj   )rj   0)
rI   summaptkgetintcgetwinfo_widthr   measurerE   )r	  rI   inner_paddingpixel_widthzero_char_widths        r%   r   EditorWindow.set_widthL  s    yyC81D1561B1D E F&&(1}+<< IIf-.66s; 	 3
r'   c                 r    U R                   R                  5       u  p#U R                  R                  U5        grW   )r   defaultfilenamerw   new)r	  rZ   dirnamebasenames       r%   r   EditorWindow.new_callbackY  s*     GG335

wr'   c                 B   UR                   S-  S:w  a  UR                  S:X  a  g U R                  R                  S5      (       a{  U R                  R	                  SSS5      (       aY  U R                  R	                  SSS5      (       a7  [        U R                  R                  S5      R                  S5      S	   5      nOLU R                  R                  SS5      n[        [        U5      5       H  nX2   S
;  d  M    O   [        U5      n[        U R                  R                  S5      R                  S5      S	   5      nX$:X  a  SnS[        U5      -   S-   nUR                   S	-  S:X  a  U R                  R                  SSS5        GO]U R                  R                  S5      (       d  U R                  R                  SS5        OU R                  R	                  U R                  R                  S5      SU R                  R                  S5      5      (       a  U R                  R                  SS5        OU R                  R                  SS5        U R                  R                  U5      nU R                  R                  S5      nU R                  R	                  USU5      (       a  XvpvU R                  R                  SSS5        U R                  R                  SXg5        U R                  R                  SU5        U R                  R                  S5        g)N   r   Homeiomark<=zinsert lineendinsert linestart.r_   ) 	insertzinsert linestart+csel1.0rp   	sel.first	my_anchor<sel.last>rX   )statekeysymrI   r   comparerF   splitr   rangelenstr
tag_removemark_settag_addsee)r	  rZ   insertptlinelineatdestfirstlasts           r%   r   EditorWindow.home_callback^  sV   KK!O!ellf&<99??8$$99Xt-=>>99/x@@499??84::3?BCH99==!35EFD!#d),>3 - TTYY__X.44S9!<=H"3x=04KKMaII  u599??;//		"";999$$TYY__[%A3%)YY__X%>@ @II&&{K@II&&{J?IIOOD)E99??;/Dyy  s400!dII  u5IIeU1		8T*		hr'   c                    U R                  U R                  5      U l        [        U R                  SSSS9n[        R
                  S:X  a  U R                  R                  SS[        S9  U R                  R                  SS	[        S9  U R                  R                  S
S[        S9  U R                  R                  [        [        S9  UR                  [        [        S9  U R                  R                  SU R                  5        U R                  R                  SSS5        U R                  R                  U R                  5        g )Nr_   grey75)rM   borderwidth
backgroundr   	_padding1z    )r`   rg   zCol: ?rK  zLn: ?)r`   ra   z<<set-line-and-column>>z<KeyRelease>z<ButtonRelease>)r2   r|   
status_barr   r   platform	set_labelRIGHTr   BOTTOMXrI   r   set_line_and_columnr   
after_idle)r	  seps     r%   r   EditorWindow.set_status_bar  s    --dhh7DHHQA(K<<8# OO%%k6%F!!(H5!A!!&'!>&q1f1%		0$2J2JK		5*,=	?		T556r'   c                     U R                   R                  [        5      R                  S5      u  p#U R                  R                  SSU-  5        U R                  R                  SSU-  5        g )Nr3  rg   zCol: %srK  zLn: %s)rI   r   INSERTrB  rV  rX  )r	  rZ   rK  rg   s       r%   r\   EditorWindow.set_line_and_column  sR    yyv.44S9!!(I,>?!!&(T/:r'   ))file_File)edit_Edit)formatF_ormat)run_Run)rr   _Options)r   _Window)r   _Helpc                 T   U R                   n0 =U l        nU R                   H@  u  p4[        U5      u  pT[	        X S3S5      n[        XSUS9=X#'   nUR                  XGUS9  MB     [        R                  " 5       (       a   [        USSS9=US'   nUR                  S	US
9  U R                  5         [        U R                   SS9U l
        U R                  S   R                  SSSU R                  S9  U R                  S   R                  [        5      U l        U R                  5         g)a  Populate the menu bar widget for the editor window.

Each option on the menubar is itself a cascade-type Menu widget
with the menubar as the parent.  The names, labels, and menu
shortcuts for the menubar items are stored in menu_specs.  Each
submenu is subsequently populated in fill_menus(), except for
'Recent Files' which is added to the File menu here.

Instance variables:
menubar: Menu widget containing first level menu items.
menudict: Dictionary of {menuname: Menu instance} items.  The keys
    represent the valid menu items for this window and may be a
    subset of all the menudefs available.
recent_files_menu: Menu widget contained within the 'file' menudict.
_menu_postcommandNr   )rC   tearoffpostcommand)labelr@   	underlineapple)rC   rp  applicationIDLE)rr  r@   rp  rc     zRecent Files)rr  rs  r@   r   )rz   r   
menu_specsprepstrgetattrry   add_cascader   
isCarbonTk
fill_menusrecent_files_menuinsert_cascader   ENDbase_helpmenu_lengthreset_help_menu_entries)r	  mbarr   rC   rr  rs  rq  r@   s           r%   r   EditorWindow.createmenubar  s-     ||#%%??KD&u~I!$&0A(BDIK$(!5@%B BHNT5yI + -1$W:;.= =H]#d65!%dllA!>f,,Qn78262H2H 	- 	J %)MM&$9$?$?$D!$$&r'   c                     U R                   S   nUR                  S5      nUc  SnX R                  :  a  UR                  U R                  S-   U5        [        R
                  " U5        g)zCCallback to register window.

Only called when Window menu exists.
r   rp   Nrq   r_   )r   r   r   deleter   add_windows_to_menu)r	  r@   rp   s      r%   r   EditorWindow.postwindowsmenu  sY    
 }}X&jj;CKKq(#.""4(r'   c                 @    U R                   U   nUR                  X#S9  g)z$Update label for menu item at index.)rr  Nr   entryconfig)r	  r@   r   rr  menuitems        r%   update_menu_labelEditorWindow.update_menu_label  !    ==&U0r'   c                 @    U R                   U   nUR                  X#S9  g)z$Update state for menu item at index.r?  Nr  )r	  r@   r   r?  r  s        r%   r  EditorWindow.update_menu_state  r  r'   c                     US:X  aC  [        US   5      n[        U R                  S5      U-  5      U R                  S5      -
  nSnUS4nU R                  R                  " U/UQ76   g)zHandle scrollbar.movetor   rp   @0,0scrollunitsrX   )floatround	getlinenorI   yview)r	  rZ   argsfractionliness        r%   r   EditorWindow.handle_yview  sg    HT!W~H4>>%08;<^^F+,EE7#D		%%r'   c                 2   U R                   nUR                  SUR                   SUR                   35      n UR	                  SSU5      =(       a    UR	                  USS5      nU(       d%  UR                  SSS	5        UR                  S
U5        U R                  (       d  U R                  5         U R                  nXl
        [        R                  S S S:H  nU(       a  UR                  SS9  U R                   H-  n Uu  pn
U
c  M  [!        X
5      " 5       nUR#                  XS9  M/     UR%                  UR&                  UR(                  5        U(       a  U R                   R                  SS9  g! [
         a    Sn GNf = f! [         a     M  f = f)N@,r:  r1  r=  Fr8  r9  rp   r6  rx  winarrow)cursorr  ibeamrX   )rI   r   xyrA  TclErrorrF  rG  rmenu
make_rmenurZ   r   rW  configrmenu_specs
ValueErrorr{  entryconfiguretk_popupx_rooty_root)r	  rZ   rI   newdexin_selectionr  iswinitemrr  	eventnameverify_stater?  s               r%   r   EditorWindow.right_menu_event  sj   yyay%''34	! LLdFC C<<zB  OOE5%0MM(F+zzOO


Ra E)KKwK'$$D15., #D/1E   4 % 	u||U\\2IIG,7  	! L	!   s#   -E5 F5FF
FF)CloserS   Nc                     [        U R                  SS9nU R                   HA  nUS   US   pCUb"  U R                  U4S jnUR                  X5S9  M1  UR	                  5         MC     Xl        g )Nr   rw  r_   c                 &    U R                  U5        g r  event_generaterI   r  s     r%   rd   (EditorWindow.make_rmenu.<locals>.command2  s    ''	2r'   rr  rd   )ry   rI   r  add_commandr   r  )r	  r  r  rr  r  rd   s         r%   r  EditorWindow.make_rmenu-  si    TYY*$$D#AwQ9 !%i 3!!!?##% % 
r'   c                 "    U R                  5       $ r  )rmenu_check_copyr	  s    r%   rmenu_check_cutEditorWindow.rmenu_check_cut9  s    $$&&r'   c                 p     U R                   R                  S5      nU(       a  S$ S$ ! [         a     gf = f)Nr:  normalrs   rI   r   r  )r	  indxs     r%   r  EditorWindow.rmenu_check_copy<  s<    	499??;/D  $833  		s   ( 
55c                      U R                   R                  R                  SU R                   S5        g! [         a     gf = f)Nztk::GetSelection	CLIPBOARDr  rs   )rI   r  callr  r  s    r%   rmenu_check_pasteEditorWindow.rmenu_check_pasteD  s?    	IILL0$))[I   		s   14 
A Ac                 D    [         R                  " U R                  5        g)zHandle Help 'About IDLE' event.rX   )r   AboutDialogr|   r  s     r%   r   EditorWindow.about_dialogL  s     	txx(r'   c                 F    [         R                  " U R                  S5        g)z&Handle Options 'Configure IDLE' event.SettingsrX   )r	   ConfigDialogr|   r  s     r%   r   EditorWindow.config_dialogR  s     	!!$((:6r'   c                     U R                   (       a  U R                   nOU R                  n[        R                  " U5        g)zHandle Help 'IDLE Help' event.rX   )rx   r|   r   show_idlehelp)r	  rZ   parents      r%   r   EditorWindow.help_dialogX  s.     99YYFXXF6"r'   c                 6   [         R                  S S S:X  a"   [        R                  " U R                  5        g[        R                  " U R                  5        g! [
         a3  n[        R                  " S[        U5      U R                  S9   S nAgS nAff = f)Nrx  r  Document Start Failuretitlemessager  rX   )r   rW  r   	startfilerv   OSErrorr   r   rE  rI   
webbrowseropen)r	  rZ   whys      r%   r   EditorWindow.python_docsb  sy    <<u$8T]]+  OODMM*  8$$+CHTYY8 8s    A 
B%)BBc                 :    U R                   R                  S5        g)Nz<<Cut>>rX   rI   r  r  s     r%   r   EditorWindow.cutm  s    		  +r'   c                 |    U R                   R                  S5      (       d  g U R                   R                  S5        g)Nr8  z<<Copy>>rX   )rI   
tag_rangesr  r  s     r%   r   EditorWindow.copyq  s/    yy##E**		  ,r'   c                 p    U R                   R                  S5        U R                   R                  S5        g)Nz	<<Paste>>r6  rX   )rI   r  rI  r  s     r%   r   EditorWindow.pastex  s'    		  -		hr'   c                     U R                   R                  SSS5        U R                   R                  SS5        U R                   R                  S5        g)Nr8  r9  zend-1cr6  rX   )rI   rH  rG  rI  r  s     r%   r   EditorWindow.select_all}  s?    		%1		8U+		hr'   c                 t    U R                   R                  SSS5        U R                   R                  S5        g)Nr8  r9  rp   r6  rX   )rI   rF  rI  r  s     r%   r   EditorWindow.remove_selection  s+    		UE51		hr'   c                 |   ^^^^ U R                   R                  mU R                   R                  mSmUUUU4S jnU$ )zCursor 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.

)zsel.first+1czsel.last-1cc                 x   > U R                   S-  S:X  a   T" S5        T" STT   5        g g ! [         a     g f = f)NrJ   r   r:  r6  )r?  r  )rZ   
edge_indexedges_tableself_text_indexself_text_mark_sets    r%   move_at_edge<EditorWindow.move_at_edge_if_selection.<locals>.move_at_edge  sH    aA%#K0&xZ1HI &   s   , 
99)rI   r   rG  )r	  r  r  r  r  r  s    ` @@@r%   r   &EditorWindow.move_at_edge_if_selection  s9     ))//!YY//5	 	 r'   c                 :    U R                   R                  S5        g)Nz<Meta-Delete>rX   r  r  s     r%   r   EditorWindow.del_word_left  s    		  1r'   c                 :    U R                   R                  S5        g)Nz<Meta-d>rX   r  r  s     r%   r   EditorWindow.del_word_right  s    		  ,r'   c                 D    [         R                  " U R                  5        grW   )r   findrI   r  s     r%   r   EditorWindow.find_event  s    DIIr'   c                 D    [         R                  " U R                  5        grW   )r   
find_againrI   r  s     r%   r   EditorWindow.find_again_event  s    $))$r'   c                 D    [         R                  " U R                  5        grW   )r   find_selectionrI   r  s     r%   r   !EditorWindow.find_selection_event  s    dii(r'   c                 p    [         R                   " U R                  U R                  U R                  5        grW   )r
   rI   r   rw   r  s     r%   r    EditorWindow.find_in_files_event  s!    		$))TWWdjj1r'   c                 D    [         R                   " U R                  5        grW   )r   rI   r  s     r%   r   EditorWindow.replace_event  s    		"r'   c                     U R                   n[        R                  " USS5      R                  nUbI  UR	                  SSS5        UR                  SU S35        UR                  S5        U R                  5         g)	Nz
Go To Linez/Enter a positive integer
('big' = end of file):r8  r9  rp   r6  .0rX   )rI   r   GotoresultrF  rG  rI  r\  )r	  rZ   rI   linenos       r%   r   EditorWindow.goto_line_event  st    yyl) &	 	
 OOE5%0MM(vhbM2HHX$$&r'   c                 r    U R                   R                  SS5      R                  5       n[        R
                  " U R                   SSU5      R                  nUbI  U R                  (       a  U R                  R                  U5        U$ U R                  R                  U5        U$ ! [         a    Sn Nf = f)zGet 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.
r:  r=  rA   zOpen ModulezAEnter the name of a Python module
to search on sys.path and open:)rI   r   stripr  r   
ModuleNamer  rw   r  r   r   )r	  rC   	file_paths      r%   open_moduleEditorWindow.open_module  s    	99==j9??AD $$		=2	 f	 	
  zz

	*    +  	D	s   *B' 'B65B6c                 $    U R                  5         grW   )r  r  s     r%   r   EditorWindow.open_module_event  s    r'   c                     U R                   R                  nU R                  R                  S:X  a  U(       d  U R	                  5       nUc  gSSKJn  UR                  U R                  U5        g)NPyShellEditorWindowrX   r   )browser)	r   r
  	__class____name__r  idlelibr   ModuleBrowserrx   )r	  rZ   r
  r   s       r%   r    EditorWindow.open_module_browser  sX    77##''+@@'')H#dii2r'   c                 F    SSK Jn  UR                  U R                  5        g)Nr   )pathbrowserrX   )r#  r'  PathBrowserrx   )r	  rZ   r'  s      r%   r   EditorWindow.open_path_browser  s    '		*r'   c                 R    SS K n[        R                  SS/nUR                  USS9  g)Nr   z-cz,from turtledemo.__main__ import main; main()F)shellrX   )
subprocessr   
executablePopen)r	  rZ   r,  cmds       r%   r   EditorWindow.open_turtle_demo  s1    ~~=? 	E*r'   c                     Ubq  US:  aj  U R                   R                  SSU-  5        U R                   R                  SSS5        U R                   R                  SSS5        U R	                  5         g g g )Nr   r6  z%d.0r8  r9  rp   z
insert +1l)rI   rG  rF  rH  center)r	  r  s     r%   gotolineEditorWindow.gotoline  sc    &1*IIx&9II  u5IIeX|<KKM	 #-r'   c                    U(       a$  [         R                  R                  U5      (       a  g[         R                  R                  [         R                  R	                  U5      5      u  p#[         R                  R                  U5      [        ;   a  gU R                  R                  SS5      nUR                  S5      =(       a    SU;   $ )NTr9  z1.0 lineendz#!python)
r   r   r   splitextr+  normcaser   rI   r   
startswith)r	  r
  baseextrK  s        r%   r   EditorWindow.ispythonsource  s    277==22GG$$RWW%5%5h%?@	77C M1yy}}UM2t$9T)99r'   c                 l    U R                   (       a#  U R                   R                  U 5        S U l         g g r  )rw   unregister_maybe_terminater  s    r%   
close_hookEditorWindow.close_hook  s'    ::JJ11$7DJ r'   c                     Xl         g r  )r?  )r	  r?  s     r%   set_close_hookEditorWindow.set_close_hook  s    $r'   c                     U R                   (       a  U R                   R                  U 5        U R                  5         U R                  R	                  U 5        U R                  5         g r  )rw   filename_changed_editr   r|   update_windowlist_registryr   r  s    r%   r   !EditorWindow.filename_change_hook  sE    ::JJ,,T2 ++D1r'   c                 &   U R                   (       a  g U R                  U R                  R                  5      (       a  U R	                  5       U l         U R                   (       a/  U R
                  R                  U R                   U R                  S9  g g )N)filterafter)r   r   r   r
  r,   r   insertfilterafterr   r  s    r%   _addcolorizerEditorWindow._addcolorizer  sb    ::tww//00,,.DJ::HH&&djj		&J r'   c                     U R                   (       d  g U R                   R                  5         U R                  R                  U R                   5        S U l         g r  )r   removecolorsr   removefilterr  s    r%   _rmcolorizerEditorWindow._rmcolorizer#  s9    zz

!djj)
r'   c                     U R                  5         U R                  5         [        R                  U R                  5        U R
                  b  U R
                  R                  5         U R                  b  U R                  R                  5         gg)zUpdate the color themeN)	rQ  rL  r)   r-   rI   r   update_highlight_colorsr   update_colorsr  s    r%   r   EditorWindow.ResetColorizer*  so     	!!$)),(557(++- )r'   _c                 >   UR                  SU5        UR                  U5      nU(       a%  X0R                  ;   a  UR                  SUS-   U5        SUR                  U5      :X  a  UR                  SU5        OUR                  SUS-   5        UR	                  U5        g )NERRORz
 wordstart
r6  z+1c)rH  r   
IDENTCHARSrG  rI  )r	  rI   poschars       r%   colorize_syntax_error"EditorWindow.colorize_syntax_error9  sy    Wc"xx}DOO+LL#"4c:488C= MM(C(MM(C%K0r'   c                     [         R                  " SSSSS9nU(       d  SU R                  S'   g[         R                  U R                  S'   g)	z&Update the cursor blink configuration.rD   r)   zcursor-blinkrl   rG   r   rn   N)r   r   rI   rm   )r	  cursorblinks     r%   r    EditorWindow.update_cursor_blinkD  sC    ((VE)*DIIo& *2)@)@DIIo&r'   c                     U R                   b  U R                   R                  5         U R                  b  U R                  R                  5         [        R                  " U R
                  SS5      nXR                  S'   U R                  5         g)z.Update the text widgets' font if it is changedNrD   r)   rj   )r   update_fontr   r   r   rx   rI   r   )r	  new_fonts     r%   	ResetFontEditorWindow.ResetFontN  sp     ())+ ())+##DIIv~F$		&r'   c                    [         R                  " 5       =U R                  l        nUR	                  5        H"  u  p#U R
                  R                  " U/UQ76   M$     U R                  5        HX  n[         R                  " U5      nU(       d  M"  UR	                  5        H"  u  p#U R
                  R                  " U/UQ76   M$     MZ     g)zWRemove the virtual, configurable keybindings.

Leaves the default Tk Text keybindings.
N)	r   GetCurrentKeySetr1   default_keydefsitemsrI   event_deleteget_standard_extension_namesGetExtensionBindings)r	  keydefsrZ   keylistextensionNamexkeydefss         r%   RemoveKeybindingsEditorWindow.RemoveKeybindings_  s     3;2K2K2MM%%mmoNEII""5373 .!>>@M44]CHx&.nn&6NEII**5;7; '7 Ar'   c                 N   [         R                  " 5       =U R                  l        nU R	                  5         U R                  5        H3  n[         R                  " U5      nU(       d  M"  U R	                  U5        M5     0 nU R                  R                   H;  n0 XES   '   US    H(  nU(       d  M  US   XES      [        US   5      S   '   M*     M=     U R                   H  nU R                  U   nUR                  [        5      nUc  M,  US-  n[        SU5       H  n	UR                  U	5      S:X  d  M  UR                  U	S5      n
U
(       d  M5  UR                  U	S5      nSnXt;   a  XU   ;   a  XG   U   nU(       d  Mf  [        X5      n
UR!                  XS9  M     M     g)	zUApply the virtual, configurable keybindings.

Also update hotkeys to current keyset.
r   r_   Nrd   acceleratorrr  rA   )rv  )r   ri  r1   rj  r   rm  rn  menudefsrz  r   r   r  rC  rH   	entrycgetget_acceleratorr  )r	  ro  rq  rr  menuEventDictr@   r  menubarItemrp   r   accelitemNamerZ   s                r%   ApplyKeybindingsEditorWindow.ApplyKeybindingsn  s    3;2K2K2MM%!>>@M44]CHx##H- A MM**D%'Mq'"Q4BFq'Mq'*747+;A+>?   +
  ==K==-D**S/C{1HCq#99U#y0 NN5-@Eu#'>>%#A "&7'+EE(5(B8(L 5$3G$CE ,,U,F ' )r'   c                 `    U R                   (       d  [        R                  " SSSSS9U l        gg)zCUpdate the indentwidth if changed and not using tabs in this windowrD   rk   z
num-spacesrF   rG   N)r   r   r   r   r  s    r%   r   #EditorWindow.set_notabs_indentwidth  s,     ||'11&(<7< >D r'   c                 |   [         R                  " 5       nU R                  S   nUR                  [        5      nX0R
                  :  a  UR                  U R
                  S-   U5        U(       a@  UR                  5         U H*  nU R                  US   5      nUR                  US   US9  M,     X R                  S'   g)z4Update the additional help entries on the Help menu.r   r_   r   r  N)
r   GetAllExtraHelpSourcesListr   r   r  r  r  r   _extra_help_callbackr  )r	  	help_listhelpmenuhelpmenu_lengthentryr/  s         r%   r  $EditorWindow.reset_help_menu_entries  s    779	==("..-666OOT66:_M""$"//a9$$58S$A # !)fr'   c                    ^  U4U 4S jjnU$ )z9Return a callback that loads resource (file or web page).c                 z  > U R                  S5      (       d  [        R                  R                  U 5      n [        R
                  S S S:X  a   [        R                  " U 5        g [        R                  " U 5        g ! [         a3  n[        R                  " S[        U5      TR                  S9   S nAg S nAff = f)N)wwwhttprx  r  r  r  )r9  r   r   normpathr   rW  r  r  r   r   rE  rI   r  r  )helpfiler  r	  s     r%   display_extra_help=EditorWindow._extra_help_callback.<locals>.display_extra_help  s    &&7777++H5||BQ5(<LL*
 )	  <((/G #C<<s   A= =
B:)B55B:rY   )r	  resourcer  s   `  r%   r  !EditorWindow._extra_help_callback  s    (0 
	* "!r'   c                    / nU R                   nU(       aH  [        R                  R                  U5      (       a$  [	        USSS9 nUR                  5       nSSS5        U(       aJ  [        R                  R                  U5      S-   nX;   a  UR                  U5        UR                  SU5        / nU HC  nSU;   d)  [        R                  R                  USS 5      (       a  M2  UR                  U5        ME     U Vs/ s H  ofU;  d  M
  UPM     nnS	nUS[        U5       nU(       a'   [	        US
SSS9 nUR                  U5        SSS5        U R&                  R(                   Hs  n
U
R*                  nUR-                  S[.        5        [1        U5       H?  u  pUR3                  5       nU
R5                  U5      nUR7                  X|   S-   U-   USS9  MA     Mu     g! , (       d  f       GN= fs  snf ! , (       d  f       N= f! [         a\  n	[        U R                  SS5      (       d5  SU R                  l        [         R"                  " SSU	 S3U R$                  S9   Sn	A	GNSn	A	ff = f)z/Load and update the recent files list and menusutf_8r   )r0   errorsNrZ  r    rq   1234567890ABCDEFGHIJKwrecentfiles_messageFTzIDLE Warningz)Cannot save Recent Files list to disk.
  z
Select OK to continue.r  r4  )rr  rd   rs  )r   r   r   r   r  	readlinesabspathremover6  appendrD  
writelinesr  r{  rx   r  r   showwarningrI   r|   r   r  r  r  	enumeraterstrip#_EditorWindow__recent_file_callbackr  )r	  new_filerf_listr  rf_list_file	bad_pathsr   ulcharsrf_fileerrinstancer@   i	file_namecallbacks                  r%   r   %EditorWindow.update_recent_files_list  s$    **		22i&y:=I&002: wwx047H"x(NN1h'	Dt|277>>$q*#=#=  &  %,EGD9/D4GE)!CL)*)S#*9>AH&&w/> ..H--DKK3 )' 2%,,.	#::9E  wzC'7)'C)1+, ! . !3 /=: : F
> >  *tyy*?GG48DII1**!%%(E *9!9  $yy	**sO   G>	G1G1+H 7G6	H 
G.6
H H H 
I-AI((I-c                    ^  U4U 4S jjnU$ )Nc                 8   > TR                   R                  U S9  g )N)editFile)r   r  )
fn_closurer	  s    r%   open_recent_file=EditorWindow.__recent_file_callback.<locals>.open_recent_file  s    GGLL*L-r'   rY   )r	  r  r  s   `  r%   __recent_file_callback#EditorWindow.__recent_file_callback  s    (1 	.r'   c                 ~   U R                  5       nU R                  5       nU(       a1  U(       a*  [        R                  " 5       (       d  US-   U-   [        -   nOU(       a  UnOU(       a  UnOSnU=(       d    U=(       d    UnU R                  5       (       d
  SU-  nSU-  nU R                  R                  U5        U R                  R                  U5        [        R                  " 5       (       aL  U R                  R                  SU5        U R                  R                  SU R                  5       (       + 5        g g )Nz - untitledz*%s*z*%sz
-titlepathz	-modified)
short_title
long_titler   	isCocoaTk_py_version	get_savedr|   wm_titlewm_iconnamewm_attributes)r	  shortlongr  icons        r%   r   EditorWindow.saved_change_hook  s      " T&"2"2"4"4 EMD(;6EEEE%%~~UNE4<D% T"HH""<6 HH"";DNN4D0DE r'   c                 6    U R                   R                  5       $ r  )r   r  r  s    r%   r  EditorWindow.get_saved  s    yy""$$r'   c                 :    U R                   R                  U5        g r  )r   	set_saved)r	  flags     r%   r  EditorWindow.set_saved  s    		D!r'   c                 8    U R                   R                  5         g r  )r   
reset_undor  s    r%   r  EditorWindow.reset_undo  s    		r'   c                 ~    U R                   R                  nU(       a  [        R                  R	                  U5      $ S$ )Nr  )r   r
  r   r   r+  )r	  r
  s     r%   r  EditorWindow.short_title  s-    77##-5rww)E:Er'   c                 @    U R                   R                  =(       d    S$ )NrA   )r   r
  r  s    r%   r  EditorWindow.long_title  s    ww%2%r'   c                 $    U R                  5         grW   )r2  r  s     r%   r    EditorWindow.center_insert_event  s    r'   c                     U R                   nU R                  5       u  p4U R                  U5      nXC-
  n[        SXVS-  -
  5      nUR	                  [        U5      5        g )Nr_   re   )rI   getwindowlinesr  maxr  r  )r	  markrI   r|   botr  rM   newtops           r%   r2  EditorWindow.center  sS    yy&&(%Q*+

5=!r'   c                     U R                   nU R                  S5      nU R                  S5      nX#:X  a)  UR                  5       S:X  a  [        US   5      nX$-   S-
  nX#4$ )Nr  z@0,65535r_   rM   )rI   r  winfo_heightrF   )r	  rI   r|   r  rM   s        r%   r  EditorWindow.getwindowlines'  s]    yynnV$nnZ(:$++-2h(F,"Cxr'   c                 `    U R                   n[        [        UR                  U5      5      5      $ r  )rI   rF   r  r   )r	  r  rI   s      r%   r  EditorWindow.getlineno1  s$    yy5D)*++r'   c                     U R                   R                  5       n[        R                  " SU5      n[	        [        [        UR                  5       5      5      $ )zReturn (width, height, x, y)z(\d+)x(\d+)\+(-?\d+)\+(-?\d+))r|   wm_geometryrematchlistr  rF   groups)r	  geomms      r%   get_geometryEditorWindow.get_geometry5  s=    xx##%HH5t<CQXXZ())r'   c                 $    U R                  5         grW   )r   r  s     r%   r   EditorWindow.close_event;  s    

r'   c                 \   U R                   (       a  U R                  5       (       dl  U R                  R                  5       S:w  a  U R                  R	                  5         U R                  R                  5         U R                  R                  5         U R                   R                  5       $ g )Nr  )r   r  r|   r?  	deiconifylowerlift	maybesaver  s    r%   r  EditorWindow.maybesave?  sl    77>>##88>>#X-HH&&( 77$$&& r'   c                      U R                  5       n[        U5      S:w  a  U R                  5         U$ ! [         a     g f = f)Ncancel)r  rE  _closeAttributeError)r	  replys     r%   r   EditorWindow.closeH  s?    	NN$E5zX%L 		s   03 
A A c                 j   U R                   R                  (       a#  U R                  U R                   R                  S9  [        R                  " U R
                  5        U R                  5         U R                   R                  5         S U l         S U l        U R                  (       a!  U R                  R                  5         S U l	        S U l
        S U l        U R                  R                  5         S U l        U R                  R                  5         U R                  (       a  U R                  5         g g )N)r  )r   r
  r   r   unregister_callbackr   unload_extensionsr   r   r   rI   r~   r   r|   destroyr?  r  s    r%   r  EditorWindow._closeQ  s    77))4773C3C)D""4#7#78 	::JJDJ	 ??OO r'   c                 2    0 U l         U R                  5         g r  )
extensionsload_standard_extensionsr  s    r%   r   EditorWindow.load_extensionse  s    %%'r'   c                     [        U R                  R                  5       5       H&  n[        US5      (       d  M  UR	                  5         M(     0 U l        g )Nr   )r  r  valuesr   r   )r	  inss     r%   r  EditorWindow.unload_extensionsi  s=    ..01CsG$$		 2 r'   c                     U R                  5        H  n U R                  U5        M     g !   [        S[        U5      5        [        R
                  " 5          MI  = f)NzFailed to load extension)rm  load_extensionprintrepr	traceback	print_exc)r	  rC   s     r%   r   %EditorWindow.load_standard_extensionso  sJ    557D&##D) 8&0$t*=##%s	   +,Ac                 *    [         R                  " SS9$ )NT)editor_only)r   GetExtensionsr  s    r%   rm  )EditorWindow.get_standard_extension_namesw  s    %%$77r'   ZzDummyzzdummyc                    U R                   R                  X5      n  [        R                  " SU-   [        S9n[        X15      n[        R                  " U5      n[        US5      (       a  U R                  UR                  U5        U" U 5      nX`R                  U'   U(       a  U R                  U5        U H  nUR!                  SS5      nUS S S:X  a  USS  nUS S S:X  a  M  US	S  S
:X  a  US S	 nUS	S  S
:X  a  M  US-   n[        Xh5      (       d  M^  U R"                  R%                  U[        Xh5      5        M     g g ! [
        [        4 a    [        R                  " U5      n GN0f = f! [
         a    [        SU5        e f = f)Nr3  )packagez
Failed to import extension: rw  -rW  r_   r<  rq   r>  _event)extfilesr   	importlibimport_module__package__ImportError	TypeErrorr  r{  r   rn  r   r~  rw  r  r   r   rI   r   )	r	  rC   fnamemodclsro  r  vevent
methodnames	            r%   r  EditorWindow.load_extension~  sv   !!$-	5--cEk;O c //53
##OOCLL'2$i #(!#^^C5
 !n+!+ABJ !!n+ o,!+CRJ !o,'(2
3++IINN673+CD "   + 5--e45 	2D9	s#   E &E+'E. *E++E. .Fc                     Uc  U R                   R                  nU R                  nXl        UR	                  5        H!  u  p4U(       d  M  UR
                  " U/UQ76   M#     g)z"Add events with keys to self.text.N)r1   rj  rI   ro  rk  r   )r	  ro  rI   rZ   rp  s        r%   r   EditorWindow.apply_bindings  sL    ?mm33Gyy%mmoNEwu/w/ .r'   c           
         Uc  U R                   R                  nUc  U R                   R                  nU R                  nU R                  nU H  u  pVUR                  U5      nU(       d  M  U H  nUc  UR                  5         M  Uu  pU	SS S:H  nU(       a  U	SS n	[        U	5      u  p[        X*5      nXJ4S jnU(       a)  U R                  U
[        5      nUR                  XXUS9  M~  UR                  XUUS9  M     M     g)zFill in dropdown menus used by this window.

Items whose name begins with '!' become checkbuttons.
Other names indicate commands.  None becomes a separator.
Nr_   !c                 &    U R                  U5        g r  r  r  s     r%   rd   (EditorWindow.fill_menus.<locals>.command  s    ++I6r'   )rr  rs  rd   rv  variable)rr  rs  rd   rv  )r1   rw  rj  r   rI   r   r   rz  ry  get_var_obj
BooleanVaradd_checkbuttonr  )r	  rw  ro  r   rI   mname	entrylistr@   r  rr  r  checkbuttonrs  rv  rd   vars                   r%   r~  EditorWindow.fill_menus  s    }}--H?mm33G==yy (E<<&D"=&&(',$E#(!9#3K" %ab	'.u~$I"1'"EK%) 7""..y*E,,5$+%( - * ((u185@ ) B% #	 !)r'   c                 l    U R                  U5      nU(       a  UR                  5       nU$ [        U5      er  )r*  r   	NameError)r	  rC   r0  values       r%   getvarEditorWindow.getvar  s/    t$GGIELD/!r'   c                 l    U R                  X5      nU(       a  UR                  U5        g [        U5      er  )r*  r   r3  )r	  rC   r4  vartyper0  s        r%   setvarEditorWindow.setvar  s*    t-GGEND/!r'   c                     U R                   R                  U5      nU(       d(  U(       a!  U" U R                  5      =U R                   U'   nU$ )z:Return a tkinter variable instance for the event.
        )r~   r   rI   )r	  r  r8  r0  s       r%   r*  EditorWindow.get_var_obj  sB     ##I.w181CCDi(3
r'   c                     U R                   (       aA  U R                  R                  SU5      =(       d    SU R                  R                  U5      ;   $ g)NTODOSTRINGr_   )r   rI   tag_prevrange	tag_names)r	  
text_indexs     r%   is_char_in_stringEditorWindow.is_char_in_string  sE    :: 99**6:> ?tyy22:>>? r'   c                      U R                   R                  S5      nU R                   R                  S5      nX4$ ! [         a     gf = f)Nr:  r=  NNr  )r	  rN  rO  s      r%   get_selection_indices"EditorWindow.get_selection_indices  sE    	IIOOK0E99??:.D; 		s   8; 
AAc                 P    U R                   S   =(       d    [        n[        U5      $ )Ntabs)rI   TK_TABWIDTH_DEFAULTrF   )r	  currents     r%   get_tk_tabwidthEditorWindow.get_tk_tabwidth  s     ))F#:':7|r'   c           	          U R                   nU R                  5       U:w  a@  UR                  R                  SSUS   SUR                  SU-  5      nUR                  US9  g g )Nrj   r"  z
-displayofn)rJ  )rI   rM  r  r  master	configure)r	  newtabwidthrI   pixelss       r%   set_tk_tabwidthEditorWindow.set_tk_tabwidth  s^    yy![0WW\\&)T&\"."%"35F NNN' 1r'   c                     U(       aN  U(       aG  U R                  5       nSUs=::  a  S::  a	  O  OX0l        U R                  U R                  :w  a  SU l        U R	                  U R                  5        g )Nre   r   F)guess_indentr   r   r   rU  )r	  r  guessr  s       r%   r   #EditorWindow.set_indentation_params  sQ    !!#AA{{#$ 4==0$T]]+r'   c                 2   U R                   nU R                  5       u  p4U(       a+  U(       a$  UR                  X45        UR                  SU5        gUR	                  SS5      nUS:X  a;  UR                  SSS5      (       a  UR                  S5        gUR                  5         gUS   S	;  a  UR                  S5        gU R                  n[        UR                  U5      5      nUS
-
  U R                  -  U R                  -  nSn	 US S nU	S
-   n	[        UR                  U5      5      nXx::  d	  US   S	;  a  OM5  UR                  5         UR                  SU	-  S5        Xx:  a"  UR                  SSX-
  -  U R                  5        UR                  5         g)Nr6  rX   r2  rA   r>  r9  z	insert-1crq    	r_   r   z
insert-%dcr4  )rI   rG  r  rG  r   rA  bellr   rD  
expandtabsr   r   r6  r   r   )
r	  rZ   rI   rN  rO  charsr   havewantncharsdeleteds
             r%   r   "EditorWindow.smart_backspace_event  s   yy002TKK$MM(E* +X6B;||Hc511K(  		"IU"KK$ ==5##H-.d...$2B2BB#2JE)A-Mu''12D|uRy5  	L=0(;;KK#"5335r'   c                 8   U R                   nU R                  5       u  p4UR                  5          U(       am  U(       af  [        U5      [        U5      :w  a+  U R                  R                  U5      UR                  5         $ UR                  X45        UR                  SU5        UR                  SS5      n[        XPR                  5      u  pgU[        U5      :X  a  U R                  XpR                  -   5        OjU R                  (       a  SnO:[        UR!                  U R                  5      5      nU R                  n	SXU	-  -
  -  nUR#                  SXR$                  5        UR'                  S5         UR                  5         g! UR                  5         f = f)Nr6  r2  r5  r4  rX   )rI   rG  r   
index2liner   r   r   r  rG  r   get_line_indentr   rD  reindent_tor   r   r^  r6  r   rI  )
r	  rZ   rI   rN  rO  prefixraw	effectivepadrP  s
             r%   r   EditorWindow.smart_indent_eventG  sD    yy002	#e$
4(88<<;;EB(   "' E(h.XX0(;F,V]]CNCc&k!  -=-=!=> <<C #F$5$5dmm$D EI((A]!23CHc+F+FGHHX  "D  "s   A F C4F Fc                 	   U R                   nU R                  5       u  p4UR                  5          U(       a*  U(       a#  UR                  X45        UR	                  SU5        UR                  SS5      nS[        U5      pvXg:  a  XV   S;   a  US-  nXg:  a
  XV   S;   a  M  Xg:X  a@  UR                  SSU R                  5         UR                  S5        UR                  5         gUSU nSnU(       a%  US	   S;   a  USS	 nUS-  nU(       a  US	   S;   a  M  U(       a  UR                  S
U-  S5        UR                  S5      S;   a(  UR                  S5        UR                  S5      S;   a  M(  UR                  SSU R                  5        [        UR                  S5      5      n	[        R                  " U R                  U R                   5      n
U R"                  (       d  U R$                   Hm  n['        X-
  S5      n[)        U5      S-   nUR                  US5      nU
R+                  U5        U
R-                  U R/                  U5      5      nUc  US:X  d  Mm    O   U
R1                  W=(       d    S5        OUUR3                  SS5      nU(       a  US   nOSnUR                  US5      nU
R+                  U5        U
R1                  S5        U
R5                  5       nU[        R6                  :w  Ga  U[        R8                  :X  a  OU[        R:                  :X  a  UR                  SXR                  5        OU[        R<                  :X  a   U R?                  U
RA                  5       5        OfU[        RB                  :X  aR  U
RE                  5       S:  a  UR                  SUU R                  5        O U R?                  U
RG                  5       5          UR                  S5        UR                  5         gU
RI                  5       nUR                  SXR                  5        U
RK                  5       (       a  U RM                  U5        O-U(       a&  U
RO                  5       (       a  U RQ                  U5         UR                  S5        UR                  5         g! UR                  S5        UR                  5         f = f)aU  Insert a newline and indentation after Enter keypress event.

Properly position the cursor on the new line based on information
from the current line.  This takes into account if the current line
is a shell prompt, is empty, has selected text, contains a block
opener, contains a block closer, is a continuation line, or
is inside a string.
r6  r2  r   r\  r_   rZ  rX   Nrq   zinsert - %d charsr  consoler9  ))rI   rG  r   r  rG  r   rD  r6  r   rI  r   re  r   r   Parserr   r   r   r   r  r	  set_codefind_good_parse_start_build_char_in_string_funcset_lor@  get_continuation_typeC_NONEC_STRING_FIRST_LINEC_STRING_NEXT_LINES	C_BRACKETrg  compute_bracket_indentC_BACKSLASHget_num_lines_in_stmtcompute_backslash_indentget_base_indent_stringis_block_openerr   is_block_closerr   )r	  rZ   rI   rN  rO  rK  r  rP  indentlnor  contextstartatstartatindexrawtextbodrr7  s                     r%   r   %EditorWindow.newline_and_indent_eventj  s    yy002e	#E(h.88.9D c$iq%DGu,Q %DGu,v . 779j HHX  "k "1XF A48u,CRyQ 48u, /!3X> ((8$-H% ((8$- KK$(C(CD TZZ12Ct//?A((#55G!#-3G#'=4#7L"hh|X>GJJw'11 ;;LIKC'Q,  6 "&&y(;#$Q4L#(L((<:

7#'')AGNN"333'555 KK&2M2MN'+++
 $$Q%=%=%?@'--- ..014Hf$($?$?A (()C)C)EF  HHX  " --/FKK&*E*EF  ""''.A--//**51HHX  " HHX  "s4   A.R  "R %1R AR 1C(R E9R 9B R #R?c                 (    UU R                   4S jnU$ )Nc                     U" USU -  -   5      $ )Nz+%dcrY   )offset_startindex_iciss      r%   inner6EditorWindow._build_char_in_string_func.<locals>.inner  s    v677r'   )rC  )r	  
startindexr  s      r%   rr  'EditorWindow._build_char_in_string_func  s    &0..	8 r'   c                 r    U R                   (       a"  [        XR                  5      u  p#SU-  SU-  -   $ SU-  $ )Nr5  r4  )r   divmodr   )r	  rP  ntabsnspacess       r%   _make_blanksEditorWindow._make_blanks  s5    <<#A}}5NE%<#-//7Nr'   c                    U R                   nUR                  5         UR                  SSS5      (       a  UR                  SS5        U(       a,  UR	                  SU R                  U5      U R                  5        UR                  5         g )Nr2  z!=r6  )rI   r   rA  r  r6  r  r   r   )r	  rg   rI   s      r%   rg  EditorWindow.reindent_to  sm    yy<<*D(;;KK*H5KK$"3"3F";335r'   c                     [        U R                  5      R                  5       u  pU(       a9  U(       a2  [        XR                  5      u  p4[        X R                  5      u  p5XT-
  $ S=pEXT-
  $ Nr   )IndentSearcherrI   ri  rf  r   )r	  openerindentedri  indentsmallindentlarges         r%   rX  EditorWindow.guess_indent  sa    )$))488:h.v}}EC.xGC (( )*)K((r'   c                     U R                   c  g U R                   R                  (       a  U R                   R                  5         SnOU R                   R                  5         SnU R	                  SSU S3S9  g )NShowHiderr   rt   z Line Numbers)r@   r   rr  )r   is_shownhide_sidebarshow_sidebarr  )r	  rZ   
menu_labels      r%   r  &EditorWindow.toggle_line_numbers_event  sp    $%%**,J**,JI](2|=%A 	 	Cr'   )$r   r   r  r?  r   r   r   rZ   r  rw   r   r   r   r   r   rz   r   r   r   r   r  r   r  rx   r   rV  r   rI   r   r~   r|   r   r   rB   rE   r   )NNNNr  )r6  rF  )T)r"  
__module____qualname____firstlineno__idlelib.percolatorr+   idlelib.colorizerr,   r-   idlelib.undor.   idlelib.iomenur/   r0   r#  r1   idlelib.statusbarr2   idlelib.autocompleter3   idlelib.autoexpandr4   idlelib.calltipr5   idlelib.codecontextr6   idlelib.sidebarr7   idlelib.formatr8   r9   r:   r;   idlelib.parenmatchr<   idlelib.zoomheightr=   r   getfilesystemencodingfilesystemencodingrv   r  r  r   r  r   r   r   r   r   r\  ry  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   r   r   r   r3  r   r?  rB  r   rL  rQ  r   stringascii_lettersdigitsr[  r^  r   rf  rs  r~  r   r  r  r   r  r   r  r  r  r  r  r   r2  r  r  r  r   r  r   r  r   r  r   rm  r  r  r   r~  r5  r9  r*  rC  rG  rM  rU  r   r   r   r   rr  r  rg  rX  r  __static_attributes__rY   r'   r%   r)   r)   4   s   ->*2 01-'/+MM--224H!|I|4
)V7 ;&J#'J)1
1
	 E!J 	,K

'4	

(0	
:
%K. %%5;J	A"<&GP>)"",.\ 
F6%"F&",*'((&8 	9
HE80$BL""$(,)V!#Fq#p )Cr'   r)   c                 *    [        [        U 5      5      $ r  )rF   r  )r   s    r%   re  re  "  s    uU|r'   z[ \t]*c                     [         R                  U 5      nUR                  5       [        UR	                  5       R                  U5      5      4$ )zReturn a line's indentation as (# chars, effective # of spaces).

The effective # of spaces is the length after properly "expanding"
the tabs into spaces, as done by str.expandtabs(tabwidth).
)_line_indent_rer  rp   rD  groupr^  )rK  r   r  s      r%   rf  rf  '  s;     	d#A557C	,,X6777r'   c                   b    \ rS rSrSrS rS r\R                  \R                  S4S jr
S rSrg	)
r  i1  z4Manage initial indent guess, returned by run method.c                 H    Xl         S=U l        U l        S =U l        U l        g r  )rI   r  finishedblkopenlineindentedline)r	  rI   s     r%   r  IndentSearcher.__init__4  s%    	!""/334,r'   c                     U R                   (       a  gU R                  S-   =ol        [        U5      S-   nU R                  R	                  USS5      (       a  gU R                  R                  X"S-   5      $ )NrA   r_   r  z>=rp   z lineend+1c)r  r  r	  rI   rA  r   )r	  r  r  s      r%   readlineIndentSearcher.readline9  s_    ==VVaZFAw~99T4//yy}}T-#788r'   )classdefforifr  trywhilewithc	                     U R                   (       a  g X:X  a  X(;   a  XPl        g X:X  a   U R                  (       a  XPl        SU l         g g g )Nr_   )r  r  r  )	r	  rH   tokenstartrp   rK  INDENTNAMEOPENERSs	            r%   
tokeneaterIndentSearcher.tokeneaterB  s?    
 ==\e.#^ 0 0 $DM !1^r'   c                      [         R                  " U R                  5      nU H  nU R                  " U6   M     U R                  U R                  4$ ! [         R                  [
        4 a     N4f = f)z`Return 2 lines containing block opener and indent.

Either the indent line or both may be None.
)tokenizegenerate_tokensr  r  
TokenErrorSyntaxErrorr  r  )r	  tokensr  s      r%   ri  IndentSearcher.runO  si    
	--dmm<F'  
 !2!222 ##[1 		s   8A A/.A/)r  r  r  r  rI   N)r"  r  r  r  __doc__r  r  r  r  r  r  ri  r  rY   r'   r%   r  r  1  s.    :4
9 #// -3r'   r  c                 P    U R                  S5      nUS:  a  U SU XS-   S -   n X4$ )zExtract the underscore from a string.

For example, prepstr("Co_py") returns (2, "Copy").

Args:
    s: String with underscore.

Returns:
    Tuple of (position of underscore, string without underscore).
rW  r   Nr_   )r  )sr  s     r%   rz  rz  `  s6     	
sAAvbqEAcdGO4Kr'   []/)bracketleftbracketrightslashc                 6   U R                  U5      nU(       a   [        R                  " 5       (       a  US;   a  gUS   n[        R                  " SS U5      n[        R                  " SS U5      n[        R                  " SSU5      n[        R                  " S	S
U5      n[        R                  " SSU5      n[        R                  " SSU5      n[        R                  " SSU5      n[        R                  " SSU5      n[        R                  " SSU5      nU$ )aK  Return a formatted string for the keybinding of an event.

Convert the first keybinding for a given event to a form that
can be displayed as an accelerator on the menu.

Args:
    keydefs: Dictionary of valid events to keybindings.
    eventname: Event to retrieve keybinding for.

Returns:
    Formatted string of the keybinding.
>   r]   rU   r^   rA   r   z-[a-z]\bc                 >    U R                  5       R                  5       $ r  )r  upperr  s    r%   r[   !get_accelerator.<locals>.<lambda>  s    aggioo&7r'   z\b\w+\bc                 f    [         R                  U R                  5       U R                  5       5      $ r  )keynamesr   r  r  s    r%   r[   r    s    X\\!'')QWWY%Gr'   zKey-Cancelz
Ctrl-BreakzControl-zCtrl-r  +z><r4  r<  r>  )r   r   r  r  sub)ro  r  rp  r  s       r%   ry  ry  w  s     kk)$G ))++	 >6 16 
A
{7;A
zGKA
vr1A
xq)A
z7A&A
sCA
tS!A
sBA
sBAHr'   c                     U R                   nUR                  SSS5        UR                  SSS5        UR                  SSS5        g )	Ntcl_wordBreakAfterza br   r   tcl_wordcharsz\wtcl_nonwordcharsz\W)r  r  )rx   r  s     r%   fixwordbreaksr    s?     
BGG %+GGE?E*GGE%u-r'   c                 H   U n[        U5        [        R                  SS  (       a  [        R                  S   nOS n[        R                  " US 5        [        XS9nUR                  nSUS'   [        S5       H'  nUR                  SSU-  [        U5      -   S-   5        M)     g )	Nr_   )rx   r
  
   rM      r6  z  rZ  )
r  r   argvr   setupAppr)   rI   rC  r6  rE  )r  rx   r
  re  rI   r  s         r%   _editor_windowr     s    D$
xx|88A;
OOD$T5D99DDN2YHd1fs1vo45 r'   __main__)rD   zidlelib.idle_test.test_editorre   F)	verbosityexit)ri  )<importlib.abcr  importlib.utilr   rW  r  r  r   r  r
  r  tkintertkinter.fontr   tkinter.ttkr   r   r   idlelib.configr   r#  r	   r
   r   r   r   idlelib.multicallr   r   r   r   r   idlelib.treer   idlelib.utilr   r   idlelib.helpr   rK  python_versionr  r   r&   r)   re  compiler  rf  r  rz  r  ry  r  r   r"  unittestrD   idlelib.idle_test.htestri  rY   r'   r%   <module>r     s     	  	  
      !    #       .     $ &  %  //11		!
kC kC\/ **Y'8*3 *3^$ 
(V.6& z	(AEB+ r'   