annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/idlelib/mainmenu.py @ 69:33d812a61356

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