diff options
author | Tom Tromey <tom@tromey.com> | 2020-02-22 11:48:26 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-02-22 12:57:25 -0700 |
commit | 01b1af321f804ef6dfd40d3054c8757f31096ea8 (patch) | |
tree | 03c14bda00b71bb7322ff5d2bfc3e2355b37e932 /gdb/tui/tui-layout.c | |
parent | fc96d20b2c6d7ff24349ad015119438077d3f1e9 (diff) | |
download | fsf-binutils-gdb-01b1af321f804ef6dfd40d3054c8757f31096ea8.zip fsf-binutils-gdb-01b1af321f804ef6dfd40d3054c8757f31096ea8.tar.gz fsf-binutils-gdb-01b1af321f804ef6dfd40d3054c8757f31096ea8.tar.bz2 |
Allow TUI windows in Python
This patch adds support for writing new TUI windows in Python.
2020-02-22 Tom Tromey <tom@tromey.com>
* NEWS: Add entry for gdb.register_window_type.
* tui/tui-layout.h (window_factory): New typedef.
(tui_register_window): Declare.
* tui/tui-layout.c (saved_tui_windows): New global.
(tui_apply_current_layout): Use it.
(tui_register_window): New function.
* python/python.c (do_start_initialization): Call
gdbpy_initialize_tui.
(python_GdbMethods): Add "register_window_type" function.
* python/python-internal.h (gdbpy_register_tui_window)
(gdbpy_initialize_tui): Declare.
* python/py-tui.c: New file.
* Makefile.in (SUBDIR_PYTHON_SRCS): Add py-tui.c.
gdb/doc/ChangeLog
2020-02-22 Tom Tromey <tom@tromey.com>
* python.texi (Python API): Add menu item.
(TUI Windows In Python): New node.
gdb/testsuite/ChangeLog
2020-02-22 Tom Tromey <tom@tromey.com>
* gdb.python/tui-window.exp: New file.
* gdb.python/tui-window.py: New file.
Change-Id: I85fbfb923a1840450a00a7dce113a05d7f048baa
Diffstat (limited to 'gdb/tui/tui-layout.c')
-rw-r--r-- | gdb/tui/tui-layout.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 748a106..66c7449 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -65,6 +65,11 @@ static tui_layout_split *asm_regs_layout; /* See tui-data.h. */ std::vector<tui_win_info *> tui_windows; +/* When applying a layout, this is the list of all windows that were + in the previous layout. This is used to re-use windows when + changing a layout. */ +static std::vector<tui_win_info *> saved_tui_windows; + /* See tui-layout.h. */ void @@ -75,10 +80,10 @@ tui_apply_current_layout () extract_display_start_addr (&gdbarch, &addr); - std::vector<tui_win_info *> saved_windows = std::move (tui_windows); + saved_tui_windows = std::move (tui_windows); tui_windows.clear (); - for (tui_win_info *win_info : saved_windows) + for (tui_win_info *win_info : saved_tui_windows) win_info->make_visible (false); applied_layout->apply (0, 0, tui_term_width (), tui_term_height ()); @@ -94,7 +99,7 @@ tui_apply_current_layout () /* Now delete any window that was not re-applied. */ tui_win_info *focus = tui_win_with_focus (); - for (tui_win_info *win_info : saved_windows) + for (tui_win_info *win_info : saved_tui_windows) { if (!win_info->is_visible ()) { @@ -107,6 +112,8 @@ tui_apply_current_layout () if (gdbarch == nullptr && TUI_DISASM_WIN != nullptr) tui_get_begin_asm_address (&gdbarch, &addr); tui_update_source_windows_with_addr (gdbarch, addr); + + saved_tui_windows.clear (); } /* See tui-layout. */ @@ -395,6 +402,21 @@ initialize_known_windows () /* See tui-layout.h. */ +void +tui_register_window (const char *name, window_factory &&factory) +{ + std::string name_copy = name; + + if (name_copy == "src" || name_copy == "cmd" || name_copy == "regs" + || name_copy == "asm" || name_copy == "status") + error (_("Window type \"%s\" is built-in"), name); + + known_window_types->emplace (std::move (name_copy), + std::move (factory)); +} + +/* See tui-layout.h. */ + std::unique_ptr<tui_layout_base> tui_layout_window::clone () const { |