blob: 9fe6b5229446e3072744db46de8a3001f6adff47 [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', [
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000063 ('_Indent Region', '<<indent-region>>'),
64 ('_Dedent Region', '<<dedent-region>>'),
65 ('Comment _Out Region', '<<comment-region>>'),
66 ('U_ncomment Region', '<<uncomment-region>>'),
67 ('Tabify Region', '<<tabify-region>>'),
68 ('Untabify Region', '<<untabify-region>>'),
69 ('Toggle Tabs', '<<toggle-tabs>>'),
70 ('New Indent Width', '<<change-indentwidth>>'),
wohlganger58fc71c2017-09-10 16:19:47 -050071 ('F_ormat Paragraph', '<<format-paragraph>>'),
72 ('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', [
Kurt B. Kaiserd375abe2002-12-24 00:51:05 +000076 ('Python Shell', '<<open-python-shell>>'),
wohlganger58fc71c2017-09-10 16:19:47 -050077 ('C_heck Module', '<<check-module>>'),
78 ('R_un Module', '<<run-module>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000079 ]),
Terry Jan Reedyea3dc802018-06-18 04:47:59 -040080
Kurt B. Kaiser1061e722003-01-04 01:43:53 +000081 ('shell', [
82 ('_View Last Restart', '<<view-restart>>'),
83 ('_Restart Shell', '<<restart-shell>>'),
Terry Jan Reedy4b736762016-09-12 01:50:03 -040084 None,
85 ('_Interrupt Execution', '<<interrupt-execution>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000086 ]),
Terry Jan Reedyea3dc802018-06-18 04:47:59 -040087
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000088 ('debug', [
Kurt B. Kaiserd375abe2002-12-24 00:51:05 +000089 ('_Go to File/Line', '<<goto-file-line>>'),
David Scherer7aced172000-08-15 01:13:23 +000090 ('!_Debugger', '<<toggle-debugger>>'),
Kurt B. Kaiser1061e722003-01-04 01:43:53 +000091 ('_Stack Viewer', '<<open-stack-viewer>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000092 ('!_Auto-open Stack Viewer', '<<toggle-jit-stack-viewer>>'),
93 ]),
Terry Jan Reedyea3dc802018-06-18 04:47:59 -040094
Kurt B. Kaiser1061e722003-01-04 01:43:53 +000095 ('options', [
Terry Jan Reedya9421fb2014-10-22 20:15:18 -040096 ('Configure _IDLE', '<<open-config-dialog>>'),
wohlganger58fc71c2017-09-10 16:19:47 -050097 ('_Code Context', '<<toggle-code-context>>'),
98 ]),
Terry Jan Reedyea3dc802018-06-18 04:47:59 -040099
Terry Jan Reedy33c74202018-06-20 22:49:55 -0400100 ('window', [
wohlganger58fc71c2017-09-10 16:19:47 -0500101 ('Zoom Height', '<<zoom-height>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +0000102 ]),
Terry Jan Reedyea3dc802018-06-18 04:47:59 -0400103
David Scherer7aced172000-08-15 01:13:23 +0000104 ('help', [
Kurt B. Kaiser8e92bf72003-01-14 22:03:31 +0000105 ('_About IDLE', '<<about-idle>>'),
David Scherer7aced172000-08-15 01:13:23 +0000106 None,
Kurt B. Kaiser8e92bf72003-01-14 22:03:31 +0000107 ('_IDLE Help', '<<help>>'),
108 ('Python _Docs', '<<python-docs>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +0000109 ]),
David Scherer7aced172000-08-15 01:13:23 +0000110]
111
Terry Jan Reedy7e55db22014-07-28 22:23:59 -0400112if find_spec('turtledemo'):
113 menudefs[-1][1].append(('Turtle Demo', '<<open-turtle-demo>>'))
114
Steven M. Gava72c3bf02002-01-19 10:41:51 +0000115default_keydefs = idleConf.GetCurrentKeySet()
Terry Jan Reedyea3dc802018-06-18 04:47:59 -0400116
117if __name__ == '__main__':
118 from unittest import main
119 main('idlelib.idle_test.test_mainmenu', verbosity=2)