3 § f¼%ã@s¼dZddlmZddlZddlmZddlZdadd„Zdd„Z d d „Z d d „Z d d„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zedkr¸dd lmZed!d"d#�dS)$z3 A number of functions that enhance IDLE on macOS. é)Ú expanduserN)ÚplatformcCsjtdkrbtjƒ}|jjddƒ}d|kr,dan,d|kr:dand|jjd d d ƒkrTd and a|jƒndadS)zl Initializes OS X Tk variant values for isAquaTk(), isCarbonTk(), isCocoaTk(), and isXQuartz(). ÚdarwinÚtkZwindowingsystemZx11ÚxquartzZaquaÚotherZAppKitZwinfoZserverÚ.ÚcocoaÚcarbonN)rÚtkinterZTkrÚcallÚ_tk_typeZdestroy)ÚrootZws©rú3/opt/alt/python36/lib64/python3.6/idlelib/macosx.pyÚ _init_tk_types rcCsts tƒtdkptdkS)zK Returns True if IDLE is using a native OS X Tk (Cocoa or Carbon). r r )r rrrrrÚisAquaTk%srcCsts tƒtdkS)zb Returns True if IDLE is using a Carbon Aqua Tk (instead of the newer Cocoa Aqua Tk). r )r rrrrrÚ isCarbonTk-srcCsts tƒtdkS)z8 Returns True if IDLE is using a Cocoa Aqua Tk. r )r rrrrrÚ isCocoaTk6srcCsts tƒtdkS)z7 Returns True if IDLE is using an OS X X11 Tk. r)r rrrrrÚ isXQuartz>srcCs2tƒr*|jjddƒ}|dkr dSdj|ƒSdSdS) a2 Returns a string warning message if the Tk version in use appears to be one known to cause problems with IDLE. 1. Apple Cocoa-based Tk 8.5.7 shipped with Mac OS X 10.6 is unusable. 2. Apple Cocoa-based Tk 8.5.9 in OS X 10.7 and 10.8 is better but can still crash unexpectedly. ÚinfoÚ patchlevelú8.5.7ú8.5.9Fz…WARNING: The version of Tcl/Tk ({0}) in use may be unstable. Visit http://www.python.org/download/mac/tcltk/ for current information.N)rr)rrr Úformat)rrrrrÚtkVersionWarningGs rcCsNtdkr dStdƒ}y t|dƒ� }tj|ƒSQRXWntk rHdSXdS)z- Fetch the macOS system preferences. rNz.~/Library/Preferences/.GlobalPreferences.plistÚrb)rrÚopenÚplistlibÚloadÚOSError)Z plist_pathZ plist_filerrrÚreadSystemPreferences\s r!cCs,tdkr dStƒ}|r(|jdƒdkr(dSdS)zJ Warn if "Prefer tabs when opening documents" is set to "Always". rNZAppleWindowTabbingModeÚalwayszäWARNING: 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).)rr!Úget)ZprefsrrrÚpreferTabsPreferenceWarningks r$cs‡fdd„}|jd|ƒ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. csx|D]}ˆj|ƒqWdS)N)r)ÚargsÚfn)ÚflistrrÚ doOpenFile„s z'addOpenEventSupport..doOpenFilez::tk::mac::OpenDocumentN)Ú createcommand)rr'r(r)r'rÚaddOpenEventSupports r*c Cs.y|jjddƒWntjk r(YnXdS)NZconsoleZhide)rr r ZTclError)rrrrÚ hideTkConsole�sr+c sÄddlm}ddlm}ddlm‰|jddd#}|jddd$d…=|jddjd |ƒ|jd%ddd…=|jd&dd=|ˆƒ}ˆj|d �i}||d dd �|d <}|jd |dd�|f‡fdd„ }ˆj |ƒd'‡fdd„ } d(‡‡fdd„ } d)‡fdd„ } ˆj d| ƒˆj d| ƒˆj d| ƒˆ�rNˆj dˆj ƒˆj dˆj ƒt ƒ�r�||ddd �|d<}|jd|d�|jjddd*dgfƒtƒ�rÀˆj d!| ƒˆj d"| ƒ|jd+dd=dS),zf Replace the Tk root menu by something that is more appropriate for IDLE with an Aqua Tk. r)ÚMenu)Úmainmenu)ÚwindowéééNé)Úmenur.)ÚnameZtearoffZWindow)Úlabelr3Z underlinecs8|jdƒ}|dkrd}|dkr*|jd|ƒˆj|ƒdS)NÚendr/réÿÿÿÿ)ÚindexÚdeleteZadd_windows_to_menu)r3r6)r.rrÚpostwindowsmenu½s   z)overrideRootMenu..postwindowsmenucsddlm}|jˆƒdS)zHandle Help 'About IDLE' event.r)Ú help_aboutN)Úidlelibr;Z AboutDialog)Úeventr;)rrrÚ about_dialogÇs z&overrideRootMenu..about_dialogcs$ddlm}ˆjˆ_|jˆdƒdS)z&Handle Options 'Configure IDLE' event.r)Ú configdialogZSettingsN)r<r?Z inversedictZ instance_dictZ ConfigDialog)r=r?)r'rrrÚ config_dialogÍs z'overrideRootMenu..config_dialogcsddlm}|jˆƒdS)zHandle Help 'IDLE Help' event.r)ÚhelpN)r<rAZ show_idlehelp)r=rA)rrrÚ help_dialogÙs z%overrideRootMenu..help_dialogú<>z<>z::tk::mac::ShowPreferencesz<>ÚexitZappleZ applicationZIDLE)r5r3ú About IDLEZ tkAboutDialogz::tk::mac::ShowHelpéþÿÿÿéýÿÿÿr7rF)N)N)N)rErCr7)r r,r<r-r.ZmenudefsÚinsertZ configureZ add_cascadeZregister_callbackZbindr)Zclose_all_callbackrr) rr'r,r-Z closeItemZmenubarZmenudictr3r:r>r@rBr)r'rr.rÚoverrideRootMenu”sH            rIcCs(|jddƒ|jddƒ|jddƒdS)zšRemoved bad AquaTk Button-2 (right) and Paste bindings. They prevent context menu access and seem to be gone in AquaTk8.6. See issue #24801. ZTextzz z<>N)Z unbind_class)rrrrÚ fixb2contextüs  rJcCs.tƒr*t|ƒt||ƒt||ƒt|ƒdS)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)rr+rIr*rJ)rr'rrrÚsetupApps   rKÚ__main__)Úmainzidlelib.idle_test.test_macosxr0)Ú verbosity)Ú__doc__Zos.pathrrÚsysrr r rrrrrrr!r$r*r+rIrJrKÚ__name__ZunittestrMrrrrÚs*    h