jpayne@68
|
1 """Define the menu contents, hotkeys, and event bindings.
|
jpayne@68
|
2
|
jpayne@68
|
3 There is additional configuration information in the EditorWindow class (and
|
jpayne@68
|
4 subclasses): the menus are created there based on the menu_specs (class)
|
jpayne@68
|
5 variable, and menus not created are silently skipped in the code here. This
|
jpayne@68
|
6 makes it possible, for example, to define a Debug menu which is only present in
|
jpayne@68
|
7 the PythonShell window, and a Format menu which is only present in the Editor
|
jpayne@68
|
8 windows.
|
jpayne@68
|
9
|
jpayne@68
|
10 """
|
jpayne@68
|
11 from importlib.util import find_spec
|
jpayne@68
|
12
|
jpayne@68
|
13 from idlelib.config import idleConf
|
jpayne@68
|
14
|
jpayne@68
|
15 # Warning: menudefs is altered in macosx.overrideRootMenu()
|
jpayne@68
|
16 # after it is determined that an OS X Aqua Tk is in use,
|
jpayne@68
|
17 # which cannot be done until after Tk() is first called.
|
jpayne@68
|
18 # Do not alter the 'file', 'options', or 'help' cascades here
|
jpayne@68
|
19 # without altering overrideRootMenu() as well.
|
jpayne@68
|
20 # TODO: Make this more robust
|
jpayne@68
|
21
|
jpayne@68
|
22 menudefs = [
|
jpayne@68
|
23 # underscore prefixes character to underscore
|
jpayne@68
|
24 ('file', [
|
jpayne@68
|
25 ('_New File', '<<open-new-window>>'),
|
jpayne@68
|
26 ('_Open...', '<<open-window-from-file>>'),
|
jpayne@68
|
27 ('Open _Module...', '<<open-module>>'),
|
jpayne@68
|
28 ('Module _Browser', '<<open-class-browser>>'),
|
jpayne@68
|
29 ('_Path Browser', '<<open-path-browser>>'),
|
jpayne@68
|
30 None,
|
jpayne@68
|
31 ('_Save', '<<save-window>>'),
|
jpayne@68
|
32 ('Save _As...', '<<save-window-as-file>>'),
|
jpayne@68
|
33 ('Save Cop_y As...', '<<save-copy-of-window-as-file>>'),
|
jpayne@68
|
34 None,
|
jpayne@68
|
35 ('Prin_t Window', '<<print-window>>'),
|
jpayne@68
|
36 None,
|
jpayne@68
|
37 ('_Close', '<<close-window>>'),
|
jpayne@68
|
38 ('E_xit', '<<close-all-windows>>'),
|
jpayne@68
|
39 ]),
|
jpayne@68
|
40
|
jpayne@68
|
41 ('edit', [
|
jpayne@68
|
42 ('_Undo', '<<undo>>'),
|
jpayne@68
|
43 ('_Redo', '<<redo>>'),
|
jpayne@68
|
44 None,
|
jpayne@68
|
45 ('Cu_t', '<<cut>>'),
|
jpayne@68
|
46 ('_Copy', '<<copy>>'),
|
jpayne@68
|
47 ('_Paste', '<<paste>>'),
|
jpayne@68
|
48 ('Select _All', '<<select-all>>'),
|
jpayne@68
|
49 None,
|
jpayne@68
|
50 ('_Find...', '<<find>>'),
|
jpayne@68
|
51 ('Find A_gain', '<<find-again>>'),
|
jpayne@68
|
52 ('Find _Selection', '<<find-selection>>'),
|
jpayne@68
|
53 ('Find in Files...', '<<find-in-files>>'),
|
jpayne@68
|
54 ('R_eplace...', '<<replace>>'),
|
jpayne@68
|
55 ('Go to _Line', '<<goto-line>>'),
|
jpayne@68
|
56 ('S_how Completions', '<<force-open-completions>>'),
|
jpayne@68
|
57 ('E_xpand Word', '<<expand-word>>'),
|
jpayne@68
|
58 ('Show C_all Tip', '<<force-open-calltip>>'),
|
jpayne@68
|
59 ('Show Surrounding P_arens', '<<flash-paren>>'),
|
jpayne@68
|
60 ]),
|
jpayne@68
|
61
|
jpayne@68
|
62 ('format', [
|
jpayne@68
|
63 ('F_ormat Paragraph', '<<format-paragraph>>'),
|
jpayne@68
|
64 ('_Indent Region', '<<indent-region>>'),
|
jpayne@68
|
65 ('_Dedent Region', '<<dedent-region>>'),
|
jpayne@68
|
66 ('Comment _Out Region', '<<comment-region>>'),
|
jpayne@68
|
67 ('U_ncomment Region', '<<uncomment-region>>'),
|
jpayne@68
|
68 ('Tabify Region', '<<tabify-region>>'),
|
jpayne@68
|
69 ('Untabify Region', '<<untabify-region>>'),
|
jpayne@68
|
70 ('Toggle Tabs', '<<toggle-tabs>>'),
|
jpayne@68
|
71 ('New Indent Width', '<<change-indentwidth>>'),
|
jpayne@68
|
72 ('S_trip Trailing Whitespace', '<<do-rstrip>>'),
|
jpayne@68
|
73 ]),
|
jpayne@68
|
74
|
jpayne@68
|
75 ('run', [
|
jpayne@68
|
76 ('R_un Module', '<<run-module>>'),
|
jpayne@68
|
77 ('Run... _Customized', '<<run-custom>>'),
|
jpayne@68
|
78 ('C_heck Module', '<<check-module>>'),
|
jpayne@68
|
79 ('Python Shell', '<<open-python-shell>>'),
|
jpayne@68
|
80 ]),
|
jpayne@68
|
81
|
jpayne@68
|
82 ('shell', [
|
jpayne@68
|
83 ('_View Last Restart', '<<view-restart>>'),
|
jpayne@68
|
84 ('_Restart Shell', '<<restart-shell>>'),
|
jpayne@68
|
85 None,
|
jpayne@68
|
86 ('_Previous History', '<<history-previous>>'),
|
jpayne@68
|
87 ('_Next History', '<<history-next>>'),
|
jpayne@68
|
88 None,
|
jpayne@68
|
89 ('_Interrupt Execution', '<<interrupt-execution>>'),
|
jpayne@68
|
90 ]),
|
jpayne@68
|
91
|
jpayne@68
|
92 ('debug', [
|
jpayne@68
|
93 ('_Go to File/Line', '<<goto-file-line>>'),
|
jpayne@68
|
94 ('!_Debugger', '<<toggle-debugger>>'),
|
jpayne@68
|
95 ('_Stack Viewer', '<<open-stack-viewer>>'),
|
jpayne@68
|
96 ('!_Auto-open Stack Viewer', '<<toggle-jit-stack-viewer>>'),
|
jpayne@68
|
97 ]),
|
jpayne@68
|
98
|
jpayne@68
|
99 ('options', [
|
jpayne@68
|
100 ('Configure _IDLE', '<<open-config-dialog>>'),
|
jpayne@68
|
101 None,
|
jpayne@68
|
102 ('Show _Code Context', '<<toggle-code-context>>'),
|
jpayne@68
|
103 ('Show _Line Numbers', '<<toggle-line-numbers>>'),
|
jpayne@68
|
104 ('_Zoom Height', '<<zoom-height>>'),
|
jpayne@68
|
105 ]),
|
jpayne@68
|
106
|
jpayne@68
|
107 ('window', [
|
jpayne@68
|
108 ]),
|
jpayne@68
|
109
|
jpayne@68
|
110 ('help', [
|
jpayne@68
|
111 ('_About IDLE', '<<about-idle>>'),
|
jpayne@68
|
112 None,
|
jpayne@68
|
113 ('_IDLE Help', '<<help>>'),
|
jpayne@68
|
114 ('Python _Docs', '<<python-docs>>'),
|
jpayne@68
|
115 ]),
|
jpayne@68
|
116 ]
|
jpayne@68
|
117
|
jpayne@68
|
118 if find_spec('turtledemo'):
|
jpayne@68
|
119 menudefs[-1][1].append(('Turtle Demo', '<<open-turtle-demo>>'))
|
jpayne@68
|
120
|
jpayne@68
|
121 default_keydefs = idleConf.GetCurrentKeySet()
|
jpayne@68
|
122
|
jpayne@68
|
123 if __name__ == '__main__':
|
jpayne@68
|
124 from unittest import main
|
jpayne@68
|
125 main('idlelib.idle_test.test_mainmenu', verbosity=2)
|