summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/PyShell.py
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2012-11-01 20:44:45 (GMT)
committerAndrew Svetlov <andrew.svetlov@gmail.com>2012-11-01 20:44:45 (GMT)
commitd98ee9781b6d1a2fc890253814cdcb05588321d7 (patch)
treea187e0aa8c8549671e3f668aca120fca367902f8 /Lib/idlelib/PyShell.py
parente0614327ffbae71ba71202015f23047b0c523c72 (diff)
parente2af5098295c97aae8802d8dc7c332bd75e6ab89 (diff)
downloadcpython-d98ee9781b6d1a2fc890253814cdcb05588321d7.zip
cpython-d98ee9781b6d1a2fc890253814cdcb05588321d7.tar.gz
cpython-d98ee9781b6d1a2fc890253814cdcb05588321d7.tar.bz2
Merge 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.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index 142c924..bff52a9 100644
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -117,8 +117,14 @@ 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"),
+ (None, None, None),
+ ("Set Breakpoint", "<<set-breakpoint-here>>", None),
+ ("Clear Breakpoint", "<<clear-breakpoint-here>>", None)
+ ]
def set_breakpoint(self, lineno):
text = self.text
@@ -1259,6 +1265,19 @@ class PyShell(OutputWindow):
raise KeyboardInterrupt
return count
+ 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().rmenu_check_cut()
+
+ def rmenu_check_paste(self):
+ if self.text.compare('insert','<','iomark'):
+ return 'disabled'
+ return super().rmenu_check_paste()
+
class PseudoFile(object):
def __init__(self, shell, tags, encoding=None):