[CONUTILS:PAGER][MORE] Fix the default paging region.

- The column extent should cover the whole width of the console screenbuffer.
  On the contrary, the line extent covers only the number of lines that
  cover the current displayed console window.

- Since the console can be resized while the pager is prompting, we need
  to actually recalculate in the prompt routine the default number of
  lines for a screen.

- Reset s_nNextLineNo when paging a new file.
This commit is contained in:
Hermès Bélusca-Maïto 2021-06-27 15:58:25 +02:00
parent f74a3f6e29
commit ff445ca184
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 21 additions and 4 deletions

View file

@ -312,7 +312,7 @@ ConWritePaging(
if (bIsConsole)
{
/* Calculate the console screen extent */
Pager->PageColumns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
Pager->PageColumns = csbi.dwSize.X;
Pager->PageRows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
}
else
@ -324,14 +324,14 @@ ConWritePaging(
if (StartPaging)
{
if (bIsConsole)
if (bIsConsole && (Pager->PageRows >= 2))
{
/* Reset to display one page by default */
Pager->ScrollRows = Pager->PageRows - 1;
}
else
{
/* File output: all lines are displayed at once; reset to a default value */
/* File output, or single line: all lines are displayed at once; reset to a default value */
Pager->ScrollRows = 0;
}
}
@ -371,7 +371,7 @@ ConWritePaging(
* in case the user has redimensioned it during the prompt. */
if (bIsConsole && ConGetScreenInfo(Pager->Screen, &csbi))
{
Pager->PageColumns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
Pager->PageColumns = csbi.dwSize.X;
Pager->PageRows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
}
}