mirror of
https://github.com/reactos/reactos.git
synced 2025-01-03 21:09:19 +00:00
[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
This commit is contained in:
parent
21e39738fe
commit
0671cb8e23
3 changed files with 63 additions and 68 deletions
|
@ -18,12 +18,6 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/*
|
||||
// Define wmemset(...)
|
||||
#include <wchar.h>
|
||||
#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);
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue