diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2016-06-11 06:06:26 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2016-06-11 06:06:26 (GMT) |
commit | 5ad8599caad9f2f2fdefb927fc4bb19973d6c72e (patch) | |
tree | edcb731826ff92eff9ed46bdb13eccc43e4572f2 /Lib/idlelib/PyShell.py | |
parent | 904a2ef2e20ad22d324da18a9c98cb65666babb8 (diff) | |
download | cpython-5ad8599caad9f2f2fdefb927fc4bb19973d6c72e.zip cpython-5ad8599caad9f2f2fdefb927fc4bb19973d6c72e.tar.gz cpython-5ad8599caad9f2f2fdefb927fc4bb19973d6c72e.tar.bz2 |
Issue #5124: Paste with selection should always replace.
This is how paste work on Windows, Mac, modern Linux apps, and ttk widgets.
The exception was X11 tk widgets. Original patch by Serhiy Storchake.
Diffstat (limited to 'Lib/idlelib/PyShell.py')
-rwxr-xr-x | Lib/idlelib/PyShell.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py index 1bcc9b6..5dec68e 100755 --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -1396,6 +1396,17 @@ class PseudoInputFile(PseudoFile): self.shell.close() +def fix_x11_paste(root): + "Make paste replace selection on x11. See issue #5124." + if root._windowingsystem == 'x11': + for cls in 'Text', 'Entry', 'Spinbox': + root.bind_class( + cls, + '<<Paste>>', + 'catch {%W delete sel.first sel.last}\n' + + root.bind_class(cls, '<<Paste>>')) + + usage_msg = """\ USAGE: idle [-deins] [-t title] [file]* @@ -1528,8 +1539,10 @@ def main(): 'editor-on-startup', type='bool') enable_edit = enable_edit or edit_start enable_shell = enable_shell or not enable_edit + # start editor and/or shell windows: root = Tk(className="Idle") + root.withdraw() # set application icon icondir = os.path.join(os.path.dirname(__file__), 'Icons') @@ -1544,7 +1557,7 @@ def main(): root.wm_iconphoto(True, *icons) fixwordbreaks(root) - root.withdraw() + fix_x11_paste(root) flist = PyShellFileList(root) macosxSupport.setupApp(root, flist) |