console writing
Eric Pouech
eric.pouech at wanadoo.fr
Mon Apr 1 10:33:49 CST 2002
this patch mainly fixes some bugs when a buffer spreading on more than 2
lines was written
A+
-------------- next part --------------
Name: con_ml_block
ChangeLog: fixed writing multiline block while wrapping enabled
fixed startup information reading (console size)
License: X11
GenDate: 2002/04/01 15:30:46 UTC
ModifiedFiles: win32/console.c
AddedFiles:
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/win32/console.c,v
retrieving revision 1.88
diff -u -u -r1.88 console.c
--- win32/console.c 10 Mar 2002 00:18:37 -0000 1.88
+++ win32/console.c 30 Mar 2002 18:01:41 -0000
@@ -225,7 +225,7 @@
SetStdHandle(STD_ERROR_HANDLE, handle_err);
GetStartupInfoW(&si);
- if (si.dwFlags & STARTF_USESIZE)
+ if (si.dwFlags & STARTF_USECOUNTCHARS)
{
COORD c;
c.X = si.dwXCountChars;
@@ -866,36 +866,49 @@
* write_block
*
* WriteConsoleOutput helper: writes a block of non special characters
+ * Block can spread on several lines, and wrapping, if needed, is
+ * handled
*
*/
static int write_block(HANDLE hCon, CONSOLE_SCREEN_BUFFER_INFO* csbi,
DWORD mode, LPWSTR ptr, int len)
{
- int blk; /* number of chars to write on first line */
+ int blk; /* number of chars to write on current line */
if (len <= 0) return 1;
- blk = min(len, csbi->dwSize.X - csbi->dwCursorPosition.X);
+ if (mode & ENABLE_WRAP_AT_EOL_OUTPUT) /* writes remaining on next line */
+ {
+ int done;
- if (write_char(hCon, ptr, blk, &csbi->dwCursorPosition) != blk)
- return 0;
+ for (done = 0; done < len; done += blk)
+ {
+ blk = min(len - done, csbi->dwSize.X - csbi->dwCursorPosition.X);
- if (blk < len) /* special handling for right border */
+ if (write_char(hCon, ptr + done, blk, &csbi->dwCursorPosition) != blk)
+ return 0;
+ if (csbi->dwCursorPosition.X == csbi->dwSize.X && !next_line(hCon, csbi))
+ return 0;
+ }
+ }
+ else
{
- if (mode & ENABLE_WRAP_AT_EOL_OUTPUT) /* writes remaining on next line */
- {
- if (!next_line(hCon, csbi) ||
- write_char(hCon, ptr + blk, len - blk, &csbi->dwCursorPosition) != len - blk)
- return 0;
- }
- else /* all remaining chars should be written on last column, so only write the last one */
- {
- csbi->dwCursorPosition.X = csbi->dwSize.X - 1;
- if (write_char(hCon, ptr + len - 1, 1, &csbi->dwCursorPosition) != 1)
- return 0;
- csbi->dwCursorPosition.X = csbi->dwSize.X - 1;
- }
+ blk = min(len, csbi->dwSize.X - csbi->dwCursorPosition.X);
+
+ if (write_char(hCon, ptr, blk, &csbi->dwCursorPosition) != blk)
+ return 0;
+ if (blk < len)
+ {
+ csbi->dwCursorPosition.X = csbi->dwSize.X - 1;
+ /* all remaining chars should be written on last column,
+ * so only overwrite the last column with last char in block
+ */
+ if (write_char(hCon, ptr + len - 1, 1, &csbi->dwCursorPosition) != 1)
+ return 0;
+ csbi->dwCursorPosition.X = csbi->dwSize.X - 1;
+ }
}
+
return 1;
}
More information about the wine-patches
mailing list