mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +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
2 changed files with 20 additions and 8 deletions
|
@ -110,7 +110,7 @@ GuiConsoleReadUserSettings(IN OUT PGUI_CONSOLE_INFO TermInfo,
|
|||
}
|
||||
else if (!wcscmp(szValueName, L"WindowPosition"))
|
||||
{
|
||||
TermInfo->AutoPosition = FALSE;
|
||||
TermInfo->AutoPosition = FALSE;
|
||||
TermInfo->WindowOrigin.x = LOWORD(Value);
|
||||
TermInfo->WindowOrigin.y = HIWORD(Value);
|
||||
RetVal = TRUE;
|
||||
|
@ -326,7 +326,6 @@ GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData,
|
|||
GuiInfo->FontWeight = GuiData->GuiInfo.FontWeight;
|
||||
GuiInfo->UseRasterFonts = GuiData->GuiInfo.UseRasterFonts;
|
||||
GuiInfo->FullScreen = GuiData->GuiInfo.FullScreen;
|
||||
/// GuiInfo->WindowPosition = GuiData->GuiInfo.WindowPosition;
|
||||
GuiInfo->AutoPosition = GuiData->GuiInfo.AutoPosition;
|
||||
GuiInfo->WindowOrigin = GuiData->GuiInfo.WindowOrigin;
|
||||
/* Offsetize */
|
||||
|
|
|
@ -59,6 +59,11 @@ GuiCopyFromTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
|
|||
Console->Selection.srSelection.Right,
|
||||
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... */
|
||||
size = selWidth;
|
||||
/* ... 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++)
|
||||
{
|
||||
ULONG length = selWidth;
|
||||
|
||||
ptr = ConioCoordToPointer(Buffer,
|
||||
Console->Selection.srSelection.Left,
|
||||
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 */
|
||||
for (xPos = 0; xPos < selWidth; xPos++)
|
||||
for (xPos = 0; xPos < length; xPos++)
|
||||
{
|
||||
/*
|
||||
* Sometimes, applications can put NULL chars into the screen-buffer
|
||||
* (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 += selWidth;
|
||||
dstPos += length;
|
||||
|
||||
/* Add newline characters if we are not in inline-text copy mode */
|
||||
if (!InlineCopyMode)
|
||||
|
|
Loading…
Reference in a new issue