1 | n/a | """Define the menu contents, hotkeys, and event bindings. |
---|
2 | n/a | |
---|
3 | n/a | There is additional configuration information in the EditorWindow class (and |
---|
4 | n/a | subclasses): the menus are created there based on the menu_specs (class) |
---|
5 | n/a | variable, and menus not created are silently skipped in the code here. This |
---|
6 | n/a | makes it possible, for example, to define a Debug menu which is only present in |
---|
7 | n/a | the PythonShell window, and a Format menu which is only present in the Editor |
---|
8 | n/a | windows. |
---|
9 | n/a | |
---|
10 | n/a | """ |
---|
11 | n/a | from importlib.util import find_spec |
---|
12 | n/a | |
---|
13 | n/a | from idlelib.config import idleConf |
---|
14 | n/a | |
---|
15 | n/a | # Warning: menudefs is altered in macosx.overrideRootMenu() |
---|
16 | n/a | # after it is determined that an OS X Aqua Tk is in use, |
---|
17 | n/a | # which cannot be done until after Tk() is first called. |
---|
18 | n/a | # Do not alter the 'file', 'options', or 'help' cascades here |
---|
19 | n/a | # without altering overrideRootMenu() as well. |
---|
20 | n/a | # TODO: Make this more robust |
---|
21 | n/a | |
---|
22 | n/a | menudefs = [ |
---|
23 | n/a | # underscore prefixes character to underscore |
---|
24 | n/a | ('file', [ |
---|
25 | n/a | ('_New File', '<<open-new-window>>'), |
---|
26 | n/a | ('_Open...', '<<open-window-from-file>>'), |
---|
27 | n/a | ('Open _Module...', '<<open-module>>'), |
---|
28 | n/a | ('Class _Browser', '<<open-class-browser>>'), |
---|
29 | n/a | ('_Path Browser', '<<open-path-browser>>'), |
---|
30 | n/a | None, |
---|
31 | n/a | ('_Save', '<<save-window>>'), |
---|
32 | n/a | ('Save _As...', '<<save-window-as-file>>'), |
---|
33 | n/a | ('Save Cop_y As...', '<<save-copy-of-window-as-file>>'), |
---|
34 | n/a | None, |
---|
35 | n/a | ('Prin_t Window', '<<print-window>>'), |
---|
36 | n/a | None, |
---|
37 | n/a | ('_Close', '<<close-window>>'), |
---|
38 | n/a | ('E_xit', '<<close-all-windows>>'), |
---|
39 | n/a | ]), |
---|
40 | n/a | ('edit', [ |
---|
41 | n/a | ('_Undo', '<<undo>>'), |
---|
42 | n/a | ('_Redo', '<<redo>>'), |
---|
43 | n/a | None, |
---|
44 | n/a | ('Cu_t', '<<cut>>'), |
---|
45 | n/a | ('_Copy', '<<copy>>'), |
---|
46 | n/a | ('_Paste', '<<paste>>'), |
---|
47 | n/a | ('Select _All', '<<select-all>>'), |
---|
48 | n/a | None, |
---|
49 | n/a | ('_Find...', '<<find>>'), |
---|
50 | n/a | ('Find A_gain', '<<find-again>>'), |
---|
51 | n/a | ('Find _Selection', '<<find-selection>>'), |
---|
52 | n/a | ('Find in Files...', '<<find-in-files>>'), |
---|
53 | n/a | ('R_eplace...', '<<replace>>'), |
---|
54 | n/a | ('Go to _Line', '<<goto-line>>'), |
---|
55 | n/a | ]), |
---|
56 | n/a | ('format', [ |
---|
57 | n/a | ('_Indent Region', '<<indent-region>>'), |
---|
58 | n/a | ('_Dedent Region', '<<dedent-region>>'), |
---|
59 | n/a | ('Comment _Out Region', '<<comment-region>>'), |
---|
60 | n/a | ('U_ncomment Region', '<<uncomment-region>>'), |
---|
61 | n/a | ('Tabify Region', '<<tabify-region>>'), |
---|
62 | n/a | ('Untabify Region', '<<untabify-region>>'), |
---|
63 | n/a | ('Toggle Tabs', '<<toggle-tabs>>'), |
---|
64 | n/a | ('New Indent Width', '<<change-indentwidth>>'), |
---|
65 | n/a | ]), |
---|
66 | n/a | ('run', [ |
---|
67 | n/a | ('Python Shell', '<<open-python-shell>>'), |
---|
68 | n/a | ]), |
---|
69 | n/a | ('shell', [ |
---|
70 | n/a | ('_View Last Restart', '<<view-restart>>'), |
---|
71 | n/a | ('_Restart Shell', '<<restart-shell>>'), |
---|
72 | n/a | None, |
---|
73 | n/a | ('_Interrupt Execution', '<<interrupt-execution>>'), |
---|
74 | n/a | ]), |
---|
75 | n/a | ('debug', [ |
---|
76 | n/a | ('_Go to File/Line', '<<goto-file-line>>'), |
---|
77 | n/a | ('!_Debugger', '<<toggle-debugger>>'), |
---|
78 | n/a | ('_Stack Viewer', '<<open-stack-viewer>>'), |
---|
79 | n/a | ('!_Auto-open Stack Viewer', '<<toggle-jit-stack-viewer>>'), |
---|
80 | n/a | ]), |
---|
81 | n/a | ('options', [ |
---|
82 | n/a | ('Configure _IDLE', '<<open-config-dialog>>'), |
---|
83 | n/a | None, |
---|
84 | n/a | ]), |
---|
85 | n/a | ('help', [ |
---|
86 | n/a | ('_About IDLE', '<<about-idle>>'), |
---|
87 | n/a | None, |
---|
88 | n/a | ('_IDLE Help', '<<help>>'), |
---|
89 | n/a | ('Python _Docs', '<<python-docs>>'), |
---|
90 | n/a | ]), |
---|
91 | n/a | ] |
---|
92 | n/a | |
---|
93 | n/a | if find_spec('turtledemo'): |
---|
94 | n/a | menudefs[-1][1].append(('Turtle Demo', '<<open-turtle-demo>>')) |
---|
95 | n/a | |
---|
96 | n/a | default_keydefs = idleConf.GetCurrentKeySet() |
---|