* [PATCH 4/6] Remove declaration from tui-wingeneral.h
2019-10-02 23:12 [PATCH 0/6] More TUI updates Tom Tromey
@ 2019-10-02 23:12 ` Tom Tromey
2019-10-02 23:12 ` [PATCH 1/6] Remove two TUI comments Tom Tromey
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2019-10-02 23:12 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
tui-wingeneral.h has an unused forward declaration. This removes it.
gdb/ChangeLog
2019-10-02 Tom Tromey <tom@tromey.com>
* tui/tui-wingeneral.h (struct tui_gen_win_info): Don't declare.
---
gdb/ChangeLog | 4 ++++
gdb/tui/tui-wingeneral.h | 1 -
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/gdb/tui/tui-wingeneral.h b/gdb/tui/tui-wingeneral.h
index 53d72327b94..1831d7b7cb6 100644
--- a/gdb/tui/tui-wingeneral.h
+++ b/gdb/tui/tui-wingeneral.h
@@ -25,7 +25,6 @@
#include "gdb_curses.h"
struct tui_win_info;
-struct tui_gen_win_info;
/* Makes all windows invisible. */
extern void tui_make_all_invisible (void);
--
2.17.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 6/6] Don't call erase_data_content from tui_data_window::show_registers
2019-10-02 23:12 [PATCH 0/6] More TUI updates Tom Tromey
2019-10-02 23:12 ` [PATCH 4/6] Remove declaration from tui-wingeneral.h Tom Tromey
2019-10-02 23:12 ` [PATCH 1/6] Remove two TUI comments Tom Tromey
@ 2019-10-02 23:12 ` Tom Tromey
2019-10-02 23:12 ` [PATCH 5/6] Make TUI window handle a unique_ptr Tom Tromey
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2019-10-02 23:12 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
tui_data_window::show_registers currently calls erase_data_content.
However, I think it's better to have fewer calls to this (ideally just
one would suffice). This refactors that function to remove this call.
gdb/ChangeLog
2019-10-02 Tom Tromey <tom@tromey.com>
* tui/tui-regs.c (tui_data_window::show_registers): Don't call
erase_data_content.
---
gdb/ChangeLog | 5 +++++
gdb/tui/tui-regs.c | 5 +++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 474b62e2047..1d936f712b6 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -154,13 +154,14 @@ tui_data_window::show_registers (struct reggroup *group)
for (auto &&data_item_win : m_regs_content)
data_item_win.highlight = false;
m_current_group = group;
- rerender ();
}
else
{
m_current_group = 0;
- erase_data_content (_("[ Register Values Unavailable ]"));
+ m_regs_content.clear ();
}
+
+ rerender ();
}
--
2.17.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/6] Remove two TUI comments
2019-10-02 23:12 [PATCH 0/6] More TUI updates Tom Tromey
2019-10-02 23:12 ` [PATCH 4/6] Remove declaration from tui-wingeneral.h Tom Tromey
@ 2019-10-02 23:12 ` Tom Tromey
2019-10-02 23:12 ` [PATCH 6/6] Don't call erase_data_content from tui_data_window::show_registers Tom Tromey
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2019-10-02 23:12 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This removes two comments from tui.h. These were not useful.
gdb/ChangeLog
2019-10-02 Tom Tromey <tom@tromey.com>
* tui/tui.h: Remove comments.
---
gdb/ChangeLog | 4 ++++
gdb/tui/tui.h | 2 --
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/gdb/tui/tui.h b/gdb/tui/tui.h
index baf4a813b60..dac410fcfa1 100644
--- a/gdb/tui/tui.h
+++ b/gdb/tui/tui.h
@@ -45,8 +45,6 @@ enum tui_win_type
DATA_ITEM_WIN
};
-/* GENERAL TUI FUNCTIONS */
-/* tui.c */
extern CORE_ADDR tui_get_low_disassembly_address (struct gdbarch *,
CORE_ADDR, CORE_ADDR);
extern void tui_show_assembly (struct gdbarch *gdbarch, CORE_ADDR addr);
--
2.17.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 5/6] Make TUI window handle a unique_ptr
2019-10-02 23:12 [PATCH 0/6] More TUI updates Tom Tromey
` (2 preceding siblings ...)
2019-10-02 23:12 ` [PATCH 6/6] Don't call erase_data_content from tui_data_window::show_registers Tom Tromey
@ 2019-10-02 23:12 ` Tom Tromey
2019-10-02 23:22 ` [PATCH 3/6] Remove tui_win_is_auxiliary Tom Tromey
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2019-10-02 23:12 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
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-02 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.
---
gdb/ChangeLog | 29 +++++++++++++++++++++++++++++
gdb/tui/tui-command.c | 8 ++++----
gdb/tui/tui-data.c | 5 -----
gdb/tui/tui-data.h | 15 +++++++++++++--
gdb/tui/tui-io.c | 23 ++++++++++-------------
gdb/tui/tui-layout.c | 9 ++++-----
gdb/tui/tui-regs.c | 29 +++++++++++++----------------
gdb/tui/tui-stack.c | 14 +++++++-------
gdb/tui/tui-win.c | 6 +++---
gdb/tui/tui-wingeneral.c | 22 +++++-----------------
gdb/tui/tui-wingeneral.h | 1 -
gdb/tui/tui-winsource.c | 22 +++++++++++-----------
gdb/tui/tui.c | 6 +++---
13 files changed, 102 insertions(+), 87 deletions(-)
diff --git a/gdb/tui/tui-command.c b/gdb/tui/tui-command.c
index 62595808cd8..9a432971339 100644
--- a/gdb/tui/tui-command.c
+++ b/gdb/tui/tui-command.c
@@ -64,10 +64,10 @@ tui_cmd_window::resize (int height_, int width_, int origin_x, int origin_y)
it. However we can at least move it and keep the old size if
wresize isn't available. */
#ifdef HAVE_WRESIZE
- wresize (handle, height, width);
+ wresize (handle.get (), height, width);
#endif
- mvwin (handle, origin.y, origin.x);
- wmove (handle, 0, 0);
+ mvwin (handle.get (), origin.y, origin.x);
+ wmove (handle.get (), 0, 0);
}
}
@@ -76,7 +76,7 @@ tui_cmd_window::resize (int height_, int width_, int origin_x, int origin_y)
void
tui_refresh_cmd_win (void)
{
- WINDOW *w = TUI_CMD_WIN->handle;
+ WINDOW *w = TUI_CMD_WIN->handle.get ();
wrefresh (w);
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index f1f3947e028..522bb9acebd 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -205,11 +205,6 @@ tui_win_info::tui_win_info (enum tui_win_type type)
{
}
-tui_gen_win_info::~tui_gen_win_info ()
-{
- tui_delete_win (handle);
-}
-
void
tui_win_info::rerender ()
{
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 6d4fb78334f..4710c760211 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -36,6 +36,15 @@ struct tui_point
int x, y;
};
+/* A deleter that calls delwin. */
+struct curses_deleter
+{
+ void operator() (WINDOW *win) const
+ {
+ delwin (win);
+ }
+};
+
/* Generic window information. */
struct tui_gen_win_info
{
@@ -57,7 +66,9 @@ protected:
public:
tui_gen_win_info (tui_gen_win_info &&) = default;
- virtual ~tui_gen_win_info ();
+ virtual ~tui_gen_win_info ()
+ {
+ }
/* Call to refresh this window. */
virtual void refresh_window ();
@@ -83,7 +94,7 @@ public:
}
/* Window handle. */
- WINDOW *handle = nullptr;
+ std::unique_ptr<WINDOW, curses_deleter> handle;
/* Type of window. */
enum tui_win_type type;
/* Window width. */
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index ee581a2ff66..6bb495beaa9 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -179,8 +179,7 @@ do_tui_putc (WINDOW *w, char c)
static void
update_cmdwin_start_line ()
{
- TUI_CMD_WIN->start_line
- = getcury (TUI_CMD_WIN->handle);
+ TUI_CMD_WIN->start_line = getcury (TUI_CMD_WIN->handle.get ());
}
/* Print a character in the curses command window. The output is
@@ -190,9 +189,7 @@ update_cmdwin_start_line ()
static void
tui_putc (char c)
{
- WINDOW *w = TUI_CMD_WIN->handle;
-
- do_tui_putc (w, c);
+ do_tui_putc (TUI_CMD_WIN->handle.get (), c);
update_cmdwin_start_line ();
}
@@ -495,7 +492,7 @@ tui_puts_internal (WINDOW *w, const char *string, int *height)
}
}
}
- if (TUI_CMD_WIN != nullptr && w == TUI_CMD_WIN->handle)
+ if (TUI_CMD_WIN != nullptr && w == TUI_CMD_WIN->handle.get ())
update_cmdwin_start_line ();
if (saw_nl)
wrefresh (w);
@@ -509,7 +506,7 @@ void
tui_puts (const char *string, WINDOW *w)
{
if (w == nullptr)
- w = TUI_CMD_WIN->handle;
+ w = TUI_CMD_WIN->handle.get ();
tui_puts_internal (w, string, nullptr);
}
@@ -545,13 +542,13 @@ tui_redisplay_readline (void)
c_pos = -1;
c_line = -1;
- w = TUI_CMD_WIN->handle;
+ w = TUI_CMD_WIN->handle.get ();
start_line = TUI_CMD_WIN->start_line;
wmove (w, start_line, 0);
prev_col = 0;
height = 1;
if (prompt != nullptr)
- tui_puts_internal (TUI_CMD_WIN->handle, prompt, &height);
+ tui_puts_internal (w, prompt, &height);
prev_col = getcurx (w);
for (in = 0; in <= rl_end; in++)
@@ -670,7 +667,7 @@ tui_mld_puts (const struct match_list_displayer *displayer, const char *s)
static void
tui_mld_flush (const struct match_list_displayer *displayer)
{
- wrefresh (TUI_CMD_WIN->handle);
+ wrefresh (TUI_CMD_WIN->handle.get ());
}
/* TUI version of displayer.erase_entire_line. */
@@ -678,7 +675,7 @@ tui_mld_flush (const struct match_list_displayer *displayer)
static void
tui_mld_erase_entire_line (const struct match_list_displayer *displayer)
{
- WINDOW *w = TUI_CMD_WIN->handle;
+ WINDOW *w = TUI_CMD_WIN->handle.get ();
int cur_y = getcury (w);
wmove (w, cur_y, 0);
@@ -716,7 +713,7 @@ gdb_wgetch (WINDOW *win)
static int
tui_mld_getc (FILE *fp)
{
- WINDOW *w = TUI_CMD_WIN->handle;
+ WINDOW *w = TUI_CMD_WIN->handle.get ();
int c = gdb_wgetch (w);
return c;
@@ -970,7 +967,7 @@ tui_getc (FILE *fp)
int ch;
WINDOW *w;
- w = TUI_CMD_WIN->handle;
+ w = TUI_CMD_WIN->handle.get ();
#ifdef TUI_USE_PIPE_FOR_READLINE
/* Flush readline output. */
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index ccc750e1db4..3a510f436d2 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -511,12 +511,11 @@ tui_gen_win_info::resize (int height_, int width_,
if (handle != nullptr)
{
#ifdef HAVE_WRESIZE
- wresize (handle, height, width);
- mvwin (handle, origin.y, origin.x);
- wmove (handle, 0, 0);
+ wresize (handle.get (), height, width);
+ mvwin (handle.get (), origin.y, origin.x);
+ wmove (handle.get (), 0, 0);
#else
- tui_delete_win (handle);
- handle = NULL;
+ handle.reset (nullptr);
#endif
}
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index c4769cbcb43..474b62e2047 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -361,17 +361,14 @@ void
tui_data_window::delete_data_content_windows ()
{
for (auto &&win : m_regs_content)
- {
- tui_delete_win (win.handle);
- win.handle = NULL;
- }
+ win.handle.reset (nullptr);
}
void
tui_data_window::erase_data_content (const char *prompt)
{
- werase (handle);
+ werase (handle.get ());
check_and_display_highlight_if_needed ();
if (prompt != NULL)
{
@@ -382,9 +379,9 @@ tui_data_window::erase_data_content (const char *prompt)
x_pos = 1;
else
x_pos = half_width - strlen (prompt);
- mvwaddstr (handle, (height / 2), x_pos, (char *) prompt);
+ mvwaddstr (handle.get (), (height / 2), x_pos, (char *) prompt);
}
- wrefresh (handle);
+ wrefresh (handle.get ());
}
/* See tui-regs.h. */
@@ -470,21 +467,21 @@ tui_data_item_window::rerender ()
{
int i;
- scrollok (handle, FALSE);
+ scrollok (handle.get (), FALSE);
if (highlight)
/* We ignore the return value, casting it to void in order to avoid
a compiler warning. The warning itself was introduced by a patch
to ncurses 5.7 dated 2009-08-29, changing this macro to expand
to code that causes the compiler to generate an unused-value
warning. */
- (void) wstandout (handle);
+ (void) wstandout (handle.get ());
- wmove (handle, 0, 0);
+ wmove (handle.get (), 0, 0);
for (i = 1; i < width; i++)
- waddch (handle, ' ');
- wmove (handle, 0, 0);
+ waddch (handle.get (), ' ');
+ wmove (handle.get (), 0, 0);
if (content)
- waddstr (handle, content.get ());
+ waddstr (handle.get (), content.get ());
if (highlight)
/* We ignore the return value, casting it to void in order to avoid
@@ -492,7 +489,7 @@ tui_data_item_window::rerender ()
to ncurses 5.7 dated 2009-08-29, changing this macro to expand
to code that causes the compiler to generate an unused-value
warning. */
- (void) wstandend (handle);
+ (void) wstandend (handle.get ());
refresh_window ();
}
@@ -504,8 +501,8 @@ tui_data_item_window::refresh_window ()
/* This seems to be needed because the data items are nested
windows, which according to the ncurses man pages aren't well
supported. */
- touchwin (handle);
- wrefresh (handle);
+ touchwin (handle.get ());
+ wrefresh (handle.get ());
}
}
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index d66e3589e42..078f81992ab 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -229,19 +229,19 @@ tui_locator_window::rerender ()
if (handle != NULL)
{
std::string string = make_status_line ();
- scrollok (handle, FALSE);
- wmove (handle, 0, 0);
+ scrollok (handle.get (), FALSE);
+ wmove (handle.get (), 0, 0);
/* We ignore the return value from wstandout and wstandend, casting
them to void in order to avoid a compiler warning. The warning
itself was introduced by a patch to ncurses 5.7 dated 2009-08-29,
changing these macro to expand to code that causes the compiler
to generate an unused-value warning. */
- (void) wstandout (handle);
- waddstr (handle, string.c_str ());
- wclrtoeol (handle);
- (void) wstandend (handle);
+ (void) wstandout (handle.get ());
+ waddstr (handle.get (), string.c_str ());
+ wclrtoeol (handle.get ());
+ (void) wstandend (handle.get ());
refresh_window ();
- wmove (handle, 0, 0);
+ wmove (handle.get (), 0, 0);
}
}
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 37e22c550f9..41c61f12b21 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -529,7 +529,7 @@ tui_resize_all (void)
#endif
/* Turn keypad off while we resize. */
if (win_with_focus != TUI_CMD_WIN)
- keypad (TUI_CMD_WIN->handle, FALSE);
+ keypad (TUI_CMD_WIN->handle.get (), FALSE);
tui_update_gdb_sizes ();
tui_set_term_height_to (screenheight);
tui_set_term_width_to (screenwidth);
@@ -639,7 +639,7 @@ tui_resize_all (void)
/* Turn keypad back on, unless focus is in the command
window. */
if (win_with_focus != TUI_CMD_WIN)
- keypad (TUI_CMD_WIN->handle, TRUE);
+ keypad (TUI_CMD_WIN->handle.get (), TRUE);
}
}
@@ -791,7 +791,7 @@ tui_set_focus_command (const char *arg, int from_tty)
error (_("Window \"%s\" is not visible"), arg);
tui_set_win_focus_to (win_info);
- keypad (TUI_CMD_WIN->handle, (win_info != TUI_CMD_WIN));
+ keypad (TUI_CMD_WIN->handle.get (), win_info != TUI_CMD_WIN);
printf_filtered (_("Focus set to %s window.\n"),
tui_win_with_focus ()->name ());
}
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 713059d6632..b6dd3f9b26a 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. */
diff --git a/gdb/tui/tui-wingeneral.h b/gdb/tui/tui-wingeneral.h
index 1831d7b7cb6..9995250ce9a 100644
--- a/gdb/tui/tui-wingeneral.h
+++ b/gdb/tui/tui-wingeneral.h
@@ -32,6 +32,5 @@ extern void tui_make_all_invisible (void);
extern void tui_unhighlight_win (struct tui_win_info *);
extern void tui_highlight_win (struct tui_win_info *);
extern void tui_refresh_all ();
-extern void tui_delete_win (WINDOW *window);
#endif /* TUI_TUI_WINGENERAL_H */
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 683856de817..f1c9f958a99 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -193,14 +193,14 @@ tui_source_window_base::do_erase_source_content (const char *str)
content.clear ();
if (handle != NULL)
{
- werase (handle);
+ werase (handle.get ());
check_and_display_highlight_if_needed ();
if (strlen (str) >= half_width)
x_pos = 1;
else
x_pos = half_width - strlen (str);
- mvwaddstr (handle,
+ mvwaddstr (handle.get (),
(height / 2),
x_pos,
(char *) str);
@@ -219,19 +219,19 @@ tui_show_source_line (struct tui_source_window_base *win_info, int lineno)
line = &win_info->content[lineno - 1];
if (line->is_exec_point)
- tui_set_reverse_mode (win_info->handle, true);
+ tui_set_reverse_mode (win_info->handle.get (), true);
- wmove (win_info->handle, lineno, TUI_EXECINFO_SIZE);
- tui_puts (line->line.get (), win_info->handle);
+ wmove (win_info->handle.get (), lineno, TUI_EXECINFO_SIZE);
+ tui_puts (line->line.get (), win_info->handle.get ());
if (line->is_exec_point)
- tui_set_reverse_mode (win_info->handle, false);
+ tui_set_reverse_mode (win_info->handle.get (), false);
/* Clear to end of line but stop before the border. */
- x = getcurx (win_info->handle);
+ x = getcurx (win_info->handle.get ());
while (x + 1 < win_info->width)
{
- waddch (win_info->handle, ' ');
- x = getcurx (win_info->handle);
+ waddch (win_info->handle.get (), ' ');
+ x = getcurx (win_info->handle.get ());
}
}
@@ -261,7 +261,7 @@ tui_source_window_base::tui_source_window_base (enum tui_win_type type)
void
tui_source_window_base::update_tab_width ()
{
- werase (handle);
+ werase (handle.get ());
rerender ();
}
@@ -479,7 +479,7 @@ tui_source_window_base::update_exec_info ()
if (src_element->is_exec_point)
element[TUI_EXEC_POS] = '>';
- mvwaddstr (handle, i + 1, 1, element);
+ mvwaddstr (handle.get (), i + 1, 1, element);
}
refresh_window ();
}
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index 30bf5488794..e765d58f97d 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -237,7 +237,7 @@ tui_rl_other_window (int count, int key)
if (win_info)
{
tui_set_win_focus_to (win_info);
- keypad (TUI_CMD_WIN->handle, (win_info != TUI_CMD_WIN));
+ keypad (TUI_CMD_WIN->handle.get (), win_info != TUI_CMD_WIN);
}
return 0;
}
@@ -478,8 +478,8 @@ tui_enable (void)
tui_show_frame_info (0);
tui_set_layout (SRC_COMMAND);
tui_set_win_focus_to (TUI_SRC_WIN);
- keypad (TUI_CMD_WIN->handle, TRUE);
- wrefresh (TUI_CMD_WIN->handle);
+ keypad (TUI_CMD_WIN->handle.get (), TRUE);
+ wrefresh (TUI_CMD_WIN->handle.get ());
tui_finish_init = 0;
}
else
--
2.17.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 0/6] More TUI updates
@ 2019-10-02 23:12 Tom Tromey
2019-10-02 23:12 ` [PATCH 4/6] Remove declaration from tui-wingeneral.h Tom Tromey
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Tom Tromey @ 2019-10-02 23:12 UTC (permalink / raw)
To: gdb-patches
Here are a few more minor TUI updates I found. A couple of these are
trivial.
Regression tested using the x86-64 builder on the buildbot.
Tom
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/6] Remove tui_win_is_auxiliary
2019-10-02 23:12 [PATCH 0/6] More TUI updates Tom Tromey
` (3 preceding siblings ...)
2019-10-02 23:12 ` [PATCH 5/6] Make TUI window handle a unique_ptr Tom Tromey
@ 2019-10-02 23:22 ` Tom Tromey
2019-10-02 23:22 ` [PATCH 2/6] Remove tui_default_win_viewport_height Tom Tromey
2019-10-09 22:50 ` [PATCH 0/6] More TUI updates Tom Tromey
6 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2019-10-02 23:22 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
tui_win_is_auxiliary is not used, so remove it.
gdb/ChangeLog
2019-10-02 Tom Tromey <tom@tromey.com>
* tui/tui-data.c (tui_win_is_auxiliary): Remove.
* tui/tui-data.h (tui_win_is_auxiliary): Don't declare.
---
gdb/ChangeLog | 5 +++++
gdb/tui/tui-data.c | 6 ------
gdb/tui/tui-data.h | 2 --
3 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 748d8978218..f1f3947e028 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -34,12 +34,6 @@ static struct tui_win_info *win_with_focus = NULL;
static bool win_resized = false;
-int
-tui_win_is_auxiliary (enum tui_win_type win_type)
-{
- return (win_type > MAX_MAJOR_WINDOWS);
-}
-
/* Answer a whether the terminal window has been resized or not. */
bool
tui_win_resized ()
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 264652361ef..6d4fb78334f 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -207,8 +207,6 @@ public:
bool is_highlighted = false;
};
-extern int tui_win_is_auxiliary (enum tui_win_type win_type);
-
/* Global Data. */
extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
--
2.17.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/6] Remove tui_default_win_viewport_height
2019-10-02 23:12 [PATCH 0/6] More TUI updates Tom Tromey
` (4 preceding siblings ...)
2019-10-02 23:22 ` [PATCH 3/6] Remove tui_win_is_auxiliary Tom Tromey
@ 2019-10-02 23:22 ` Tom Tromey
2019-10-09 22:50 ` [PATCH 0/6] More TUI updates Tom Tromey
6 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2019-10-02 23:22 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
tui_default_win_viewport_height was only called from a single spot,
for a single type of window. This patch removes the function and
moves the logic into the sole caller.
gdb/ChangeLog
2019-10-02 Tom Tromey <tom@tromey.com>
* tui/tui-disasm.c (tui_get_low_disassembly_address): Compute
window height directly.
* tui/tui-layout.h (tui_default_win_viewport_height): Don't
declare.
* tui/tui-layout.c (tui_default_win_height): Remove.
(tui_default_win_viewport_height): Remove.
---
gdb/ChangeLog | 9 +++++++
gdb/tui/tui-disasm.c | 10 +++++++-
gdb/tui/tui-layout.c | 60 --------------------------------------------
gdb/tui/tui-layout.h | 2 --
4 files changed, 18 insertions(+), 63 deletions(-)
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 51616bcf874..33a3ba12d47 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -28,6 +28,7 @@
#include "source.h"
#include "disasm.h"
#include "tui/tui.h"
+#include "tui/tui-command.h"
#include "tui/tui-data.h"
#include "tui/tui-win.h"
#include "tui/tui-layout.h"
@@ -325,7 +326,14 @@ tui_get_low_disassembly_address (struct gdbarch *gdbarch,
/* Determine where to start the disassembly so that the pc is about
in the middle of the viewport. */
- pos = tui_default_win_viewport_height (DISASSEM_WIN, DISASSEM_COMMAND) / 2;
+ if (tui_win_list[DISASSEM_WIN] != NULL)
+ pos = tui_win_list[DISASSEM_WIN]->height;
+ else if (TUI_CMD_WIN == NULL)
+ pos = tui_term_height () / 2 - 2;
+ else
+ pos = tui_term_height () - TUI_CMD_WIN->height - 2;
+ pos = (pos - 2) / 2;
+
pc = tui_find_disassembly_address (gdbarch, pc, -pos);
if (pc < low)
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 7aa670ec69d..ccc750e1db4 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -233,66 +233,6 @@ tui_add_win_to_layout (enum tui_win_type type)
}
}
-
-/* Answer the height of a window. If it hasn't been created yet,
- answer what the height of a window would be based upon its type and
- the layout. */
-static int
-tui_default_win_height (enum tui_win_type type,
- enum tui_layout_type layout)
-{
- int h;
-
- if (tui_win_list[type] != NULL)
- h = tui_win_list[type]->height;
- else
- {
- switch (layout)
- {
- case SRC_COMMAND:
- case DISASSEM_COMMAND:
- if (TUI_CMD_WIN == NULL)
- h = tui_term_height () / 2;
- else
- h = tui_term_height () - TUI_CMD_WIN->height;
- break;
- case SRC_DISASSEM_COMMAND:
- case SRC_DATA_COMMAND:
- case DISASSEM_DATA_COMMAND:
- if (TUI_CMD_WIN == NULL)
- h = tui_term_height () / 3;
- else
- h = (tui_term_height () - TUI_CMD_WIN->height) / 2;
- break;
- default:
- h = 0;
- break;
- }
- }
-
- return h;
-}
-
-
-/* Answer the height of a window. If it hasn't been created yet,
- answer what the height of a window would be based upon its type and
- the layout. */
-int
-tui_default_win_viewport_height (enum tui_win_type type,
- enum tui_layout_type layout)
-{
- int h;
-
- h = tui_default_win_height (type, layout);
-
- if (type == CMD_WIN)
- h -= 1;
- else
- h -= 2;
-
- return h;
-}
-
/* Complete possible layout names. TEXT is the complete text entered so
far, WORD is the word currently being completed. */
diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h
index a7e1e908983..23f05f34aa2 100644
--- a/gdb/tui/tui-layout.h
+++ b/gdb/tui/tui-layout.h
@@ -26,8 +26,6 @@
#include "tui/tui-data.h"
extern void tui_add_win_to_layout (enum tui_win_type);
-extern int tui_default_win_viewport_height (enum tui_win_type,
- enum tui_layout_type);
extern void tui_set_layout (enum tui_layout_type);
#endif /* TUI_TUI_LAYOUT_H */
--
2.17.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/6] More TUI updates
2019-10-02 23:12 [PATCH 0/6] More TUI updates Tom Tromey
` (5 preceding siblings ...)
2019-10-02 23:22 ` [PATCH 2/6] Remove tui_default_win_viewport_height Tom Tromey
@ 2019-10-09 22:50 ` Tom Tromey
6 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2019-10-09 22:50 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
Tom> Here are a few more minor TUI updates I found. A couple of these are
Tom> trivial.
Tom> Regression tested using the x86-64 builder on the buildbot.
I'm checking these in now.
Tom
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-10-09 22:50 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-02 23:12 [PATCH 0/6] More TUI updates Tom Tromey
2019-10-02 23:12 ` [PATCH 4/6] Remove declaration from tui-wingeneral.h Tom Tromey
2019-10-02 23:12 ` [PATCH 1/6] Remove two TUI comments Tom Tromey
2019-10-02 23:12 ` [PATCH 6/6] Don't call erase_data_content from tui_data_window::show_registers Tom Tromey
2019-10-02 23:12 ` [PATCH 5/6] Make TUI window handle a unique_ptr Tom Tromey
2019-10-02 23:22 ` [PATCH 3/6] Remove tui_win_is_auxiliary Tom Tromey
2019-10-02 23:22 ` [PATCH 2/6] Remove tui_default_win_viewport_height Tom Tromey
2019-10-09 22:50 ` [PATCH 0/6] More TUI updates Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).