
    ѝi                    &   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'\R                  S:H  r( " S S5      r)S r*\RV                  " S5      r,S r- " S S5      r.S r/S S!S"S#.r0S$ r1S% r2S& r3\4S':X  a  S S(K5J6r6  \6" S)S*S+S,9  S S-K7J8r8  \8" \35        gg).    N)*)Font)	Scrollbar)simpledialog)
messagebox)idleConf)configdialog)grep)help)
help_about)macosx)MultiCallCreator)pyparse)query)replace)search)wheel_event)py_extensions)window)_get_dochome   darwinc                      \ 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)~EditorWindow&   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)r4   padxwraphighlightthicknessr6   tabstyler>   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     lib/python3.13/idlelib/editor.py<lambda>'EditorWindow.__init__.<locals>.<lambda>   s    '    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.runscriptr0   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   r3   	GetOptionr   Textr:   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_eventr*   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hasattrr`   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_addr$   user_input_insert_tagsautocomplete_eventtry_open_completions_eventforce_open_completions_eventr%   expand_word_eventr)   format_paragraph_eventr-   flash_paren_eventparen_closed_eventcheck_module_eventrun_module_eventrun_custom_eventr,   	do_rstripr&   ctiptry_open_calltip_eventrefresh_calltip_eventforce_open_calltip_eventr.   zoom_height_eventallow_code_contextr'   toggle_code_context_eventupdate_menu_stateallow_line_numbersr(   toggle_line_numbers_event)selfrj   filenamekeyrk   r0   ro   r{   r3   r6   text_optionsr:   r   indents	usespacesr   r   r   	is_py_srcr1   rc   autocomplete
parenmatchscriptbindingr   s                            rL   __init__EditorWindow.__init__=   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HrO   c                 $    U R                  5         g N)r   r   rK   s     rL   r   EditorWindow.handle_winconfig;  s    rO   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borderr?   rX   r]   )r]   0)
r:   summaptkgetintcgetwinfo_widthr   measurer6   )r   r:   inner_paddingpixel_widthzero_char_widths        rL   r   EditorWindow.set_width>  s    yyC81D1561B1D E F&&(1}+<< IIf-.66s; 	 3
rO   c                 r    U R                   R                  5       u  p#U R                  R                  U5        grH   )r   defaultfilenamerj   new)r   rK   dirnamebasenames       rL   r   EditorWindow.new_callbackK  s*     GG335

wrO   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.rR   ) 	insertzinsert linestart+csel1.0rc   	sel.first	my_anchor<sel.last>rI   )statekeysymr:   r   comparer7   splitr   rangelenstr
tag_removemark_settag_addsee)r   rK   insertptlinelineatdestfirstlasts           rL   r   EditorWindow.home_callbackP  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rO   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 )NrR   grey75)r>   borderwidth
backgroundr   	_padding1z    )rS   rZ   zCol: ?r>  zLn: ?)rS   rT   z<<set-line-and-column>>z<KeyRelease>z<ButtonRelease>)r#   ro   
status_barrz   sysplatform	set_labelRIGHTr   BOTTOMXr:   r   set_line_and_columnr   
after_idle)r   seps     rL   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6rO   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 )Nr&  rZ   zCol: %sr>  zLn: %s)r:   r   INSERTr5  rI  rL  )r   rK   r>  rZ   s       rL   rP   EditorWindow.set_line_and_column  sR    yyv.44S9!!(I,>?!!&(T/:rO   ))file_File)edit_Edit)formatF_ormat)run_Run)re   _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   )r4   tearoffpostcommand)labelr1   	underlineapple)r4   rd  applicationIDLE)rf  r1   rd  rW     zRecent Files)rf  rg  r1   r   )rm   r   
menu_specsprepstrgetattrrl   add_cascader   
isCarbonTk
fill_menusrecent_files_menuinsert_cascader   ENDbase_helpmenu_lengthreset_help_menu_entries)r   mbarr   r4   rf  rg  re  r1   s           rL   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!$$&rO   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   rc   Nrd   rR   )r   r   r   deleter   add_windows_to_menu)r   r1   rc   s      rL   r   EditorWindow.postwindowsmenu  sY    
 }}X&jj;CKKq(#.""4(rO   c                 @    U R                   U   nUR                  X#S9  g)z$Update label for menu item at index.)rf  Nr   entryconfig)r   r1   r   rf  menuitems        rL   update_menu_labelEditorWindow.update_menu_label  !    ==&U0rO   c                 @    U R                   U   nUR                  X#S9  g)z$Update state for menu item at index.r2  Nr  )r   r1   r   r2  r  s        rL   r   EditorWindow.update_menu_state  r  rO   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   rc   @0,0scrollunitsrI   )floatround	getlinenor:   yview)r   rK   argsfractionliness        rL   r   EditorWindow.handle_yview  sg    HT!W~H4>>%08;<^^F+,EE7#D		%%rO   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-  r$  r0  Fr+  r,  rc   r)  rl  winarrow)cursorr  ibeamrI   )r:   r   xyr4  TclErrorr9  r:  rmenu
make_rmenurK   rJ  rK  configrmenu_specs
ValueErrorro  entryconfiguretk_popupx_rooty_root)r   rK   r:   newdexin_selectionr  iswinitemrf  	eventnameverify_stater2  s               rL   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)CloserD   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   rk  rR   c                 &    U R                  U5        g r	  event_generater:   r  s     rL   rW   (EditorWindow.make_rmenu.<locals>.command$  s    ''	2rO   rf  rW   )rl   r:   r  add_commandr   r  )r   r  r  rf  r  rW   s         rL   r  EditorWindow.make_rmenu  si    TYY*$$D#AwQ9 !%i 3!!!?##% % 
rO   c                 "    U R                  5       $ r	  )rmenu_check_copyr   s    rL   rmenu_check_cutEditorWindow.rmenu_check_cut+  s    $$&&rO   c                 p     U R                   R                  S5      nU(       a  S$ S$ ! [         a     gf = f)Nr-  normalrf   r:   r   r  )r   indxs     rL   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  rf   )r:   r  callr  r  s    rL   rmenu_check_pasteEditorWindow.rmenu_check_paste6  s?    	IILL0$))[I   		s   14 
A Ac                 D    [         R                  " U R                  5        g)zHandle Help 'About IDLE' event.rI   )r   AboutDialogro   r
  s     rL   r   EditorWindow.about_dialog>  s     	txx(rO   c                 F    [         R                  " U R                  S5        g)z&Handle Options 'Configure IDLE' event.SettingsrI   )r	   ConfigDialogro   r
  s     rL   r   EditorWindow.config_dialogD  s     	!!$((:6rO   c                     U R                   (       a  U R                   nOU R                  n[        R                  " U5        g)zHandle Help 'IDLE Help' event.rI   )rk   ro   r   show_idlehelp)r   rK   parents      rL   r   EditorWindow.help_dialogJ  s.     99YYFXXF6"rO   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)Nrl  r  Document Start Failuretitlemessager  rI   )rJ  rK  ru   	startfileri   OSErrorr   r   r8  r:   
webbrowseropen)r   rK   whys      rL   r   EditorWindow.python_docsT  sy    <<u$8T]]+  OODMM*  8$$+CHTYY8 8s    A 
B%)BBc                 :    U R                   R                  S5        g)Nz<<Cut>>rI   r:   r  r
  s     rL   r   EditorWindow.cut_  s    		  +rO   c                 |    U R                   R                  S5      (       d  g U R                   R                  S5        g)Nr+  z<<Copy>>rI   )r:   
tag_rangesr  r
  s     rL   r   EditorWindow.copyc  s/    yy##E**		  ,rO   c                 p    U R                   R                  S5        U R                   R                  S5        g)Nz	<<Paste>>r)  rI   )r:   r  r<  r
  s     rL   r   EditorWindow.pastej  s'    		  -		hrO   c                     U R                   R                  SSS5        U R                   R                  SS5        U R                   R                  S5        g)Nr+  r,  zend-1cr)  rI   )r:   r;  r:  r<  r
  s     rL   r   EditorWindow.select_allo  s?    		%1		8U+		hrO   c                 t    U R                   R                  SSS5        U R                   R                  S5        g)Nr+  r,  rc   r)  rI   )r:   r9  r<  r
  s     rL   r   EditorWindow.remove_selectionu  s+    		UE51		hrO   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)Nr;   r   r-  r)  )r2  r  )rK   
edge_indexedges_tableself_text_indexself_text_mark_sets    rL   move_at_edge<EditorWindow.move_at_edge_if_selection.<locals>.move_at_edge  sH    aA%#K0&xZ1HI &   s   , 
99)r:   r   r:  )r   r  r  r  r  r  s    ` @@@rL   r   &EditorWindow.move_at_edge_if_selectionz  s9     ))//!YY//5	 	 rO   c                 :    U R                   R                  S5        g)Nz<Meta-Delete>rI   r  r
  s     rL   r   EditorWindow.del_word_left  s    		  1rO   c                 :    U R                   R                  S5        g)Nz<Meta-d>rI   r  r
  s     rL   r   EditorWindow.del_word_right  s    		  ,rO   c                 D    [         R                  " U R                  5        grH   )r   findr:   r
  s     rL   r   EditorWindow.find_event  s    DIIrO   c                 D    [         R                  " U R                  5        grH   )r   
find_againr:   r
  s     rL   r   EditorWindow.find_again_event  s    $))$rO   c                 D    [         R                  " U R                  5        grH   )r   find_selectionr:   r
  s     rL   r   !EditorWindow.find_selection_event  s    dii(rO   c                 p    [         R                   " U R                  U R                  U R                  5        grH   )r
   r:   r   rj   r
  s     rL   r    EditorWindow.find_in_files_event  s!    		$))TWWdjj1rO   c                 D    [         R                   " U R                  5        grH   )r   r:   r
  s     rL   r   EditorWindow.replace_event  s    		"rO   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):r+  r,  rc   r)  .0rI   )r:   r   Gotoresultr9  r:  r<  rP  )r   rK   r:   linenos       rL   r   EditorWindow.goto_line_event  st    yyl) &	 	
 OOE5%0MM(vhbM2HHX$$&rO   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-  r0  r2   zOpen ModulezAEnter the name of a Python module
to search on sys.path and open:)r:   r   stripr  r   
ModuleNamer  rj   r  r   r   )r   r4   	file_paths      rL   open_moduleEditorWindow.open_module  s    	99==j9??AD $$		=2	 f	 	
  zz

	*    +  	D	s   *B' 'B65B6c                 $    U R                  5         grH   )r  r
  s     rL   r   EditorWindow.open_module_event  s    rO   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PyShellEditorWindowrI   r   )browser)	r   r   	__class____name__r  idlelibr  ModuleBrowserrk   )r   rK   r   r  s       rL   r    EditorWindow.open_module_browser  sX    77##''+@@'')H#dii2rO   c                 F    SSK Jn  UR                  U R                  5        g)Nr   )pathbrowserrI   )r  r  PathBrowserrk   )r   rK   r  s      rL   r   EditorWindow.open_path_browser  s    '		*rO   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)shellrI   )
subprocessrJ  
executablePopen)r   rK   r   cmds       rL   r   EditorWindow.open_turtle_demo  s1    ~~=? 	E*rO   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   r)  z%d.0r+  r,  rc   z
insert +1l)r:   r:  r9  r;  center)r   r  s     rL   gotolineEditorWindow.gotoline  sc    &1*IIx&9II  u5IIeX|<KKM	 #-rO   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;   $ )NTr,  z1.0 lineendz#!python)
ru   rv   r   splitextr  normcaser   r:   r   
startswith)r   r   baseextr>  s        rL   r   EditorWindow.ispythonsource  s    277==22GG$$RWW%5%5h%?@	77C M1yy}}UM2t$9T)99rO   c                 l    U R                   (       a#  U R                   R                  U 5        S U l         g g r	  )rj   unregister_maybe_terminater  s    rL   
close_hookEditorWindow.close_hook  s'    ::JJ11$7DJ rO   c                     Xl         g r	  )r3  )r   r3  s     rL   set_close_hookEditorWindow.set_close_hook  s    $rO   c                     U R                   (       a  U R                   R                  U 5        U R                  5         U R                  R	                  U 5        U R                  5         g r	  )rj   filename_changed_editr   ro   update_windowlist_registryr   r  s    rL   r   !EditorWindow.filename_change_hook  sE    ::JJ,,T2 ++D1rO   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    rL   _addcolorizerEditorWindow._addcolorizer  sb    ::tww//00,,.DJ::HH&&djj		&J rO   c                     U R                   (       d  g U R                   R                  5         U R                  R                  U R                   5        S U l         g r	  )r   removecolorsr   removefilterr  s    rL   _rmcolorizerEditorWindow._rmcolorizer  s9    zz

!djj)
rO   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)	rE  r@  r   r   r:   r   update_highlight_colorsr   update_colorsr  s    rL   r   EditorWindow.ResetColorizer  so     	!!$)),(557(++- )rO   _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
r)  z+1c)r;  r   
IDENTCHARSr:  r<  )r   r:   poschars       rL   colorize_syntax_error"EditorWindow.colorize_syntax_error+  sy    Wc"xx}DOO+LL#"4c:488C= MM(C(MM(C%K0rO   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.r5   r   zcursor-blinkr_   r8   r   ra   N)r   r|   r:   r`   )r   cursorblinks     rL   r    EditorWindow.update_cursor_blink6  sC    ((VE)*DIIo& *2)@)@DIIo&rO   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 changedNr5   r   r]   )r   update_fontr   r   r   rk   r:   r   )r   new_fonts     rL   	ResetFontEditorWindow.ResetFont@  sp     ())+ ())+##DIIv~F$		&rO   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   GetCurrentKeySetr"   default_keydefsitemsr:   event_deleteget_standard_extension_namesGetExtensionBindings)r   keydefsrK   keylistextensionNamexkeydefss         rL   RemoveKeybindingsEditorWindow.RemoveKeybindingsQ  s     3;2K2K2MM%%mmoNEII""5373 .!>>@M44]CHx&.nn&6NEII**5;7; '7 ArO   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   rR   NrW   acceleratorrf  r2   )rj  )r   r]  r"   r^  r   ra  rb  menudefsrn  r   r   ru  r6  r9   	entrycgetget_acceleratorr  )r   rc  re  rf  menuEventDictr1   r  menubarItemrc   r   accelitemNamerK   s                rL   ApplyKeybindingsEditorWindow.ApplyKeybindings`  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 ' )rO   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 windowr5   r^   z
num-spacesr7   r8   N)r   r   r|   r   r  s    rL   r   #EditorWindow.set_notabs_indentwidth  s,     ||'11&(<7< >D rO   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   rR   r   r  N)
r   GetAllExtraHelpSourcesListr   r   ru  rv  r{  r   _extra_help_callbackr  )r   	help_listhelpmenuhelpmenu_lengthentryr#  s         rL   rw  $EditorWindow.reset_help_menu_entries  s    779	==("..-666OOT66:_M""$"//a9$$58S$A # !)frO   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httprl  r  r  r  )r-  ru   rv   normpathrJ  rK  r  r  r   r   r8  r:   r  r  )helpfiler  r   s     rL   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:rJ   )r   resourcer  s   `  rL   rx  !EditorWindow._extra_help_callback  s    (0 
	* "!rO   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   )r!   errorsNrN  r    rd   1234567890ABCDEFGHIJKwrecentfiles_messageFTzIDLE Warningz)Cannot save Recent Files list to disk.
  z
Select OK to continue.r  r'  )rf  rW   rg  )rx   ru   rv   r   r  	readlinesabspathremover)  appendr7  
writelinesr  ro  rk   r  r   showwarningr:   ro   rs   rs  r{  ru  	enumeraterstrip#_EditorWindow__recent_file_callbackr  )r   new_filerf_listr  rf_list_file	bad_pathsrv   ulcharsrf_fileerrinstancer1   i	file_namecallbacks                  rL   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    rL   open_recent_file=EditorWindow.__recent_file_callback.<locals>.open_recent_file  s    GGLL*L-rO   rJ   )r   r  r  s   `  rL   __recent_file_callback#EditorWindow.__recent_file_callback  s    (1 	.rO   c                    U R                  5       nU R                  5       nS[        R                  " 5       -  nU(       a-  U(       a&  [        R
                  " 5       (       d  US-   U-   U-   nO:U(       a'  US:X  a  US-   [        R                  " 5       -   nOX-   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 (%s)z - z
IDLE Shellr'  untitledz*%s*z*%sz
-titlepathz	-modified)short_title
long_titlerK  python_versionr   	isCocoaTk	get_savedro   wm_titlewm_iconnamewm_attributes)r   shortlong_py_versionr  icons         rL   r   EditorWindow.saved_change_hook  s(     "  7 7 99T&"2"2"4"4 EMD(;6E$x'>'>'@@+EE%%~~UNE4<D% T"HH""<6 HH"";DNN4D0DE rO   c                 6    U R                   R                  5       $ r	  )r   r  r  s    rL   r  EditorWindow.get_saved  s    yy""$$rO   c                 :    U R                   R                  U5        g r	  )r   	set_saved)r   flags     rL   r  EditorWindow.set_saved  s    		D!rO   c                 8    U R                   R                  5         g r	  )r   
reset_undor  s    rL   r  EditorWindow.reset_undo  s    		rO   c                 ~    U R                   R                  nU(       a  [        R                  R	                  U5      $ S$ )Nr  )r   r   ru   rv   r  )r   r   s     rL   r  EditorWindow.short_title
  s-    77##-5rww)E:ErO   c                 @    U R                   R                  =(       d    S$ )Nr2   )r   r   r  s    rL   r  EditorWindow.long_title  s    ww%2%rO   c                 $    U R                  5         grH   )r&  r
  s     rL   r    EditorWindow.center_insert_event  s    rO   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 )NrR   rX   )r:   getwindowlinesr  maxr  r  )r   markr:   ro   botr  r>   newtops           rL   r&  EditorWindow.center  sS    yy&&(%Q*+

5=!rO   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,65535rR   r>   )r:   r  winfo_heightr7   )r   r:   ro   r  r>   s        rL   r  EditorWindow.getwindowlines  s]    yynnV$nnZ(:$++-2h(F,"CxrO   c                 `    U R                   n[        [        UR                  U5      5      5      $ r	  )r:   r7   r  r   )r   r  r:   s      rL   r  EditorWindow.getlineno'  s$    yy5D)*++rO   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+))ro   wm_geometryrematchlistr  r7   groups)r   geomms      rL   get_geometryEditorWindow.get_geometry+  s=    xx##%HH5t<CQXXZ())rO   c                 $    U R                  5         grH   )r   r
  s     rL   r   EditorWindow.close_event1  s    

rO   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  ro   r2  	deiconifylowerlift	maybesaver  s    rL   r  EditorWindow.maybesave5  sl    77>>##88>>#X-HH&&( 77$$&& rO   c                      U R                  5       n[        U5      S:w  a  U R                  5         U$ ! [         a     g f = f)Ncancel)r  r8  _closeAttributeError)r   replys     rL   r   EditorWindow.close>  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   r:   rq   r   ro   destroyr3  r  s    rL   r  EditorWindow._closeG  s    77))4773C3C)D""4#7#78 	::JJDJ	 ??OO rO   c                 2    0 U l         U R                  5         g r	  )
extensionsload_standard_extensionsr  s    rL   r   EditorWindow.load_extensions[  s    %%'rO   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     rL   r  EditorWindow.unload_extensions_  s=    ..01CsG$$		 2 rO   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)ra  load_extensionprintrepr	traceback	print_exc)r   r4   s     rL   r  %EditorWindow.load_standard_extensionse  sJ    557D&##D) 8&0$t*=##%s	   +,Ac                 *    [         R                  " SS9$ )NT)editor_only)r   GetExtensionsr  s    rL   ra  )EditorWindow.get_standard_extension_namesm  s    %%$77rO   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)Nr&  )packagez
Failed to import extension: rk  -rK  rR   r/  rd   r1  _event)extfilesr   	importlibimport_module__package__ImportError	TypeErrorr  ro  r   rb  r   rr  rk  r  r   r   r:   r   )	r   r4   fnamemodclsrc  r  vevent
methodnames	            rL   r  EditorWindow.load_extensiont  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)r"   r^  r:   rc  r_  r   )r   rc  r:   rK   rd  s        rL   r   EditorWindow.apply_bindings  sL    ?mm33Gyy%mmoNEwu/w/ .rO   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.
NrR   !c                 &    U R                  U5        g r	  r  r  s     rL   rW   (EditorWindow.fill_menus.<locals>.command  s    ++I6rO   )rf  rg  rW   rj  variable)rf  rg  rW   rj  )r"   rk  r^  r   r:   r   r   rn  rm  get_var_obj
BooleanVaradd_checkbuttonr  )r   rk  rc  r   r:   mname	entrylistr1   r|  rf  r  checkbuttonrg  rj  rW   vars                   rL   rr  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% #	 !)rO   c                 l    U R                  U5      nU(       a  UR                  5       nU$ [        U5      er	  )r  r   	NameError)r   r4   r%  values       rL   getvarEditorWindow.getvar  s/    t$GGIELD/!rO   c                 l    U R                  X5      nU(       a  UR                  U5        g [        U5      er	  )r  r   r(  )r   r4   r)  vartyper%  s        rL   setvarEditorWindow.setvar  s*    t-GGEND/!rO   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.
        )rq   r   r:   )r   r  r-  r%  s       rL   r  EditorWindow.get_var_obj  sB     ##I.w181CCDi(3
rO   c                     U R                   (       aA  U R                  R                  SU5      =(       d    SU R                  R                  U5      ;   $ g)NTODOSTRINGrR   )r   r:   tag_prevrange	tag_names)r   
text_indexs     rL   is_char_in_stringEditorWindow.is_char_in_string  sE    :: 99**6:> ?tyy22:>>? rO   c                      U R                   R                  S5      nU R                   R                  S5      nX4$ ! [         a     gf = f)Nr-  r0  NNr  )r   rA  rB  s      rL   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)r:   TK_TABWIDTH_DEFAULTr7   )r   currents     rL   get_tk_tabwidthEditorWindow.get_tk_tabwidth  s     ))F#:':7|rO   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 )Nr]   r  z
-displayofn)r?  )r:   rB  r  r  master	configure)r   newtabwidthr:   pixelss       rL   set_tk_tabwidthEditorWindow.set_tk_tabwidth  s^    yy![0WW\\&)T&\"."%"35F NNN' 1rO   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 )NrX   r   F)guess_indentr   r   r   rJ  )r   r  guessr  s       rL   r   #EditorWindow.set_indentation_params	  sQ    !!#AA{{#$ 4==0$T]]+rO   c                 B   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
:  d   e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)Nr)  rI   r%  r2   r1  r,  z	insert-1crd    	r   rR   z
insert-%dcr'  )r:   r<  r{  r:  r   r4  bellr   r7  
expandtabsr   r   r)  r   r   )
r   rK   r:   rA  rB  charsr   havewantncharsdeleteds
             rL   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-.axxd...$2B2BB#2JE)A-Mu''12D|uRy5  	L=0(;;KK#"5335rO   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)Nr)  r%  r(  r'  rI   )r:   r<  r   
index2liner   r   r   r{  r:  r   get_line_indentr   r7  reindent_tor   r   rS  r)  r   r<  )
r   rK   r:   rA  rB  prefixraw	effectivepadrE  s
             rL   r   EditorWindow.smart_indent_event=  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        OqU[        RB                  :X  aR  U
RE                  5       S:  a  UR                  SUU R                  5        O+U R?                  U
RG                  5       5        O SU< 35       e 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.
r)  r%  r   rQ  rR   rN  rI   Nrd   zinsert - %d charsr  consoler,  zbogus continuation type ))r:   r<  r   r{  r:  r   r7  r)  r   r<  r   rZ  r   r   Parserr   r   ry   r   r  r  set_codefind_good_parse_start_build_char_in_string_funcset_lor5  get_continuation_typeC_NONEC_STRING_FIRST_LINEC_STRING_NEXT_LINES	C_BRACKETr\  compute_bracket_indentC_BACKSLASHget_num_lines_in_stmtcompute_backslash_indentget_base_indent_stringis_block_openerr   is_block_closerr   )r   rK   r:   rA  rB  r>  r  rE  indentlnor  contextstartatstartatindexrawtextbodrr*  s                     rL   r   %EditorWindow.newline_and_indent_event`  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> 8>>1 HHX  " --/FKK&*E*EF  ""''.A--//**51HHX  " HHX  "s4   A.R'  "R' %1R' AR' 1C(R' FR' B R' '#S
c                 (    UU R                   4S jnU$ )Nc                     U" USU -  -   5      $ )Nz+%dcrJ   )offset_startindex_iciss      rL   inner6EditorWindow._build_char_in_string_func.<locals>.inner  s    v677rO   )r8  )r   
startindexr  s      rL   rg  'EditorWindow._build_char_in_string_func  s    &0..	8 rO   c                 r    U R                   (       a"  [        XR                  5      u  p#SU-  SU-  -   $ SU-  $ )Nr(  r'  )r   divmodr   )r   rE  ntabsnspacess       rL   _make_blanksEditorWindow._make_blanks  s5    <<#A}}5NE%<#-//7NrO   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 )Nr%  z!=r)  )r:   r   r4  r{  r)  r  r   r   )r   rZ   r:   s      rL   r\  EditorWindow.reindent_to  sm    yy<<*D(;;KK*H5KK$"3"3F";335rO   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   )IndentSearcherr:   r]  r[  r   )r   openerindentedr^  indentsmallindentlarges         rL   rM  EditorWindow.guess_indent  sa    )$))488:h.v}}EC.xGC (( )*)K((rO   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Hidere   rg   z Line Numbers)r1   r   rf  )r   is_shownhide_sidebarshow_sidebarr  )r   rK   
menu_labels      rL   r   &EditorWindow.toggle_line_numbers_event
  sp    $%%**,J**,JI](2|=%A 	 	CrO   )$r   r   rv  r3  r   r   r   rK   r  rj   r   r   r   r   r   rm   r   r   r   ry   rs  rx   r  rk   r   rI  r   r:   r{   rq   ro   r   r   r3   r6   r   )NNNNr	  )r)  r;  )T)r  
__module____qualname____firstlineno__idlelib.percolatorr   idlelib.colorizerr   r   idlelib.undor   idlelib.iomenur    r!   r  r"   idlelib.statusbarr#   idlelib.autocompleter$   idlelib.autoexpandr%   idlelib.calltipr&   idlelib.codecontextr'   idlelib.sidebarr(   idlelib.formatr)   r*   r+   r,   idlelib.parenmatchr-   idlelib.zoomheightr.   rJ  getfilesystemencodingfilesystemencodingri   r   r   r   r  r   r   r   r   r   rP  rm  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   r'  r   r3  r6  r   r@  rE  r   stringascii_lettersdigitsrO  rR  r   rZ  rg  rr  r   rw  rx  r   r  r   r  r  r  r  r  r   r&  r  r  r  r   r  r   r  r   r  r  ra  r  r  r   rr  r*  r.  r  r8  r<  rB  rJ  r   r   r   r   rg  r  r\  rM  r   __static_attributes__rJ   rO   rL   r   r   &   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>%"F&",*'((&8 	9
HE80$BL""$(,)V!#Fq#p )CrO   r   c                 *    [        [        U 5      5      $ r	  )r7   r  )r   s    rL   rZ  rZ    s    uU|rO   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  rc   r7  grouprS  )r>  r   r  s      rL   r[  r[    s;     	d#A557C	,,X6777rO   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  i'  z4Manage initial indent guess, returned by run method.c                 H    Xl         S=U l        U l        S =U l        U l        g r  )r:   r  finishedblkopenlineindentedline)r   r:   s     rL   r  IndentSearcher.__init__*  s%    	!""/334,rO   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      $ )Nr2   rR   r  z>=rc   z lineend+1c)r  r  r  r:   r4  r   )r   r  r  s      rL   readlineIndentSearcher.readline/  s_    ==VVaZFAw~99T4//yy}}T-#788rO   )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 )NrR   )r  r  r  )	r   r9   tokenstartrc   r>  INDENTNAMEOPENERSs	            rL   
tokeneaterIndentSearcher.tokeneater8  s?    
 ==\e.#^ 0 0 $DM !1^rO   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      rL   r]  IndentSearcher.runE  si    
	--dmm<F'  
 !2!222 ##[1 		s   8A A/.A/)r  r  r  r  r:   N)r  r  r  r  __doc__r  r  r  r  r  r  r]  r  rJ   rO   rL   r  r  '  s.    :4
9 #// -3rO   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).
rK  r   NrR   )r  )sr  s     rL   rn  rn  V  s6     	
sAAvbqEAcdGO4KrO   []/)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.
>   rP   rF   rQ   r2   r   z-[a-z]\bc                 >    U R                  5       R                  5       $ r	  )r  upperr  s    rL   rM   !get_accelerator.<locals>.<lambda>  s    aggioo&7rO   z\b\w+\bc                 f    [         R                  U R                  5       U R                  5       5      $ r	  )keynamesr   r  r  s    rL   rM   r    s    X\\!'')QWWY%GrO   zKey-Cancelz
Ctrl-BreakzControl-zCtrl-r
  +z><r'  r/  r1  )r   r   r  r  sub)rc  r  rd  r  s       rL   rm  rm  m  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HrO   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  )rk   r  s     rL   fixwordbreaksr    s?     
BGG %+GGE?E*GGE%u-rO   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 )	NrR   )rk   r   
   r>      r)  z  rN  )
r  rJ  argvr   setupAppr   r:   r6  r)  r8  )r  rk   r   rY  r:   r  s         rL   _editor_windowr    s    D$
xx|88A;
OOD$T5D99DDN2YHd1fs1vo45 rO   __main__)r5   zidlelib.idle_test.test_editorrX   F)	verbosityexit)r]  )9importlib.abcr  importlib.utilru   rK  r  r  rJ  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   r@  r   r   rZ  compiler  r[  r  rn  r  rm  r  r  r  unittestr5   idlelib.idle_test.htestr]  rJ   rO   rL   <module>r     s      	  	  
      !    #       .     $ &  %  		!oC oCd/ **Y'8*3 *3^$ 
(V.6& z	(AEB+ rO   