diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-11-01 20:39:14 (GMT) |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-11-01 20:39:14 (GMT) |
commit | 5018db76aa433430e1bdb0826086df1c025a1f70 (patch) | |
tree | 0d4c426e53eac287d2fa77c54230b8837b4a9bb7 /Lib/idlelib/PyShell.py | |
parent | 2c184c6d75bb60ec7f8f564a91b4ac55d4796da7 (diff) | |
download | cpython-5018db76aa433430e1bdb0826086df1c025a1f70.zip cpython-5018db76aa433430e1bdb0826086df1c025a1f70.tar.gz cpython-5018db76aa433430e1bdb0826086df1c025a1f70.tar.bz2 |
Issue #1207589: Add Cut/Copy/Paste items to IDLE right click Context Menu
Patch by Todd Rovito.
Diffstat (limited to 'Lib/idlelib/PyShell.py')
-rw-r--r-- | Lib/idlelib/PyShell.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py index d6f3ce3..15ca392 100644 --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -122,8 +122,13 @@ class PyShellEditorWindow(EditorWindow): old_hook() self.io.set_filename_change_hook(filename_changed_hook) - rmenu_specs = [("Set Breakpoint", "<<set-breakpoint-here>>"), - ("Clear Breakpoint", "<<clear-breakpoint-here>>")] + rmenu_specs = [ + ("Cut", "<<cut>>", "rmenu_check_cut"), + ("Copy", "<<copy>>", "rmenu_check_copy"), + ("Paste", "<<paste>>", "rmenu_check_paste"), + ("Set Breakpoint", "<<set-breakpoint-here>>", None), + ("Clear Breakpoint", "<<clear-breakpoint-here>>", None) + ] def set_breakpoint(self, lineno): text = self.text @@ -1261,6 +1266,19 @@ class PyShell(OutputWindow): if not use_subprocess: raise KeyboardInterrupt + def rmenu_check_cut(self): + try: + if self.text.compare('sel.first', '<', 'iomark'): + return 'disabled' + except TclError: # no selection, so the index 'sel.first' doesn't exist + return 'disabled' + return super(PyShell, self).rmenu_check_cut() + + def rmenu_check_paste(self): + if self.text.compare('insert', '<', 'iomark'): + return 'disabled' + return super(PyShell, self).rmenu_check_paste() + class PseudoFile(object): def __init__(self, shell, tags, encoding=None): |