[accerciser: 3/4] ipython_view: Copy selection to clipboard on Ctrl+C (Ctrl+Shift+c)




commit 750eb94f8f3b562c3d1dda38840b57449fb143f7
Author: Michael Weghorn <m weghorn posteo de>
Date:   Wed Aug 3 10:51:42 2022 +0200

    ipython_view: Copy selection to clipboard on Ctrl+C (Ctrl+Shift+c)
    
    This adds the functionality to copy the current selection
    in the iypthon_view to the clipboard
    by pressing Ctrl+C (upper-case 'C' only).
    
    Ctrl+c (lower-case 'C') is already used to trigger
    a keyboard interrupt.
    Use Ctrl+C (upper-case 'C') as an alternative
    to copy text as e.g. various terminal emulators (like
    gnome-terminal or konsole) also do.

 plugins/ipython_view.py | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/plugins/ipython_view.py b/plugins/ipython_view.py
index 832bbba..956991e 100755
--- a/plugins/ipython_view.py
+++ b/plugins/ipython_view.py
@@ -580,6 +580,10 @@ class ConsoleView(gtk.TextView):
       if insert_iter.editable(True):
         self.text_buffer.delete(insert_iter, self.text_buffer.get_end_iter())
       return True
+    elif event.state & gdk.ModifierType.CONTROL_MASK and event.keyval == gdk.KEY_C:
+      # copy selection on Ctrl+C (upper-case 'C' only)
+      self.text_buffer.copy_clipboard(gtk.Clipboard.get(gdk.SELECTION_CLIPBOARD))
+      return True
     elif not event.string:
       pass
     elif start_iter.compare(insert_iter) <= 0 and \


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]