[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 10/13] python/aqmp-tui: Add scrolling to history box
From: |
G S Niteesh Babu |
Subject: |
[PATCH v3 10/13] python/aqmp-tui: Add scrolling to history box |
Date: |
Sat, 31 Jul 2021 01:48:43 +0530 |
Adds scroll support to history box. The list can now be scrolled
using arrow keys, page up/down and the mouse.
The current implementation requires the widget to be in focus
to enable scrolling. Therefore the user has to click on the widget
before scrolling.
Signed-off-by: G S Niteesh Babu <niteesh.gs@gmail.com>
---
python/qemu/aqmp/aqmp_tui.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/python/qemu/aqmp/aqmp_tui.py b/python/qemu/aqmp/aqmp_tui.py
index ef91883fa5..fb828b1a27 100644
--- a/python/qemu/aqmp/aqmp_tui.py
+++ b/python/qemu/aqmp/aqmp_tui.py
@@ -351,6 +351,19 @@ def add_to_history(self,
if self.history:
self.history.set_focus(len(self.history) - 1)
+ def mouse_event(self, size: Tuple[int, int], _event: str, button: float,
+ _x: int, _y: int, focus: bool) -> None:
+ # Scroll only on focus. Therefore it is required to
+ # click on the widget to enable scrolling.
+ if not focus:
+ return
+ # button == 4 represents scroll up event
+ if button == 4.0:
+ super().keypress(size, 'up')
+ # button == 5 represents scroll down event
+ elif button == 5.0:
+ super().keypress(size, 'down')
+
class HistoryWindow(urwid.Frame):
"""
--
2.17.1
- [PATCH v3 00/13] AQMP TUI Draft, G S Niteesh Babu, 2021/07/30
- [PATCH v3 01/13] python/aqmp: Fix wait_closed work-around for python 3.6, G S Niteesh Babu, 2021/07/30
- [PATCH v3 02/13] python: disable pylint errors for aqmp-tui, G S Niteesh Babu, 2021/07/30
- [PATCH v3 03/13] python: Add dependencies for AQMP TUI, G S Niteesh Babu, 2021/07/30
- [PATCH v3 04/13] python/aqmp-tui: Add AQMP TUI draft, G S Niteesh Babu, 2021/07/30
- [PATCH v3 05/13] python: add entry point for aqmp-tui, G S Niteesh Babu, 2021/07/30
- [PATCH v3 06/13] python/aqmp-tui: Added type annotations for aqmp-tui, G S Niteesh Babu, 2021/07/30
- [PATCH v3 07/13] python: add optional pygments dependency, G S Niteesh Babu, 2021/07/30
- [PATCH v3 08/13] python/aqmp-tui: add syntax highlighting, G S Niteesh Babu, 2021/07/30
- [PATCH v3 09/13] python/aqmp-tui: Add QMP connection manager, G S Niteesh Babu, 2021/07/30
- [PATCH v3 10/13] python/aqmp-tui: Add scrolling to history box,
G S Niteesh Babu <=
- [PATCH v3 11/13] python/aqmp-tui: Add ability to highlight messages, G S Niteesh Babu, 2021/07/30
- [PATCH v3 12/13] python/aqmp-tui: Add pyperclip dependency, G S Niteesh Babu, 2021/07/30
- [PATCH v3 13/13] python/aqmp-tui: Allow copying message from TUI, G S Niteesh Babu, 2021/07/30