aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui/tui-wingeneral.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-10-01 17:29:49 -0600
committerTom Tromey <tom@tromey.com>2019-10-09 16:50:35 -0600
commit7523da63ca33a37b54c2cde18b7752d0f0f11c26 (patch)
tree9c89a33c5d2848fa4613e5b558136a6cd000fb24 /gdb/tui/tui-wingeneral.c
parenta7798e7f7dd1c4226376d455af957e369aa2a192 (diff)
downloadbinutils-7523da63ca33a37b54c2cde18b7752d0f0f11c26.zip
binutils-7523da63ca33a37b54c2cde18b7752d0f0f11c26.tar.gz
binutils-7523da63ca33a37b54c2cde18b7752d0f0f11c26.tar.bz2
Make TUI window handle a unique_ptr
This changes tui_gen_win_info::handle to be a specialization of unique_ptr. This is perhaps mildly uglier in some spots, due to the proliferation of "get"; but on the other hand it cleans up some manual management and it allows for the removal of tui_delete_win. gdb/ChangeLog 2019-10-09 Tom Tromey <tom@tromey.com> * tui/tui-wingeneral.h (tui_delete_win): Don't declare. * tui/tui-stack.c (tui_locator_window::rerender): Update. * tui/tui-command.c (tui_cmd_window::resize) (tui_refresh_cmd_win): Update. * tui/tui-win.c (tui_resize_all, tui_set_focus_command): Update. * tui/tui.c (tui_rl_other_window, tui_enable): Update. * tui/tui-data.c (~tui_gen_win_info): Remove. * tui/tui-layout.c (tui_gen_win_info::resize): Update. * tui/tui-io.c (update_cmdwin_start_line, tui_putc, tui_puts) (tui_redisplay_readline, tui_mld_flush) (tui_mld_erase_entire_line, tui_mld_getc, tui_getc): Update. * tui/tui-regs.c (tui_data_window::delete_data_content_windows) (tui_data_window::erase_data_content) (tui_data_item_window::rerender) (tui_data_item_window::refresh_window): Update. * tui/tui-wingeneral.c (tui_gen_win_info::refresh_window) (box_win, tui_gen_win_info::make_window) (tui_gen_win_info::make_visible): Update. (tui_delete_win): Remove. * tui/tui-winsource.c (tui_source_window_base::do_erase_source_content): Update. (tui_show_source_line, tui_source_window_base::update_tab_width) (tui_source_window_base::update_exec_info): Update. * tui/tui-data.h (struct curses_deleter): New. (struct tui_gen_win_info) <handle>: Now a unique_ptr. (struct tui_gen_win_info) <~tui_gen_win_info>: Define.
Diffstat (limited to 'gdb/tui/tui-wingeneral.c')
-rw-r--r--gdb/tui/tui-wingeneral.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 713059d..b6dd3f9 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -34,18 +34,9 @@ void
tui_gen_win_info::refresh_window ()
{
if (handle != NULL)
- wrefresh (handle);
+ wrefresh (handle.get ());
}
-/* Function to delete the curses window, checking for NULL. */
-void
-tui_delete_win (WINDOW *window)
-{
- if (window != NULL)
- delwin (window);
-}
-
-
/* Draw a border arround the window. */
static void
box_win (struct tui_win_info *win_info,
@@ -54,7 +45,7 @@ box_win (struct tui_win_info *win_info,
WINDOW *win;
int attrs;
- win = win_info->handle;
+ win = win_info->handle.get ();
if (highlight_flag)
attrs = tui_active_border_attrs;
else
@@ -132,9 +123,9 @@ tui_win_info::check_and_display_highlight_if_needed ()
void
tui_gen_win_info::make_window ()
{
- handle = newwin (height, width, origin.y, origin.x);
+ handle.reset (newwin (height, width, origin.y, origin.x));
if (handle != NULL)
- scrollok (handle, TRUE);
+ scrollok (handle.get (), TRUE);
}
void
@@ -157,10 +148,7 @@ tui_gen_win_info::make_visible (bool visible)
if (visible)
make_window ();
else
- {
- tui_delete_win (handle);
- handle = NULL;
- }
+ handle.reset (nullptr);
}
/* See tui-wingeneral.h. */