A+ -- Eric Pouech
Name: con_nonwrap ChangeLog: fixed console output for non wrapped mode License: X11 GenDate: 2003/05/08 18:57:40 UTC ModifiedFiles: dlls/kernel/console.c =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/dlls/kernel/console.c,v retrieving revision 1.14 diff -u -u -r1.14 console.c --- dlls/kernel/console.c 3 Apr 2003 18:04:40 -0000 1.14 +++ dlls/kernel/console.c 7 May 2003 18:50:40 -0000 @@ -1579,11 +1583,12 @@ /****************************************************************** - * write_char + * CONSOLE_WriteChars * * 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; @@ -1651,18 +1656,17 @@ DWORD mode, LPWSTR ptr, int len) { int blk; /* number of chars to write on current line */ + int done; /* number of chars already written */ if (len <= 0) return 1; if (mode & ENABLE_WRAP_AT_EOL_OUTPUT) /* writes remaining on next line */ { - int done; - for (done = 0; done < len; done += blk) { 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; if (csbi->dwCursorPosition.X == csbi->dwSize.X && !next_line(hCon, csbi)) return 0; @@ -1670,19 +1674,19 @@ } else { - blk = min(len, csbi->dwSize.X - csbi->dwCursorPosition.X); - - if (write_char(hCon, ptr, blk, &csbi->dwCursorPosition) != blk) - return 0; - if (blk < len) + int pos = csbi->dwCursorPosition.X; + /* FIXME: we could reduce the number of loops + * but, in most cases we wouldn't gain lots of time (it would only + * happen if we're asked to overwrite more than twice the part of the line, + * which is unlikely + */ + for (blk = done = 0; done < len; done += blk) { - 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) + blk = min(len - done, csbi->dwSize.X - csbi->dwCursorPosition.X); + + csbi->dwCursorPosition.X = pos; + if (CONSOLE_WriteChars(hCon, ptr + done, blk, &csbi->dwCursorPosition) != blk) return 0; - csbi->dwCursorPosition.X = csbi->dwSize.X - 1; } }