[06/14] Move scrollok call in register window

Message ID 20231217-tui-regs-cleanup-v1-6-67bd0ea1e8be@tromey.com
State New
Headers
Series Cleanups for the TUi register window |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Tom Tromey Dec. 17, 2023, 7:50 p.m. UTC
  The register window calls scrollok each time a register is written to
the window.  However, we only need to call this once, at the start of
display.  (We could actually call it just once when the window is
made, but that would involve making another method virtual or adding a
new member -- both which I think are worse than this approach.)
---
 gdb/tui/tui-regs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Comments

Andrew Burgess Dec. 18, 2023, 7:28 p.m. UTC | #1
Tom Tromey <tom@tromey.com> writes:

> The register window calls scrollok each time a register is written to
> the window.  However, we only need to call this once, at the start of
> display.  (We could actually call it just once when the window is
> made, but that would involve making another method virtual

Did you consider overriding make_window in the tui_data_window class?
Like this:

  void
  tui_data_window::make_window ()
  {
    tui_win_info::make_window ();
  
    /* In case the regs window is not boxed, we'll write the last char in the
       last line here, causing a scroll, so prevent that.  */
   if (this->handle != nullptr)
      scrollok (this->handle.get (), FALSE);
  }

Thanks,
Andrew




>                                                             or adding a
> new member -- both which I think are worse than this approach.)
> ---
>  gdb/tui/tui-regs.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
> index 9108e460d6f..0ad23e93778 100644
> --- a/gdb/tui/tui-regs.c
> +++ b/gdb/tui/tui-regs.c
> @@ -237,6 +237,10 @@ tui_data_window::update_register_data (const reggroup *group,
>  void
>  tui_data_window::display_registers_from (int start_element_no)
>  {
> +  /* In case the regs window is not boxed, we'll write the last char in the
> +     last line here, causing a scroll, so prevent that.  */
> +  scrollok (handle.get (), FALSE);
> +
>    int max_len = 0;
>    for (auto &&data_item_win : m_regs_content)
>      {
> @@ -449,10 +453,6 @@ tui_data_window::check_register_values (frame_info_ptr frame)
>  void
>  tui_register_info::rerender (WINDOW *handle, int field_width)
>  {
> -  /* In case the regs window is not boxed, we'll write the last char in the
> -     last line here, causing a scroll, so prevent that.  */
> -  scrollok (handle, 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
>
> -- 
> 2.43.0
  
Tom Tromey Dec. 18, 2023, 11:33 p.m. UTC | #2
>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:

Andrew> Tom Tromey <tom@tromey.com> writes:
>> The register window calls scrollok each time a register is written to
>> the window.  However, we only need to call this once, at the start of
>> display.  (We could actually call it just once when the window is
>> made, but that would involve making another method virtual

Andrew> Did you consider overriding make_window in the tui_data_window class?
Andrew> Like this:

I did, but there aren't any other overrides of make_window, and it seems
like a mistake that it is virtual at all.

Tom
  

Patch

diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 9108e460d6f..0ad23e93778 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -237,6 +237,10 @@  tui_data_window::update_register_data (const reggroup *group,
 void
 tui_data_window::display_registers_from (int start_element_no)
 {
+  /* In case the regs window is not boxed, we'll write the last char in the
+     last line here, causing a scroll, so prevent that.  */
+  scrollok (handle.get (), FALSE);
+
   int max_len = 0;
   for (auto &&data_item_win : m_regs_content)
     {
@@ -449,10 +453,6 @@  tui_data_window::check_register_values (frame_info_ptr frame)
 void
 tui_register_info::rerender (WINDOW *handle, int field_width)
 {
-  /* In case the regs window is not boxed, we'll write the last char in the
-     last line here, causing a scroll, so prevent that.  */
-  scrollok (handle, 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