
   #                      S r SSKrSSKJrJrJrJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r   SSK!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.  SSKJ/r/  SSK0J1r2  SSKJ3r3  SSK4J5r5J6r6  SSK7J8r8  SS	K9J:r:  SS
K;J<r<  SSK=J>r>J?r?  SSK@JArA  SSKBJCrC  SSKDJErE  SSKFJGrG  SSKHJIrI  SSKJJKrK  SSK@JLrL  \6" 5       rM\C\E\G\I\K4rN " S S\5      rOSqP " S S\"5      rQ " S S\"5      rR " S S\"5      rS " S S\"5      rT " S S\"5      rU " S  S!\"5      rV " S" S#\#5      rW " S$ S%5      rX\X" 5       rYS&rZS'S(S)S*S+S,.r[S- r\ " S. S/\"5      r]\^S0:X  a  SS1K_J`r`  \`" S2S3S4S59  SS6KaJbrb  \b" \O5        gg)7a  IDLE Configuration Dialog: support user customization of IDLE by GUI

Customize font faces, sizes, and colorization attributes.  Set indentation
defaults.  Customize keybindings.  Colorization and keybindings can be
saved as user defined sets.  Select startup options including shell/editor
and default window size.  Define additional help sources.

Note that tab width in IDLE is currently fixed at eight due to Tk issues.
Refer to comments in EditorWindow autoindent code for details.

    N)ToplevelListboxCanvas	StringVar
BooleanVarIntVarTRUEFALSETOPBOTTOMRIGHTLEFTSOLIDGROOVENONEBOTHXYWEEWNSNSEWNW
HORIZONTALVERTICALANCHORACTIVEENDTclError)Frame
LabelFrameButtonCheckbuttonEntryLabel
OptionMenuNotebookRadiobutton	ScrollbarStyleSpinboxCombobox)colorchooser)
messagebox)idleConfConfigChanges)GetKeysWindow)DynOptionMenu)macosx)SectionName
HelpSource)	view_text)AutoComplete)CodeContext)
ParenMatch)FormatParagraph)Squeezer)ScrollableTextFramec                   p   ^  \ rS rSrSrSSSS.S jjrS rS rS rS	 r	S
 r
U 4S jrS rS rS rSrU =r$ )ConfigDialog-   zConfig dialog for IDLE.
    F)_htest_utestc                   [         R                  " X5        Xl        U(       a  0 Ul        U(       d  U R	                  5         U R                  U=(       d    S5        UR                  5       S-   nUR                  5       U(       d  SOS-   nU R                  SU SU 35        U R                  5         U R                  [        [        S9  U R                  U5        U R                  SU R                  5        U R                  R                   R#                  5         [$        R'                  5         U(       d1  U R)                  5         U R+                  5         U R-                  5         gg)	a{  Show the tabbed dialog for user configuration.

Args:
    parent - parent of this dialog
    title - string which is the title of this popup dialog
    _htest - bool, change box location when running htest
    _utest - bool, don't wait_window when running unittest

Note: Focus set on font page fontlist.

Methods:
    create_widgets
    cancel: Bound to DELETE_WINDOW protocol.
zIDLE Preferences         +heightwidthWM_DELETE_WINDOWN)r   __init__parentinstance_dictwithdrawtitlewinfo_rootxwinfo_rootygeometrycreate_widgets	resizabler
   	transientprotocolcancelfontpagefontlist	focus_settracersattachgrab_setwm_deiconifywait_window)selfrM   rP   rA   rB   xys          +/usr/lib/python3.13/idlelib/configdialog.pyrL   ConfigDialog.__init__1   s
    	$'#%F MMO

5../ 2% fB#>!AaSk" 	e51v($++6((* 	MMO     c                 L   [        U SS9=U l        nU R                  R                  SS9  [        U5      =U l        n[        U5      U l        [        X R                  5      U l        [        X R                  5      U l
        [        X R                  5      U l        [        U5      U l        [        U5      U l        UR#                  U R                  SS9  UR#                  U R                  SS9  UR#                  U R                  SS9  UR#                  U R                  S	S9  UR#                  U R                   S
S9  UR#                  U R                  SS9  UR%                  5         UR'                  [(        [*        [,        S9  U R/                  5       R'                  [0        S9  g)a  Create and place widgets for tabbed dialog.

Widgets Bound to self:
    frame: encloses all other widgets
    note: Notebook
    highpage: HighPage
    fontpage: FontPage
    keyspage: KeysPage
    winpage: WinPage
    shedpage: ShedPage
    extpage: ExtPage

Methods:
    create_action_buttons
    load_configs: Load pages except for extensions.
    activate_config_changes: Tell editors to reload.
   paddingnwes)stickyz Fonts text
Highlightsz Keys z	 Windows z
 Shell/Ed 
Extensionssideexpandfillrr   N)r!   framegridr(   noteExtPageextpageHighPagehighpageFontPagerY   KeysPagekeyspageWinPagewinpageShedPageshedpageaddenable_traversalpackr   r	   r   create_action_buttonsr   )ra   rv   rx   s      rd   rT   ConfigDialog.create_widgets`   s:   $ #433
U

v&#E?*	Dt} ||4 }}5 ||4t} Y/\2X.K0\2L1		s4d	3""$))v)6rf   c                    [         R                  " 5       (       a  0 nOSS0n[        U R                  SS9n[        USS9n0 U l        SU R
                  4SU R                  4SU R                  4SU R                  44 HF  u  pE[        U4XE[        S	.UD6U R                  U'   U R                  U   R                  [        S
S9  MH     [        USSS9R                  [        S9  UR                  [        S9  U$ )aa  Return frame of action buttons for dialog.

Methods:
    ok
    apply
    cancel
    help

Widget Structure:
    outer: Frame
        buttons: Frame
            (no assignment): Button (ok)
            (no assignment): Button (apply)
            (no assignment): Button (cancel)
            (no assignment): Button (help)
        (no assignment): Frame
rj   )         ri   OkApplyCancelHelp)rn   command	takefocusrh   )rr   padxr   )rI   borderwidthru   )r4   isAquaTkr!   rv   buttonsokapplyrX   helpr#   r
   r   r   r   r   )ra   padding_argsouterbuttons_frametxtcmds         rd   r   "ConfigDialog.create_action_buttons   s    $ ?? L%v.Ldjj!,eQ/477Odjj!t{{#TYY	!HC
 !'} !83!&!8*6!8DLLLL""1"5! 	eA1-222<'rf   c                 D    U R                  5         U R                  5         g)z*Apply config changes, then dismiss dialog.N)r   destroyra   s    rd   r   ConfigDialog.ok   s    

rf   c                     U R                  5         [        R                  5         U R                  R	                  5         U R                  5         g)z+Apply config changes and leave dialog open.N)deactivate_current_configchangessave_allrz   save_all_changed_extensionsactivate_config_changesr   s    rd   r   ConfigDialog.apply   s6    &&(002$$&rf   c                 L    [         R                  5         U R                  5         g)z8Dismiss config dialog.

Methods:
    destroy: inherited
N)r   clearr   r   s    rd   rX   ConfigDialog.cancel   s     	rf   c                    > U R                   R                  R                  SS5      qU R	                  5         [
        TU ]  5         g )N1.0end)rY   font_samplegetfont_sample_textgrab_releasesuperr   )ra   	__class__s    rd   r   ConfigDialog.destroy   s6    ==4488Frf   c           	          U R                   R                  U R                   R                  5       SS9R                  5       n[	        U S[
        [        R                  US5      -   S9  g)z|Create textview for config dialog help.

Attributes accessed:
    note
Methods:
    view_text: Method from textview module.
rn   )optionzHelp for IDLE preferences )rP   contentsN)rx   tabselectstripr7   help_common
help_pagesr   )ra   pages     rd   r   ConfigDialog.help   sQ     yy}}TYY--/}?EEG$9&z~~dB'??	Arf   c                 ^    U R                   R                   H  nUR                  5         M     g)z/Remove current key bindings in current windows.N)rM   rN   RemoveKeybindings)ra   instances     rd   r   &ConfigDialog.deactivate_current_config   s"    11H&&( 2rf   c                 8   U R                   R                   Hc  nUR                  5         UR                  5         UR	                  5         UR                  5         UR                  5         UR                  5         Me     [         H  nUR                  5         M     g)zApply configuration changes to current windows.

Dynamically update the current parent window instances
with some of the configuration changes.
N)
rM   rN   ResetColorizer	ResetFontset_notabs_indentwidthApplyKeybindingsreset_help_menu_entriesupdate_cursor_blinkreloadablesreload)ra   r   klasss      rd   r   $ConfigDialog.activate_config_changes   su     11H##% ++-%%',,.((* 2 !ELLN !rf   )
r   rz   rY   rv   r|   r   rx   rM   r   r   )r   )__name__
__module____qualname____firstlineno____doc__rL   rT   r   r   r   rX   r   r   r   r   __static_attributes____classcell__r   s   @rd   r?   r?   -   sL    -5 -^$7L&P
'
A)
 rf   r?   u^  <ASCII/Latin1>
AaBbCcDdEeFfGgHhIiJj
1234567890#:+=(){}[]
¢£¥§©«®¶½ĞÀÁÂÃÄÅÇÐØß

<IPA,Greek,Cyrillic>
ɐɕɘɞɟɤɫɮɰɷɻʁʃʆʎʞʢʫʭʯ
ΑαΒβΓγΔδΕεΖζΗηΘθΙιΚκ
БбДдЖжПпФфЧчЪъЭэѠѤѬӜ

<Hebrew, Arabic>
אבגדהוזחטיךכלםמןנסעף
ابجدهوزحطي٠١٢٣٤٥٦٧٨٩

<Devanagari, Tamil>
०१२३४५६७८९अआइईउऊएऐओऔ
௦௧௨௩௪௫௬௭௮௯அஇஉஎ

<East Asian>
〇一二三四五六七八九
汉字漢字人木火土金水
가냐더려모뵤수유즈치
あいうえおアイウエオ
c                   J   ^  \ rS rSrU 4S jrS rS rS rS rS	S jr	Sr
U =r$ )
r}   i  c                    > [         TU ]  U5        UR                  U l        U R                  5         U R	                  5         g N)r   rL   highlight_samplecreate_page_fontload_font_cfg)ra   masterr|   r   s      rd   rL   FontPage.__init__  s6      ( 9 9rf   c           	         [         R                  [        U 5      U R                  5      U l        [         R                  [        U 5      U R                  5      U l        [         R                  [        U 5      U R                  5      U l        [        U S[        SS9n[        U S[        SS9n[        U5      n[        U5      n[        U[        SS9n[        USS[        S	9U l        U R                  R!                  S
U R"                  5        U R                  R!                  SU R"                  5        U R                  R!                  SU R"                  5        [%        U5      nUR'                  U R                  R(                  S9  U R                  R'                  UR*                  S9  [        USS9n[-        X@R
                  S5      U l        [1        X@R                  SSSS9U l        [5        U5      nUR6                  U l        U R8                  R'                  [:        SSS9  U R8                  R=                  [>        [@        5        U RC                  SSS9  U RE                  SSS9  URG                  SSSSS9  URG                  SSSSSSS9  URI                  [J        SS[L        S9  URI                  [J        SS[L        S9  URI                  [J        [N        S9  U R                  RI                  [        [P        [L        S9  URI                  [        [R        S 9  URI                  [        [N        S9  U R.                  RI                  [        [N        S9  U R2                  RI                  [        [N        S!S"9  URI                  [P        [T        S#9  g)$aj  Return frame of widgets for Font tab.

Fonts: Enable users to provisionally change font face, size, or
boldness and to see the consequence of proposed choices.  Each
action set 3 options in changes structuree and changes the
corresponding aspect of the font sample on this page and
highlight sample on highlight page.

Function load_font_cfg initializes font vars and widgets from
idleConf entries and tk.

Fontlist: mouse button 1 click or up or down key invoke
on_fontlist_select(), which sets var font_name.

Sizelist: clicking the menubutton opens the dropdown menu. A
mouse button 1 click or return key sets var font_size.

Bold_toggle: clicking the box toggles var font_bold.

Changing any of the font vars invokes var_changed_font, which
adds all 3 font options to changes and calls set_samples.
Set_samples applies a new font constructed from the font vars to
font_sample and to highlight_sample on the highlight page.

Widgets for FontPage(Frame):  (*) widgets bound to self
    frame_font: LabelFrame
        frame_font_name: Frame
            font_name_title: Label
            (*)fontlist: ListBox - font_name
            scroll_font: Scrollbar
        frame_font_param: Frame
            font_size_title: Label
            (*)sizelist: DynOptionMenu - font_size
            (*)bold_toggle: Checkbutton - font_bold
    frame_sample: LabelFrame
        (*)font_sample: Label
r   z Shell/Editor Font r   reliefrn   z Font Sample (Editable) zFont Face :)justifyrn      TrI   r   exportselection<ButtonRelease-1>z<KeyRelease-Up>z<KeyRelease-Down>r   )yscrollcommandzSize :rm   N   r   Bold)variableonvalueoffvaluern   )wraprJ   rI   weightrh   )rowcolumnr   padyr   nsew)r   r   rowspanr   r   rl   rr   r   r   rt   rr   anchorrq   )rr   rt   rD   rr   r   r   )rs   rt   )+r\   r   r   var_changed_font	font_name	font_sizer   	font_boldr"   r   r!   r&   r   r   r
   rZ   bindon_fontlist_selectr*   configyviewsetr3   sizelistr$   bold_toggler=   rn   r   r   insertr   r   columnconfigurerowconfigurerw   r   r   r   r   r	   r   r   )	ra   
frame_fontframe_sampleframe_font_nameframe_font_paramfont_name_titlescroll_fontfont_size_titlefont_sample_frames	            rd   r   FontPage.create_page_font!  s   L !Yt_d6K6KL Yt_d6K6KL Z%5t7L7LM  !F%:<
!$Af'AC  
+ ,MC*.G.0G0GH,d.E.EF.0G0GH04==#6#67KOO< 0x@%&6M& >>AF4 0=,11T1=%56 	Qq)!A&Aaaa8a111!' 	 	) 	#AAA>3QQQ?#a0T:d+$q1Q/4;d6rf   c                 >   [         R                  " U SS5      nUS   R                  5       nUS   nUS   S:H  n[        [	        [
        R                  " U 5      5      5      nU H#  nU R                  R                  [        U5        M%     U R                  R	                  U5        U Vs/ s H  owR                  5       PM     nn UR                  U5      n	U R                  R                  U	5        U R                  R                  U	5        U R                  R                  U	5        U R                  R                  U	5        U R"                  R%                  SU5        U R&                  R	                  U5        U R)                  5         gs  snf ! [          a     NYf = f)	zLoad current configuration settings for the font options.

Retrieve current font with idleConf.GetFont and font families
from tk. Setup fontlist and set font_name.  Setup sizelist,
which sets font_size.  Set font_bold.  Call set_samples.
mainEditorWindowr   r   r   bold)78910111213141618202225293440N)r0   GetFontlowersortedr  tkfontfamiliesrZ   r  r   r   indexsee
select_setselect_anchoractivate
ValueErrorr  SetMenur   set_samples)
ra   configured_fontr   r   r   fontsfontslc_fontscurrent_font_indexs
             rd   r   FontPage.load_font_cfgz  s\    #**4H#A&,,.	#A&	$Q'/	 s6??4012DMM  d+ 9%',-u!GGIu-	!)	!:MM01MM$$%78MM''(:;MM""#56 	 O'	) 	9% .  		s   )F
A=F 
FFc                 P   U R                   R                  5       n[        R                  SSSU5        U R                  R                  5       n[        R                  SSSU5        U R
                  R                  5       n[        R                  SSSU5        U R                  5         g)zStore changes to font attributes.

When one font attribute changes, save them all, as they are
not independent from each other. In particular, when we are
overriding the default font, we need to write out everything.
r  r  r7  z	font-sizez	font-boldN)r   r   r   
add_optionr   r   r4  ra   paramsvalues      rd   r   FontPage.var_changed_font  s     ""$6>65A""$6>;F""$6>;Frf   c                     U R                   R                  UR                  R                  S:X  a  [        O[
        5      nU R                  R                  UR                  5       5        g)zHandle selecting a font from the list.

Event can result from either mouse click or Up or Down key.
Set font_name and example displays to selection.

KeyReleaseN)	rZ   r   typenamer   r   r   r  r)  )ra   eventr7  s      rd   r  FontPage.on_fontlist_select  sE     }}  **//\9vG4::<(rf   c                 &   U R                   R                  5       nU R                  R                  5       (       a  [        R                  O[        R
                  nX R                  R                  5       U4nX@R                  S'   X@R                  S'   g)zUpdate both screen samples with the font settings.

Called on font initialization and change events.
Accesses font_name, font_size, and font_bold Variables.
Updates font_sample and highlight page highlight_sample.
r7  N)	r   r   r   r+  BOLDNORMALr   r   r   )ra   rF  r   font_weightnew_fonts        rd   r4  FontPage.set_samples  sj     NN&&(	%)^^%7%7%9%9fkkv}}~~113[A#+ (0f%rf   )r  r   r   r   r   rZ   r   r  r   )r   r   r   r   rL   r   r   r   r  r4  r   r   r   s   @rd   r}   r}     s)    W7r D)1 1rf   r}   c                      ^  \ rS rSrU 4S jrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rSrU =r$ )r{   i  c                    > [         TU ]  U5        X l        UR                  5       U l        [        U5      U l        U R                  5         U R                  5         g r   )	r   rL   rz   winfo_toplevelcdr+   stylecreate_page_highlightload_theme_cfgra   r   rz   r   s      rd   rL   HighPage.__init__  sH     '')6]
""$rf   c           
        ^  0 SS_SS_SS_SS_S	S
_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS _T l         [        R                  [        T 5      T R                  5      T l        [        R                  [        T 5      T R                  5      T l        [        T 5      T l	        [        R                  [        T 5      T R                  5      T l        [        R                  [        T 5      T R                  5      T l        [        R                  [        T 5      T R                  5      T l        [!        T S!["        S"S#9n[!        T S!["        S$S#9n[%        U[&        S%S&9nUR(                  =nT l        UR-                  S'S(S%S%[.        S)[0        S*9  UR3                  S+S, 5        UR3                  S-S. 5        S/nU H  u  pgUR5                  [6        Xg5        M     [9        UR;                  S0[6        5      R=                  5       5      n[?        S%U5       H2  n	UR5                  U	 S13U	[9        [A        U5      5       S23 S33S 5        M4     T R                    H,  n
U
4U 4S4 jjnURC                  T R                   U
   S5U5        M.     S6US7'   T RD                  R-                  S8S%S9S:9  [G        US8S;9T l$        [G        U5      n[K        T RH                  S<T RL                  S=9T l'        [Q        T RH                  T R                  S>S)S?9T l)        [U        UT R                  S%S@T RV                  SA9T l,        [U        UT R                  S)SBT RV                  SA9T l-        T R                  R]                  S%5        [K        USCT R^                  S=9T l0        [c        USDSE9n[U        UT R                  S%T Rd                  SFSG9T l3        [U        UT R                  S)T Rd                  SHSG9T l4        [Q        UT R
                  S>S>SI9T l5        [Q        UT R                  S>S>SI9T l6        [K        USJT Rn                  S=9T l8        [c        US!SK9T l9        URu                  [v        SLSL[x        [z        SM9  URu                  [|        SLSL[~        SN9  T RH                  Ru                  [|        SLSL[~        SN9  URu                  [|        SLS)SO9  URu                  [|        SLSL[x        [z        SM9  T RN                  Ru                  [|        [x        [~        SPSQSR9  T RR                  Ru                  [|        [x        [~        SPSSSR9  T RX                  Ru                  [v        [        ST9  T RZ                  Ru                  [        [        ST9  T R`                  Ru                  [        [~        SLSLSU9  URu                  [|        [        SLSLSV9  T Rf                  Ru                  [|        [        SLSW9  T Rh                  Ru                  [|        [        SLS!SV9  T Rj                  Ru                  [|        [~        SLSLSU9  T Rl                  Ru                  [|        [~        [        SLSLSX9  T Rp                  Ru                  [|        [~        SLSLSU9  T Rr                  Ru                  [|        [~        SLSY9  g>)Za  Return frame of widgets for Highlights tab.

Enable users to provisionally change foreground and background
colors applied to textual tags.  Color mappings are stored in
complete listings called themes.  Built-in themes in
idlelib/config-highlight.def are fixed as far as the dialog is
concerned. Any theme can be used as the base for a new custom
theme, stored in .idlerc/config-highlight.cfg.

Function load_theme_cfg() initializes tk variables and theme
lists and calls paint_theme_sample() and set_highlight_target()
for the current theme.  Radiobuttons builtin_theme_on and
custom_theme_on toggle var theme_source, which controls if the
current set of colors are from a builtin or custom theme.
DynOptionMenus builtinlist and customlist contain lists of the
builtin and custom themes, respectively, and the current item
from each list is stored in vars builtin_name and custom_name.

Function paint_theme_sample() applies the colors from the theme
to the tags in text widget highlight_sample and then invokes
set_color_sample().  Function set_highlight_target() sets the state
of the radiobuttons fg_on and bg_on based on the tag and it also
invokes set_color_sample().

Function set_color_sample() sets the background color for the frame
holding the color selector.  This provides a larger visual of the
color for the current tag and plane (foreground/background).

Note: set_color_sample() is called from many places and is often
called more than once when a change is made.  It is invoked when
foreground or background is selected (radiobuttons), from
paint_theme_sample() (theme is changed or load_cfg is called), and
from set_highlight_target() (target tag is changed or load_cfg called).

Button delete_custom invokes delete_custom() to delete
a custom theme from idleConf.userCfg['highlight'] and changes.
Button save_custom invokes save_as_new_theme() which calls
get_new_theme_name() and create_new() to save a custom theme
and its colors to idleConf.userCfg['highlight'].

Radiobuttons fg_on and bg_on toggle var fg_bg_toggle to control
if the current selected color for a tag is for the foreground or
background.

DynOptionMenu targetlist contains a readable description of the
tags applied to Python source within IDLE.  Selecting one of the
tags from this list populates highlight_target, which has a callback
function set_highlight_target().

Text widget highlight_sample displays a block of text (which is
mock Python code) in which is embedded the defined tags and reflects
the color attributes of the current theme and changes for those tags.
Mouse button 1 allows for selection of a tag and updates
highlight_target with that tag value.

Note: The font in highlight_sample is set through the config in
the fonts tab.

In other words, a tag can be selected either from targetlist or
by clicking on the sample text within highlight_sample.  The
plane (foreground/background) is selected via the radiobutton.
Together, these two (tag and plane) control what color is
shown in set_color_sample() for the current theme.  Button set_color
invokes get_color() which displays a ColorChooser to change the
color for the selected tag/plane.  If a new color is picked,
it will be saved to changes and the highlight_sample and
frame background will be updated.

Tk Variables:
    color: Color of selected target.
    builtin_name: Menu variable for built-in theme.
    custom_name: Menu variable for custom theme.
    fg_bg_toggle: Toggle for foreground/background color.
        Note: this has no callback.
    theme_source: Selector for built-in or custom theme.
    highlight_target: Menu variable for the highlight tag target.

Instance Data Attributes:
    theme_elements: Dictionary of tags for text highlighting.
        The key is the display name and the value is a tuple of
        (tag name, display sort order).

Methods [attachment]:
    load_theme_cfg: Load current highlight colors.
    get_color: Invoke colorchooser [button_set_color].
    set_color_sample_binding: Call set_color_sample [fg_bg_toggle].
    set_highlight_target: set fg_bg_toggle, set_color_sample().
    set_color_sample: Set frame background to target.
    on_new_color_set: Set new color and add option.
    paint_theme_sample: Recolor sample.
    get_new_theme_name: Get from popup.
    create_new: Combine theme with changes and save.
    save_as_new_theme: Save [button_save_custom].
    set_theme_type: Command for [theme_source].
    delete_custom: Activate default [button_delete_custom].
    save_new: Save to userCfg['theme'] (is function).

Widgets of highlights page frame:  (*) widgets bound to self
    frame_custom: LabelFrame
        (*)highlight_sample: Text
        (*)frame_color_set: Frame
            (*)button_set_color: Button
            (*)targetlist: DynOptionMenu - highlight_target
        frame_fg_bg_toggle: Frame
            (*)fg_on: Radiobutton - fg_bg_toggle
            (*)bg_on: Radiobutton - fg_bg_toggle
        (*)button_save_custom: Button
    frame_theme: LabelFrame
        theme_type_title: Label
        (*)builtin_theme_on: Radiobutton - theme_source
        (*)custom_theme_on: Radiobutton - theme_source
        (*)builtinlist: DynOptionMenu - builtin_name
        (*)customlist: DynOptionMenu - custom_name
        (*)button_delete_custom: Button
        (*)theme_message: Label
zNormal Code or TextnormalzCode ContextcontextzPython KeywordskeywordzPython Definitions
definitionzPython BuiltinsbuiltinzPython CommentscommentzPython StringsstringzSelected Texthilitez
Found TexthitCursorcursorzEditor BreakpointbreakzShell Promptconsolez
Error TexterrorzShell User OutputstdoutzShell User ExceptionstderrzLine Number
linenumberr   z Custom Highlighting r   z Highlighting Theme r   )r   r   )courier   r   hand2r   )r7  rb  rJ   rI   r   highlightthicknessr   z<Double-Button-1>c                     gNrc   es    rd   <lambda>0HighPage.create_page_highlight.<locals>.<lambda>o  s    rf   z<B1-Motion>c                     grn  ro  rp  s    rd   rr  rs  p  s    7rf   )")z# Click selects item.r]  
rX  )zcode context sectionrY  ru  )z| cursorrb  ru  )defrZ  ) rX  )funcr[  )z(param):
  rX  )z"Return None."r^  )z

  var0 = rX  )z'string'r^  )z

  var1 = rX  )z
'selected'r_  )z

  var2 = rX  )z'found'r`  )z

  var3 = rX  )listr\  )(rX  )NonerZ  )z)
rX  )z  breakpoint("line")rc  )z

rX  z>>>rd  )z	 3.14**2
rX  )z9.8596rf  ru  r}  )z pri rX  )nre  )zt(
rX  )SyntaxErrorrg  ru  r   z.0drx  c                 <   > TR                   R                  U5        g r   )highlight_targetr  )rF  elemra   s     rd   tem+HighPage.create_page_highlight.<locals>.tem  s    %%))$/rf   z<ButtonPress-1>disabledstateframe_color_set.TFramesolid)r   r   )rR  zChoose Color for :rn   r   N)rl  
Foreground)r   r@  rn   r   
BackgroundzSave as New Custom Themez	Select : rm   za Built-in Themer   r@  r   rn   za Custom Themer   zDelete Custom Themer   rh   rr   r   r   rs   rt   r   rr   r   r         )rr   rs   rt   r   r   r   r   rr   rt   r   r   rr   r   r   r   r   )rr   rt   r   r   r   )rr   rt   r   )Dtheme_elementsr\   r   r   var_changed_builtin_namebuiltin_namevar_changed_custom_namecustom_namer   fg_bg_togglevar_changed_colorcolorvar_changed_theme_sourcetheme_sourcevar_changed_highlight_targetr  r"   r   r=   r   rn   r   	configurer
   r   r  r  r   lenr   
splitlinesrangestrtag_bindrR  r!   frame_color_setr#   	get_colorbutton_set_colorr3   
targetlistr)   set_color_sample_bindingfg_onbg_onr  save_as_new_themebutton_save_customr&   set_theme_typebuiltin_theme_oncustom_theme_onbuiltinlist
customlistdelete_custombutton_delete_customtheme_messager   r   r	   r   r   r   r   r   r   r   )ra   frame_customframe_themesample_framern   string_tagsr^  tagn_lineslinenoelementr  frame_fg_bg_toggletheme_type_titles   `             rd   rS  HighPage.create_page_highlight  sh   j!8 I y	
 !, y y h X % h   I '    #H!" <#& $KK$!>!>@";;$!=!=?&t,[[$!7!79
#KK4 $"?"?A '$!B!B!D
 "$Af'>@ 1V&<> +U;'3'8'88t$(!AD 	 	B 			%'89		-!239$ 'KFKKV) 'dhhuc*5578Aw'FKK6("!3s7|#4"5Q!67q9$& ( **G ' 0 MM''02CSJ	 + #W

51$+ 	 	-$\9QR"<0 &$$+?!( ($$d&;&;T#$& !"T->->a!4+H+HJ
 !"T->->a!4+H+HJ
 	a "(#=..#0 !;? +d&7&7q++2D!F  +d&7&7q++2B D )T..dD'T--tTC$*"7**%,! #;A> 	t!!DtLc:!!s!CSqq9qqD 	 	B""Dqqq"Q#dK

T!,

U1-$$&qqq$I3qqqA""AA">!!s111!E3QQQ?#AaaaH!!&&Caaa&HSqq9rf   c           
      .   U R                   R                  [        R                  " SSSSSS95        [        R                  " 5       nU R                   R                  5       (       a  [        R                  " SS5      nUR                  5         U R                  R                  X!5        [        R                  " SS5      nUR                  5         U(       d7  U R                  R                  S	5        U R                  R                  S
5        OU R                  R                  X"S   5        O[        R                  " SS5      nUR                  5         U R                  R                  X!5        [        R                  " SS5      nUR                  5         U R                  R                  X"S   5        U R                  5         [        U R                   5      nU R"                  R                  X3S   5        U R%                  5         U R'                  5         g)ar  Load current configuration settings for the theme options.

Based on the theme_source toggle, the theme is set as
either builtin or custom and the initial widget values
reflect the current settings from idleConf.

Attributes updated:
    theme_source: Set from idleConf.
    builtinlist: List of default themes from idleConf.
    customlist: List of custom themes from idleConf.
    custom_theme_on: Disabled if there are no custom themes.
    custom_theme: Message with additional information.
    targetlist: Create menu from self.theme_elements.

Methods:
    set_theme_type
    paint_theme_sample
    set_highlight_target
r  Themedefaultboolr   rD  r  	highlightuserr  - no custom themes -r   N)r  r  r0   	GetOptionCurrentThemer   GetSectionListsortr  r3  r  r  r  r  r  rz  r  r  paint_theme_sampleset_highlight_target)ra   current_option	item_listtheme_namess       rd   rT  HighPage.load_theme_cfg  s   * 	h00D 	E "..0  "" //	;GINN$$Y? //DINN$$**=9  $$%;<''	Q<@ //DINNOO##I> //	;GINN$$Y!=4../^<!!!#rf   c                    SnU R                   R                  5       nX2;  a_  [        R                  " SSS5      U;  a  [        R                  SSSUS   5        [        R                  SSSU5        SU R                  S'   O?[        R                  SSSU5        [        R                  SSSS	5        S	U R                  S'   U R                  5         g
)zProcess new builtin theme selection.

Add the changed theme's name to the changed_items and recreate
the sample with the values from the selected theme.
)zIDLE ClassiczIDLE Newr  r  rE  r   name2zNew theme, see Helprn   r   N)r  r   r0   r  r   r=  r  r  )ra   r?  
old_themesr@  s       rd   r  !HighPage.var_changed_builtin_name  s     2
!!%%'"!!&'6:*L""67FJqMJvw?)>Dv&vw>vw<)+Dv&!rf   c                     U R                   R                  5       nUS:w  a)  [        R                  SSSU5        U R	                  5         gg)zProcess new custom theme selection.

If a new custom theme is selected, add the name to the
changed_items and apply the theme to the sample.
r  r  r  rE  N)r  r   r   r=  r  r>  s      rd   r   HighPage.var_changed_custom_name  sF       $$&**vw>##% +rf   c                     U R                   R                  5       n[        R                  SSSU5        U(       a  U R	                  5         gU R                  5         g)z{Process toggle between builtin and custom theme.

Update the default toggle value and apply the newly
selected theme type.
r  r  r  N)r  r   r   r=  r  r  r>  s      rd   r  !HighPage.var_changed_theme_source  sG     !!%%'67Iu=))+((*rf   c                 $    U R                  5         g)zProcess change to color choice.N)on_new_color_setra   r?  s     rd   r  HighPage.var_changed_color*  s    rf   c                 $    U R                  5         g)z5Process selection of new target tag for highlighting.N)r  r  s     rd   r  %HighPage.var_changed_highlight_target.      !!#rf   c                 ^   U R                   R                  5       (       a:  SU R                  S'   SU R                  S'   U R                  R                  S5        gSU R                  S'   U R                  R                  S5        SU R                  S'   U R                  R                  S5        g)a>  Set available screen options based on builtin or custom theme.

Attributes accessed:
    theme_source

Attributes updated:
    builtinlist
    customlist
    button_delete_custom
    custom_theme_on

Called from:
    handler for builtin_theme_on and custom_theme_on
    delete_custom
    create_new
    load_theme_cfg
rX  r  r  r  z	!disabledN)r  r   r  r  r  r  r  r   s    rd   r  HighPage.set_theme_type2  s    $   ""(0DW%'1DOOG$%%++M:(2DW%  &&~6'/DOOG$%%++N;rf   c                    U R                   R                  5       nU R                  R                  U R                  S   S5      n[
        R                  " U SU-   US9u  p4U(       a  XB:w  a  U R                  R                  5       (       aH  SnU R                  U5      nU(       d  gU R                  U5        U R                  R                  U5        gU R                  R                  U5        ggg)aB  Handle button to select a new color for the target tag.

If a new color is selected while using a builtin theme, a
name must be supplied to create a custom theme.

Attributes accessed:
    highlight_target
    frame_color_set
    theme_source

Attributes updated:
    color

Methods:
    get_new_theme_name
    create_new
rR  
backgroundzPick new color for : )rM   rP   initialcolorz_Your changes will be saved as a new Custom Theme. Enter a name for your new Custom Theme below.N)r  r   rR  lookupr  r.   askcolorr  get_new_theme_name
create_newr  r  )ra   target
prev_color	rgbTupletcolor_stringmessage	new_themes          rd   r  HighPage.get_colorN  s    $ &&**,ZZ&&t';';G'D'35
"."7"7#:6#A'#)	 \7  $$&&K 33G<	 OOI.JJNN<0

|, 8<rf   c                    U R                   R                  5       nU R                  R                  SUS9  U R                  R                  5       (       a  SOSnU R
                  U R                  R                  5          nU R                  R                  " U40 X!0D6  U R                  R                  5       nUS-   U-   n[        R                  SXEU5        g)z4Display sample of new color selection on the dialog.r  r  
foregroundr  -r  N)r  r   rR  r  r  r  r  r   
tag_configr  r   r=  )ra   	new_colorplanesample_elementthemetheme_elements         rd   r  HighPage.on_new_color_sett  s    JJNN$	

5)L $ 1 1 5 5 7 7\,,T-B-B-F-F-HI((NE;MN  $$&&,u4;iHrf   c                     [         R                  " SS5      [         R                  " SS5      -   n[        U SX5      R                  nU$ )z*Return name of new theme from query popup.r  r  r  zNew Custom Themer0   r  r5   result)ra   r  
used_namesr  s       rd   r  HighPage.get_new_theme_name  sJ    --fkB''	;?@
('??Ev 	rf   c                 X    U R                  S5      nU(       a  U R                  U5        gg)z`Prompt for new theme name and create the theme.

Methods:
    get_new_theme_name
    create_new
zNew Theme Name:N)r  r  )ra   new_theme_names     rd   r  HighPage.save_as_new_theme  s)     001BCOON+ rf   c                 ,   U R                   R                  5       (       a  SnU R                  R                  5       nOSnU R                  R                  5       n[        R
                  " X#5      nU[        S   ;   a  [        S   U   nU H	  nXV   XF'   M     U R                  X5        [        R                  " SS5      nUR                  5         U R                  R                  Xq5        U R                   R                  S5        U R                  5         g)aQ  Create a new custom theme with the given name.

Create the new theme based on the previously active theme
with the current changes applied.  Once it is saved, then
activate the new theme.

Attributes accessed:
    builtin_name
    custom_name

Attributes updated:
    customlist
    theme_source

Method:
    save_new
    set_theme_type
r  r  r  r   N)r  r   r  r  r0   GetThemeDictr   save_newr  r  r  r3  r  r  )ra   r  
theme_type
theme_namer  theme_changesr  custom_theme_lists           rd   r  HighPage.create_new  s    &   """J**..0JJ))--/J))*A	--#K0<M(%2%;	" ) 	n0$33FKH  1Ba rf   c                    U R                   R                  5       S:X  aR  U R                  R                  S5        U R                  R                  S5        U R
                  R                  S5        OQU R                  R                  S5        U R                  R                  S5        U R
                  R                  S5        U R                  5         g)a  Set fg/bg toggle and color based on highlight tag target.

Instance variables accessed:
    highlight_target

Attributes updated:
    fg_on
    bg_on
    fg_bg_toggle

Methods:
    set_color_sample

Called from:
    var_changed_highlight_target
    load_theme_cfg
ra  r  r   r  N)r  r   r  r  r  r  r  set_color_sampler   s    rd   r  HighPage.set_highlight_target  s    $   $$&(2JJ]+JJ]+!!!$JJ^,JJ^,!!!$rf   c                 $    U R                  5         g)zZChange color sample based on foreground/background toggle.

Methods:
    set_color_sample
N)r  )ra   argss     rd   r  !HighPage.set_color_sample_binding  s     	rf   c                    U R                   U R                  R                  5          nU R                  R                  5       (       a  SOSnU R                  R                  X5      nU R                  R                  SUS9  g)zSet the color of the frame background to reflect the selected target.

Instance variables accessed:
    theme_elements
    highlight_target
    fg_bg_toggle
    highlight_sample

Attributes updated:
    frame_color_set
r  r  r  r  N)r  r  r   r  r   tag_cgetrR  r  )ra   r  r  r  s       rd   r  HighPage.set_color_sample  sl     !!$"7"7";";"=> $ 1 1 5 5 7 7\%%..s:

5%Hrf   c                 :   U R                   R                  5       (       a  U R                  R                  5       nOU R                  R                  5       nU R                   H  nU R                  U   n[
        R                  " X5      nUS:X  a  [
        R                  " US5      S   US'   U[        S   ;   a2  [        S   U   nUS-   U;   a
  XSS-      US'   US-   U;   a
  XSS-      US'   U R                  R                  " U40 UD6  M     U R                  5         g)	aj  Apply the theme colors to each element tag in the sample text.

Instance attributes accessed:
    theme_elements
    theme_source
    builtin_name
    custom_name

Attributes updated:
    highlight_sample: Set the tag elements to the theme.

Methods:
    set_color_sample

Called from:
    var_changed_builtin_name
    var_changed_custom_name
    load_theme_cfg
rb  rX  r  r  z-foregroundr  z-backgroundN)r  r   r  r  r  r0   GetHighlightr   r   r  r  )ra   r  element_titler  colors
theme_dicts         rd   r  HighPage.paint_theme_sample  s   (   ""%%))+E$$((*E!00M))-8G**5:F("'/'<'<x())5(7|$ ,,$[1%8
]*j8+56M+NF<(]*j8+56M+NF<(!!,,W?? 1 	rf   c                     [         R                  S   R                  U5        U H*  nX#   n[         R                  S   R                  XU5        M,     g)zSave a newly created theme to idleConf.

theme_name - string, the name of the new theme
theme - dictionary containing the new theme
r  Nr0   userCfg
AddSection	SetOption)ra   r  r  r  r@  s        rd   r
  HighPage.save_new  sI     	%00<GNE[)33JO rf   c                 .    [         R                  " U0 UD6$ r   r/   askyesnora   r  kwargss      rd   r'  HighPage.askyesno#      ""D3F33rf   c                 v   U R                   R                  5       nSnU R                  SX!-  U S9(       d  gU R                  R	                  5         [
        R                  SU5        [        R                  " SS5      nUR                  5         U(       d8  U R                  R                  S5        U R                  R                  US5        OU R                  R                  X3S	   5        U R                  R                  [        R                   S
   R#                  SS5      5        U R$                  R                  [        R                   S
   R#                  SS5      5        [
        R'                  5         U R(                  R+                  5         U R                  R-                  5         U R/                  5         g)a  Handle event to delete custom theme.

The current theme is deactivated and the default theme is
activated.  The custom theme is permanently removed from
the config file.

Attributes accessed:
    custom_name

Attributes updated:
    custom_theme_on
    customlist
    theme_source
    builtin_name

Methods:
    deactivate_current_config
    save_all_changed_extensions
    activate_config_changes
    set_theme_type
z.Are you sure you wish to delete the theme %r ?zDelete ThemerM   Nr  r  r  r  r   r  r  r  rE  )r  r   r'  rQ  r   r   delete_sectionr0   r  r  r  r  r  r3  r  r  
defaultCfgGetr  r   rz   r   r   r  )ra   r  delmsgr  s       rd   r  HighPage.delete_custom'  sJ   , %%))+
A}}!4T  C))+{J7++FK@	  &&}5OO##I/EFOO##I|<h11&9==gyQRh11&9==gvNO002'')rf   )r  r  r  r  r  r  r  rQ  r  r  r  r  rz   r  r  r  r   r  rR  r  r  r  r  )r   r   r   r   rL   rS  rT  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  r'  r  r   r   r   s   @rd   r{   r{     sz    }:~1$f"&	&+ $<8$-L	I	,&P 8 I$& P	P4- -rf   r{   c                      ^  \ rS rSrU 4S jrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS r\S 5       rS rS rSrU =r$ )r~   iW  c                    > [         TU ]  U5        X l        UR                  5       U l        U R                  5         U R                  5         g r   )r   rL   rz   rP  rQ  create_page_keysload_key_cfgrU  s      rd   rL   KeysPage.__init__Y  s=     '')rf   c           	      	   [         R                  [        U 5      U R                  5      U l        [         R                  [        U 5      U R
                  5      U l        [         R                  [        U 5      U R                  5      U l	        [         R                  [        U 5      U R                  5      U l        [        U S[        SS9n[        U S[        SS9n[        U5      n[        USS9n[!        U5      n[!        U["        S9n[%        U[&        [&        S9U l        U R(                  R+                  S	U R,                  5        U R(                  R.                  US
'   U R(                  R0                  US
'   UR2                  U R(                  S'   UR2                  U R(                  S'   [5        USU R6                  SS9U l        [;        S5       Vs/ s H  n[        USSS9PM     nn[=        US   U R                  SU R>                  SS9U l         [=        US   U R                  SU R>                  SS9U l!        [E        US   U R                  SSS9U l#        [E        US   U R                  SSS9U l$        [5        US   SU RJ                  S9U l&        [5        US   SU RN                  S9U l(        [        US   SS9U l)        URU                  [V        SS[X        [Z        S9  URU                  [V        SS[Z        S9  U R8                  RU                  [V        [\        SSS9  URU                  [^        SS[X        [Z        S9  URa                  SSS 9  URc                  SSS 9  URe                  SSS[f        S!9  U R(                  Re                  SS[h        S"9  URe                  SS[j        S"9  URe                  SS[l        S"9  U R@                  Re                  SS[f        [j        -   S"9  U RB                  Re                  SS[f        [j        -   S"9  U RF                  Re                  SS[h        S"9  U RH                  Re                  SS[h        S"9  U RR                  Re                  SS[h        SSS#9  U RL                  RU                  [^        [\        S$SS%9  U RP                  RU                  [^        [\        S$SS%9  US   RU                  [n        [Z        S$S&9  US   RU                  [n        [\        S$SS'9  gs  snf )(a  Return frame of widgets for Keys tab.

Enable users to provisionally change both individual and sets of
keybindings (shortcut keys). Except for features implemented as
extensions, keybindings are stored in complete sets called
keysets. Built-in keysets in idlelib/config-keys.def are fixed
as far as the dialog is concerned. Any keyset can be used as the
base for a new custom keyset, stored in .idlerc/config-keys.cfg.

Function load_key_cfg() initializes tk variables and keyset
lists and calls load_keys_list for the current keyset.
Radiobuttons builtin_keyset_on and custom_keyset_on toggle var
keyset_source, which controls if the current set of keybindings
are from a builtin or custom keyset. DynOptionMenus builtinlist
and customlist contain lists of the builtin and custom keysets,
respectively, and the current item from each list is stored in
vars builtin_name and custom_name.

Button delete_custom_keys invokes delete_custom_keys() to delete
a custom keyset from idleConf.userCfg['keys'] and changes.  Button
save_custom_keys invokes save_as_new_key_set() which calls
get_new_keys_name() and create_new_key_set() to save a custom keyset
and its keybindings to idleConf.userCfg['keys'].

Listbox bindingslist contains all of the keybindings for the
selected keyset.  The keybindings are loaded in load_keys_list()
and are pairs of (event, [keys]) where keys can be a list
of one or more key combinations to bind to the same event.
Mouse button 1 click invokes on_bindingslist_select(), which
allows button_new_keys to be clicked.

So, an item is selected in listbindings, which activates
button_new_keys, and clicking button_new_keys calls function
get_new_keys().  Function get_new_keys() gets the key mappings from the
current keyset for the binding event item that was selected.  The
function then displays another dialog, GetKeysDialog, with the
selected binding event and current keys and allows new key sequences
to be entered for that binding event.  If the keys aren't
changed, nothing happens.  If the keys are changed and the keyset
is a builtin, function get_new_keys_name() will be called
for input of a custom keyset name.  If no name is given, then the
change to the keybinding will abort and no updates will be made.  If
a custom name is entered in the prompt or if the current keyset was
already custom (and thus didn't require a prompt), then
idleConf.userCfg['keys'] is updated in function create_new_key_set()
with the change to the event binding.  The item listing in bindingslist
is updated with the new keys.  Var keybinding is also set which invokes
the callback function, var_changed_keybinding, to add the change to
the 'keys' or 'extensions' changes tracker based on the binding type.

Tk Variables:
    keybinding: Action/key bindings.

Methods:
    load_keys_list: Reload active set.
    create_new_key_set: Combine active keyset and changes.
    set_keys_type: Command for keyset_source.
    save_new_key_set: Save to idleConf.userCfg['keys'] (is function).
    deactivate_current_config: Remove keys bindings in editors.

Widgets for KeysPage(frame):  (*) widgets bound to self
    frame_key_sets: LabelFrame
        frames[0]: Frame
            (*)builtin_keyset_on: Radiobutton - var keyset_source
            (*)custom_keyset_on: Radiobutton - var keyset_source
            (*)builtinlist: DynOptionMenu - var builtin_name,
                    func keybinding_selected
            (*)customlist: DynOptionMenu - var custom_name,
                    func keybinding_selected
            (*)keys_message: Label
        frames[1]: Frame
            (*)button_delete_custom_keys: Button - delete_custom_keys
            (*)button_save_custom_keys: Button -  save_as_new_key_set
    frame_custom: LabelFrame
        frame_target: Frame
            target_title: Label
            scroll_target_y: Scrollbar
            scroll_target_x: Scrollbar
            (*)bindingslist: ListBox - on_bindingslist_select
            (*)button_new_keys: Button - get_new_keys & ..._name
r   z Custom Key Bindings r   z	 Key Set zAction - Key(s)rm   orient)r   r   r   r   r   xscrollcommandzGet New Keys for Selectionr  )rn   r   r  r   )rj   r   r   zUse a Built-in Key Setr  zUse a Custom Key SetNr   zDelete Custom Key Setr  zSave as New Custom Key Setr  rh   r  r   r  r   )r   r   
columnspanrl   r   r   rl   )r   r   rl   r   r   T)rr   rt   rs   r   rr   rt   rs   )rr   rt   rs   r   )8r\   r   r   r  r  r  r  r   var_changed_keyset_sourcekeyset_sourcevar_changed_keybinding
keybindingr"   r   r!   r&   r*   r   r   r
   bindingslistr  on_bindingslist_selectr  xviewr  r#   get_new_keysbutton_new_keysr  r)   set_keys_typebuiltin_keyset_oncustom_keyset_onr3   r  r  delete_custom_keysbutton_delete_custom_keyssave_as_new_key_setbutton_save_custom_keyskeys_messager   r   r	   r   r   r   r	  r
  rw   r   r   r   r   r   )	ra   r  frame_key_setsframe_targettarget_titlescroll_target_yscroll_target_xiframess	            rd   r5  KeysPage.create_page_keys`  s   d $KK$!>!>@";;$!=!=?$[[4 $"@"@B!++$!<!<>
 "!F,. $!FF \*\0AB#L1#LD#uF2#::	<%)%6%6%<%<	"%)%6%6%<%<	".=.A.A*+.=.A.A*+%#?)) =
 !8%#a qA# 	 %!,q	D$6$6a**1I"K !,q	D$6$6a**1G!I )q	4,,dDB'q	4++T4A)/q	 7//*1& (.q	 <00(2$ "&); 	vAAdNaadC!!vAAA!Ft!!DtL$$Qq$1!!!A!.aaB1Qt<1R81R8##!AbD#A""q1R4"@!Ad;1T:1Qt!!L&&++AdQR+S$$))t!Dq)Qq	Cd48q	Ca1=W%s   S*c           
         U R                   R                  [        R                  " SSSSSS95        [        R                  " 5       nU R                   R                  5       (       a  [        R                  " SS5      nUR                  5         U R                  R                  X!5        [        R                  " SS5      nUR                  5         U(       d7  U R                  R                  S	5        U R                  R                  S
5        OU R                  R                  X"S   5        O[        R                  " SS5      nUR                  5         U R                  R                  X!5        [        R                  " SS5      nUR                  5         U R                  R                  U[        R                  " 5       5        U R                  5         [        R                  " 5       nU R!                  U5        g)z?Load current configuration settings for the keybinding options.r  Keysr  r  r   r  keysr  r  - no custom keys -r   N)r@  r  r0   r  CurrentKeysr   r  r  r  r3  rJ  r  r  r  default_keysrH  load_keys_list)ra   r  r  keyset_names       rd   r6  KeysPage.load_key_cfg   sv    	x11	 C 	D "--/!!## //	6BINN$$Y? //?INN%%++M:  $$%9:''	Q<@ //?INNOO##I> //	6BINN$$Y0E0E0GH**,K(rf   c                    SnU R                   R                  5       nX2;  a_  [        R                  " SSS5      U;  a  [        R                  SSSUS   5        [        R                  SSSU5        SU R                  S'   O?[        R                  SSSU5        [        R                  SSSS	5        S	U R                  S'   U R                  U5        g
)z%Process selection of builtin key set.)zIDLE Classic WindowszIDLE Classic UnixzIDLE Classic MaczIDLE Classic OSXr  rY  rE  r   r  zNew key set, see Helprn   r   N)r  r   r0   r  r   r=  rO  r^  )ra   r?  old_keysr@  s       rd   r  !KeysPage.var_changed_builtin_name  s    
 !!%%' !!&&&9I""6668A;Gvvw>(?Df%vvvu=vvw;(*Df%E"rf   c                     U R                   R                  5       nUS:w  a*  [        R                  SSSU5        U R	                  U5        gg)z$Process selection of custom key set.r[  r  rY  rE  N)r  r   r   r=  r^  r>  s      rd   r   KeysPage.var_changed_custom_name3  sF      $$&((vvvu=& )rf   c                     U R                   R                  5       n[        R                  SSSU5        U(       a  U R	                  5         gU R                  5         g)z:Process toggle between builtin key set and custom key set.r  rY  r  N)r@  r   r   r=  r  r  r>  s      rd   r?  "KeysPage.var_changed_keyset_source:  sE    ""&&(669e<))+((*rf   c                    U R                   R                  5       nU R                  R                  5       nU R                  R                  [        5      R                  5       S   n[        R                  " U5      (       a  [        R                  SX4U5        g[        R                  " U5      nUS-   n[        R                  SXdU5        g)zStore change to a keybinding.r   rZ  _cfgBindings
extensionsN)rB  r   r  rC  r   splitr0   IsCoreBindingr   r=  GetExtnNameForEvent)ra   r?  r@  key_setrF  ext_nameext_keybind_sections          rd   rA  KeysPage.var_changed_keybindingC  s    ##%""&&(!!%%f-335a8!!%((vwu=33E:H"*^";|-@Orf   c                 ^   U R                   R                  5       (       a:  SU R                  S'   SU R                  S'   U R                  R                  S5        gSU R                  S'   U R                  R                  S5        SU R                  S'   U R                  R                  S5        g)z@Set available screen options based on builtin or custom key set.rX  r  r  r  r  N)r@  r   r  r  rL  r  rJ  r   s    rd   rH  KeysPage.set_keys_typeO  s    !!##(0DW%'1DOOG$**00?(2DW%!!''7'/DOOG$**00@rf   c                    U R                   R                  [        5      nU R                   R                  U5      nUR	                  5       S   nU R
                  R                  5       (       a  U R                  R                  5       nOU R                  R                  5       n[        R                  " 5       nU[        S   ;   a)  [        S   U   nU H  nXg   R	                  5       XW'   M     [        UR                  5       5      n[        U SUU5      R                  n	U	(       Ga  U R
                  R                  5       (       ab  Sn
U R                  U
5      nU(       d7  U R                   R!                  U5        U R                   R#                  U5        gU R%                  U5        U R                   R'                  U5        U R                   R)                  XS-   U	-   5        U R                   R!                  U5        U R                   R#                  U5        U R*                  R-                  U	5        gU R                   R!                  U5        U R                   R#                  U5        g)a.  Handle event to change key binding for selected line.

A selection of a key/binding in the list of current
bindings pops up a dialog to enter a new binding.  If
the current key set is builtin and a binding has
changed, then a name for a custom key set needs to be
entered for the change to be applied.
r   rZ  zGet New KeyszcYour changes will be saved as a new Custom Key Set. Enter a name for your new Custom Key Set below.N - )rC  r-  r   r   rk  r@  r  r  r0   GetCurrentKeySetr   rz  valuesr2   r  get_new_keys_namer/  r0  create_new_key_setdeleter  rB  r  )ra   
list_indexbinding	bind_namecurrent_key_set_namecurrent_bindingskey_set_changesrF  current_key_sequencesnew_keysr  
new_keysets               rd   rF  KeysPage.get_new_keys[  s    &&,,V4
##''
3MMOA&	!!###'#4#4#8#8#: #'#3#3#7#7#9 #44676?2%fo.BCO(*9*@*F*F*H ' ) $%5%<%<%> ? ~y%''-v 	!!%%''N!33G<
!%%00<%%33J?++J7$$Z0$$Z51IJ((4++J7OO)((4++J7rf   c                     [         R                  " SS5      [         R                  " SS5      -   n[        U SX5      R                  nU$ )z)Return new key set name from query popup.r  rZ  r  zNew Custom Key Setr  )ra   r  r  r  s       rd   rx  KeysPage.get_new_keys_name  sJ    --ff=''	6:;
 *GAAG 	rf   c                 X    U R                  S5      nU(       a  U R                  U5        gg)z@Prompt for name of new key set and save changes using that name.zNew Key Set Name:N)rx  ry  )ra   new_keys_names     rd   rM  KeysPage.save_as_new_key_set  s)    ../BC##M2 rf   c                 :    U R                   R                  S5        g)z6Activate button to assign new keys to selected action.r  N)rG  r  ra   rF  s     rd   rD  KeysPage.on_bindingslist_select  s    "">2rf   c                 r   U R                   R                  5       (       a  U R                  R                  5       nOU R                  R                  5       n[        R
                  " U5      n0 nU H  nUSS nSR                  X5   5      nXtU'   M!     U[        S   ;   a  [        S   U   nU H	  nX   XE'   M     U R                  X5        [        R                  " SS5      n	U	R                  5         U R                  R                  X5        U R                   R                  S5        U R                  5         g)zCreate a new custom key set with the given name.

Copy the bindings/keys from the previously active keyset
to the new keyset and activate the new custom keyset.
r   rx  rZ  r  r   N)r@  r   r  r  r0   GetCoreKeysjoinr   save_new_key_setr  r  r  r3  r  rH  )
ra   new_key_set_nameprev_key_set_name	prev_keysr  rF  
event_namer|  r  custom_key_lists
             rd   ry  KeysPage.create_new_key_set  s    !!## $ 1 1 5 5 7 $ 0 0 4 4 6(():;	EqJhhy/0G#*Z  
 /%fo.?@O("1"8 ) 	.9"11&&ABq!rf   c                    SnU R                   R                  5       (       a!  SnU R                   R                  [        5      n[        R
                  " U5      n[        U5      nUR                  5         U R                   R                  S[        5        U Hm  nSR                  XF   5      nUSS nU[        S   ;   a  U[        S   U   ;   a  [        S   U   U   nU R                   R                  [        US-   U-   5        Mo     U(       aR  U R                   R                  W5        U R                   R                  U5        U R                   R                  U5        g	g	)
zReload the list of action/key binding pairs for the active key set.

An action/key binding can be selected to change the key binding.
FTr   rx  r   r  rZ  ru  N)rC  curselectionr-  r   r0   	GetKeySetrz  r  rz  r   r  r   r  r.  r/  r0  )ra   r_  reselectr{  keyset
bind_namesr}  keys           rd   r^  KeysPage.load_keys_list  s-   
 ))++H**008J##K0&\
  C(#I((6,-C!!BIgfo- <<!&/+6yAC$$S)E/#*=> $ !!*-((4++J7 rf   c                     [         R                  S   R                  U 5        U H*  nX   n[         R                  S   R                  XU5        M,     g)a!  Save a newly created core key set.

Add keyset to idleConf.userCfg['keys'], not to disk.
If the keyset doesn't exist, it is created.  The
binding/keys are taken from the keyset argument.

keyset_name - string, the name of the new key set
keyset - dictionary containing the new keybindings
rZ  Nr   )r_  r  rF  r@  s       rd   r  KeysPage.save_new_key_set  sI     	 ++K8EMEV$..{5I rf   c                 .    [         R                  " U0 UD6$ r   r&  r(  s      rd   r'  KeysPage.askyesno  r+  rf   c                    U R                   R                  5       nSnU R                  SX!-  U S9(       d  gU R                  R	                  5         [
        R                  SU5        [        R                  " SS5      nUR                  5         U(       d8  U R                  R                  S5        U R                  R                  US5        OU R                  R                  X3S	   5        U R                  R                  [        R                   S
   R#                  SS5      5        U R$                  R                  [        R                   S
   R#                  SS5      =(       d    [        R&                  " 5       5        [
        R)                  5         U R*                  R-                  5         U R                  R/                  5         U R1                  5         g)zHandle event to delete a custom key set.

Applying the delete deactivates the current configuration and
reverts to the default.  The custom key set is permanently
deleted from the config file.
z0Are you sure you wish to delete the key set %r ?zDelete Key Setr-  NrZ  r  r  r[  r   r  rY  r  rE  )r  r   r'  rQ  r   r   r.  r0   r  r  rJ  r  r  r3  r@  r  r/  r0  r  r]  r   rz   r   r   rH  )ra   r_  r1  r  s       rd   rK  KeysPage.delete_custom_keys  s`    &&**,C}} 6#7  F))+v{3++FF;	!!''6OO##I/CDOO##I|<x226: #FI 6	8h11&9==ffM 9!)!6!6!8	: 	002'')rf   )rC  rI  r  r  rL  rG  rN  rQ  rJ  r  r  rz   rB  rO  r@  )r   r   r   r   rL   r5  r6  r  r  r?  rA  rH  rF  rx  rM  rD  ry  r^  staticmethodr  r'  rK  r   r   r   s   @rd   r~   r~   W  ss    ^>@)>#('+
P
A*8X33<86 J J4   rf   r~   c                   :   ^  \ rS rSrU 4S jrS rS rS rSrU =r	$ )r   i	  c                    > [         TU ]  U5        U R                  5         U R                  5         U R	                  5         g r   )r   rL   init_validatorscreate_page_windowsload_windows_cfgra   r   r   s     rd   rL   WinPage.__init__  s4       "rf   c                 n   ^ [         R                  " S5      mU4S jnU R                  U5      S4U l        g )N[0-9]*c                 *   > TR                  U 5      SL$ z+Return 's is blank or contains only digits'N	fullmatchr8  digits_or_empty_res    rd   is_digits_or_empty3WinPage.init_validators.<locals>.is_digits_or_empty      %//2$>>rf   %Precompileregisterdigits_onlyra   r  r  s     @rd   r  WinPage.init_validators  0    ZZ	2	? !MM*<=tErf   c                    [         R                  [        U 5      S5      U l        [         R                  [	        U 5      S5      U l        [         R                  [	        U 5      S5      U l        [         R                  [	        U 5      S5      U l        [         R                  [        U 5      S5      U l	        [         R                  [	        U 5      S5      U l
        [         R                  [	        U 5      S5      U l        [         R                  [	        U 5      S5      U l        [         R                  [        U 5      S	5      U l        [         R                  [	        U 5      S
5      U l        [        U S[         SS9n[#        USS9n[%        USS9n['        X R                  SSS9U l        ['        X R                  SSS9U l        [#        USS9n[%        USS9n[%        USS9n[-        X@R
                  SU R.                  SS9U l        [%        USS9n[-        X@R                  SU R.                  SS9U l        [#        USS9n[%        USS9n	 [5        XR                  SSSU R.                  SS9U l        [%        US"S9n
[A        US#U R                  S$9U l!        [#        USS9n[%        US%S9n[-        XR                  S&U R.                  SS9U l"        [#        USS9n[%        US'S9n[G        XR                  S(S)S*S(5      U l$        [#        USS9n[%        US+S9n[-        XR                  S&U R.                  SS9U l%        [A        US,U R                  S$9U l&        [#        USS9n[%        US-S9n[-        UU R                  S.U R.                  SS9U l'        URQ                  [R        S/S/[T        [V        S09  URQ                  [R        S/S[X        S19  URQ                  [Z        [\        S/S/S29  U R*                  RQ                  [^        [\        S/S/S29  U R(                  RQ                  [^        [\        S/S/S29  URQ                  [R        S/S[X        S19  URQ                  [Z        [\        S/S/S29  U R2                  RQ                  [^        [`        SS/S29  URQ                  [^        [`        S/S39  U R0                  RQ                  [^        [`        SS/S29  URQ                  [^        [`        S/S39  URQ                  [R        S/S[X        S19  U	RQ                  [Z        [\        S/S49  U R6                  RQ                  [Z        [\        SS49  U RB                  RQ                  [^        [`        S5S/S29  URQ                  [R        S/S[X        S19  URQ                  [Z        [\        S/S/S29  U RD                  RQ                  [R        SS/S69  URQ                  [R        S/S[X        S19  URQ                  [Z        [\        S/S/S29  U RH                  RQ                  [R        SS/S69  URQ                  [R        S/S[X        S19  URQ                  [Z        [\        S/S49  U RL                  RQ                  [^        [`        S5S/S29  U RJ                  RQ                  [R        [\        S5S/S29  URQ                  [R        S/S[X        S19  URQ                  [Z        [\        S/S/S29  U RN                  RQ                  [R        SS/S69  g7! [8         a2    [;        XR                  S[=        [?        SS 5      5      SS!9U l         GNf = f)8a  Return frame of widgets for Windows tab.

Enable users to provisionally change general window options.
Function load_windows_cfg initializes tk variable idleConf.
Radiobuttons startup_shell_on and startup_editor_on set var
startup_edit. Entry boxes win_width_int and win_height_int set var
win_width and win_height.  Setting var_name invokes the default
callback that adds option to changes.

Widgets for WinPage(Frame):  > vars, bound to self
    frame_window: LabelFrame
        frame_run: Frame
            startup_title: Label
            startup_editor_on: Radiobutton > startup_edit
            startup_shell_on: Radiobutton > startup_edit
        frame_win_size: Frame
            win_size_title: Label
            win_width_title: Label
            win_width_int: Entry > win_width
            win_height_title: Label
            win_height_int: Entry > win_height
        frame_cursor: Frame
            indent_title: Label
            indent_chooser: Spinbox > indent_spaces
            blink_on: Checkbutton > cursor_blink
        frame_autocomplete: Frame
            auto_wait_title: Label
            auto_wait_int: Entry > autocomplete_wait
        frame_paren1: Frame
            paren_style_title: Label
            paren_style_type: OptionMenu > paren_style
        frame_paren2: Frame
            paren_time_title: Label
            paren_flash_time: Entry > flash_delay
            bell_on: Checkbutton > paren_bell
        frame_format: Frame
            format_width_title: Label
            format_width_int: Entry > format_width
)r  Generaleditor-on-startup)r  r  rJ   )r  r  rI   )r  Indent
num-spaces)r  r  cursor-blink)rj  r8   	popupwait)rj  r:   rR  )rj  r:   flash-delay)rj  r:   bell)rj  r;   	max-widthr   z Window Preferencesr   r   r  z
At Startuprm   r   zOpen Edit Windowr   r@  rn   zOpen Shell Windowz$Initial Window Size  (in characters)Widthr   r  textvariablerJ   validatecommandvalidateHeightzIndent spaces (4 is standard)
   )r  from_torJ   r  r  readonly   )r  r  rw  rJ   zCursor BlinkzCursor blink)rn   r   z%Completions Popup Wait (milliseconds)r   zParen Match Style
expressionopenerparensz;Time Match Displayed (milliseconds)
(0 is until next input)zBell on MismatchzFormat Paragraph Max Widthr  rh   r  r   r  rr   r   r   r   r   r  N)1r\   r   r   startup_editr   	win_width
win_heightindent_spacesr   cursor_blinkautocomplete_waitparen_styleflash_delay
paren_bellformat_widthr"   r   r!   r&   r)   startup_editor_onstartup_shell_onr%   r  win_width_intwin_height_intr,   indent_chooserr    r-   rz  r  r$   cursor_blink_boolauto_wait_intr'   paren_style_typeparen_flash_timebell_onformat_width_intr   r   r	   r   r   r   r   r   r   )ra   frame_window	frame_runstartup_titleframe_win_sizewin_size_titlewin_width_titlewin_height_titleframe_cursorindent_titlecursor_blink_titleframe_autocompleteauto_wait_titleframe_paren1paren_style_titleframe_paren2paren_time_titleframe_formatformat_width_titles                      rd   r  WinPage.create_page_windows  s   R $KKtFH $!BD!++$!CE$[[$!AC#KK4 "JL!($!L"N";;$!FH";;$!LN!++4 "FH#KK$!OQ "$Af'<> ,A6	il;!,$5$5Q'") !,$5$5Q(!* |;%KMW="^^1 $ 0 05
 !h?#__A $ 0 05

 \q9\"AC	I") /A/A!$($4$4u#FD #<nE!,\6:6G6G"I #<Q@ 2%LN""1G1G)9)9EK \q9!,5HI *..,!0 \q9  $<= !&+;+;1 $ 0 05!B ##5Q\q9"<(DF %4+<+<A $ 0 05! 	s4dKCaaa8QQQ?""aaa"H##qqq#I111=aaa@  eABQ G5;U12AF%:s;tAA6  d12 >##qr#JSqqqA$qqqASr:s;DC"""1"=s;4:uQRa@""ABQ"Gs;T!!!D"""1"=O  	I"* /A/A$T%"+->a#ID	Is   '[ 8[?>[?c           	         U R                   R                  [        R                  " SSSSS95        U R                  R                  [        R                  " SSSSS95        U R
                  R                  [        R                  " SSS	SS95        U R                  R                  [        R                  " SS
SSS95        U R                  R                  [        R                  " SSSSS95        U R                  R                  [        R                  " SSSSS95        U R                  R                  [        R                  " SSS5      5        U R                  R                  [        R                  " SSSSS95        U R                  R                  [        R                  " SSS5      5        U R                  R                  [        R                  " SSSSS95        g )Nr  r  r  r  rD  r  rJ   intrI   r  r  r  rj  r8   r  r:   rR  r  r  r;   r  )r  r  r0   r  r  r  r  r  r  r  r  r  r  r   s    rd   r  WinPage.load_windows_cfg  s   h00	#6VE 	F8--e= 	>H..u> 	?x11,U < 	=h00VE 	F""8#5#5nk$G 	HX//lG5 	6X//lMG 	HH..lF4 	5h00/5J 	Krf   )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   rL   r  r  r  r   r   r   s   @rd   r   r   	  s!     Fh>TK Krf   r   c                   :   ^  \ rS rSrU 4S jrS rS rS rSrU =r	$ )r   i  c                    > [         TU ]  U5        U R                  5         U R                  5         U R	                  5         g r   )r   rL   r  create_page_shedload_shelled_cfgr  s     rd   rL   ShedPage.__init__  s4     rf   c                 n   ^ [         R                  " S5      mU4S jnU R                  U5      S4U l        g )Nr  c                 *   > TR                  U 5      SL$ r  r  r  s    rd   r  4ShedPage.init_validators.<locals>.is_digits_or_empty  r  rf   r  r  r  s     @rd   r  ShedPage.init_validators  r  rf   c                    [         R                  [        U 5      S5      U l        [         R                  [	        U 5      S5      U l        [         R                  [        U 5      S5      U l        [         R                  [        U 5      S5      U l        [        U S[        SS9n[        U S[        SS9n[        US	S
9n[        USS9n[        USU R                  U R                  SS9U l        [        US	S
9n[        USS9n[!        XPR
                  S	SS9U l        [!        XPR
                  SSS9U l        [        US	S
9n[        USS9n['        UU R                  SS9U l        [        US	S
9n	[        U	SS9n
[        XR                  SU R                  SS9U l        UR-                  [.        SS[0        S9  [        U 5      R-                  5         UR-                  [.        SS[0        S9  UR-                  [.        SS	[2        S9  UR-                  [4        [6        SSS9  U R                  R-                  [.        SSS9  UR-                  [.        SS	[2        S9  UR-                  [4        [6        SSS9  U R$                  R-                  [8        [6        SSS9  U R"                  R-                  [8        [6        SSS9  UR-                  [.        SS	[2        S9  UR-                  [4        [6        SSS9  U R(                  R-                  [4        SSS9  U	R-                  [.        SS	[2        S9  U
R-                  [4        [6        SSS9  U R*                  R-                  [.        SSS9  g)a  Return frame of widgets for Shell/Ed tab.

Enable users to provisionally change shell and editor options.
Function load_shed_cfg initializes tk variables using idleConf.
Entry box auto_squeeze_min_lines_int sets
auto_squeeze_min_lines_int.  Setting var_name invokes the
default callback that adds option to changes.

Widgets for ShedPage(Frame):  (*) widgets bound to self
    frame_shell: LabelFrame
        frame_auto_squeeze_min_lines: Frame
            auto_squeeze_min_lines_title: Label
            (*)auto_squeeze_min_lines_int: Entry -
               auto_squeeze_min_lines
    frame_editor: LabelFrame
        frame_save: Frame
            run_save_title: Label
            (*)save_ask_on: Radiobutton - autosave
            (*)save_auto_on: Radiobutton - autosave
        frame_format: Frame
            format_width_title: Label
            (*)format_width_int: Entry - format_width
        frame_line_numbers_default: Frame
            line_numbers_default_title: Label
            (*)line_numbers_default_bool: Checkbutton - line_numbers_default
        frame_context: Frame
            context_title: Label
            (*)context_int: Entry - context_lines
)r  PyShellauto-squeeze-min-lines)r  r  autosave)r  r  line-numbers-default)rj  r9   maxlinesr   z Shell Preferencesr   z Editor Preferencesr   r  zAuto-Squeeze Min. Lines:rm   r  r  )rJ   r  r  r  zAt Start of Run (F5)  zPrompt to Saver  r   z	No Promptz Show line numbers in new windows)r   rJ   zMax Context Lines :r   r  rh   r   r  r  N)r\   r   r   auto_squeeze_min_linesr   r  r   line_numbers_defaultcontext_linesr"   r   r!   r&   r%   r  auto_squeeze_min_lines_intr)   save_ask_onsave_auto_onr$   line_numbers_default_boolcontext_intr   r   r   r   r   r   r   )ra   frame_shellframe_editorframe_auto_squeeze_min_linesauto_squeeze_min_lines_title
frame_saverun_save_titleframe_line_numbers_defaultline_numbers_default_titleframe_contextcontext_titles              rd   r
  ShedPage.create_page_shed  s0   > '.kk$!N'P#  t=?$+KK4 @%B! %[[$!JL !1V&:<!$Af'<> (-[a'H$',-I2L(N$*/,A!88 $ 0 05+
' <Q7
z0HI&]]!%' (]]! " &+<Q%G"%*&-O&Q")4*22*&
 l:m2GH ,>,>a $ 0 05
 	c=ds>$))s)K$))tAAA)N'',,#AA,FSqqq9aaa@E!!!D5C"''Sqqq'I"''T!!!'L&&++AA+F!!!<QQQ?3QQ7rf   c           
         U R                   R                  [        R                  " SSSSS95        U R                  R                  [        R                  " SSSSS	S
95        U R
                  R                  [        R                  " SSSS	S95        U R                  R                  [        R                  " SSSSS95        g )Nr  r  r  r  r  r  r  r   r  )r  rD  r  r  rj  r9   r  )r  r  r0   r  r  r  r  r   s    rd   r  ShedPage.load_shelled_cfgS  s    ##''(:(:	#;%)I 	J 	(,,	:qvG 	H!!%%h&8&8(>V'M 	Nx11mZe E 	Frf   )
r  r  r  r  r  r  r  r  r  r  )
r   r   r   r   rL   r  r
  r  r   r   r   s   @rd   r   r     s!     Ff8P
F 
Frf   r   c                   L   ^  \ rS rSrU 4S jrS rS rS rS rS r	S r
S	rU =r$ )
ry   i`  c                    > [         TU ]  U5        [        R                  S   U l        [        R
                  S   U l        U R                  [        5      U l        U R                  5         U R                  5         g )Nrj  )r   rL   r0   r/  ext_defaultCfgr!  ext_userCfgr  is_intload_extensionscreate_page_extensionsr  s     rd   rL   ExtPage.__init__a  s^     &11,?#++L9mmF+##%rf   c                 D   [        U 5      U l        [        U S[        SS9n[	        U S[        SS9U l        UR                  SSS9  UR                  SSS9  [        XR                  SS	9U l	        U R                  R                  S
U R                  5        [        XR                  R                  S9nUR                  U R                  l        [        USSS9U l        U R                  R#                  SSSS9  UR#                  SSSS9  U R                   R#                  SSSSS/S9  UR%                  SS9  0 U l        SU l        X l        U R                  U l        Sn[/        U R0                  5       H  nU R3                  U5        US-   U-   S-   nM!     U R                  R                  U5        U R                  R5                  S5        U R                  S5        UR#                  SSSS9  [7        U 5      R#                  SSS9  U R
                  R#                  SSSS9  g)am  Configure IDLE feature extensions and help menu extensions.

List the feature extensions and a configuration box for the
selected extension.  Help menu extensions are in a HelpFrame.

This code reads the current configuration using idleConf,
supplies a GUI interface to change the configuration values,
and saves the changes using idleConf.

Some changes may require restarting IDLE.  This depends on each
extension's implementation.

All values are treated as text, and it is up to the user to
supply reasonable values. The only exception to this are the
'enable*' options, which are boolean, and can be toggled with a
True/False button.

Methods:
    extension_selected: Handle selection from list.
    create_extension_frame: Hold widgets for one extension.
    set_extension_value: Set in userCfg['extensions'].
    save_all_changed_extensions: Call extension page Save().
r   z Feature Extensions r   z Help Menu Extensions r   r   r   browse)listvariable
selectmodez<<ListboxSelect>>r      )rJ   rI   nwsr   r   rl   nsr   r  )r   r   rl   r   ri   Nr   {z} r=  )r   r   sew)r   extension_namesr"   r   	HelpFrame
frame_helpr
  r	  r   extension_listr  extension_selectedr*   r  r  r   details_framerw   r  config_framecurrent_extension
outerframetabbed_page_setr*  rj  create_extension_frameselection_setr&   )ra   	frame_extscroll	ext_namesro  s        rd   r2  ExtPage.create_page_extensionsi  s   0  )t6$:<	#Da$<> 	q+!!!A!.%i>R>R19;  !4d6M6MN9.A.A.G.GH+1::*'	SI  q ?1!D1qab!WMB'!%#22 	t/H''1!C(2T9I 0 	  +))!,% 	1Qv6dQq)1U;rf   c           
      $   0 U l         [        R                  " SS9 H  n/ U R                   U'   M     U R                    GH  n[        U R                  R                  U5      5      nU Vs/ s H  nUR                  S5      (       d  M  UPM     nnU H  nUR                  U5        M     XB-   nU H  nU R                  R                  XSS9n SSS.U   nSn U R                  R                  XUSUS
9n[        U 5      n	U	R                  [        U5      5        U R                   U   R!                  UUUUU	S.5        M     GM     g	s  snf ! [         a&     [        U5      nSn N! [         a    UnS	n  Nf = ff = f! [         a    Un Nf = f)zAFill self.extensions with data from the default and user configs.F)active_onlyenableT)raw)TrueFalser  r  N)rD  rQ  r  )rE  rD  r  r@  var)rj  r0   GetExtensionsr*  r.  GetOptionList
startswithremover0  KeyErrorr  r2  r/  r   r  r  append)
ra   ro  opt_listopt_nameenablesdef_strdef_objopt_typer@  rT  s
             rd   r1  ExtPage.load_extensions  s    ..5AH(*DOOH% B Hd11??IJH 19 9H"--h7  G 9#) $)H$--11  2 6	(&*E:7CG%H$ ,,00$X4$+ 1 -E
  oE
#)00(:B=D;@9<	23 4- % (9   (("%g,#(% (")#'(	( " $#E$sH   *EE
EF 
E=E''E9	5E=8E9	9E= FFc                    U R                   R                  5       nU(       a  U R                   R                  U5      nUb  X R                  :w  aX  U R                  (       aG  U R                  R                  SS9  U R                  U R                     R                  5         SU l        U(       a>  U R                  R                  US9  U R                  U   R                  SSSS9  X l        gg)z/Handle selection of an extension from the list.Nr   rm   r   r   r:  )	rA  r  r   rE  rC  r  rD  grid_forgetrw   )ra   rF  newsels      rd   rB  ExtPage.extension_selected  s    $$113((,,V4F>V'='==%%""))r)2!!$"8"89EEG)-&%%6%2f%**!6*J%+" rf   c           	         [        U R                  SSS9nX R                  U'   UR                  n[	        U R
                  U   5       H  u  pE[        X5S   S9nUR                  US[        S9  US   nUS   S	:X  a"  [        X7S
SSS9R                  US[        SS9  MV  US   S:X  a.  [        X7SU R                  S4SS9R                  US[        SS9  M  [        X7SS9R                  US[        SS9  M     g)z=Create a frame holding the widgets to configure one extensionr8  rH   rE  rm   r   r=  rT  rD  r  rR  rS  r  )r   r   r   rJ   r      )r   r   rl   r   r  r  r  r  )r  r  r  rJ   r   )r  rJ   N)VerticalScrolledFramerC  rD  interior	enumeraterj  r&   rw   r   r$   r   r%   r0  r   )ra   ro  f
entry_arear   optlabelrT  s           rd   rH  ExtPage.create_extension_frame  s    !$"4"4SL&'(#ZZ
!$//(";<HC*v;7EJJ3qJ4e*C6{f$J$*WA"ds1QQdGV%jU'+{{D&9Qt!D j" Qt!D# =$ 	rf   c                 
   US   nUS   nUS   R                  5       R                  5       =(       d    UnUS   R                  U5        XT:X  a  U R                  R	                  X5      $ U R                  R                  XU5      $ )zReturn True if the configuration was added or changed.

If the value is the same as the default, then remove it
from user config file.
rE  r  rT  )r   r   r  r/  RemoveOptionr#  )ra   sectionrm  rE  r  r@  s         rd   set_extension_valueExtPage.set_extension_value  s|     6{i.E
 &&(3GE
u ##00??))'??rf   c                     SnU R                    H5  nU R                   U   nU H  nU R                  X$5      (       d  M  SnM     M7     U(       a  U R                  R                  5         gg)z{Save configuration changes to the user config file.

Attributes accessed:
    extensions

Methods:
    set_extension_value
FTN)rj  rs  r/  Save)ra   has_changesro  optionsrm  s        rd   r   #ExtPage.save_all_changed_extensions  sa     Hooh/G++H::"&K  (
 !!# rf   )rD  rE  rC  r.  r/  rA  r>  rj  r@  r0  rF  rG  )r   r   r   r   rL   r2  r1  rB  rH  rs  r   r   r   r   s   @rd   ry   ry   `  s.    &=<~,4\,4@"$ $rf   ry   c                   X   ^  \ rS rSrU 4S jrS rS rS rS rS r	S r
S	 rS
 rSrU =r$ )r?  i#  c                 h   > [         TU ]  " U40 UD6  U R                  5         U R                  5         g r   )r   rL   create_frame_helpload_helplist)ra   r   cfgr   s      rd   rL   HelpFrame.__init__%  s-    '3' rf   c                    [        U 5      n[        USS[        S9U l        [	        U5      nU R                  R
                  US'   UR                  U R                  S'   U R                  R                  SU R                  5        [        U 5      n[        USSS	U R                  S
9U l        [        USS	U R                  S9U l        [        USSS	U R                  S
9U l        UR!                  ["        SS[$        [&        S9  U R                  R!                  ["        [(        [$        [&        S9  UR!                  [*        [,        [.        S9  UR!                  [*        SS[.        S9  U R                  R!                  [0        [,        SS9  U R                  R!                  [0        [,        S9  U R                  R!                  [0        [,        SS9  g)a  Create LabelFrame for additional help menu sources.

load_helplist loads list user_helplist with
name, position pairs and copies names to listbox helplist.
Clicking a name invokes help_source selected. Clicking
button_helplist_name invokes helplist_item_name, which also
changes user_helplist.  These functions all call
set_add_delete_state. All but load call update_help_changes to
rewrite changes['main']['HelpFiles'].

Widgets for HelpFrame(LabelFrame):  (*) widgets bound to self
    frame_helplist: Frame
        (*)helplist: ListBox
        scroll_helplist: Scrollbar
    frame_buttons: Frame
        (*)button_helplist_edit
        (*)button_helplist_add
        (*)button_helplist_remove
rh   Tr   r   r   r   Editr  r  )rn   r  rJ   r   Add)rn   rJ   r   Remover  )rr   r   rs   rt   )rr   r   rt   r   r  r   N)r!   r   r
   helplistr*   r  r  r  help_source_selectedr#   helplist_item_editbutton_helplist_edithelplist_item_addbutton_helplist_addhelplist_item_removebutton_helplist_remover   r   r	   r   r   r   r   r   r   )ra   frame_helplistscroll_helplistframe_buttonss       rd   r|  HelpFrame.create_frame_help*  s   * tqD %' $N3%)]]%8%8	"*9*=*=&'.0I0IJd$*F*!8!8%:! $*E!7!7$9  '-HJ!:!:'<#
 	AAdNQt$G%:AAA>!!&&C&B  %%3q%9##((c!!(Drf   c                 $    U R                  5         g)z+Handle event for selecting additional help.N)set_add_delete_stater  s     rd   r  HelpFrame.help_source_selected\  r  rf   c                    U R                   R                  5       S:  a7  U R                  R                  S5        U R                  R                  S5        gU R                   R                  5       (       a7  U R                  R                  S5        U R                  R                  S5        gU R                  R                  S5        U R                  R                  S5        g)zAToggle the state for the help list buttons based on list entries.r   r  r  N)r  sizer  r  r  r  r   s    rd   r  HelpFrame.set_add_delete_state`  s    ==!#%%++M:''--m<}}))++))//?++11.A))//>++11-@rf   c                     [        U S5      R                  nU(       aO  U R                  R                  U5        U R                  R                  [        US   5        U R                  5         gg)zpHandle add button for the help list.

Query for name and location of new help sources and add
them to the list.
zNew Help Sourcer   N)r6   r  user_helplistrZ  r  r  r   update_help_changes)ra   help_sources     rd   r  HelpFrame.helplist_item_addm  sW     !'89@@%%k2MM  k!n5$$& rf   c                    U R                   R                  [        5      nU R                  U   n[	        U SUS   US   S9R
                  nU(       an  X2:w  ah  X0R                  U'   U R                   R                  U5        U R                   R                  XS   5        U R                  5         U R                  5         ggg)zHandle edit button for the help list.

Query with existing help source information and update
config if the values are changed.
zEdit Help Sourcer   r   )menuitemfilepathN)
r  r-  r   r  r6   r  rz  r  r  r  )ra   
item_indexr  new_help_sources       rd   r  HelpFrame.helplist_item_edity  s     ]]((0
((4$($Q$Q &	 	
 =-<z*MM  ,MM  Q-?@$$&%%'  >?rf   c                     U R                   R                  [        5      nU R                  U	 U R                   R	                  U5        U R                  5         U R                  5         g)zPHandle remove button for the help list.

Delete the help list item from config.
N)r  r-  r   r  rz  r  r  )ra   r  s     rd   r  HelpFrame.helplist_item_remove  sP    
 ]]((0
z*Z(  "!!#rf   c                     0 [         S   S'   [        S[        U R                  5      S-   5       HF  n[         R	                  SS[        U5      SR                  U R                  US-
     SS 5      5        MH     g)z2Clear and rebuild the HelpFiles section in changesr  	HelpFilesr   ;Nr   )r   r  r  r  r=  r  r  )ra   nums     rd   r  HelpFrame.update_help_changes  sl    ')$C 2 23a78CKSHHT//A6r:;= 9rf   c                     [         R                  " 5       U l        U R                  R	                  SS5        U R                   H&  nU R                  R                  [        US   5        M(     U R                  5         g )Nr   r   )r0   GetAllExtraHelpSourcesListr  r  rz  r  r   r  )ra   	help_items     rd   r}  HelpFrame.load_helplist  s[    %@@BQ&++IMM  il3 ,!!#rf   )r  r  r  r  r  )r   r   r   r   rL   r|  r  r  r  r  r  r  r}  r   r   r   s   @rd   r?  r?  #  s8    
0Ed$A
'((	$=$ $rf   r?  c                   F    \ rS rSrSrS rS rS r\S 5       r	S r
S rS	rg
)VarTracei  z"Maintain Tk variables trace state.c                      / U l         / U l        g)zStore Tk variables and callbacks.

untraced: List of tuples (var, callback)
    that do not have the callback attached
    to the Tk var.
traced: List of tuples (var, callback) where
    that callback has been attached to the var.
N)untracedtracedr   s    rd   rL   VarTrace.__init__  s     rf   c                 l    U R                   R                  5         U R                  R                  5         g)zClear lists (for tests).N)r  r   r  r   s    rd   r   VarTrace.clear  s$     	rf   c                     [        U[        5      (       a  U R                  X5      nU R                  R	                  X45        U$ )a  Add (var, callback) tuple to untraced list.

Args:
    var: Tk variable instance.
    callback: Either function name to be used as a callback
        or a tuple with IdleConf config-type, section, and
        option names used in the default callback.

Return:
    Tk variable instance.
)
isinstancetuplemake_callbackr  rZ  ra   rT  callbacks      rd   r   VarTrace.add  s:     h&&))#8Hc_-
rf   c                    ^ ^ UU 4S jnU$ )zCReturn default callback function to add values to changes instance.c                  R   > [         R                  " / TQTR                  5       P76   g)z&Add config values to changes instance.N)r   r=  r   )r?  r  rT  s    rd   default_callback0VarTrace.make_callback.<locals>.default_callback  s    22	2rf   ro  )rT  r  r  s   `` rd   r  VarTrace.make_callback  s    	3  rf   c                     U R                   (       a^  U R                   R                  5       u  pUR                  SU5        U R                  R	                  X45        U R                   (       a  M]  gg)z0Attach callback to all vars that are not traced.writeN)r  pop	trace_addr  rZ  r  s      rd   r]   VarTrace.attach  sJ    mm MM--/MCMM'8,KK/ mmmrf   c                 
   U R                   (       ar  U R                   R                  5       u  pUR                  SUR                  5       S   S   5        U R                  R                  X45        U R                   (       a  Mq  gg)z!Remove callback from traced vars.r  r   r   N)r  r  trace_remove
trace_infor  rZ  r  s      rd   detachVarTrace.detach  s[    kk KKOO-MCWcnn&6q&9!&<=MM  #1 kkkrf   )r  r  N)r   r   r   r   r   rL   r   r   r  r  r]   r  r   ro  rf   rd   r  r    s2    ,
"    02rf   r  a7  When you click either the Apply or Ok buttons, settings in this
dialog that are different from IDLE's default are saved in
a .idlerc directory in your home directory. Except as noted,
these changes apply to all versions of IDLE installed on this
machine. [Cancel] only cancels changes made since the last save.
u  
Font sample: This shows what a selection of Basic Multilingual Plane
unicode characters look like for the current font selection.  If the
selected font does not define a character, Tk attempts to find another
font that does.  Substitute glyphs depend on what is available on a
particular system and will not necessarily have the same size as the
font selected.  Line contains 20 characters up to Devanagari, 14 for
Tamil, and 10 for East Asia.

Hebrew and Arabic letters should display right to left, starting with
alef, א and ا.  Arabic digits display left to right.  The
Devanagari and Tamil lines start with digits.  The East Asian lines
are Chinese digits, Chinese Hanzi, Korean Hangul, and Japanese
Hiragana and Katakana.

You can edit the font sample. Changes remain until IDLE is closed.
z
Highlighting:
The IDLE Dark color theme is new in October 2015.  It can only
be used with older IDLE releases if it is saved as a custom
theme, with a different name.
z
Keys:
The IDLE Modern Unix key set is new in June 2016.  It can only
be used with older IDLE releases if it is saved as a custom
key set, with a different name.
a_  
General:

AutoComplete: Popupwait is milliseconds to wait after key char, without
cursor movement, before popping up completion box.  Key char is '.' after
identifier or a '/' (or '\' on Windows) within a string.

FormatParagraph: Max-width is max chars in lines after re-formatting.
Use with paragraphs in both strings and comment blocks.

ParenMatch: Style indicates what is highlighted when closer is entered:
'opener' - opener '({[' corresponding to closer; 'parens' - both chars;
'expression' (default) - also everything in between.  Flash-delay is how
long to highlight if cursor is not moved (0 means forever).

CodeContext: Maxlines is the maximum number of code context lines to
display when Code Context is turned on for an editor window.

Shell Preferences: Auto-Squeeze Min. Lines is the minimum number of lines
of output to automatically "squeeze".
a  
ZzDummy: This extension is provided as an example for how to create and
use an extension.  Enable indicates whether the extension is active or
not; likewise enable_editor and enable_shell indicate which windows it
will be active on.  For this extension, z-text is the text that will be
inserted at or removed from the beginning of the lines of selected text,
or the current line if no selection.
)z
Fonts/Tabsro   rY  r  rp   c                 L    U (       d  g [        U 5        g! [         a     gf = f)z(Return 's is blank or represents an int'TF)r  r2  )r8  s    rd   r0  r0  -	  s)    A s    
##c                       \ rS rSrSrS rSrg)rh  i8	  zA pure Tkinter vertically scrollable frame.

* Use the 'interior' attribute to place widgets inside the scrollable frame
* Construct and pack/place/grid normally
* This frame only allows vertical scrolling
c                 (  ^^^	 [         R                  " X/UQ70 UD6  [        U [        S9nUR	                  [
        [        [        S9  [        U SSUR                  SS9mTR	                  [        [        [        S9  UR                  TR                  S9  TR                  S5        TR!                  S5        [        T5      =U l        mTR%                  SST[&        S9m	UU4S	 jnTR)                  S
U5        UUU	4S jnTR)                  S
U5        g )Nr9  )rt   rr   rs   r      )r   rl  r   rJ   r>  r   )windowr   c                 j   > TR                  5       TR                  5       4nTR                  SU-  S9  g )Nz	0 0 %s %s)scrollregion)winfo_reqwidthwinfo_reqheightr  )rF  r  canvasri  s     rd   _configure_interior;VerticalScrolledFrame.__init__.<locals>._configure_interiorT	  s2    ++-x/G/G/IJDMM{T'9M:rf   z<Configure>c                    > TR                  5       TR                  5       :w  a  TR                  TTR                  5       S9  g g )N)rJ   )r  winfo_widthitemconfigure)rF  r  ri  interior_ids    rd   _configure_canvas9VerticalScrolledFrame.__init__.<locals>._configure_canvasZ	  s?    &&(F,>,>,@@$$[8J8J8L$M Arf   )r!   rL   r*   r   r   r   r   r
   r   r  r   r   r	   r  r  xview_movetoyview_movetori  create_windowr   r  )
ra   rM   r  kw
vscrollbarr  r  r  ri  r  s
          @@@rd   rL   VerticalScrolledFrame.__init__?	  s    t1d1b1 tH5
QU59!'1~~SBD6&,,/ 	AA $)=0**1a*L	; 	m%89	N 	M#45rf   )ri  N)r   r   r   r   r   rL   r   ro  rf   rd   rh  rh  8	  s    !rf   rh  __main__)r  z#idlelib.idle_test.test_configdialogr   F)	verbosityexit)run)cr   r  tkinterr   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    tkinter.ttkr!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   tkinter.fontr7  r+  r/   idlelib.configr0   r1   idlelib.config_keyr2   idlelib.dynoptionr3   idlelibr4   idlelib.queryr5   r6   idlelib.textviewr7   idlelib.autocompleter8   idlelib.codecontextr9   idlelib.parenmatchr:   idlelib.formatr;   idlelib.squeezerr<   r=   r   r   r?   r   r}   r{   r~   r   r   ry   r?  r  r\   r   r   r0  rh  r   unittestr  idlelib.idle_test.htestr  ro  rf   rd   <module>r     s  
 
J J J J J J J J
, , , , !   2 , +  1 & - + ) * % 0
/[*o{8 {^E <g1u g1TQ
u Q
hou odOKe OKdBFu BFJ@$e @$FC$
 C$L:2 :2z *"*g;
|(E (V z	.!%H+ rf   