PageRenderTime 29ms CodeModel.GetById 13ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/Lib/idlelib/Bindings.py

http://unladen-swallow.googlecode.com/
Python | 111 lines | 84 code | 9 blank | 18 comment | 1 complexity | ddc75071f1c878191b77983ca0f40c78 MD5 | raw file
  1"""Define the menu contents, hotkeys, and event bindings.
  2
  3There is additional configuration information in the EditorWindow class (and
  4subclasses): the menus are created there based on the menu_specs (class)
  5variable, and menus not created are silently skipped in the code here.  This
  6makes it possible, for example, to define a Debug menu which is only present in
  7the PythonShell window, and a Format menu which is only present in the Editor
  8windows.
  9
 10"""
 11import sys
 12from configHandler import idleConf
 13import macosxSupport
 14
 15menudefs = [
 16 # underscore prefixes character to underscore
 17 ('file', [
 18   ('_New Window', '<<open-new-window>>'),
 19   ('_Open...', '<<open-window-from-file>>'),
 20   ('Open _Module...', '<<open-module>>'),
 21   ('Class _Browser', '<<open-class-browser>>'),
 22   ('_Path Browser', '<<open-path-browser>>'),
 23   None,
 24   ('_Save', '<<save-window>>'),
 25   ('Save _As...', '<<save-window-as-file>>'),
 26   ('Save Cop_y As...', '<<save-copy-of-window-as-file>>'),
 27   None,
 28   ('Prin_t Window', '<<print-window>>'),
 29   None,
 30   ('_Close', '<<close-window>>'),
 31   ('E_xit', '<<close-all-windows>>'),
 32  ]),
 33 ('edit', [
 34   ('_Undo', '<<undo>>'),
 35   ('_Redo', '<<redo>>'),
 36   None,
 37   ('Cu_t', '<<cut>>'),
 38   ('_Copy', '<<copy>>'),
 39   ('_Paste', '<<paste>>'),
 40   ('Select _All', '<<select-all>>'),
 41   None,
 42   ('_Find...', '<<find>>'),
 43   ('Find A_gain', '<<find-again>>'),
 44   ('Find _Selection', '<<find-selection>>'),
 45   ('Find in Files...', '<<find-in-files>>'),
 46   ('R_eplace...', '<<replace>>'),
 47   ('Go to _Line', '<<goto-line>>'),
 48  ]),
 49('format', [
 50   ('_Indent Region', '<<indent-region>>'),
 51   ('_Dedent Region', '<<dedent-region>>'),
 52   ('Comment _Out Region', '<<comment-region>>'),
 53   ('U_ncomment Region', '<<uncomment-region>>'),
 54   ('Tabify Region', '<<tabify-region>>'),
 55   ('Untabify Region', '<<untabify-region>>'),
 56   ('Toggle Tabs', '<<toggle-tabs>>'),
 57   ('New Indent Width', '<<change-indentwidth>>'),
 58   ]),
 59 ('run', [
 60   ('Python Shell', '<<open-python-shell>>'),
 61   ]),
 62 ('shell', [
 63   ('_View Last Restart', '<<view-restart>>'),
 64   ('_Restart Shell', '<<restart-shell>>'),
 65   ]),
 66 ('debug', [
 67   ('_Go to File/Line', '<<goto-file-line>>'),
 68   ('!_Debugger', '<<toggle-debugger>>'),
 69   ('_Stack Viewer', '<<open-stack-viewer>>'),
 70   ('!_Auto-open Stack Viewer', '<<toggle-jit-stack-viewer>>'),
 71   ]),
 72 ('options', [
 73   ('_Configure IDLE...', '<<open-config-dialog>>'),
 74   None,
 75   ]),
 76 ('help', [
 77   ('_About IDLE', '<<about-idle>>'),
 78   None,
 79   ('_IDLE Help', '<<help>>'),
 80   ('Python _Docs', '<<python-docs>>'),
 81   ]),
 82]
 83
 84if macosxSupport.runningAsOSXApp():
 85    # Running as a proper MacOS application bundle. This block restructures
 86    # the menus a little to make them conform better to the HIG.
 87
 88    quitItem = menudefs[0][1][-1]
 89    closeItem = menudefs[0][1][-2]
 90
 91    # Remove the last 3 items of the file menu: a separator, close window and
 92    # quit. Close window will be reinserted just above the save item, where
 93    # it should be according to the HIG. Quit is in the application menu.
 94    del menudefs[0][1][-3:]
 95    menudefs[0][1].insert(6, closeItem)
 96
 97    # Remove the 'About' entry from the help menu, it is in the application
 98    # menu
 99    del menudefs[-1][1][0:2]
100
101    menudefs.insert(0,
102            ('application', [
103                ('About IDLE', '<<about-idle>>'),
104                None,
105                ('_Preferences....', '<<open-config-dialog>>'),
106            ]))
107
108
109default_keydefs = idleConf.GetCurrentKeySet()
110
111del sys