ยปCore Development>Code coverage>Lib/idlelib/Bindings.py

Python code coverage for Lib/idlelib/Bindings.py

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