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 | import sys |
---|
12 | n/a | from idlelib.configHandler import idleConf |
---|
13 | n/a | from idlelib import macosxSupport |
---|
14 | n/a | |
---|
15 | n/a | menudefs = [ |
---|
16 | n/a | # underscore prefixes character to underscore |
---|
17 | n/a | ('file', [ |
---|
18 | n/a | ('_New File', '<<open-new-window>>'), |
---|
19 | n/a | ('_Open...', '<<open-window-from-file>>'), |
---|
20 | n/a | ('Open _Module...', '<<open-module>>'), |
---|
21 | n/a | ('Class _Browser', '<<open-class-browser>>'), |
---|
22 | n/a | ('_Path Browser', '<<open-path-browser>>'), |
---|
23 | n/a | None, |
---|
24 | n/a | ('_Save', '<<save-window>>'), |
---|
25 | n/a | ('Save _As...', '<<save-window-as-file>>'), |
---|
26 | n/a | ('Save Cop_y As...', '<<save-copy-of-window-as-file>>'), |
---|
27 | n/a | None, |
---|
28 | n/a | ('Prin_t Window', '<<print-window>>'), |
---|
29 | n/a | None, |
---|
30 | n/a | ('_Close', '<<close-window>>'), |
---|
31 | n/a | ('E_xit', '<<close-all-windows>>'), |
---|
32 | n/a | ]), |
---|
33 | n/a | ('edit', [ |
---|
34 | n/a | ('_Undo', '<<undo>>'), |
---|
35 | n/a | ('_Redo', '<<redo>>'), |
---|
36 | n/a | None, |
---|
37 | n/a | ('Cu_t', '<<cut>>'), |
---|
38 | n/a | ('_Copy', '<<copy>>'), |
---|
39 | n/a | ('_Paste', '<<paste>>'), |
---|
40 | n/a | ('Select _All', '<<select-all>>'), |
---|
41 | n/a | None, |
---|
42 | n/a | ('_Find...', '<<find>>'), |
---|
43 | n/a | ('Find A_gain', '<<find-again>>'), |
---|
44 | n/a | ('Find _Selection', '<<find-selection>>'), |
---|
45 | n/a | ('Find in Files...', '<<find-in-files>>'), |
---|
46 | n/a | ('R_eplace...', '<<replace>>'), |
---|
47 | n/a | ('Go to _Line', '<<goto-line>>'), |
---|
48 | n/a | ]), |
---|
49 | n/a | ('format', [ |
---|
50 | n/a | ('_Indent Region', '<<indent-region>>'), |
---|
51 | n/a | ('_Dedent Region', '<<dedent-region>>'), |
---|
52 | n/a | ('Comment _Out Region', '<<comment-region>>'), |
---|
53 | n/a | ('U_ncomment Region', '<<uncomment-region>>'), |
---|
54 | n/a | ('Tabify Region', '<<tabify-region>>'), |
---|
55 | n/a | ('Untabify Region', '<<untabify-region>>'), |
---|
56 | n/a | ('Toggle Tabs', '<<toggle-tabs>>'), |
---|
57 | n/a | ('New Indent Width', '<<change-indentwidth>>'), |
---|
58 | n/a | ]), |
---|
59 | n/a | ('run', [ |
---|
60 | n/a | ('Python Shell', '<<open-python-shell>>'), |
---|
61 | n/a | ]), |
---|
62 | n/a | ('shell', [ |
---|
63 | n/a | ('_View Last Restart', '<<view-restart>>'), |
---|
64 | n/a | ('_Restart Shell', '<<restart-shell>>'), |
---|
65 | n/a | ]), |
---|
66 | n/a | ('debug', [ |
---|
67 | n/a | ('_Go to File/Line', '<<goto-file-line>>'), |
---|
68 | n/a | ('!_Debugger', '<<toggle-debugger>>'), |
---|
69 | n/a | ('_Stack Viewer', '<<open-stack-viewer>>'), |
---|
70 | n/a | ('!_Auto-open Stack Viewer', '<<toggle-jit-stack-viewer>>'), |
---|
71 | n/a | ]), |
---|
72 | n/a | ('options', [ |
---|
73 | n/a | ('_Configure IDLE...', '<<open-config-dialog>>'), |
---|
74 | n/a | None, |
---|
75 | n/a | ]), |
---|
76 | n/a | ('help', [ |
---|
77 | n/a | ('_About IDLE', '<<about-idle>>'), |
---|
78 | n/a | None, |
---|
79 | n/a | ('_IDLE Help', '<<help>>'), |
---|
80 | n/a | ('Python _Docs', '<<python-docs>>'), |
---|
81 | n/a | ]), |
---|
82 | n/a | ] |
---|
83 | n/a | |
---|
84 | n/a | if macosxSupport.runningAsOSXApp(): |
---|
85 | n/a | # Running as a proper MacOS application bundle. This block restructures |
---|
86 | n/a | # the menus a little to make them conform better to the HIG. |
---|
87 | n/a | |
---|
88 | n/a | quitItem = menudefs[0][1][-1] |
---|
89 | n/a | closeItem = menudefs[0][1][-2] |
---|
90 | n/a | |
---|
91 | n/a | # Remove the last 3 items of the file menu: a separator, close window and |
---|
92 | n/a | # quit. Close window will be reinserted just above the save item, where |
---|
93 | n/a | # it should be according to the HIG. Quit is in the application menu. |
---|
94 | n/a | del menudefs[0][1][-3:] |
---|
95 | n/a | menudefs[0][1].insert(6, closeItem) |
---|
96 | n/a | |
---|
97 | n/a | # Remove the 'About' entry from the help menu, it is in the application |
---|
98 | n/a | # menu |
---|
99 | n/a | del menudefs[-1][1][0:2] |
---|
100 | n/a | |
---|
101 | n/a | # Remove the 'Configure' entry from the options menu, it is in the |
---|
102 | n/a | # application menu as 'Preferences' |
---|
103 | n/a | del menudefs[-2][1][0:2] |
---|
104 | n/a | |
---|
105 | n/a | default_keydefs = idleConf.GetCurrentKeySet() |
---|
106 | n/a | |
---|
107 | n/a | del sys |
---|