mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-23 18:14:13 +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:
parent
002f15c277
commit
e25d200487
@ -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>
|
||||
|
||||
* 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)
|
||||
override;
|
||||
|
||||
void erase_source_content () override
|
||||
{
|
||||
do_erase_source_content (NO_DISASSEM_STRING);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
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)
|
||||
override;
|
||||
|
||||
void erase_source_content () override
|
||||
{
|
||||
do_erase_source_content (NO_SRC_STRING);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void do_scroll_vertical (int num_to_scroll) override;
|
||||
|
@ -595,7 +595,7 @@ tui_resize_all (void)
|
||||
first_win->make_visible_with_new_height ();
|
||||
TUI_CMD_WIN->make_visible_with_new_height ();
|
||||
if (src_win->content.empty ())
|
||||
tui_erase_source_content (src_win);
|
||||
src_win->erase_source_content ();
|
||||
break;
|
||||
default:
|
||||
if (cur_layout == SRC_DISASSEM_COMMAND)
|
||||
@ -659,7 +659,7 @@ tui_resize_all (void)
|
||||
second_win->make_visible_with_new_height ();
|
||||
TUI_CMD_WIN->make_visible_with_new_height ();
|
||||
if (src_win->content.empty ())
|
||||
tui_erase_source_content (src_win);
|
||||
src_win->erase_source_content ();
|
||||
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_win_info;
|
||||
if (src_base->content.empty ())
|
||||
tui_erase_source_content (src_base);
|
||||
src_base->erase_source_content ();
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1169,9 +1169,9 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
|
||||
second_win->make_visible_with_new_height ();
|
||||
first_win->make_visible_with_new_height ();
|
||||
if (src1 != nullptr && src1->content.empty ())
|
||||
tui_erase_source_content (src1);
|
||||
src1->erase_source_content ();
|
||||
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;
|
||||
|
||||
tui_erase_source_content (win_info);
|
||||
win_info->erase_source_content ();
|
||||
for (i = 0; i < win_info->content.size (); 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
|
||||
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 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);
|
||||
win_info->check_and_display_highlight_if_needed ();
|
||||
werase (handle);
|
||||
check_and_display_highlight_if_needed ();
|
||||
|
||||
const char *no_src_str;
|
||||
|
||||
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)
|
||||
if (strlen (str) >= half_width)
|
||||
x_pos = 1;
|
||||
else
|
||||
x_pos = half_width - strlen (no_src_str);
|
||||
mvwaddstr (win_info->handle,
|
||||
(win_info->height / 2),
|
||||
x_pos = half_width - strlen (str);
|
||||
mvwaddstr (handle,
|
||||
(height / 2),
|
||||
x_pos,
|
||||
(char *) no_src_str);
|
||||
(char *) str);
|
||||
|
||||
win_info->content.clear ();
|
||||
win_info->refresh_window ();
|
||||
content.clear ();
|
||||
refresh_window ();
|
||||
|
||||
struct tui_gen_win_info *exec_info = win_info->execution_info;
|
||||
|
||||
werase (exec_info->handle);
|
||||
exec_info->refresh_window ();
|
||||
werase (execution_info->handle);
|
||||
execution_info->refresh_window ();
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,7 +276,7 @@ tui_source_window_base::show_source_content ()
|
||||
tui_show_source_line (this, lineno);
|
||||
}
|
||||
else
|
||||
tui_erase_source_content (this);
|
||||
erase_source_content ();
|
||||
|
||||
check_and_display_highlight_if_needed ();
|
||||
refresh_window ();
|
||||
|
@ -100,6 +100,9 @@ protected:
|
||||
void do_scroll_horizontal (int num_to_scroll) override;
|
||||
void do_make_visible_with_new_height () override;
|
||||
|
||||
/* Erase the content and display STRING. */
|
||||
void do_erase_source_content (const char *string);
|
||||
|
||||
public:
|
||||
|
||||
void clear_detail ();
|
||||
@ -133,6 +136,9 @@ public:
|
||||
virtual void maybe_update (struct frame_info *fi, symtab_and_line sal,
|
||||
int line_no, CORE_ADDR addr) = 0;
|
||||
|
||||
/* Erase the source content. */
|
||||
virtual void erase_source_content () = 0;
|
||||
|
||||
/* Does the locator belong to this window? */
|
||||
bool m_has_locator = false;
|
||||
/* 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 *,
|
||||
int);
|
||||
extern void tui_clear_source_content (struct tui_source_window_base *);
|
||||
extern void tui_erase_source_content (struct tui_source_window_base *);
|
||||
|
||||
/* Constant definitions. */
|
||||
#define SCROLL_THRESHOLD 2 /* Threshold for lazy scroll. */
|
||||
|
Loading…
Reference in New Issue
Block a user