Files
u-boot/doc/develop/console.rst
Simon Glass 10a0dec8bc pager: doc: Add mention of the pager feature
Add a note about the pager to the console documentation, with some more
information in the developer section. Also include the pager API.

Series-to: concept
Cover-letter:
Introduce a pager for the console
Some U-Boot commands can produce a lot of output and this can run off
top of the display. This series introduces a simple pager feature, to
allow the output to be read, before pressing SPACE to continue.

A fixed buffer size (4K) is used, which sets a limit on the permmited
output before paging fails and the output is simply written all in one
lot. In most cases this is plenty, but 'env print' does print the whole
environment as one string, so if the legacy distro-boot scripts are used
it could happen.

The default number of visible lines is set with a Kconfig option. Where
a video terminal is being used, the page size is set to match that. In
general U-Boot cannot guess the number of visible lines, since a serial
terminal may be in use.

There is also a 'pager' environment variable which can override any
detected value.

This initial series only counts newlines. It has no support for counting
characters so the result will be sub-optimal if very long lines are
written. This could be addressed in a future patch.

Some effort is made to handle common cases correctly. For example, if
stdout is changed to a serial or vidconsole device, that is used to
determine the page length. When redirecting sandbox to a file, no
attempt is made.

Future work may detect the terminal size by sending an ANSI sequence.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
Series-version: 2
2025-08-26 14:36:07 -06:00

42 lines
1.3 KiB
ReStructuredText

.. SPDX-License-Identifier: GPL-2.0+
.. sectionauthor:: Simon Glass <sjg@chromium.org>
=======
Console
=======
Paging
------
See the user documentation at :doc:`/usage/console`. For the API, see
:doc:`/api/pager`.
The pager is implemented in `common/pager.c` and integrated into the console
system via `console_puts()` in `common/console.c`. When output is sent to
stdout:
1. Text is passed to `pager_post()` which buffers it
2. `pager_next()` returns portions of text up to the page limit
3. When the page limit is reached, a prompt is displayed
4. The system waits for user input (SPACE key) via `getchar()`
5. After SPACE is pressed, the prompt is cleared and output continues
The pager maintains state through the `struct pager` which tracks:
- Current line count within the page
- Page length setting
- Text buffer and overflow handling
- Current pager state (normal, waiting for user, clearing prompt)
Bypass Mode
~~~~~~~~~~~
The pager can be put into bypass mode using `pager_set_bypass()`, which is
useful for automated testing. In bypass mode, all text flows through without
any paging interruptions.
The pager automatically enters bypass mode when output is not connected to a
terminal, preventing paging prompts from appearing in non-interactive
environments like scripts or automated builds.