mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[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:
parent
f74a3f6e29
commit
ff445ca184
2 changed files with 21 additions and 4 deletions
|
@ -172,6 +172,14 @@ PagePrompt(PCON_PAGER Pager, DWORD Done, DWORD Total)
|
|||
if (!*StrLines)
|
||||
K32LoadStringW(NULL, IDS_CONTINUE_LINES, StrLines, ARRAYSIZE(StrLines));
|
||||
|
||||
/*
|
||||
* Check whether the pager is prompting, but we have actually finished
|
||||
* to display a given file, or no data is present in STDIN anymore.
|
||||
* In this case, skip the prompt altogether. The only exception is when
|
||||
* we are displaying other files.
|
||||
*/
|
||||
// TODO: Implement!
|
||||
|
||||
Restart:
|
||||
nLines = 0;
|
||||
|
||||
|
@ -323,6 +331,11 @@ Restart:
|
|||
dwMode |= ENABLE_PROCESSED_INPUT;
|
||||
SetConsoleMode(hInput, dwMode);
|
||||
|
||||
/* Refresh the screen information, as the console may have been
|
||||
* redimensioned. Update also the default number of lines to scroll. */
|
||||
ConGetScreenInfo(Pager->Screen, &csbi);
|
||||
Pager->ScrollRows = csbi.srWindow.Bottom - csbi.srWindow.Top;
|
||||
|
||||
/*
|
||||
* Erase the full line where the cursor is, and move
|
||||
* the cursor back to the beginning of the line.
|
||||
|
@ -357,6 +370,7 @@ Restart:
|
|||
{
|
||||
s_dwFlags |= FLAG_PLUSn;
|
||||
s_nNextLineNo = Pager->lineno + nLines;
|
||||
/* Use the default Pager->ScrollRows value */
|
||||
return TRUE;
|
||||
}
|
||||
default:
|
||||
|
@ -412,6 +426,7 @@ Restart:
|
|||
/* Clear the screen */
|
||||
ConClearScreen(Pager->Screen);
|
||||
}
|
||||
/* Use the default Pager->ScrollRows value */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -444,6 +459,7 @@ Restart:
|
|||
else
|
||||
{
|
||||
/* Extended features are unavailable: display one page */
|
||||
/* Use the default Pager->ScrollRows value */
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -1075,6 +1091,7 @@ int wmain(int argc, WCHAR* argv[])
|
|||
SetFilePointer(hFile, SkipBytes, NULL, FILE_BEGIN);
|
||||
|
||||
/* Reset state for paging */
|
||||
s_nNextLineNo = 0;
|
||||
s_bPrevLineIsBlank = FALSE;
|
||||
s_fPrompt = PROMPT_PERCENT;
|
||||
s_bDoNextFile = FALSE;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue