Bindings.py 2.8 KB

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