Re: wineconsole[3/6]: remove spaces from the ends of lines while copying to the clipboard
Mikołaj Zalewski wrote:
This is very practical and matches the Windows behaviour
------------------------------------------------------------------------
diff --git a/programs/wineconsole/user.c b/programs/wineconsole/user.c index e1efda2..557ccfc 100644 --- a/programs/wineconsole/user.c +++ b/programs/wineconsole/user.c @@ -689,8 +689,15 @@ static void WCUSER_CopySelectionToClipbo
for (y = 0; y < h; y++, c.Y++) { - ReadConsoleOutputCharacter(data->hConOut, &p[y * w], w - 1, c, NULL); - p[y * w + w - 1] = (y < h - 1) ? '\n' : '\0'; + LPWSTR end; + ReadConsoleOutputCharacter(data->hConOut, p, w - 1, c, NULL); + + /* strip spaces from the end of the line */ + end = p + w - 1; + while (end > p && *(end - 1) == ' ') + end--; + *end = (y < h - 1) ? '\n' : '\0'; + p = end + 1; } GlobalUnlock(hMem); SetClipboardData(CF_UNICODETEXT, hMem);
------------------------------------------------------------------------
did you check that this behavior is done for every mode of the console ? A+
Mikołaj Zalewski wrote:
did you check that this behavior is done for every mode of the console ? A+
What do you mean by every mode?
Mikolaj Zalewski
consoles have several modes (set SetConsoleMode()), which may interfer with this behavior and btw, a test case for windows behavior would also be welcomed A+
participants (2)
-
Eric Pouech -
Mikołaj Zalewski