aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-tui.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python/py-tui.c')
-rw-r--r--gdb/python/py-tui.c49
1 files changed, 43 insertions, 6 deletions
diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c
index 984fa9b..23a713e 100644
--- a/gdb/python/py-tui.c
+++ b/gdb/python/py-tui.c
@@ -1,6 +1,6 @@
/* TUI windows implemented in Python
- Copyright (C) 2020-2024 Free Software Foundation, Inc.
+ Copyright (C) 2020-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -36,6 +36,9 @@
#include "tui/tui-layout.h"
#include "tui/tui-wingeneral.h"
#include "tui/tui-winsource.h"
+#include "observable.h"
+#include "py-events.h"
+#include "py-event.h"
class tui_py_window;
@@ -95,7 +98,7 @@ public:
{
wnoutrefresh (handle.get ());
touchwin (m_inner_window.get ());
- tui_wrefresh (m_inner_window.get ());
+ wnoutrefresh (m_inner_window.get ());
}
else
tui_win_info::refresh_window ();
@@ -180,6 +183,8 @@ tui_py_window::~tui_py_window ()
void
tui_py_window::rerender ()
{
+ tui_batch_rendering batch;
+
tui_win_info::rerender ();
gdbpy_enter enter_py;
@@ -206,6 +211,8 @@ tui_py_window::rerender ()
void
tui_py_window::do_scroll_horizontal (int num_to_scroll)
{
+ tui_batch_rendering batch;
+
gdbpy_enter enter_py;
if (PyObject_HasAttrString (m_window.get (), "hscroll"))
@@ -220,6 +227,8 @@ tui_py_window::do_scroll_horizontal (int num_to_scroll)
void
tui_py_window::do_scroll_vertical (int num_to_scroll)
{
+ tui_batch_rendering batch;
+
gdbpy_enter enter_py;
if (PyObject_HasAttrString (m_window.get (), "vscroll"))
@@ -242,6 +251,8 @@ tui_py_window::resize (int height_, int width_, int origin_x_, int origin_y_)
void
tui_py_window::click (int mouse_x, int mouse_y, int mouse_button)
{
+ tui_batch_rendering batch;
+
gdbpy_enter enter_py;
if (PyObject_HasAttrString (m_window.get (), "click"))
@@ -258,6 +269,8 @@ tui_py_window::output (const char *text, bool full_window)
{
if (m_inner_window != nullptr)
{
+ tui_batch_rendering batch;
+
if (full_window)
werase (m_inner_window.get ());
@@ -265,7 +278,7 @@ tui_py_window::output (const char *text, bool full_window)
if (full_window)
check_and_display_highlight_if_needed ();
else
- tui_wrefresh (m_inner_window.get ());
+ wnoutrefresh (m_inner_window.get ());
}
}
@@ -415,8 +428,7 @@ gdbpy_register_tui_window (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- gdbpy_convert_exception (except);
- return nullptr;
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
Py_RETURN_NONE;
@@ -607,6 +619,29 @@ PyTypeObject gdbpy_tui_window_object_type =
0, /* tp_alloc */
};
+/* Called when TUI is enabled or disabled. */
+
+static void
+gdbpy_tui_enabled (bool state)
+{
+ gdbpy_enter enter_py;
+
+ if (evregpy_no_listeners_p (gdb_py_events.tui_enabled))
+ return;
+
+ gdbpy_ref<> event_obj = create_event_object (&tui_enabled_event_object_type);
+ if (event_obj == nullptr)
+ {
+ gdbpy_print_stack ();
+ return;
+ }
+
+ gdbpy_ref<> code (PyBool_FromLong (state));
+ if (evpy_add_attribute (event_obj.get (), "enabled", code.get ()) < 0
+ || evpy_emit_event (event_obj.get (), gdb_py_events.tui_enabled) < 0)
+ gdbpy_print_stack ();
+}
+
#endif /* TUI */
/* Initialize this module. */
@@ -616,8 +651,10 @@ gdbpy_initialize_tui ()
{
#ifdef TUI
gdbpy_tui_window_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&gdbpy_tui_window_object_type) < 0)
+ if (gdbpy_type_ready (&gdbpy_tui_window_object_type) < 0)
return -1;
+
+ gdb::observers::tui_enabled.attach (gdbpy_tui_enabled, "py-tui");
#endif /* TUI */
return 0;