[binutils-gdb] Forward mouse click to python TUI window
Hannes Domani
ssbssa@sourceware.org
Fri Jun 4 14:20:39 GMT 2021
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a53755664f5f904aefd0d0b87e12f9adb6b69129
commit a53755664f5f904aefd0d0b87e12f9adb6b69129
Author: Hannes Domani <ssbssa@yahoo.de>
Date: Sun Dec 20 17:25:09 2020 +0100
Forward mouse click to python TUI window
If the TUI window object implements the click method, it is called for each
mouse click event in this window.
gdb/ChangeLog:
2021-06-04 Hannes Domani <ssbssa@yahoo.de>
* python/py-tui.c (class tui_py_window): Add click function.
(tui_py_window::click): Likewise.
gdb/doc/ChangeLog:
2021-06-04 Hannes Domani <ssbssa@yahoo.de>
* python.texi (TUI Windows In Python): Document Window.click.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/doc/ChangeLog | 4 ++++
gdb/doc/python.texi | 7 +++++++
gdb/python/py-tui.c | 17 +++++++++++++++++
4 files changed, 33 insertions(+)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fca6750de38..875d8b7db0e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2021-06-04 Hannes Domani <ssbssa@yahoo.de>
+
+ * python/py-tui.c (class tui_py_window): Add click function.
+ (tui_py_window::click): Likewise.
+
2021-06-04 Hannes Domani <ssbssa@yahoo.de>
* ser-mingw.c (console_select_thread): Handle MOUSE_EVENT.
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index e78c4d4a8d8..82bc4f61eba 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,7 @@
+2021-06-04 Hannes Domani <ssbssa@yahoo.de>
+
+ * python.texi (TUI Windows In Python): Document Window.click.
+
2021-05-29 Hannes Domani <ssbssa@yahoo.de>
* python.texi (Writing a Frame Filter): Fix example.
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index f05d39f96c0..7b7f0692b3a 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -6016,6 +6016,13 @@ contents. A positive argument should cause the viewport to move down,
and so the content should appear to move up.
@end defun
+@defun Window.click (@var{x}, @var{y}, @var{button})
+This is called on a mouse click in this window. @var{x} and @var{y} are
+the mouse coordinates inside the window (0-based), and @var{button}
+specifies which mouse button was used, whose values can be 1 (left),
+2 (middle), or 3 (right).
+@end defun
+
@node Python Auto-loading
@subsection Python Auto-loading
@cindex Python auto-loading
diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c
index 97e9de7a00c..8dfed9d341f 100644
--- a/gdb/python/py-tui.c
+++ b/gdb/python/py-tui.c
@@ -101,6 +101,8 @@ public:
tui_win_info::refresh_window ();
}
+ void click (int mouse_x, int mouse_y, int mouse_button) override;
+
/* Erase and re-box the window. */
void erase ()
{
@@ -229,6 +231,21 @@ tui_py_window::do_scroll_vertical (int num_to_scroll)
}
}
+void
+tui_py_window::click (int mouse_x, int mouse_y, int mouse_button)
+{
+ gdbpy_enter enter_py (get_current_arch (), current_language);
+
+ if (PyObject_HasAttrString (m_window.get (), "click"))
+ {
+ gdbpy_ref<> result (PyObject_CallMethod (m_window.get (), "click",
+ "iii", mouse_x, mouse_y,
+ mouse_button));
+ if (result == nullptr)
+ gdbpy_print_stack ();
+ }
+}
+
void
tui_py_window::output (const char *text, bool full_window)
{
More information about the Gdb-cvs
mailing list