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 | """ |
Florent Xicluna | d630c04 | 2010-04-02 07:24:52 +0000 | [diff] [blame] | 11 | from idlelib.configHandler import idleConf |
Ned Deily | 57847df | 2014-03-27 20:47:04 -0700 | [diff] [blame] | 12 | |
| 13 | # Warning: menudefs is altered in macosxSupport.overrideRootMenu() |
| 14 | # after it is determined that an OS X Aqua Tk is in use, |
| 15 | # which cannot be done until after Tk() is first called. |
| 16 | # Do not alter the 'file', 'options', or 'help' cascades here |
| 17 | # without altering overrideRootMenu() as well. |
| 18 | # TODO: Make this more robust |
David Scherer | 7aced17 | 2000-08-15 01:13:23 +0000 | [diff] [blame] | 19 | |
| 20 | menudefs = [ |
| 21 | # underscore prefixes character to underscore |
| 22 | ('file', [ |
Terry Jan Reedy | 44d8b11 | 2013-07-01 00:42:44 -0400 | [diff] [blame] | 23 | ('_New File', '<<open-new-window>>'), |
David Scherer | 7aced17 | 2000-08-15 01:13:23 +0000 | [diff] [blame] | 24 | ('_Open...', '<<open-window-from-file>>'), |
Kurt B. Kaiser | d375abe | 2002-12-24 00:51:05 +0000 | [diff] [blame] | 25 | ('Open _Module...', '<<open-module>>'), |
| 26 | ('Class _Browser', '<<open-class-browser>>'), |
| 27 | ('_Path Browser', '<<open-path-browser>>'), |
David Scherer | 7aced17 | 2000-08-15 01:13:23 +0000 | [diff] [blame] | 28 | None, |
| 29 | ('_Save', '<<save-window>>'), |
| 30 | ('Save _As...', '<<save-window-as-file>>'), |
Kurt B. Kaiser | 7ae3548 | 2006-08-16 21:45:59 +0000 | [diff] [blame] | 31 | ('Save Cop_y As...', '<<save-copy-of-window-as-file>>'), |
David Scherer | 7aced17 | 2000-08-15 01:13:23 +0000 | [diff] [blame] | 32 | None, |
Kurt B. Kaiser | 7ae3548 | 2006-08-16 21:45:59 +0000 | [diff] [blame] | 33 | ('Prin_t Window', '<<print-window>>'), |
Steven M. Gava | 7981ce5 | 2002-06-11 04:45:34 +0000 | [diff] [blame] | 34 | None, |
David Scherer | 7aced17 | 2000-08-15 01:13:23 +0000 | [diff] [blame] | 35 | ('_Close', '<<close-window>>'), |
| 36 | ('E_xit', '<<close-all-windows>>'), |
| 37 | ]), |
| 38 | ('edit', [ |
| 39 | ('_Undo', '<<undo>>'), |
| 40 | ('_Redo', '<<redo>>'), |
| 41 | None, |
Steven M. Gava | 82c6682 | 2002-02-18 01:45:43 +0000 | [diff] [blame] | 42 | ('Cu_t', '<<cut>>'), |
| 43 | ('_Copy', '<<copy>>'), |
| 44 | ('_Paste', '<<paste>>'), |
David Scherer | 7aced17 | 2000-08-15 01:13:23 +0000 | [diff] [blame] | 45 | ('Select _All', '<<select-all>>'), |
Steven M. Gava | c597640 | 2002-01-04 03:06:08 +0000 | [diff] [blame] | 46 | None, |
| 47 | ('_Find...', '<<find>>'), |
Kurt B. Kaiser | d375abe | 2002-12-24 00:51:05 +0000 | [diff] [blame] | 48 | ('Find A_gain', '<<find-again>>'), |
| 49 | ('Find _Selection', '<<find-selection>>'), |
Steven M. Gava | c597640 | 2002-01-04 03:06:08 +0000 | [diff] [blame] | 50 | ('Find in Files...', '<<find-in-files>>'), |
| 51 | ('R_eplace...', '<<replace>>'), |
Kurt B. Kaiser | d375abe | 2002-12-24 00:51:05 +0000 | [diff] [blame] | 52 | ('Go to _Line', '<<goto-line>>'), |
David Scherer | 7aced17 | 2000-08-15 01:13:23 +0000 | [diff] [blame] | 53 | ]), |
Kurt B. Kaiser | 0c9b617 | 2002-09-14 00:50:44 +0000 | [diff] [blame] | 54 | ('format', [ |
Kurt B. Kaiser | 4cc5ef5 | 2003-01-22 00:23:23 +0000 | [diff] [blame] | 55 | ('_Indent Region', '<<indent-region>>'), |
| 56 | ('_Dedent Region', '<<dedent-region>>'), |
| 57 | ('Comment _Out Region', '<<comment-region>>'), |
| 58 | ('U_ncomment Region', '<<uncomment-region>>'), |
| 59 | ('Tabify Region', '<<tabify-region>>'), |
| 60 | ('Untabify Region', '<<untabify-region>>'), |
| 61 | ('Toggle Tabs', '<<toggle-tabs>>'), |
| 62 | ('New Indent Width', '<<change-indentwidth>>'), |
| 63 | ]), |
| 64 | ('run', [ |
Kurt B. Kaiser | d375abe | 2002-12-24 00:51:05 +0000 | [diff] [blame] | 65 | ('Python Shell', '<<open-python-shell>>'), |
Kurt B. Kaiser | 4cc5ef5 | 2003-01-22 00:23:23 +0000 | [diff] [blame] | 66 | ]), |
Kurt B. Kaiser | 1061e72 | 2003-01-04 01:43:53 +0000 | [diff] [blame] | 67 | ('shell', [ |
| 68 | ('_View Last Restart', '<<view-restart>>'), |
| 69 | ('_Restart Shell', '<<restart-shell>>'), |
Kurt B. Kaiser | 4cc5ef5 | 2003-01-22 00:23:23 +0000 | [diff] [blame] | 70 | ]), |
| 71 | ('debug', [ |
Kurt B. Kaiser | d375abe | 2002-12-24 00:51:05 +0000 | [diff] [blame] | 72 | ('_Go to File/Line', '<<goto-file-line>>'), |
David Scherer | 7aced17 | 2000-08-15 01:13:23 +0000 | [diff] [blame] | 73 | ('!_Debugger', '<<toggle-debugger>>'), |
Kurt B. Kaiser | 1061e72 | 2003-01-04 01:43:53 +0000 | [diff] [blame] | 74 | ('_Stack Viewer', '<<open-stack-viewer>>'), |
Kurt B. Kaiser | 4cc5ef5 | 2003-01-22 00:23:23 +0000 | [diff] [blame] | 75 | ('!_Auto-open Stack Viewer', '<<toggle-jit-stack-viewer>>'), |
| 76 | ]), |
Kurt B. Kaiser | 1061e72 | 2003-01-04 01:43:53 +0000 | [diff] [blame] | 77 | ('options', [ |
Terry Jan Reedy | 7a16207 | 2014-10-22 20:15:12 -0400 | [diff] [blame] | 78 | ('Configure _IDLE', '<<open-config-dialog>>'), |
| 79 | ('Configure _Extensions', '<<open-config-extensions-dialog>>'), |
Kurt B. Kaiser | 610c7e0 | 2004-04-24 03:01:48 +0000 | [diff] [blame] | 80 | None, |
Kurt B. Kaiser | 4cc5ef5 | 2003-01-22 00:23:23 +0000 | [diff] [blame] | 81 | ]), |
David Scherer | 7aced17 | 2000-08-15 01:13:23 +0000 | [diff] [blame] | 82 | ('help', [ |
Kurt B. Kaiser | 8e92bf7 | 2003-01-14 22:03:31 +0000 | [diff] [blame] | 83 | ('_About IDLE', '<<about-idle>>'), |
David Scherer | 7aced17 | 2000-08-15 01:13:23 +0000 | [diff] [blame] | 84 | None, |
Kurt B. Kaiser | 8e92bf7 | 2003-01-14 22:03:31 +0000 | [diff] [blame] | 85 | ('_IDLE Help', '<<help>>'), |
| 86 | ('Python _Docs', '<<python-docs>>'), |
Kurt B. Kaiser | 4cc5ef5 | 2003-01-22 00:23:23 +0000 | [diff] [blame] | 87 | ]), |
David Scherer | 7aced17 | 2000-08-15 01:13:23 +0000 | [diff] [blame] | 88 | ] |
| 89 | |
Steven M. Gava | 72c3bf0 | 2002-01-19 10:41:51 +0000 | [diff] [blame] | 90 | default_keydefs = idleConf.GetCurrentKeySet() |