]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Forward mouse click to python TUI window
authorHannes Domani <ssbssa@yahoo.de>
Sun, 20 Dec 2020 16:25:09 +0000 (17:25 +0100)
committerHannes Domani <ssbssa@yahoo.de>
Fri, 4 Jun 2021 14:18:10 +0000 (16:18 +0200)
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.

gdb/ChangeLog
gdb/doc/ChangeLog
gdb/doc/python.texi
gdb/python/py-tui.c

index fca6750de384a6d6199aa11216e2a5fbec788ea2..875d8b7db0e8f4459b27a91006730e19c4b2c4cf 100644 (file)
@@ -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.
index e78c4d4a8d8a028dabf5e738a54e61bae554ed29..82bc4f61eba3221dcb30029976f023a6f9959612 100644 (file)
@@ -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.
index f05d39f96c050f1a04bef013a21f022ec5014ff4..7b7f0692b3a5fff160b6959d84c81fed8c2079de 100644 (file)
@@ -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
index 97e9de7a00cb20830b910cf33c33ef8b48b6ef25..8dfed9d341f34bad0a58f30b5acbd569155edf7d 100644 (file)
@@ -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)
 {