mirror of
https://github.com/reactos/reactos.git
synced 2024-08-04 10:30:59 +00:00
[CONSRV]
- Code cleaning. - Properly remove trailing whitespace when copying text from the console. svn path=/trunk/; revision=62738
This commit is contained in:
parent
09c6736145
commit
4496c7309a
|
@ -110,7 +110,7 @@ GuiConsoleReadUserSettings(IN OUT PGUI_CONSOLE_INFO TermInfo,
|
||||||
}
|
}
|
||||||
else if (!wcscmp(szValueName, L"WindowPosition"))
|
else if (!wcscmp(szValueName, L"WindowPosition"))
|
||||||
{
|
{
|
||||||
TermInfo->AutoPosition = FALSE;
|
TermInfo->AutoPosition = FALSE;
|
||||||
TermInfo->WindowOrigin.x = LOWORD(Value);
|
TermInfo->WindowOrigin.x = LOWORD(Value);
|
||||||
TermInfo->WindowOrigin.y = HIWORD(Value);
|
TermInfo->WindowOrigin.y = HIWORD(Value);
|
||||||
RetVal = TRUE;
|
RetVal = TRUE;
|
||||||
|
@ -326,7 +326,6 @@ GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData,
|
||||||
GuiInfo->FontWeight = GuiData->GuiInfo.FontWeight;
|
GuiInfo->FontWeight = GuiData->GuiInfo.FontWeight;
|
||||||
GuiInfo->UseRasterFonts = GuiData->GuiInfo.UseRasterFonts;
|
GuiInfo->UseRasterFonts = GuiData->GuiInfo.UseRasterFonts;
|
||||||
GuiInfo->FullScreen = GuiData->GuiInfo.FullScreen;
|
GuiInfo->FullScreen = GuiData->GuiInfo.FullScreen;
|
||||||
/// GuiInfo->WindowPosition = GuiData->GuiInfo.WindowPosition;
|
|
||||||
GuiInfo->AutoPosition = GuiData->GuiInfo.AutoPosition;
|
GuiInfo->AutoPosition = GuiData->GuiInfo.AutoPosition;
|
||||||
GuiInfo->WindowOrigin = GuiData->GuiInfo.WindowOrigin;
|
GuiInfo->WindowOrigin = GuiData->GuiInfo.WindowOrigin;
|
||||||
/* Offsetize */
|
/* Offsetize */
|
||||||
|
|
|
@ -59,6 +59,11 @@ GuiCopyFromTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
|
||||||
Console->Selection.srSelection.Right,
|
Console->Selection.srSelection.Right,
|
||||||
Console->Selection.srSelection.Bottom);
|
Console->Selection.srSelection.Bottom);
|
||||||
|
|
||||||
|
#ifdef IS_WHITESPACE
|
||||||
|
#undef IS_WHITESPACE
|
||||||
|
#endif
|
||||||
|
#define IS_WHITESPACE(c) ((c) == L'\0' || (c) == L' ' || (c) == L'\t')
|
||||||
|
|
||||||
/* Basic size for one line... */
|
/* Basic size for one line... */
|
||||||
size = selWidth;
|
size = selWidth;
|
||||||
/* ... and for the other lines, add newline characters if needed. */
|
/* ... and for the other lines, add newline characters if needed. */
|
||||||
|
@ -89,23 +94,31 @@ GuiCopyFromTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
|
||||||
|
|
||||||
for (yPos = 0; yPos < selHeight; yPos++)
|
for (yPos = 0; yPos < selHeight; yPos++)
|
||||||
{
|
{
|
||||||
|
ULONG length = selWidth;
|
||||||
|
|
||||||
ptr = ConioCoordToPointer(Buffer,
|
ptr = ConioCoordToPointer(Buffer,
|
||||||
Console->Selection.srSelection.Left,
|
Console->Selection.srSelection.Left,
|
||||||
Console->Selection.srSelection.Top + yPos);
|
Console->Selection.srSelection.Top + yPos);
|
||||||
|
|
||||||
|
/* Trim whitespace from the right */
|
||||||
|
while (length > 0)
|
||||||
|
{
|
||||||
|
if (IS_WHITESPACE(ptr[length-1].Char.UnicodeChar))
|
||||||
|
--length;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Copy only the characters, leave attributes alone */
|
/* Copy only the characters, leave attributes alone */
|
||||||
for (xPos = 0; xPos < selWidth; xPos++)
|
for (xPos = 0; xPos < length; xPos++)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Sometimes, applications can put NULL chars into the screen-buffer
|
* Sometimes, applications can put NULL chars into the screen-buffer
|
||||||
* (this behaviour is allowed). Detect this and replace by a space.
|
* (this behaviour is allowed). Detect this and replace by a space.
|
||||||
* FIXME - HACK: Improve the way we're doing that (i.e., put spaces
|
|
||||||
* instead of NULLs (or even, nothing) only if it exists a non-null
|
|
||||||
* char *after* those NULLs, before the end-of-line of the selection.
|
|
||||||
* Do the same concerning spaces -- i.e. trailing spaces --).
|
|
||||||
*/
|
*/
|
||||||
dstPos[xPos] = (ptr[xPos].Char.UnicodeChar ? ptr[xPos].Char.UnicodeChar : L' ');
|
dstPos[xPos] = (ptr[xPos].Char.UnicodeChar ? ptr[xPos].Char.UnicodeChar : L' ');
|
||||||
}
|
}
|
||||||
dstPos += selWidth;
|
dstPos += length;
|
||||||
|
|
||||||
/* Add newline characters if we are not in inline-text copy mode */
|
/* Add newline characters if we are not in inline-text copy mode */
|
||||||
if (!InlineCopyMode)
|
if (!InlineCopyMode)
|
||||||
|
|
Loading…
Reference in a new issue