Commit d3446a44 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Fixed console output for non wrapped mode.

parent f06a996a
...@@ -1579,11 +1579,12 @@ BOOL WINAPI SetConsoleMode(HANDLE hcon, DWORD mode) ...@@ -1579,11 +1579,12 @@ BOOL WINAPI SetConsoleMode(HANDLE hcon, DWORD mode)
/****************************************************************** /******************************************************************
* write_char * CONSOLE_WriteChars
* *
* WriteConsoleOutput helper: hides server call semantics * WriteConsoleOutput helper: hides server call semantics
* writes a string at a given pos with standard attribute
*/ */
static int write_char(HANDLE hCon, LPCWSTR lpBuffer, int nc, COORD* pos) int CONSOLE_WriteChars(HANDLE hCon, LPCWSTR lpBuffer, int nc, COORD* pos)
{ {
int written = -1; int written = -1;
...@@ -1651,18 +1652,17 @@ static int write_block(HANDLE hCon, CONSOLE_SCREEN_BUFFER_INFO* csbi, ...@@ -1651,18 +1652,17 @@ static int write_block(HANDLE hCon, CONSOLE_SCREEN_BUFFER_INFO* csbi,
DWORD mode, LPWSTR ptr, int len) DWORD mode, LPWSTR ptr, int len)
{ {
int blk; /* number of chars to write on current line */ int blk; /* number of chars to write on current line */
int done; /* number of chars already written */
if (len <= 0) return 1; if (len <= 0) return 1;
if (mode & ENABLE_WRAP_AT_EOL_OUTPUT) /* writes remaining on next line */ if (mode & ENABLE_WRAP_AT_EOL_OUTPUT) /* writes remaining on next line */
{ {
int done;
for (done = 0; done < len; done += blk) for (done = 0; done < len; done += blk)
{ {
blk = min(len - done, csbi->dwSize.X - csbi->dwCursorPosition.X); blk = min(len - done, csbi->dwSize.X - csbi->dwCursorPosition.X);
if (write_char(hCon, ptr + done, blk, &csbi->dwCursorPosition) != blk) if (CONSOLE_WriteChars(hCon, ptr + done, blk, &csbi->dwCursorPosition) != blk)
return 0; return 0;
if (csbi->dwCursorPosition.X == csbi->dwSize.X && !next_line(hCon, csbi)) if (csbi->dwCursorPosition.X == csbi->dwSize.X && !next_line(hCon, csbi))
return 0; return 0;
...@@ -1670,19 +1670,19 @@ static int write_block(HANDLE hCon, CONSOLE_SCREEN_BUFFER_INFO* csbi, ...@@ -1670,19 +1670,19 @@ static int write_block(HANDLE hCon, CONSOLE_SCREEN_BUFFER_INFO* csbi,
} }
else else
{ {
blk = min(len, csbi->dwSize.X - csbi->dwCursorPosition.X); int pos = csbi->dwCursorPosition.X;
/* FIXME: we could reduce the number of loops
if (write_char(hCon, ptr, blk, &csbi->dwCursorPosition) != blk) * but, in most cases we wouldn't gain lots of time (it would only
return 0; * happen if we're asked to overwrite more than twice the part of the line,
if (blk < len) * which is unlikely
*/
for (blk = done = 0; done < len; done += blk)
{ {
csbi->dwCursorPosition.X = csbi->dwSize.X - 1; blk = min(len - done, csbi->dwSize.X - csbi->dwCursorPosition.X);
/* all remaining chars should be written on last column,
* so only overwrite the last column with last char in block csbi->dwCursorPosition.X = pos;
*/ if (CONSOLE_WriteChars(hCon, ptr + done, blk, &csbi->dwCursorPosition) != blk)
if (write_char(hCon, ptr + len - 1, 1, &csbi->dwCursorPosition) != 1)
return 0; return 0;
csbi->dwCursorPosition.X = csbi->dwSize.X - 1;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment