mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 23:02:59 +00:00
patch from : Paolo Devoti <devotip at gmail.com>
fix issue : The fix does a WriteFile per line insted of one per char. See issue #2015 for more details. svn path=/trunk/; revision=25703
This commit is contained in:
parent
d8540d8289
commit
0b971d5007
1 changed files with 38 additions and 48 deletions
|
@ -12,6 +12,9 @@
|
||||||
*
|
*
|
||||||
* 01-Jul-2005 (Brandon Turner) <turnerb7@msu.edu>)
|
* 01-Jul-2005 (Brandon Turner) <turnerb7@msu.edu>)
|
||||||
* Added ConPrintfPaging and ConOutPrintfPaging
|
* Added ConPrintfPaging and ConOutPrintfPaging
|
||||||
|
*
|
||||||
|
* 02-Feb-2007 (Paolo Devoti) <devotip at gmail.com>)
|
||||||
|
* Fixed ConPrintfPaging
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -252,8 +255,8 @@ INT ConPrintfPaging(BOOL NewPage, LPTSTR szFormat, va_list arg_ptr, DWORD nStdHa
|
||||||
/* the number of chars in a roow */
|
/* the number of chars in a roow */
|
||||||
int ScreenCol = 0;
|
int ScreenCol = 0;
|
||||||
|
|
||||||
/* chars since end of line */
|
/* chars since start of line */
|
||||||
int CharEL = 0;
|
int CharSL = 0;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
@ -261,67 +264,54 @@ INT ConPrintfPaging(BOOL NewPage, LPTSTR szFormat, va_list arg_ptr, DWORD nStdHa
|
||||||
LineCount = 0;
|
LineCount = 0;
|
||||||
|
|
||||||
/* rest LineCount and return if no string have been given */
|
/* rest LineCount and return if no string have been given */
|
||||||
if (szFormat == NULL)
|
if (szFormat == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
//get the size of the visual screen that can be printed too
|
//get the size of the visual screen that can be printed too
|
||||||
if (!GetConsoleScreenBufferInfo(hConsole, &csbi))
|
if (!GetConsoleScreenBufferInfo(hConsole, &csbi))
|
||||||
{
|
{
|
||||||
// we assuming its a file handle
|
// we assuming its a file handle
|
||||||
ConPrintf(szFormat, arg_ptr, nStdHandle);
|
ConPrintf(szFormat, arg_ptr, nStdHandle);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//subtract 2 to account for "press any key..." and for the blank line at the end of PagePrompt()
|
//subtract 2 to account for "press any key..." and for the blank line at the end of PagePrompt()
|
||||||
ScreenLines = (csbi.srWindow.Bottom - csbi.srWindow.Top) - 4;
|
ScreenLines = (csbi.srWindow.Bottom - csbi.srWindow.Top) - 4;
|
||||||
ScreenCol = (csbi.srWindow.Right - csbi.srWindow.Left) + 1;
|
ScreenCol = (csbi.srWindow.Right - csbi.srWindow.Left) + 1;
|
||||||
|
|
||||||
//make sure they didnt make the screen to small
|
//make sure they didnt make the screen to small
|
||||||
if(ScreenLines<4)
|
if(ScreenLines<4)
|
||||||
{
|
{
|
||||||
ConPrintf(szFormat, arg_ptr, nStdHandle);
|
ConPrintf(szFormat, arg_ptr, nStdHandle);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = _vstprintf (szOut, szFormat, arg_ptr);
|
len = _vstprintf (szOut, szFormat, arg_ptr);
|
||||||
pBuf = szOut;
|
pBuf = szOut;
|
||||||
|
|
||||||
for(i = 0; i < len; i++)
|
for(i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
|
// search 'end of string' '\n' or 'end of screen line'
|
||||||
if(pBuf[i] == _T('\n'))
|
for(; (i < len) && (pBuf[i] != _T('\n') && (CharSL<ScreenCol)) ; i++)
|
||||||
{
|
CharSL++;
|
||||||
LineCount++;
|
|
||||||
CharEL=0;
|
WriteFile (GetStdHandle (nStdHandle),&pBuf[i-CharSL],sizeof(CHAR)*(CharSL+1),&dwWritten,NULL);
|
||||||
}
|
LineCount++;
|
||||||
else
|
CharSL=0;
|
||||||
{
|
|
||||||
CharEL++;
|
if(LineCount >= ScreenLines)
|
||||||
if (CharEL>=ScreenCol)
|
{
|
||||||
{
|
if(_tcsnicmp(&pBuf[i], _T("\n"), 2)!=0)
|
||||||
if (i+1<len)
|
WriteFile (GetStdHandle (nStdHandle),_T("\n"),sizeof(CHAR),&dwWritten,NULL);
|
||||||
{
|
|
||||||
if(pBuf[i+1] != _T('\n')) LineCount++;
|
if(PagePrompt() != PROMPT_YES)
|
||||||
}
|
{
|
||||||
CharEL=0;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
//reset the number of lines being printed
|
||||||
|
LineCount = 0;
|
||||||
/* FIXME : write more that one char at time */
|
CharSL=0;
|
||||||
WriteFile (GetStdHandle (nStdHandle),&pBuf[i],sizeof(CHAR),&dwWritten,NULL);
|
}
|
||||||
if(LineCount >= ScreenLines)
|
|
||||||
{
|
|
||||||
if(_tcsnicmp(&pBuf[i], _T("\n"), 2)!=0)
|
|
||||||
WriteFile (GetStdHandle (nStdHandle),_T("\n"),sizeof(CHAR),&dwWritten,NULL);
|
|
||||||
|
|
||||||
if(PagePrompt() != PROMPT_YES)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
//reset the number of lines being printed
|
|
||||||
LineCount = 0;
|
|
||||||
CharEL=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue