blob: 74a93d3b141168abe6b94b344d177b6c22cac2b8 [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"""
David Scherer7aced172000-08-15 01:13:23 +000011import sys
Kurt B. Kaiser2d7f6a02007-08-22 23:01:33 +000012from idlelib.configHandler import idleConf
Ronald Oussoren827822e2009-02-12 15:01:44 +000013from idlelib import macosxSupport
David Scherer7aced172000-08-15 01:13:23 +000014
15menudefs = [
16 # underscore prefixes character to underscore
17 ('file', [
Kurt B. Kaiserd375abe2002-12-24 00:51:05 +000018 ('_New Window', '<<open-new-window>>'),
David Scherer7aced172000-08-15 01:13:23 +000019 ('_Open...', '<<open-window-from-file>>'),
Kurt B. Kaiserd375abe2002-12-24 00:51:05 +000020 ('Open _Module...', '<<open-module>>'),
21 ('Class _Browser', '<<open-class-browser>>'),
22 ('_Path Browser', '<<open-path-browser>>'),
David Scherer7aced172000-08-15 01:13:23 +000023 None,
24 ('_Save', '<<save-window>>'),
25 ('Save _As...', '<<save-window-as-file>>'),
Thomas Wouters00ee7ba2006-08-21 19:07:27 +000026 ('Save Cop_y As...', '<<save-copy-of-window-as-file>>'),
David Scherer7aced172000-08-15 01:13:23 +000027 None,
Thomas Wouters00ee7ba2006-08-21 19:07:27 +000028 ('Prin_t Window', '<<print-window>>'),
Steven M. Gava7981ce52002-06-11 04:45:34 +000029 None,
David Scherer7aced172000-08-15 01:13:23 +000030 ('_Close', '<<close-window>>'),
31 ('E_xit', '<<close-all-windows>>'),
32 ]),
33 ('edit', [
34 ('_Undo', '<<undo>>'),
35 ('_Redo', '<<redo>>'),
36 None,
Steven M. Gava82c66822002-02-18 01:45:43 +000037 ('Cu_t', '<<cut>>'),
38 ('_Copy', '<<copy>>'),
39 ('_Paste', '<<paste>>'),
David Scherer7aced172000-08-15 01:13:23 +000040 ('Select _All', '<<select-all>>'),
Steven M. Gavac5976402002-01-04 03:06:08 +000041 None,
42 ('_Find...', '<<find>>'),
Kurt B. Kaiserd375abe2002-12-24 00:51:05 +000043 ('Find A_gain', '<<find-again>>'),
44 ('Find _Selection', '<<find-selection>>'),
Steven M. Gavac5976402002-01-04 03:06:08 +000045 ('Find in Files...', '<<find-in-files>>'),
46 ('R_eplace...', '<<replace>>'),
Kurt B. Kaiserd375abe2002-12-24 00:51:05 +000047 ('Go to _Line', '<<goto-line>>'),
David Scherer7aced172000-08-15 01:13:23 +000048 ]),
Kurt B. Kaiser0c9b6172002-09-14 00:50:44 +000049('format', [
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000050 ('_Indent Region', '<<indent-region>>'),
51 ('_Dedent Region', '<<dedent-region>>'),
52 ('Comment _Out Region', '<<comment-region>>'),
53 ('U_ncomment Region', '<<uncomment-region>>'),
54 ('Tabify Region', '<<tabify-region>>'),
55 ('Untabify Region', '<<untabify-region>>'),
56 ('Toggle Tabs', '<<toggle-tabs>>'),
57 ('New Indent Width', '<<change-indentwidth>>'),
58 ]),
59 ('run', [
Kurt B. Kaiserd375abe2002-12-24 00:51:05 +000060 ('Python Shell', '<<open-python-shell>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000061 ]),
Kurt B. Kaiser1061e722003-01-04 01:43:53 +000062 ('shell', [
63 ('_View Last Restart', '<<view-restart>>'),
64 ('_Restart Shell', '<<restart-shell>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000065 ]),
66 ('debug', [
Kurt B. Kaiserd375abe2002-12-24 00:51:05 +000067 ('_Go to File/Line', '<<goto-file-line>>'),
David Scherer7aced172000-08-15 01:13:23 +000068 ('!_Debugger', '<<toggle-debugger>>'),
Kurt B. Kaiser1061e722003-01-04 01:43:53 +000069 ('_Stack Viewer', '<<open-stack-viewer>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000070 ('!_Auto-open Stack Viewer', '<<toggle-jit-stack-viewer>>'),
71 ]),
Kurt B. Kaiser1061e722003-01-04 01:43:53 +000072 ('options', [
Kurt B. Kaiser8e92bf72003-01-14 22:03:31 +000073 ('_Configure IDLE...', '<<open-config-dialog>>'),
Kurt B. Kaiser610c7e02004-04-24 03:01:48 +000074 None,
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000075 ]),
David Scherer7aced172000-08-15 01:13:23 +000076 ('help', [
Kurt B. Kaiser8e92bf72003-01-14 22:03:31 +000077 ('_About IDLE', '<<about-idle>>'),
David Scherer7aced172000-08-15 01:13:23 +000078 None,
Kurt B. Kaiser8e92bf72003-01-14 22:03:31 +000079 ('_IDLE Help', '<<help>>'),
80 ('Python _Docs', '<<python-docs>>'),
Kurt B. Kaiser4cc5ef52003-01-22 00:23:23 +000081 ]),
David Scherer7aced172000-08-15 01:13:23 +000082]
83
Ronald Oussoren827822e2009-02-12 15:01:44 +000084if macosxSupport.runningAsOSXApp():
Thomas Wouters0e3f5912006-08-11 14:57:12 +000085 # Running as a proper MacOS application bundle. This block restructures
86 # the menus a little to make them conform better to the HIG.
87
88 quitItem = menudefs[0][1][-1]
89 closeItem = menudefs[0][1][-2]
90
91 # Remove the last 3 items of the file menu: a separator, close window and
92 # quit. Close window will be reinserted just above the save item, where
93 # it should be according to the HIG. Quit is in the application menu.
94 del menudefs[0][1][-3:]
95 menudefs[0][1].insert(6, closeItem)
96
97 # Remove the 'About' entry from the help menu, it is in the application
98 # menu
99 del menudefs[-1][1][0:2]
100
101 menudefs.insert(0,
102 ('application', [
103 ('About IDLE', '<<about-idle>>'),
104 None,
105 ('_Preferences....', '<<open-config-dialog>>'),
106 ]))
107
108
Steven M. Gava72c3bf02002-01-19 10:41:51 +0000109default_keydefs = idleConf.GetCurrentKeySet()
David Scherer7aced172000-08-15 01:13:23 +0000110
111del sys