\d$dZddlmZddlZddlmZddlZdadZdZ dZ dZ d Z d Z d Zd Zd ZdZdZdZedkrddlmZedddSdS)z3 A number of functions that enhance IDLE on macOS. ) expanduserN)platformc^tdkrddlm}|r#ddlm}m} |dn#|$rdaYdSwxYwtj}|j dd }d |vrd an*d |vrd an#d|j dddvrdanda| nd adS)zu Initialize _tk_type for isXyzTk functions. This function is only called once, when _tk_type is still None. darwinr)testing)requiresResourceDeniedguicocoaNtkwindowingsystemx11xquartzaquaotherAppKitwinfoserver.carbon) ridlelib.__init__r test.supportrr _tk_typetkinterTkr calldestroy)rrr rootwss ..\python\lib\idlelib\macosx.py _init_tk_typer!s 8 -,,,,,   = = = = = = = = !   " z|| W\\$ 1 2 2 B;; HH 2  HH gx== = =HHH  Fs )44cXtsttdkp tdkS)zK Returns True if IDLE is using a native OS X Tk (Cocoa or Carbon). r rrr!r isAquaTkr&3s*  w  6(h"66r%cBtsttdkS)zb Returns True if IDLE is using a Carbon Aqua Tk (instead of the newer Cocoa Aqua Tk). rr#r$r%r isCarbonTkr(;s  x r%cBtsttdkS)z8 Returns True if IDLE is using a Cocoa Aqua Tk. r r#r$r%r isCocoaTkr*Ds   w r%cBtsttdkS)z7 Returns True if IDLE is using an OS X X11 Tk. rr#r$r%r isXQuartzr,Ls   y  r%ctdkrdStd} t|d5}tj|cdddS#1swxYwYdS#t $rYdSwxYw)z- Fetch the macOS system preferences. rNz.~/Library/Preferences/.GlobalPreferences.plistrb)rropenplistlibloadOSError) plist_path plist_files r readSystemPreferencesr5Us8tLMMJ *d # # -z=,, - - - - - - - - - - - - - - - - - - tts4AA AAAAA A*)A*cxtdkrdSt}|r|ddkr dSdS)zJ Warn if "Prefer tabs when opening documents" is set to "Always". rNAppleWindowTabbingModealwayszWARNING: The system preference "Prefer tabs when opening documents" is set to "Always". This will cause various problems with IDLE. For the best experience, change this setting when running IDLE (via System Preferences -> Dock).)rr5get)prefss r preferTabsPreferenceWarningr;dsT8t ! # #E  344@@ >  4r%c>fd}|d|dS)z This ensures that the application will respond to open AppleEvents, which makes is feasible to use IDLE as the default application for python files. c<|D]}|dSN)r/)argsfnflists r doOpenFilez'addOpenEventSupport..doOpenFile}s-  B JJrNNNN  r%z::tk::mac::OpenDocumentN) createcommand)rrArBs ` r addOpenEventSupportrDxs;  0*=====r%cj |jdddS#tj$rYdSwxYw)Nconsolehide)r rrTclErrorrs r hideTkConsolerJsH   Y'''''       s 22cp ddlm}ddlm}ddlm |jddd}|jdddd=|jddd ||jd ddd =|jdddd =|}| i}||d dx|d <}|d|d|f fd } |d!fd } d!fd } d!fd } d|  d|  d| r6 dj  dj trI||ddx|d<}|d||jddddgftrB d|  d | |jd dd=dSdS)"zf Replace the Tk root menu by something that is more appropriate for IDLE with an Aqua Tk. r)Menu)mainmenu)windowN)menurN)nametearoffWindow)labelrU underlinec|d}|d}|dkr|d||dS)NendrSr)indexdeleteadd_windows_to_menu)rUr\rNs r postwindowsmenuz)overrideRootMenu..postwindowsmenusUjj ;C 77 KK3   ""4(((((r%c>ddlm}|dS)zHandle Help 'About IDLE' event.r) help_aboutN)idlelibrb AboutDialog)eventrbrs r about_dialogz&overrideRootMenu..about_dialogs1 '&&&&&t$$$$$r%cXddlm}j_|ddS)z&Handle Options 'Configure IDLE' event.r) configdialogSettingsN)rcrh inversedict instance_dict ConfigDialog)rerhrArs r config_dialogz'overrideRootMenu..config_dialogs@ )((((( #.!!$ 33333r%c>ddlm}|dS)zHandle Help 'IDLE Help' event.r)helpN)rcro show_idlehelp)rerors r help_dialogz%overrideRootMenu..help_dialogs1 !      4     r%<>z<>z::tk::mac::ShowPreferencesz<>exitapple applicationIDLE)rYrU)z About IDLErr tkAboutDialogz::tk::mac::ShowHelpr>)rrLrcrMrNmenudefsinsert configure add_cascaderegister_callbackbindrCclose_all_callbackr(r*) rrArLrM closeItemmenubarmenudictrUr`rfrmrqrNs `` @r overrideRootMenurs       !!$Q'+I !Q$ a""1i000 "a 1% "a 1%d4jjGNNN   H $W8Q G G GGHX hTQ???!)))))) _---%%%%%% 4 4 4 4 4 4 4!!!!!!  II ---II& 6663]CCC = )5+CDDD 65#;<<<|| )-gG67*9*9*9 9$&t444   0     {{( ?L999 0+>>>  b !! $Q ' ' ' ((r%c|dd|dd|dddS)zRemoved bad AquaTk Button-2 (right) and Paste bindings. They prevent context menu access and seem to be gone in AquaTk8.6. See issue #24801. Textzz z<>N) unbind_classrIs r fixb2contextrsM  ff%%%fm,,,f233333r%ctr@t|t||t||t |dSdS)a Perform initial OS X customizations if needed. Called from pyshell.main() after initial calls to Tk() There are currently three major versions of Tk in use on OS X: 1. Aqua Cocoa Tk (native default since OS X 10.6) 2. Aqua Carbon Tk (original native, 32-bit only, deprecated) 3. X11 (supported by some third-party distributors, deprecated) There are various differences among the three that affect IDLE behavior, primarily with menus, mouse key events, and accelerators. Some one-time customizations are performed here. Others are dynamically tested throughout idlelib by calls to the isAquaTk(), isCarbonTk(), isCocoaTk(), isXQuartz() functions which are initialized here as well. N)r&rJrrDr)rrAs r setupApprs\ zzdu%%%D%(((T r%__main__)mainzidlelib.idle_test.test_macosxrT) verbosity)__doc__os.pathrr0sysrrrr!r&r(r*r,r5r;rDrJrrr__name__unittestrr$r%r rsJ ! ! ! F777   !!!   ( > > >   f(f(f(P444. zD (A666666r%