From a3c1e6c8c7624ee14175a5efd04a1feeea373b16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Wed, 28 Jan 2004 17:47:27 +0000 Subject: [PATCH] Patch by Michael Fritscher Fix /p when screen buffer is larger than output window svn path=/trunk/; revision=7894 --- reactos/subsys/system/cmd/dir.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/reactos/subsys/system/cmd/dir.c b/reactos/subsys/system/cmd/dir.c index 9df9c82d805..05a2d351ae9 100644 --- a/reactos/subsys/system/cmd/dir.c +++ b/reactos/subsys/system/cmd/dir.c @@ -1,4 +1,4 @@ -/* $Id: dir.c,v 1.7 2004/01/16 19:58:47 weiden Exp $ +/* $Id: dir.c,v 1.8 2004/01/28 17:47:27 gvg Exp $ * * DIR.C - dir internal command. * @@ -113,6 +113,9 @@ * * 23-Feb-2001 (Carl Nettelblad ) * dir /s now works in deeper trees + * + * 28-Jan-2004 (Michael Fritscher ) + * Fix for /p, so it is working under Windows in GUI-mode, too. */ #include "config.h" @@ -496,12 +499,23 @@ DirParsePathspec (LPTSTR szPathspec, LPTSTR szPath, LPTSTR szFilespec) static BOOL IncLine (LPINT pLine, DWORD dwFlags) { + BOOL error; + CONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo; + LONG WindowHeight; + error = GetConsoleScreenBufferInfo(hConsole, &lpConsoleScreenBufferInfo); + + WindowHeight= lpConsoleScreenBufferInfo.srWindow.Bottom - lpConsoleScreenBufferInfo.srWindow.Top; + + if (!WindowHeight) //That prevents bad behave if WindowHeight couln't calc + { + WindowHeight= 1000000; + } if (!(dwFlags & DIR_PAGE)) return FALSE; (*pLine)++; - if (*pLine >= (int)maxy - 2) + if (*pLine >= (int)maxy - 2 || *pLine >= WindowHeight) //Because I don't know if WindowsHeight work under all cases, perhaps then maxy is the right value { *pLine = 0; return (PagePrompt () == PROMPT_BREAK);