From 0671cb8e23411dc94df68bcaf05c6f3e31b10d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 3 Jul 2013 22:40:58 +0000 Subject: [PATCH] [CONSRV] - Move SrvSetConsoleWindowInfo to a better place. - When enlarging the console buffer, use the attributes of the last cell of each line to fill the new cells for each line. - Remove usage of HAVE_WMEMSET / wmemset for resizing the buffer (NOTE: maybe it will be needed again later on...) svn path=/trunk/; revision=59420 --- reactos/win32ss/user/consrv/condrv/text.c | 31 +++++--------- reactos/win32ss/user/consrv/conoutput.c | 52 +++++++++++++++++++++++ reactos/win32ss/user/consrv/frontendctl.c | 48 --------------------- 3 files changed, 63 insertions(+), 68 deletions(-) diff --git a/reactos/win32ss/user/consrv/condrv/text.c b/reactos/win32ss/user/consrv/condrv/text.c index 7c7b5d5c7ce..f74e53b045b 100644 --- a/reactos/win32ss/user/consrv/condrv/text.c +++ b/reactos/win32ss/user/consrv/condrv/text.c @@ -18,12 +18,6 @@ #define NDEBUG #include -/* -// Define wmemset(...) -#include -#define HAVE_WMEMSET -*/ - /* GLOBALS ********************************************************************/ @@ -323,13 +317,10 @@ ConioResizeBuffer(PCONSOLE Console, PCHAR_INFO Buffer; DWORD Offset = 0; PCHAR_INFO ptr; + WORD CurrentAttribute; USHORT CurrentY; PCHAR_INFO OldBuffer; -#ifdef HAVE_WMEMSET - USHORT value = MAKEWORD(' ', ScreenBuffer->ScreenDefaultAttrib); -#else DWORD i; -#endif DWORD diff; /* Buffer size is not allowed to be smaller than the view size */ @@ -374,28 +365,29 @@ ConioResizeBuffer(PCONSOLE Console, RtlCopyMemory(Buffer + Offset, ptr, ScreenBuffer->ScreenBufferSize.X * sizeof(CHAR_INFO)); Offset += ScreenBuffer->ScreenBufferSize.X; + /* The attribute to be used is the one of the last cell of the current line */ + CurrentAttribute = ConioCoordToPointer(ScreenBuffer, + ScreenBuffer->ScreenBufferSize.X - 1, + CurrentY)->Attributes; + diff = Size.X - ScreenBuffer->ScreenBufferSize.X; - /* Zero new part of it */ -#ifdef HAVE_WMEMSET - wmemset((PWCHAR)&Buffer[Offset], value, diff); -#else + + /* Zero-out the new part of the buffer */ for (i = 0; i < diff; i++) { ptr = Buffer + Offset; ptr->Char.UnicodeChar = L' '; - ptr->Attributes = ScreenBuffer->ScreenDefaultAttrib; + ptr->Attributes = CurrentAttribute; ++Offset; } -#endif } } if (Size.Y > ScreenBuffer->ScreenBufferSize.Y) { diff = Size.X * (Size.Y - ScreenBuffer->ScreenBufferSize.Y); -#ifdef HAVE_WMEMSET - wmemset((PWCHAR)&Buffer[Offset], value, diff); -#else + + /* Zero-out the new part of the buffer */ for (i = 0; i < diff; i++) { ptr = Buffer + Offset; @@ -403,7 +395,6 @@ ConioResizeBuffer(PCONSOLE Console, ptr->Attributes = ScreenBuffer->ScreenDefaultAttrib; ++Offset; } -#endif } (void)InterlockedExchangePointer((PVOID volatile*)&ScreenBuffer->Buffer, Buffer); diff --git a/reactos/win32ss/user/consrv/conoutput.c b/reactos/win32ss/user/consrv/conoutput.c index 7abde257dca..f2382a52d2f 100644 --- a/reactos/win32ss/user/consrv/conoutput.c +++ b/reactos/win32ss/user/consrv/conoutput.c @@ -756,4 +756,56 @@ CSR_API(SrvScrollConsoleScreenBuffer) return Status; } + + + + +CSR_API(SrvSetConsoleWindowInfo) +{ + NTSTATUS Status; + PCONSOLE_SETWINDOWINFO SetWindowInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetWindowInfoRequest; + PCONSOLE_SCREEN_BUFFER Buff; + SMALL_RECT WindowRect = SetWindowInfoRequest->WindowRect; + + DPRINT("SrvSetConsoleWindowInfo(0x%08x, %d, {L%d, T%d, R%d, B%d}) called\n", + SetWindowInfoRequest->OutputHandle, SetWindowInfoRequest->Absolute, + WindowRect.Left, WindowRect.Top, WindowRect.Right, WindowRect.Bottom); + + Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process), + SetWindowInfoRequest->OutputHandle, + &Buff, + GENERIC_READ, + TRUE); + if (!NT_SUCCESS(Status)) return Status; + + if (SetWindowInfoRequest->Absolute == FALSE) + { + /* Relative positions given. Transform them to absolute ones */ + WindowRect.Left += Buff->ViewOrigin.X; + WindowRect.Top += Buff->ViewOrigin.Y; + WindowRect.Right += Buff->ViewOrigin.X + Buff->ViewSize.X - 1; + WindowRect.Bottom += Buff->ViewOrigin.Y + Buff->ViewSize.Y - 1; + } + + /* See MSDN documentation on SetConsoleWindowInfo about the performed checks */ + if ( (WindowRect.Left < 0) || (WindowRect.Top < 0) || + (WindowRect.Right >= Buff->ScreenBufferSize.X) || + (WindowRect.Bottom >= Buff->ScreenBufferSize.Y) || + (WindowRect.Right <= WindowRect.Left) || + (WindowRect.Bottom <= WindowRect.Top) ) + { + ConSrvReleaseScreenBuffer(Buff, TRUE); + return STATUS_INVALID_PARAMETER; + } + + Buff->ViewOrigin.X = WindowRect.Left; + Buff->ViewOrigin.Y = WindowRect.Top; + + Buff->ViewSize.X = WindowRect.Right - WindowRect.Left + 1; + Buff->ViewSize.Y = WindowRect.Bottom - WindowRect.Top + 1; + + ConSrvReleaseScreenBuffer(Buff, TRUE); + return STATUS_SUCCESS; +} + /* EOF */ diff --git a/reactos/win32ss/user/consrv/frontendctl.c b/reactos/win32ss/user/consrv/frontendctl.c index 454702f9900..d878154a5dc 100644 --- a/reactos/win32ss/user/consrv/frontendctl.c +++ b/reactos/win32ss/user/consrv/frontendctl.c @@ -278,54 +278,6 @@ CSR_API(SrvSetConsoleMenuClose) return (Success ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL); } -CSR_API(SrvSetConsoleWindowInfo) -{ - NTSTATUS Status; - PCONSOLE_SETWINDOWINFO SetWindowInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetWindowInfoRequest; - PCONSOLE_SCREEN_BUFFER Buff; - SMALL_RECT WindowRect = SetWindowInfoRequest->WindowRect; - - DPRINT("SrvSetConsoleWindowInfo(0x%08x, %d, {L%d, T%d, R%d, B%d}) called\n", - SetWindowInfoRequest->OutputHandle, SetWindowInfoRequest->Absolute, - WindowRect.Left, WindowRect.Top, WindowRect.Right, WindowRect.Bottom); - - Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process), - SetWindowInfoRequest->OutputHandle, - &Buff, - GENERIC_READ, - TRUE); - if (!NT_SUCCESS(Status)) return Status; - - if (SetWindowInfoRequest->Absolute == FALSE) - { - /* Relative positions given. Transform them to absolute ones */ - WindowRect.Left += Buff->ViewOrigin.X; - WindowRect.Top += Buff->ViewOrigin.Y; - WindowRect.Right += Buff->ViewOrigin.X + Buff->ViewSize.X - 1; - WindowRect.Bottom += Buff->ViewOrigin.Y + Buff->ViewSize.Y - 1; - } - - /* See MSDN documentation on SetConsoleWindowInfo about the performed checks */ - if ( (WindowRect.Left < 0) || (WindowRect.Top < 0) || - (WindowRect.Right >= Buff->ScreenBufferSize.X) || - (WindowRect.Bottom >= Buff->ScreenBufferSize.Y) || - (WindowRect.Right <= WindowRect.Left) || - (WindowRect.Bottom <= WindowRect.Top) ) - { - ConSrvReleaseScreenBuffer(Buff, TRUE); - return STATUS_INVALID_PARAMETER; - } - - Buff->ViewOrigin.X = WindowRect.Left; - Buff->ViewOrigin.Y = WindowRect.Top; - - Buff->ViewSize.X = WindowRect.Right - WindowRect.Left + 1; - Buff->ViewSize.Y = WindowRect.Bottom - WindowRect.Top + 1; - - ConSrvReleaseScreenBuffer(Buff, TRUE); - return STATUS_SUCCESS; -} - CSR_API(SrvGetConsoleWindow) { NTSTATUS Status;