Merge issue #1207589: Add Cut/Copy/Paste items to IDLE right click Context Menu

Patch by Todd Rovito.
This commit is contained in:
Andrew Svetlov 2012-11-01 22:44:06 +02:00
commit e2af509829
6 changed files with 98 additions and 13 deletions

View file

@ -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
@ -1256,6 +1262,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):