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