qemu-devel
[Top][All Lists]
Advanced

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

[PATCH v3 13/13] python/aqmp-tui: Allow copying message from TUI


From: G S Niteesh Babu
Subject: [PATCH v3 13/13] python/aqmp-tui: Allow copying message from TUI
Date: Sat, 31 Jul 2021 01:48:46 +0530

This commit adds a feature that enables use to copy
messages from the TUI after highlighting the message
in the history box using up/down arrow keys and pressing
alt-c.

Signed-off-by: G S Niteesh Babu <niteesh.gs@gmail.com>
---
 python/qemu/aqmp/aqmp_tui.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/python/qemu/aqmp/aqmp_tui.py b/python/qemu/aqmp/aqmp_tui.py
index 4bae0d4e89..434f431a35 100644
--- a/python/qemu/aqmp/aqmp_tui.py
+++ b/python/qemu/aqmp/aqmp_tui.py
@@ -21,6 +21,7 @@
 
 from pygments import lexers
 from pygments import token as Token
+import pyperclip
 import urwid
 import urwid_readline
 
@@ -390,6 +391,14 @@ def keypress(self, size: Tuple[int, int], key: str) -> 
Optional[str]:
                 self._update_highlighting()
                 self.change_focus(size, self.highlighting)
             return None
+        if key == 'meta c':
+            if self.highlighting == -1:
+                return None
+            widget = self.history[self.highlighting].original_widget
+            text = widget.get_text()[0]
+            LOGGER.info('Text is %s', text)
+            pyperclip.copy(text)
+            return None
 
         # Remove highlighting if someother key is pressed
         if self.highlighting != -1:
-- 
2.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]