Mercurial > cpython-lru_cache-weakref
diff Lib/idlelib/PyShell.py @ 80173:66643fcf6ee9 3.2
Issue #1207589: Add Cut/Copy/Paste items to IDLE right click Context Menu
Patch by Todd Rovito.
| author | Andrew Svetlov <andrew.svetlov@gmail.com> |
|---|---|
| date | Thu, 01 Nov 2012 22:41:19 +0200 |
| parents | 47536beb7453 |
| children | 0d26f3aa7a8f 3f3b72ab9d65 |
line wrap: on
line diff
--- a/Lib/idlelib/PyShell.py Thu Nov 01 21:47:54 2012 +0200 +++ b/Lib/idlelib/PyShell.py Thu Nov 01 22:41:19 2012 +0200 @@ -117,8 +117,14 @@ 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 @@ -1240,6 +1246,19 @@ 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):
