Add "continue" response to pager

This adds a "continue" response to the pager.  If the user types "c"
in response to the pager prompt, pagination will be disabled for the
duration of one command -- but re-enabled afterward.  This is handy if
you type a command that produces a lot of output, and you don't want
to baby-sit it by typing "return" each time the prompt comes up.

Tested by the buildbot.

gdb/ChangeLog
2018-06-05  Tom Tromey	<tom@tromey.com>

	PR cli/12326:
	* NEWS: Add entry about pager.
	* utils.c (pagination_disabled_for_command): New global.
	(prompt_for_continue): Allow "c" response to prompt.
	(reinitialize_more_filter): Clear
	pagination_disabled_for_command.
	(fputs_maybe_filtered): Check pagination_disabled_for_command.

gdb/doc/ChangeLog
2018-06-05  Tom Tromey	<tom@tromey.com>

	PR cli/12326:
	* gdb.texinfo (Screen Size): Document "c" response to pagination
	prompt.

gdb/testsuite/ChangeLog
2018-06-05  Tom Tromey	<tom@tromey.com>

	PR cli/12326:
	* gdb.cp/static-print-quit.exp: Update.
	* lib/gdb.exp (pagination_prompt): Update.
	* gdb.base/page.exp: Use pagination_prompt.  Add new tests.
	* gdb.python/python.exp: Update.
This commit is contained in:
Tom Tromey
2018-04-25 08:52:00 -06:00
parent 5c4ce239a3
commit eb6af80922
10 changed files with 89 additions and 23 deletions

View File

@ -1283,6 +1283,10 @@ show_chars_per_line (struct ui_file *file, int from_tty,
/* Current count of lines printed on this page, chars on this line. */
static unsigned int lines_printed, chars_printed;
/* True if pagination is disabled for just one command. */
static bool pagination_disabled_for_command;
/* Buffer and start column of buffered text, for doing smarter word-
wrapping. When someone calls wrap_here(), we start buffering output
that comes through fputs_filtered(). If we see a newline, we just
@ -1467,12 +1471,14 @@ prompt_for_continue (void)
prompt_for_continue_wait_time. */
using namespace std::chrono;
steady_clock::time_point prompt_started = steady_clock::now ();
bool disable_pagination = pagination_disabled_for_command;
if (annotation_level > 1)
printf_unfiltered (("\n\032\032pre-prompt-for-continue\n"));
strcpy (cont_prompt,
"---Type <return> to continue, or q <return> to quit---");
"--Type <RET> for more, q to quit, "
"c to continue without paging--");
if (annotation_level > 1)
strcat (cont_prompt, "\n\032\032prompt-for-continue\n");
@ -1502,11 +1508,14 @@ prompt_for_continue (void)
if (p[0] == 'q')
/* Do not call quit here; there is no possibility of SIGINT. */
throw_quit ("Quit");
if (p[0] == 'c')
disable_pagination = true;
}
/* Now we have to do this again, so that GDB will know that it doesn't
need to save the ---Type <return>--- line at the top of the screen. */
reinitialize_more_filter ();
pagination_disabled_for_command = disable_pagination;
dont_repeat (); /* Forget prev cmd -- CR won't repeat it. */
}
@ -1536,6 +1545,7 @@ reinitialize_more_filter (void)
{
lines_printed = 0;
chars_printed = 0;
pagination_disabled_for_command = false;
}
/* Indicate that if the next sequence of characters overflows the line,
@ -1680,6 +1690,7 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
/* Don't do any filtering if it is disabled. */
if (stream != gdb_stdout
|| !pagination_enabled
|| pagination_disabled_for_command
|| batch_flag
|| (lines_per_page == UINT_MAX && chars_per_line == UINT_MAX)
|| top_level_interpreter () == NULL
@ -1696,8 +1707,11 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
lineptr = linebuffer;
while (*lineptr)
{
/* Possible new page. */
if (filter && (lines_printed >= lines_per_page - 1))
/* Possible new page. Note that PAGINATION_DISABLED_FOR_COMMAND
might be set during this loop, so we must continue to check
it here. */
if (filter && (lines_printed >= lines_per_page - 1)
&& !pagination_disabled_for_command)
prompt_for_continue ();
while (*lineptr && *lineptr != '\n')
@ -1737,8 +1751,11 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
if (wrap_column)
fputc_unfiltered ('\n', stream);
/* Possible new page. */
if (lines_printed >= lines_per_page - 1)
/* Possible new page. Note that
PAGINATION_DISABLED_FOR_COMMAND might be set during
this loop, so we must continue to check it here. */
if (lines_printed >= lines_per_page - 1
&& !pagination_disabled_for_command)
prompt_for_continue ();
/* Now output indentation and wrapped string. */