mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-24 12:23:31 +08:00
Turn tui_erase_source_content into a method
This changes tui_erase_source_content into a method on tui_source_window_base. The bulk of the work is moved into a helper method, so that the callers can each pass the string appropriate to the particular window class. gdb/ChangeLog 2019-08-15 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (struct tui_source_window_base) <do_erase_source_content>: New method. <erase_source_content>: New method. (tui_erase_source_content): Don't declare. * tui/tui-winsource.c (tui_clear_source_content): Update. (tui_source_window_base::do_erase_source_content): Rename from tui_erase_source_content. (tui_source_window_base::show_source_content): Update. * tui/tui-win.c (tui_resize_all, tui_adjust_win_heights): Update. * tui/tui-source.h (struct tui_source_window) <erase_source_content>: New method. * tui/tui-disasm.h (struct tui_disasm_window) <erase_source_content>: New method.
This commit is contained in:
@ -1,3 +1,19 @@
|
|||||||
|
2019-08-15 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* tui/tui-winsource.h (struct tui_source_window_base)
|
||||||
|
<do_erase_source_content>: New method.
|
||||||
|
<erase_source_content>: New method.
|
||||||
|
(tui_erase_source_content): Don't declare.
|
||||||
|
* tui/tui-winsource.c (tui_clear_source_content): Update.
|
||||||
|
(tui_source_window_base::do_erase_source_content): Rename from
|
||||||
|
tui_erase_source_content.
|
||||||
|
(tui_source_window_base::show_source_content): Update.
|
||||||
|
* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights): Update.
|
||||||
|
* tui/tui-source.h (struct tui_source_window)
|
||||||
|
<erase_source_content>: New method.
|
||||||
|
* tui/tui-disasm.h (struct tui_disasm_window)
|
||||||
|
<erase_source_content>: New method.
|
||||||
|
|
||||||
2019-08-15 Tom Tromey <tom@tromey.com>
|
2019-08-15 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* tui/tui-winsource.h (tui_alloc_source_buffer): Don't declare.
|
* tui/tui-winsource.h (tui_alloc_source_buffer): Don't declare.
|
||||||
|
@ -48,6 +48,11 @@ struct tui_disasm_window : public tui_source_window_base
|
|||||||
int line_no, CORE_ADDR addr)
|
int line_no, CORE_ADDR addr)
|
||||||
override;
|
override;
|
||||||
|
|
||||||
|
void erase_source_content () override
|
||||||
|
{
|
||||||
|
do_erase_source_content (NO_DISASSEM_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void do_scroll_vertical (int num_to_scroll) override;
|
void do_scroll_vertical (int num_to_scroll) override;
|
||||||
|
@ -51,6 +51,11 @@ struct tui_source_window : public tui_source_window_base
|
|||||||
int line_no, CORE_ADDR addr)
|
int line_no, CORE_ADDR addr)
|
||||||
override;
|
override;
|
||||||
|
|
||||||
|
void erase_source_content () override
|
||||||
|
{
|
||||||
|
do_erase_source_content (NO_SRC_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void do_scroll_vertical (int num_to_scroll) override;
|
void do_scroll_vertical (int num_to_scroll) override;
|
||||||
|
@ -595,7 +595,7 @@ tui_resize_all (void)
|
|||||||
first_win->make_visible_with_new_height ();
|
first_win->make_visible_with_new_height ();
|
||||||
TUI_CMD_WIN->make_visible_with_new_height ();
|
TUI_CMD_WIN->make_visible_with_new_height ();
|
||||||
if (src_win->content.empty ())
|
if (src_win->content.empty ())
|
||||||
tui_erase_source_content (src_win);
|
src_win->erase_source_content ();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (cur_layout == SRC_DISASSEM_COMMAND)
|
if (cur_layout == SRC_DISASSEM_COMMAND)
|
||||||
@ -659,7 +659,7 @@ tui_resize_all (void)
|
|||||||
second_win->make_visible_with_new_height ();
|
second_win->make_visible_with_new_height ();
|
||||||
TUI_CMD_WIN->make_visible_with_new_height ();
|
TUI_CMD_WIN->make_visible_with_new_height ();
|
||||||
if (src_win->content.empty ())
|
if (src_win->content.empty ())
|
||||||
tui_erase_source_content (src_win);
|
src_win->erase_source_content ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1065,7 +1065,7 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
|
|||||||
tui_source_window_base *src_base
|
tui_source_window_base *src_base
|
||||||
= (tui_source_window_base *) src_win_info;
|
= (tui_source_window_base *) src_win_info;
|
||||||
if (src_base->content.empty ())
|
if (src_base->content.empty ())
|
||||||
tui_erase_source_content (src_base);
|
src_base->erase_source_content ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1169,9 +1169,9 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
|
|||||||
second_win->make_visible_with_new_height ();
|
second_win->make_visible_with_new_height ();
|
||||||
first_win->make_visible_with_new_height ();
|
first_win->make_visible_with_new_height ();
|
||||||
if (src1 != nullptr && src1->content.empty ())
|
if (src1 != nullptr && src1->content.empty ())
|
||||||
tui_erase_source_content (src1);
|
src1->erase_source_content ();
|
||||||
if (second_win->content.empty ())
|
if (second_win->content.empty ())
|
||||||
tui_erase_source_content (second_win);
|
second_win->erase_source_content ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ tui_clear_source_content (struct tui_source_window_base *win_info)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
tui_erase_source_content (win_info);
|
win_info->erase_source_content ();
|
||||||
for (i = 0; i < win_info->content.size (); i++)
|
for (i = 0; i < win_info->content.size (); i++)
|
||||||
{
|
{
|
||||||
struct tui_source_element *element = &win_info->content[i];
|
struct tui_source_element *element = &win_info->content[i];
|
||||||
@ -211,38 +211,30 @@ tui_clear_source_content (struct tui_source_window_base *win_info)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
tui_erase_source_content (struct tui_source_window_base *win_info)
|
tui_source_window_base::do_erase_source_content (const char *str)
|
||||||
{
|
{
|
||||||
int x_pos;
|
int x_pos;
|
||||||
int half_width = (win_info->width - 2) / 2;
|
int half_width = (width - 2) / 2;
|
||||||
|
|
||||||
if (win_info->handle != NULL)
|
if (handle != NULL)
|
||||||
{
|
{
|
||||||
werase (win_info->handle);
|
werase (handle);
|
||||||
win_info->check_and_display_highlight_if_needed ();
|
check_and_display_highlight_if_needed ();
|
||||||
|
|
||||||
const char *no_src_str;
|
if (strlen (str) >= half_width)
|
||||||
|
|
||||||
if (win_info->type == SRC_WIN)
|
|
||||||
no_src_str = NO_SRC_STRING;
|
|
||||||
else
|
|
||||||
no_src_str = NO_DISASSEM_STRING;
|
|
||||||
if (strlen (no_src_str) >= half_width)
|
|
||||||
x_pos = 1;
|
x_pos = 1;
|
||||||
else
|
else
|
||||||
x_pos = half_width - strlen (no_src_str);
|
x_pos = half_width - strlen (str);
|
||||||
mvwaddstr (win_info->handle,
|
mvwaddstr (handle,
|
||||||
(win_info->height / 2),
|
(height / 2),
|
||||||
x_pos,
|
x_pos,
|
||||||
(char *) no_src_str);
|
(char *) str);
|
||||||
|
|
||||||
win_info->content.clear ();
|
content.clear ();
|
||||||
win_info->refresh_window ();
|
refresh_window ();
|
||||||
|
|
||||||
struct tui_gen_win_info *exec_info = win_info->execution_info;
|
werase (execution_info->handle);
|
||||||
|
execution_info->refresh_window ();
|
||||||
werase (exec_info->handle);
|
|
||||||
exec_info->refresh_window ();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +276,7 @@ tui_source_window_base::show_source_content ()
|
|||||||
tui_show_source_line (this, lineno);
|
tui_show_source_line (this, lineno);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
tui_erase_source_content (this);
|
erase_source_content ();
|
||||||
|
|
||||||
check_and_display_highlight_if_needed ();
|
check_and_display_highlight_if_needed ();
|
||||||
refresh_window ();
|
refresh_window ();
|
||||||
|
@ -100,6 +100,9 @@ protected:
|
|||||||
void do_scroll_horizontal (int num_to_scroll) override;
|
void do_scroll_horizontal (int num_to_scroll) override;
|
||||||
void do_make_visible_with_new_height () override;
|
void do_make_visible_with_new_height () override;
|
||||||
|
|
||||||
|
/* Erase the content and display STRING. */
|
||||||
|
void do_erase_source_content (const char *string);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void clear_detail ();
|
void clear_detail ();
|
||||||
@ -133,6 +136,9 @@ public:
|
|||||||
virtual void maybe_update (struct frame_info *fi, symtab_and_line sal,
|
virtual void maybe_update (struct frame_info *fi, symtab_and_line sal,
|
||||||
int line_no, CORE_ADDR addr) = 0;
|
int line_no, CORE_ADDR addr) = 0;
|
||||||
|
|
||||||
|
/* Erase the source content. */
|
||||||
|
virtual void erase_source_content () = 0;
|
||||||
|
|
||||||
/* Does the locator belong to this window? */
|
/* Does the locator belong to this window? */
|
||||||
bool m_has_locator = false;
|
bool m_has_locator = false;
|
||||||
/* Execution information window. */
|
/* Execution information window. */
|
||||||
@ -182,7 +188,6 @@ extern void tui_update_source_windows_with_addr (struct gdbarch *, CORE_ADDR);
|
|||||||
extern void tui_update_source_windows_with_line (struct symtab *,
|
extern void tui_update_source_windows_with_line (struct symtab *,
|
||||||
int);
|
int);
|
||||||
extern void tui_clear_source_content (struct tui_source_window_base *);
|
extern void tui_clear_source_content (struct tui_source_window_base *);
|
||||||
extern void tui_erase_source_content (struct tui_source_window_base *);
|
|
||||||
|
|
||||||
/* Constant definitions. */
|
/* Constant definitions. */
|
||||||
#define SCROLL_THRESHOLD 2 /* Threshold for lazy scroll. */
|
#define SCROLL_THRESHOLD 2 /* Threshold for lazy scroll. */
|
||||||
|
Reference in New Issue
Block a user