blob: 143570d6b11c416abbce33e202c4299525d53f30 [file] [log] [blame]
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +00001"""Define the menu contents, hotkeys, and event bindings.
David Scherer7aced172000-08-15 01:13:23 +00002
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +00003There 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"""
Terry Jan Reedy7e55db22014-07-28 22:23:59 -040011from importlib.util import find_spec
12
Terry Jan Reedy6fa5bdc2016-05-28 13:22:31 -040013from idlelib.config import idleConf
Ned Deilyb7601672014-03-27 20:49:14 -070014
Terry Jan Reedy6fa5bdc2016-05-28 13:22:31 -040015# Warning: menudefs is altered in macosx.overrideRootMenu()
Ned Deilyb7601672014-03-27 20:49:14 -070016# after it is determined that an OS X Aqua Tk is in use,
17# which cannot be done until after Tk() is first called.
18# Do not alter the 'file', 'options', or 'help' cascades here
19# without altering overrideRootMenu() as well.
20# TODO: Make this more robust
David Scherer7aced172000-08-15 01:13:23 +000021
22menudefs = [
23 # underscore prefixes character to underscore
24 ('file', [
Terry Jan Reedy8a0b7752013-07-01 00:42:52 -040025 ('_New File', '<<open-new-window>>'),
David Scherer7aced172000-08-15 01:13:23 +000026 ('_Open...', '<<open-window-from-file>>'),
Kurt B. Kaiserd375abe2002-12-24 00:51:05 +000027 ('Open _Module...', '<<open-module>>'),
Cheryl Sabellacd99e792017-09-23 16:46:01 -040028 ('Module _Browser', '<<open-class-browser>>'),
Kurt B. Kaiserd375abe2002-12-24 00:51:05 +000029 ('_Path Browser', '<<open-path-browser>>'),
David Scherer7aced172000-08-15 01:13:23 +000030 None,
31 ('_Save', '<<save-window>>'),
32 ('Save _As...', '<<save-window-as-file>>'),
Thomas Wouters00ee7ba2006-08-21 19:07:27 +000033 ('Save Cop_y As...', '<<save-copy-of-window-as-file>>'),
David Scherer7aced172000-08-15 01:13:23 +000034 None,
Thomas Wouters00ee7ba2006-08-21 19:07:27 +000035 ('Prin_t Window', '<<print-window>>'),
Steven M. Gava7981ce52002-06-11 04:45:34 +000036 None,
David Scherer7aced172000-08-15 01:13:23 +000037 ('_Close', '<<close-window>>'),
38 ('E_xit', '<<close-all-windows>>'),
39 ]),
40 ('edit', [
41 ('_Undo', '<<undo>>'),
42 ('_Redo', '<<redo>>'),
43 None,
Steven M. Gava82c66822002-02-18 01:45:43 +000044 ('Cu_t', '<<cut>>'),
45 ('_Copy', '<<copy>>'),
46 ('_Paste', '<<paste>>'),
David Scherer7aced172000-08-15 01:13:23 +000047 ('Select _All', '<<select-all>>'),
Steven M. Gavac5976402002-01-04 03:06:08 +000048 None,
49 ('_Find...', '<<find>>'),
Kurt B. Kaiserd375abe2002-12-24 00:51:05 +000050 ('Find A_gain', '<<find-again>>'),
51 ('Find _Selection', '<<find-selection>>'),
Steven M. Gavac5976402002-01-04 03:06:08 +000052 ('Find in Files...', '<<find-in-files>>'),
53 ('R_eplace...', '<<replace>>'),
Kurt B. Kaiserd375abe2002-12-24 00:51:05 +000054 ('Go to _Line', '<<goto-line>>'),
wohlganger58fc71c2017-09-10 16:19:47 -050055 ('S_how Completions', '<<force-open-completions>>'),
56 ('E_xpand Word', '<<expand-word>>'),
57 ('Show C_all Tip', '<<force-open-calltip>>'),
58 ('Show Surrounding P_arens', '<<flash-paren>>'),
59
David Scherer7aced172000-08-15 01:13:23 +000060 ]),
Kurt B. Kaiser0c9b6172002-09-14 00:50:44 +000061('format', [
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000062 ('_Indent Region', '<<indent-region>>'),
63 ('_Dedent Region', '<<dedent-region>>'),
64 ('Comment _Out Region', '<<comment-region>>'),
65 ('U_ncomment Region', '<<uncomment-region>>'),
66 ('Tabify Region', '<<tabify-region>>'),
67 ('Untabify Region', '<<untabify-region>>'),
68 ('Toggle Tabs', '<<toggle-tabs>>'),
69 ('New Indent Width', '<<change-indentwidth>>'),
wohlganger58fc71c2017-09-10 16:19:47 -050070 ('F_ormat Paragraph', '<<format-paragraph>>'),
71 ('S_trip Trailing Whitespace', '<<do-rstrip>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000072 ]),
73 ('run', [
Kurt B. Kaiserd375abe2002-12-24 00:51:05 +000074 ('Python Shell', '<<open-python-shell>>'),
wohlganger58fc71c2017-09-10 16:19:47 -050075 ('C_heck Module', '<<check-module>>'),
76 ('R_un Module', '<<run-module>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000077 ]),
Kurt B. Kaiser1061e722003-01-04 01:43:53 +000078 ('shell', [
79 ('_View Last Restart', '<<view-restart>>'),
80 ('_Restart Shell', '<<restart-shell>>'),
Terry Jan Reedy4b736762016-09-12 01:50:03 -040081 None,
82 ('_Interrupt Execution', '<<interrupt-execution>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000083 ]),
84 ('debug', [
Kurt B. Kaiserd375abe2002-12-24 00:51:05 +000085 ('_Go to File/Line', '<<goto-file-line>>'),
David Scherer7aced172000-08-15 01:13:23 +000086 ('!_Debugger', '<<toggle-debugger>>'),
Kurt B. Kaiser1061e722003-01-04 01:43:53 +000087 ('_Stack Viewer', '<<open-stack-viewer>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000088 ('!_Auto-open Stack Viewer', '<<toggle-jit-stack-viewer>>'),
89 ]),
Kurt B. Kaiser1061e722003-01-04 01:43:53 +000090 ('options', [
Terry Jan Reedya9421fb2014-10-22 20:15:18 -040091 ('Configure _IDLE', '<<open-config-dialog>>'),
wohlganger58fc71c2017-09-10 16:19:47 -050092 ('_Code Context', '<<toggle-code-context>>'),
93 ]),
94 ('windows', [
95 ('Zoom Height', '<<zoom-height>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000096 ]),
David Scherer7aced172000-08-15 01:13:23 +000097 ('help', [
Kurt B. Kaiser8e92bf72003-01-14 22:03:31 +000098 ('_About IDLE', '<<about-idle>>'),
David Scherer7aced172000-08-15 01:13:23 +000099 None,
Kurt B. Kaiser8e92bf72003-01-14 22:03:31 +0000100 ('_IDLE Help', '<<help>>'),
101 ('Python _Docs', '<<python-docs>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +0000102 ]),
David Scherer7aced172000-08-15 01:13:23 +0000103]
104
Terry Jan Reedy7e55db22014-07-28 22:23:59 -0400105if find_spec('turtledemo'):
106 menudefs[-1][1].append(('Turtle Demo', '<<open-turtle-demo>>'))
107
Steven M. Gava72c3bf02002-01-19 10:41:51 +0000108default_keydefs = idleConf.GetCurrentKeySet()