Index: Lib/idlelib/PyShell.py =================================================================== --- Lib/idlelib/PyShell.py (revision 74276) +++ Lib/idlelib/PyShell.py (working copy) @@ -840,6 +840,7 @@ # text = self.text text.configure(wrap="char") + text.bind("<>", self.paste_callback) text.bind("<>", self.enter_callback) text.bind("<>", self.linefeed_callback) text.bind("<>", self.cancel_callback) @@ -1032,6 +1033,39 @@ def isatty(self): return True + def paste_callback(self, event): + text = self.text + tk = text.tk + + try: + selection = tk.call('::tk::GetSelection', text, 'CLIPBOARD') + except TclError: + # No selection, probably. + return "break" + oldseparator = text.cget('autoseparators') + if oldseparator: + text.configure(autoseparators=0) + text.edit_separator() + if tk.call('tk', 'windowingsystem') != 'x11': + try: + text.delete('sel.first', 'sel.last') + except TclError: + # Nothing tagged with 'sel', probably. + pass + selection = selection.split('\n')[::-1] + while selection: + line = selection.pop() + if line == '': + text.event_generate('<>') + else: + text.insert('insert', line) + + if oldseparator: + text.edit_separator() + text.configure(autoseparators=1) + + return "break" + def cancel_callback(self, event=None): try: if self.text.compare("sel.first", "!=", "sel.last"):