î Óê[`!ã@sÔdZddlZddlZddlmZddlZdd„Zdd„Zdadd „Z d d „Z d d „Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„ZdS)z5 A number of functions that enhance IDLE on Mac OSX. éN)ÚpathcCstjdtddƒtƒS)Nz/runningAsOSXApp() is deprecated, use isAquaTk()Ú stacklevelé)ÚwarningsÚwarnÚDeprecationWarningÚisAquaTk©r r ú+/usr/lib/python3.4/idlelib/macosxSupport.pyÚrunningAsOSXApp s  r cCstjdtddƒtƒS)Nz4isCarbonAquaTk(root) is deprecated, use isCarbonTk()rr)rrrÚ isCarbonTk)Úrootr r r ÚisCarbonAquaTks  rcCsˆtjdkr~|jjddƒ}d|kr9daq„d|krNdaq„d|jjd d d ƒkrud aq„d andadS)zl Initializes OS X Tk variant values for isAquaTk(), isCarbonTk(), isCocoaTk(), and isXQuartz(). ÚdarwinÚtkZwindowingsystemZx11ÚxquartzZaquaÚotherZAppKitZwinfoZserverÚ.ÚcocoaÚcarbonN)ÚsysÚplatformrÚcallÚ_tk_type)r Zwsr r r Ú_initializeTkVariantTestss      rcCs(tdk st‚tdkp'tdkS)zK Returns True if IDLE is using a native OS X Tk (Cocoa or Carbon). Nrr)rÚAssertionErrorr r r r r(srcCstdk st‚tdkS)zb Returns True if IDLE is using a Carbon Aqua Tk (instead of the newer Cocoa Aqua Tk). Nr)rrr r r r r /sr cCstdk st‚tdkS)z8 Returns True if IDLE is using a Cocoa Aqua Tk. Nr)rrr r r r Ú isCocoaTk7srcCstdk st‚tdkS)z7 Returns True if IDLE is using an OS X X11 Tk. Nr)rrr r r r Ú isXQuartz>srcCsCtƒ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.\nVisit http://www.python.org/download/mac/tcltk/ for current information.N)r r!)rrrÚformat)r rr r r ÚtkVersionWarningEs  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. cs"x|D]}ˆj|ƒqWdS)N)Úopen)ÚargsÚfn)Úflistr r Ú doOpenFile^s z'addOpenEventSupport..doOpenFilez::tk::mac::OpenDocumentN)Ú createcommand)r r'r(r )r'r ÚaddOpenEventSupportYsr*c Cs3y|jjddƒWntjk r.YnXdS)NZconsoleZhide)rrÚtkinterZTclError)r r r r Ú hideTkConsolegsr,csÝddlm}m}m}ddlm}m}ddlm}ddlm‰ddl m }|j ddd+}|j ddd,d …=|j ddj d |ƒ|j d-ddd…=|j d.dd=|ˆƒ} ˆj d | ƒi} || d dƒ| d<} | jddd | ddƒ| ‡fdd†} ˆj| ƒd ‡fdd†} d ‡‡fdd†}d ‡fdd†}ˆjd| ƒˆjd|ƒˆjd|ƒˆrïˆjdˆjƒˆjdˆjƒntƒr›|| d dƒ| d <} | jdd!d | ƒ|j j dd d/d gfƒˆjjd#ƒ}ttt|jd$ƒƒƒd0kr›|j ddjd1ƒq›ntƒrÙˆjd)| ƒˆjd*|ƒ|j d2dd=nd S)3zf Replace the Tk root menu by something that is more appropriate for IDLE with an Aqua Tk. r)ÚMenuÚTextr.)ÚprepstrÚget_accelerator)ÚBindings)Ú WindowList)ÚMultiCallCreatoréréNéÚmenuÚnameZwindowsZlabelZWindowZ underlinecsT|jdƒ}|dkr$d}n|dkrC|jd|ƒnˆj|ƒdS)NÚendr4réÿÿÿÿ)ÚindexZdeleteZadd_windows_to_menu)r7r9)r2r r Úpostwindowsmenu™s    z)overrideRootMenu..postwindowsmenucs$ddlm}|jˆdƒdS)Nr)Ú aboutDialogz About IDLE)Úidlelibr=Z AboutDialog)Úeventr=)r r r Ú about_dialog£sz&overrideRootMenu..about_dialogcs<ddlm}ˆjˆ_ˆjˆ_|jˆdƒdS)Nr)Ú configDialogZSettings)r>rAZ inversedictZ instance_dictZ ConfigDialog)r?rA)r'r r r Ú config_dialog§s  z'overrideRootMenu..config_dialogcsKddlm}tjtjtjtƒƒdƒ}|jˆd|ƒdS)Nr)ÚtextViewzhelp.txtZHelp)r>rCrÚjoinÚabspathÚdirnameÚ__file__Z view_file)r?rCr&)r r r Ú help_dialog²s$z%overrideRootMenu..help_dialogú<>ú<>z::tk::mac::ShowPreferencesz<>ÚexitZappleZ applicationZIDLEú About IDLEzinfo patchlevelréééú_Preferences....Z tkAboutDialogz::tk::mac::ShowHelpéþÿÿÿéýÿÿÿr:rQ)rLrI)rMrNrO)rPrJr:)r+r-r.Zidlelib.EditorWindowr/r0r>r1r2Zidlelib.MultiCallr3ZmenudefsÚinsertZ configureZ add_cascadeZregister_callbackZbindr)Zclose_all_callbackr rÚevalÚtupleÚmapÚintÚsplitÚappendr)r r'r-r.r/r0r1r3Z closeItemZmenubarZmenudictr7r<r@rBrHZ tkversionr )r2r'r r ÚoverrideRootMenunsR      $  rZcCs>t|ƒtƒr:t|ƒt||ƒt||ƒndS)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)rrr,rZr*)r r'r r r ÚsetupAppÙs     r[)Ú__doc__rr+Úosrrr rrrrr rrr#r*r,rZr[r r r r Ús"              k