gdb/cli-out.c: clear_current_line shouldn't trigger pagination prompt
Commit Message
On Mon, May 15, 2023 at 10:27 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Aaron Merey <amerey@redhat.com>
> > Date: Mon, 15 May 2023 17:32:48 -0400
> > Cc: gdb-patches@sourceware.org
> >
> > > I'm not sure we should rely on the fact that the final character of
> > > the line is never there. clear_current_line is a general-purpose
> > > method, so it should do its job regardless.
> > >
> > > Can't we do something to handle the last character as well? E.g.,
> > > could it be possible first to delete one character, so there are
> > > really only N-1 characters to fill with blank spaces?
> >
> > We could rename clear_current_line to something like clear_progress_notify
> > to help indicate that this is a special purpose function. We could also
> > just disable pagination for the duration of clear_current_line.
>
> I think we should do both, thanks.
I revised the patch with clear_current_line renamed to clear_progress_notify.
This function has been changed back to overwriting an entire line with whitespace
and pagination is disabled for its duration.
Aaron
---
gdb/cli-out.c | 11 +++++++----
gdb/cli-out.h | 2 +-
2 files changed, 8 insertions(+), 5 deletions(-)
Comments
> From: Aaron Merey <amerey@redhat.com>
> Cc: gdb-patches@sourceware.org,
> Aaron Merey <amerey@redhat.com>
> Date: Fri, 19 May 2023 17:38:24 -0400
>
> On Mon, May 15, 2023 at 10:27 PM Eli Zaretskii <eliz@gnu.org> wrote:
> >
> > > From: Aaron Merey <amerey@redhat.com>
> > > Date: Mon, 15 May 2023 17:32:48 -0400
> > > Cc: gdb-patches@sourceware.org
> > >
> > > > I'm not sure we should rely on the fact that the final character of
> > > > the line is never there. clear_current_line is a general-purpose
> > > > method, so it should do its job regardless.
> > > >
> > > > Can't we do something to handle the last character as well? E.g.,
> > > > could it be possible first to delete one character, so there are
> > > > really only N-1 characters to fill with blank spaces?
> > >
> > > We could rename clear_current_line to something like clear_progress_notify
> > > to help indicate that this is a special purpose function. We could also
> > > just disable pagination for the duration of clear_current_line.
> >
> > I think we should do both, thanks.
>
> I revised the patch with clear_current_line renamed to clear_progress_notify.
> This function has been changed back to overwriting an entire line with whitespace
> and pagination is disabled for its duration.
Thanks.
Acked-by: Eli Zaretskii <eliz@gnu.org>
On Sat, May 20, 2023 at 1:47 AM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Aaron Merey <amerey@redhat.com>
> > Cc: gdb-patches@sourceware.org,
> > Aaron Merey <amerey@redhat.com>
> > Date: Fri, 19 May 2023 17:38:24 -0400
> >
> > On Mon, May 15, 2023 at 10:27 PM Eli Zaretskii <eliz@gnu.org> wrote:
> > >
> > > > From: Aaron Merey <amerey@redhat.com>
> > > > Date: Mon, 15 May 2023 17:32:48 -0400
> > > > Cc: gdb-patches@sourceware.org
> > > >
> > > > > I'm not sure we should rely on the fact that the final character of
> > > > > the line is never there. clear_current_line is a general-purpose
> > > > > method, so it should do its job regardless.
> > > > >
> > > > > Can't we do something to handle the last character as well? E.g.,
> > > > > could it be possible first to delete one character, so there are
> > > > > really only N-1 characters to fill with blank spaces?
> > > >
> > > > We could rename clear_current_line to something like clear_progress_notify
> > > > to help indicate that this is a special purpose function. We could also
> > > > just disable pagination for the duration of clear_current_line.
> > >
> > > I think we should do both, thanks.
> >
> > I revised the patch with clear_current_line renamed to clear_progress_notify.
> > This function has been changed back to overwriting an entire line with whitespace
> > and pagination is disabled for its duration.
>
> Thanks.
>
> Acked-by: Eli Zaretskii <eliz@gnu.org>
Thanks Eli, merged as commit 6aebb6e100fb3c
Aaron
@@ -378,15 +378,18 @@ cli_ui_out::do_progress_notify (const std::string &msg,
return;
}
-/* Clear the current line of the most recent progress update. Overwrites
- the current line with whitespace. */
+/* Clear do_progress_notify output from the current line. Overwrites the
+ notification with whitespace. */
void
-cli_ui_out::clear_current_line ()
+cli_ui_out::clear_progress_notify ()
{
struct ui_file *stream = m_streams.back ();
int chars_per_line = get_chars_per_line ();
+ scoped_restore save_pagination
+ = make_scoped_restore (&pagination_enabled, false);
+
if (!stream->isatty ()
|| !current_ui->input_interactive_p ()
|| chars_per_line < MIN_CHARS_PER_LINE)
@@ -413,7 +416,7 @@ cli_ui_out::do_progress_end ()
m_progress_info.pop_back ();
if (stream->isatty ())
- clear_current_line ();
+ clear_progress_notify ();
}
/* local functions */
@@ -104,7 +104,7 @@ class cli_ui_out : public ui_out
/* Stack of progress info. */
std::vector<cli_progress_info> m_progress_info;
- void clear_current_line ();
+ void clear_progress_notify ();
};
extern void cli_display_match_list (char **matches, int len, int max);