mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-28 15:18:37 +08:00
Change tui_make_window to be a method
I combined several small changes into one patch here. I believe I started by noticing that the "title" is not needed by tui_gen_win_info and could be self-managing (i.e. std::string). Moving this revealed that "can_box" is also a property of tui_win_info and not tui_gen_win_info; and this in turn caused the changes to tui_make_window and box_win. 2019-08-20 Tom Tromey <tom@tromey.com> * tui/tui-wingeneral.h (tui_make_window): Don't declare. * tui/tui-wingeneral.c (box_win): Change type of win_info. (box_win): Update. (tui_gen_win_info::make_window): Rename from tui_make_window. (tui_win_info::make_window): New method. (tui_gen_win_info::make_visible): Update. * tui/tui-source.c (tui_source_window::set_contents): Update. * tui/tui-regs.c (tui_data_window::show_register_group): Update. (tui_data_window::display_registers_from): Update. * tui/tui-layout.c (tui_gen_win_info::resize): Update. * tui/tui-data.h (struct tui_gen_win_info) <make_window>: Declare. <can_box>: Remove. <title>: Remove. (struct tui_win_info) <make_window>: Declare. <can_box>: Now virtual. <title>: New member. * tui/tui-data.c (~tui_gen_win_info): Don't free title. * tui/tui-command.c (tui_cmd_window::resize): Update.
This commit is contained in:
@ -1,3 +1,25 @@
|
|||||||
|
2019-08-20 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* tui/tui-wingeneral.h (tui_make_window): Don't declare.
|
||||||
|
* tui/tui-wingeneral.c (box_win): Change type of win_info.
|
||||||
|
(box_win): Update.
|
||||||
|
(tui_gen_win_info::make_window): Rename from tui_make_window.
|
||||||
|
(tui_win_info::make_window): New method.
|
||||||
|
(tui_gen_win_info::make_visible): Update.
|
||||||
|
* tui/tui-source.c (tui_source_window::set_contents): Update.
|
||||||
|
* tui/tui-regs.c (tui_data_window::show_register_group): Update.
|
||||||
|
(tui_data_window::display_registers_from): Update.
|
||||||
|
* tui/tui-layout.c (tui_gen_win_info::resize): Update.
|
||||||
|
* tui/tui-data.h (struct tui_gen_win_info) <make_window>:
|
||||||
|
Declare.
|
||||||
|
<can_box>: Remove.
|
||||||
|
<title>: Remove.
|
||||||
|
(struct tui_win_info) <make_window>: Declare.
|
||||||
|
<can_box>: Now virtual.
|
||||||
|
<title>: New member.
|
||||||
|
* tui/tui-data.c (~tui_gen_win_info): Don't free title.
|
||||||
|
* tui/tui-command.c (tui_cmd_window::resize): Update.
|
||||||
|
|
||||||
2019-08-20 Tom Tromey <tom@tromey.com>
|
2019-08-20 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* tui/tui-regs.h (struct tui_data_window) <display_regs>: Remove.
|
* tui/tui-regs.h (struct tui_data_window) <display_regs>: Remove.
|
||||||
|
@ -54,7 +54,7 @@ tui_cmd_window::resize (int height_, int width_, int origin_x, int origin_y)
|
|||||||
origin.y = origin_y;
|
origin.y = origin_y;
|
||||||
|
|
||||||
if (handle == nullptr)
|
if (handle == nullptr)
|
||||||
tui_make_window (this);
|
make_window ();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Another reason we don't call the base class method here is
|
/* Another reason we don't call the base class method here is
|
||||||
|
@ -243,7 +243,6 @@ tui_win_info::tui_win_info (enum tui_win_type type)
|
|||||||
tui_gen_win_info::~tui_gen_win_info ()
|
tui_gen_win_info::~tui_gen_win_info ()
|
||||||
{
|
{
|
||||||
tui_delete_win (handle);
|
tui_delete_win (handle);
|
||||||
xfree (title);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -52,6 +52,8 @@ protected:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void make_window ();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual ~tui_gen_win_info ();
|
virtual ~tui_gen_win_info ();
|
||||||
@ -73,12 +75,6 @@ public:
|
|||||||
virtual void resize (int height, int width,
|
virtual void resize (int height, int width,
|
||||||
int origin_x, int origin_y);
|
int origin_x, int origin_y);
|
||||||
|
|
||||||
/* Return true if this can be boxed. */
|
|
||||||
virtual bool can_box () const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return true if this window is visible. */
|
/* Return true if this window is visible. */
|
||||||
bool is_visible () const
|
bool is_visible () const
|
||||||
{
|
{
|
||||||
@ -97,8 +93,6 @@ public:
|
|||||||
struct tui_point origin = {0, 0};
|
struct tui_point origin = {0, 0};
|
||||||
/* Viewport height. */
|
/* Viewport height. */
|
||||||
int viewport_height = 0;
|
int viewport_height = 0;
|
||||||
/* Window title to display. */
|
|
||||||
char *title = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Constant definitions. */
|
/* Constant definitions. */
|
||||||
@ -173,6 +167,8 @@ protected:
|
|||||||
|
|
||||||
void rerender () override;
|
void rerender () override;
|
||||||
|
|
||||||
|
void make_window () override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
~tui_win_info () override
|
~tui_win_info () override
|
||||||
@ -213,13 +209,16 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool can_box () const override
|
virtual bool can_box () const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_and_display_highlight_if_needed ();
|
void check_and_display_highlight_if_needed ();
|
||||||
|
|
||||||
|
/* Window title to display. */
|
||||||
|
std::string title;
|
||||||
|
|
||||||
/* Can this window ever be highlighted? */
|
/* Can this window ever be highlighted? */
|
||||||
bool can_highlight = true;
|
bool can_highlight = true;
|
||||||
|
|
||||||
|
@ -602,7 +602,7 @@ tui_gen_win_info::resize (int height_, int width_,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (handle == nullptr)
|
if (handle == nullptr)
|
||||||
tui_make_window (this);
|
make_window ();
|
||||||
|
|
||||||
rerender ();
|
rerender ();
|
||||||
}
|
}
|
||||||
|
@ -185,8 +185,7 @@ tui_data_window::show_register_group (struct reggroup *group,
|
|||||||
int regnum, pos;
|
int regnum, pos;
|
||||||
|
|
||||||
/* Make a new title showing which group we display. */
|
/* Make a new title showing which group we display. */
|
||||||
xfree (title);
|
title = string_printf ("Register group: %s", reggroup_name (group));
|
||||||
title = xstrprintf ("Register group: %s", reggroup_name (group));
|
|
||||||
|
|
||||||
/* See how many registers must be displayed. */
|
/* See how many registers must be displayed. */
|
||||||
nr_regs = 0;
|
nr_regs = 0;
|
||||||
@ -302,7 +301,7 @@ tui_data_window::display_registers_from (int start_element_no)
|
|||||||
data_item_win->width = item_win_width;
|
data_item_win->width = item_win_width;
|
||||||
data_item_win->origin.x = (item_win_width * j) + 1;
|
data_item_win->origin.x = (item_win_width * j) + 1;
|
||||||
data_item_win->origin.y = cur_y;
|
data_item_win->origin.y = cur_y;
|
||||||
tui_make_window (data_item_win);
|
data_item_win->make_visible (true);
|
||||||
scrollok (data_item_win->handle, FALSE);
|
scrollok (data_item_win->handle, FALSE);
|
||||||
}
|
}
|
||||||
touchwin (data_item_win->handle);
|
touchwin (data_item_win->handle);
|
||||||
|
@ -153,8 +153,7 @@ tui_source_window::set_contents (struct gdbarch *arch,
|
|||||||
= tui_locator_win_info_ptr ();
|
= tui_locator_win_info_ptr ();
|
||||||
const char *s_filename = symtab_to_filename_for_display (s);
|
const char *s_filename = symtab_to_filename_for_display (s);
|
||||||
|
|
||||||
xfree (title);
|
title = s_filename;
|
||||||
title = xstrdup (s_filename);
|
|
||||||
|
|
||||||
xfree (fullname);
|
xfree (fullname);
|
||||||
fullname = xstrdup (symtab_to_fullname (s));
|
fullname = xstrdup (symtab_to_fullname (s));
|
||||||
|
@ -55,7 +55,7 @@ tui_delete_win (WINDOW *window)
|
|||||||
|
|
||||||
/* Draw a border arround the window. */
|
/* Draw a border arround the window. */
|
||||||
static void
|
static void
|
||||||
box_win (struct tui_gen_win_info *win_info,
|
box_win (struct tui_win_info *win_info,
|
||||||
int highlight_flag)
|
int highlight_flag)
|
||||||
{
|
{
|
||||||
if (win_info && win_info->handle)
|
if (win_info && win_info->handle)
|
||||||
@ -78,8 +78,8 @@ box_win (struct tui_gen_win_info *win_info,
|
|||||||
#else
|
#else
|
||||||
box (win, tui_border_vline, tui_border_hline);
|
box (win, tui_border_vline, tui_border_hline);
|
||||||
#endif
|
#endif
|
||||||
if (win_info->title)
|
if (!win_info->title.empty ())
|
||||||
mvwaddstr (win, 0, 3, win_info->title);
|
mvwaddstr (win, 0, 3, win_info->title.c_str ());
|
||||||
wattroff (win, attrs);
|
wattroff (win, attrs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,23 +126,20 @@ tui_win_info::check_and_display_highlight_if_needed ()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
tui_make_window (struct tui_gen_win_info *win_info)
|
tui_gen_win_info::make_window ()
|
||||||
{
|
{
|
||||||
WINDOW *handle;
|
handle = newwin (height, width, origin.y, origin.x);
|
||||||
|
|
||||||
handle = newwin (win_info->height,
|
|
||||||
win_info->width,
|
|
||||||
win_info->origin.y,
|
|
||||||
win_info->origin.x);
|
|
||||||
win_info->handle = handle;
|
|
||||||
if (handle != NULL)
|
if (handle != NULL)
|
||||||
{
|
scrollok (handle, TRUE);
|
||||||
if (win_info->can_box ())
|
|
||||||
box_win (win_info, NO_HILITE);
|
|
||||||
scrollok (handle, TRUE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tui_win_info::make_window ()
|
||||||
|
{
|
||||||
|
tui_gen_win_info::make_window ();
|
||||||
|
if (handle != NULL && can_box ())
|
||||||
|
box_win (this, NO_HILITE);
|
||||||
|
}
|
||||||
|
|
||||||
/* We can't really make windows visible, or invisible. So we have to
|
/* We can't really make windows visible, or invisible. So we have to
|
||||||
delete the entire window when making it visible, and create it
|
delete the entire window when making it visible, and create it
|
||||||
@ -154,7 +151,7 @@ tui_gen_win_info::make_visible (bool visible)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (visible)
|
if (visible)
|
||||||
tui_make_window (this);
|
make_window ();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tui_delete_win (handle);
|
tui_delete_win (handle);
|
||||||
|
@ -31,7 +31,6 @@ struct tui_gen_win_info;
|
|||||||
extern void tui_make_all_invisible (void);
|
extern void tui_make_all_invisible (void);
|
||||||
|
|
||||||
extern void tui_unhighlight_win (struct tui_win_info *);
|
extern void tui_unhighlight_win (struct tui_win_info *);
|
||||||
extern void tui_make_window (struct tui_gen_win_info *);
|
|
||||||
extern void tui_highlight_win (struct tui_win_info *);
|
extern void tui_highlight_win (struct tui_win_info *);
|
||||||
extern void tui_refresh_all ();
|
extern void tui_refresh_all ();
|
||||||
extern void tui_delete_win (WINDOW *window);
|
extern void tui_delete_win (WINDOW *window);
|
||||||
|
Reference in New Issue
Block a user