Skip to content

Commit 4496c73

Browse files
committed
[CONSRV]
- Code cleaning. - Properly remove trailing whitespace when copying text from the console. svn path=/trunk/; revision=62738
1 parent 09c6736 commit 4496c73

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

reactos/win32ss/user/winsrv/consrv/frontends/gui/guisettings.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ GuiConsoleReadUserSettings(IN OUT PGUI_CONSOLE_INFO TermInfo,
110110
}
111111
else if (!wcscmp(szValueName, L"WindowPosition"))
112112
{
113-
TermInfo->AutoPosition = FALSE;
113+
TermInfo->AutoPosition = FALSE;
114114
TermInfo->WindowOrigin.x = LOWORD(Value);
115115
TermInfo->WindowOrigin.y = HIWORD(Value);
116116
RetVal = TRUE;
@@ -326,7 +326,6 @@ GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData,
326326
GuiInfo->FontWeight = GuiData->GuiInfo.FontWeight;
327327
GuiInfo->UseRasterFonts = GuiData->GuiInfo.UseRasterFonts;
328328
GuiInfo->FullScreen = GuiData->GuiInfo.FullScreen;
329-
/// GuiInfo->WindowPosition = GuiData->GuiInfo.WindowPosition;
330329
GuiInfo->AutoPosition = GuiData->GuiInfo.AutoPosition;
331330
GuiInfo->WindowOrigin = GuiData->GuiInfo.WindowOrigin;
332331
/* Offsetize */

reactos/win32ss/user/winsrv/consrv/frontends/gui/text.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ GuiCopyFromTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
5959
Console->Selection.srSelection.Right,
6060
Console->Selection.srSelection.Bottom);
6161

62+
#ifdef IS_WHITESPACE
63+
#undef IS_WHITESPACE
64+
#endif
65+
#define IS_WHITESPACE(c) ((c) == L'\0' || (c) == L' ' || (c) == L'\t')
66+
6267
/* Basic size for one line... */
6368
size = selWidth;
6469
/* ... and for the other lines, add newline characters if needed. */
@@ -89,23 +94,31 @@ GuiCopyFromTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
8994

9095
for (yPos = 0; yPos < selHeight; yPos++)
9196
{
97+
ULONG length = selWidth;
98+
9299
ptr = ConioCoordToPointer(Buffer,
93100
Console->Selection.srSelection.Left,
94101
Console->Selection.srSelection.Top + yPos);
102+
103+
/* Trim whitespace from the right */
104+
while (length > 0)
105+
{
106+
if (IS_WHITESPACE(ptr[length-1].Char.UnicodeChar))
107+
--length;
108+
else
109+
break;
110+
}
111+
95112
/* Copy only the characters, leave attributes alone */
96-
for (xPos = 0; xPos < selWidth; xPos++)
113+
for (xPos = 0; xPos < length; xPos++)
97114
{
98115
/*
99116
* Sometimes, applications can put NULL chars into the screen-buffer
100117
* (this behaviour is allowed). Detect this and replace by a space.
101-
* FIXME - HACK: Improve the way we're doing that (i.e., put spaces
102-
* instead of NULLs (or even, nothing) only if it exists a non-null
103-
* char *after* those NULLs, before the end-of-line of the selection.
104-
* Do the same concerning spaces -- i.e. trailing spaces --).
105118
*/
106119
dstPos[xPos] = (ptr[xPos].Char.UnicodeChar ? ptr[xPos].Char.UnicodeChar : L' ');
107120
}
108-
dstPos += selWidth;
121+
dstPos += length;
109122

110123
/* Add newline characters if we are not in inline-text copy mode */
111124
if (!InlineCopyMode)

0 commit comments

Comments
 (0)