blob: 74edce234838292859c4e5e17e5ac0f428b7dffd [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>>'),
Terry Jan Reedyea3dc802018-06-18 04:47:59 -040039 ]),
40
David Scherer7aced172000-08-15 01:13:23 +000041 ('edit', [
42 ('_Undo', '<<undo>>'),
43 ('_Redo', '<<redo>>'),
44 None,
Steven M. Gava82c66822002-02-18 01:45:43 +000045 ('Cu_t', '<<cut>>'),
46 ('_Copy', '<<copy>>'),
47 ('_Paste', '<<paste>>'),
David Scherer7aced172000-08-15 01:13:23 +000048 ('Select _All', '<<select-all>>'),
Steven M. Gavac5976402002-01-04 03:06:08 +000049 None,
50 ('_Find...', '<<find>>'),
Kurt B. Kaiserd375abe2002-12-24 00:51:05 +000051 ('Find A_gain', '<<find-again>>'),
52 ('Find _Selection', '<<find-selection>>'),
Steven M. Gavac5976402002-01-04 03:06:08 +000053 ('Find in Files...', '<<find-in-files>>'),
54 ('R_eplace...', '<<replace>>'),
Kurt B. Kaiserd375abe2002-12-24 00:51:05 +000055 ('Go to _Line', '<<goto-line>>'),
wohlganger58fc71c2017-09-10 16:19:47 -050056 ('S_how Completions', '<<force-open-completions>>'),
57 ('E_xpand Word', '<<expand-word>>'),
58 ('Show C_all Tip', '<<force-open-calltip>>'),
59 ('Show Surrounding P_arens', '<<flash-paren>>'),
Terry Jan Reedyea3dc802018-06-18 04:47:59 -040060 ]),
wohlganger58fc71c2017-09-10 16:19:47 -050061
Terry Jan Reedyea3dc802018-06-18 04:47:59 -040062 ('format', [
Miss Islington (bot)1fc43a32019-07-17 07:45:20 -070063 ('F_ormat Paragraph', '<<format-paragraph>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000064 ('_Indent Region', '<<indent-region>>'),
65 ('_Dedent Region', '<<dedent-region>>'),
66 ('Comment _Out Region', '<<comment-region>>'),
67 ('U_ncomment Region', '<<uncomment-region>>'),
68 ('Tabify Region', '<<tabify-region>>'),
69 ('Untabify Region', '<<untabify-region>>'),
70 ('Toggle Tabs', '<<toggle-tabs>>'),
71 ('New Indent Width', '<<change-indentwidth>>'),
wohlganger58fc71c2017-09-10 16:19:47 -050072 ('S_trip Trailing Whitespace', '<<do-rstrip>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000073 ]),
Terry Jan Reedyea3dc802018-06-18 04:47:59 -040074
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000075 ('run', [
wohlganger58fc71c2017-09-10 16:19:47 -050076 ('R_un Module', '<<run-module>>'),
Miss Islington (bot)ae526ee2019-06-17 19:47:55 -070077 ('Run... _Customized', '<<run-custom>>'),
Miss Islington (bot)9c95fc72019-08-04 14:04:49 -070078 ('C_heck Module', '<<check-module>>'),
79 ('Python Shell', '<<open-python-shell>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000080 ]),
Terry Jan Reedyea3dc802018-06-18 04:47:59 -040081
Kurt B. Kaiser1061e722003-01-04 01:43:53 +000082 ('shell', [
83 ('_View Last Restart', '<<view-restart>>'),
84 ('_Restart Shell', '<<restart-shell>>'),
Terry Jan Reedy4b736762016-09-12 01:50:03 -040085 None,
Cheryl Sabellac0381aa2018-12-28 15:11:30 -050086 ('_Previous History', '<<history-previous>>'),
87 ('_Next History', '<<history-next>>'),
88 None,
Terry Jan Reedy4b736762016-09-12 01:50:03 -040089 ('_Interrupt Execution', '<<interrupt-execution>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000090 ]),
Terry Jan Reedyea3dc802018-06-18 04:47:59 -040091
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000092 ('debug', [
Kurt B. Kaiserd375abe2002-12-24 00:51:05 +000093 ('_Go to File/Line', '<<goto-file-line>>'),
David Scherer7aced172000-08-15 01:13:23 +000094 ('!_Debugger', '<<toggle-debugger>>'),
Kurt B. Kaiser1061e722003-01-04 01:43:53 +000095 ('_Stack Viewer', '<<open-stack-viewer>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000096 ('!_Auto-open Stack Viewer', '<<toggle-jit-stack-viewer>>'),
97 ]),
Terry Jan Reedyea3dc802018-06-18 04:47:59 -040098
Kurt B. Kaiser1061e722003-01-04 01:43:53 +000099 ('options', [
Terry Jan Reedya9421fb2014-10-22 20:15:18 -0400100 ('Configure _IDLE', '<<open-config-dialog>>'),
Cheryl Sabellac1b4b0f2018-12-22 01:25:45 -0500101 None,
102 ('Show _Code Context', '<<toggle-code-context>>'),
Miss Islington (bot)1da6a312019-07-23 06:04:13 -0700103 ('Show _Line Numbers', '<<toggle-line-numbers>>'),
104 ('_Zoom Height', '<<zoom-height>>'),
wohlganger58fc71c2017-09-10 16:19:47 -0500105 ]),
Terry Jan Reedyea3dc802018-06-18 04:47:59 -0400106
Terry Jan Reedy33c74202018-06-20 22:49:55 -0400107 ('window', [
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +0000108 ]),
Terry Jan Reedyea3dc802018-06-18 04:47:59 -0400109
David Scherer7aced172000-08-15 01:13:23 +0000110 ('help', [
Kurt B. Kaiser8e92bf72003-01-14 22:03:31 +0000111 ('_About IDLE', '<<about-idle>>'),
David Scherer7aced172000-08-15 01:13:23 +0000112 None,
Kurt B. Kaiser8e92bf72003-01-14 22:03:31 +0000113 ('_IDLE Help', '<<help>>'),
114 ('Python _Docs', '<<python-docs>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +0000115 ]),
David Scherer7aced172000-08-15 01:13:23 +0000116]
117
Terry Jan Reedy7e55db22014-07-28 22:23:59 -0400118if find_spec('turtledemo'):
119 menudefs[-1][1].append(('Turtle Demo', '<<open-turtle-demo>>'))
120
Steven M. Gava72c3bf02002-01-19 10:41:51 +0000121default_keydefs = idleConf.GetCurrentKeySet()
Terry Jan Reedyea3dc802018-06-18 04:47:59 -0400122
123if __name__ == '__main__':
124 from unittest import main
125 main('idlelib.idle_test.test_mainmenu', verbosity=2)