return STATUS_SUCCESS;
}
+NTSTATUS NTAPI
+ConDrvChangeScreenBufferAttributes(IN PCONSOLE Console,
+ IN PTEXTMODE_SCREEN_BUFFER Buffer,
+ IN USHORT NewScreenAttrib,
+ IN USHORT NewPopupAttrib)
+{
+ DWORD X, Y, Length;
+ PCHAR_INFO Ptr;
+
+ COORD TopLeft = {0};
+ ULONG NumCodesToWrite = Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y;
+ USHORT OldScreenAttrib = Buffer->ScreenDefaultAttrib;
+
+ if (Console == NULL || Buffer == NULL)
+ {
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* Validity check */
+ ASSERT(Console == Buffer->Header.Console);
+
+ X = TopLeft.X;
+ Y = (TopLeft.Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
+ Length = NumCodesToWrite;
+ // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work
+ // Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X]; // May work
+
+ while (Length--)
+ {
+ // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work either
+ Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X];
+
+ /*
+ * Change the current colors only if they are the old ones.
+ */
+
+ /* Foreground color */
+ if ((Ptr->Attributes & 0x0F) == (OldScreenAttrib & 0x0F))
+ Ptr->Attributes = (Ptr->Attributes & 0xFFF0) | (NewScreenAttrib & 0x0F);
+
+ /* Background color */
+ if ((Ptr->Attributes & 0xF0) == (OldScreenAttrib & 0xF0))
+ Ptr->Attributes = (Ptr->Attributes & 0xFF0F) | (NewScreenAttrib & 0xF0);
+
+ // ++Ptr;
+
+ if (++X == Buffer->ScreenBufferSize.X)
+ {
+ X = 0;
+
+ if (++Y == Buffer->ScreenBufferSize.Y)
+ {
+ Y = 0;
+ }
+ }
+ }
+
+ /* Save foreground and background colors for both screen and popup */
+ Buffer->ScreenDefaultAttrib = (NewScreenAttrib & 0x00FF);
+ Buffer->PopupDefaultAttrib = (NewPopupAttrib & 0x00FF);
+
+ /* Refresh the display if needed */
+ if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
+ {
+ SMALL_RECT UpdateRect;
+ ConioComputeUpdateRect(Buffer, &UpdateRect, &TopLeft, NumCodesToWrite);
+ TermDrawRegion(Console, &UpdateRect);
+ }
+
+ return STATUS_SUCCESS;
+}
+
/* PUBLIC DRIVER APIS *********************************************************/
PWCHAR tmpString = NULL;
DWORD X, Y, Length; // , Written = 0;
ULONG CodeSize;
- SMALL_RECT UpdateRect;
PCHAR_INFO Ptr;
if (Console == NULL || Buffer == NULL ||
if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
{
+ SMALL_RECT UpdateRect;
ConioComputeUpdateRect(Buffer, &UpdateRect, WriteCoord, NumCodesToWrite);
TermDrawRegion(Console, &UpdateRect);
}
{
DWORD X, Y, Length; // , Written = 0;
PCHAR_INFO Ptr;
- SMALL_RECT UpdateRect;
if (Console == NULL || Buffer == NULL || Code == NULL ||
WriteCoord == NULL /* || CodesWritten == NULL */)
if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
{
+ SMALL_RECT UpdateRect;
ConioComputeUpdateRect(Buffer, &UpdateRect, WriteCoord, NumCodesToWrite);
TermDrawRegion(Console, &UpdateRect);
}
}
}
-
+NTSTATUS NTAPI
+ConDrvChangeScreenBufferAttributes(IN PCONSOLE Console,
+ IN PTEXTMODE_SCREEN_BUFFER Buffer,
+ IN USHORT NewScreenAttrib,
+ IN USHORT NewPopupAttrib);
/*
* NOTE: This function explicitely references Console->ActiveBuffer.
* It is possible that it should go into some frontend...
Console->QuickEdit = ConsoleInfo->QuickEdit;
Console->InsertMode = ConsoleInfo->InsertMode;
- /*
- * Apply foreground and background colors for both screen and popup
- * and copy the new palette.
- */
- if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
- {
- PTEXTMODE_SCREEN_BUFFER Buffer = (PTEXTMODE_SCREEN_BUFFER)ActiveBuffer;
-
- Buffer->ScreenDefaultAttrib = ConsoleInfo->ScreenAttrib;
- Buffer->PopupDefaultAttrib = ConsoleInfo->PopupAttrib;
- }
- else // if (Console->ActiveBuffer->Header.Type == GRAPHICS_BUFFER)
- {
- }
-
+ /* Copy the new console palette */
// FIXME: Possible buffer overflow if s_colors is bigger than pConInfo->Colors.
memcpy(Console->Colors, ConsoleInfo->Colors, sizeof(s_Colors));
- // TODO: Really update the screen attributes as FillConsoleOutputAttribute does.
-
/* Apply cursor size */
ActiveBuffer->CursorInfo.bVisible = (ConsoleInfo->CursorSize != 0);
ActiveBuffer->CursorInfo.dwSize = min(max(ConsoleInfo->CursorSize, 0), 100);
if (SizeChanged) TermResizeTerminal(Console);
}
+
+ /* Apply foreground and background colors for both screen and popup */
+ ConDrvChangeScreenBufferAttributes(Console,
+ Buffer,
+ ConsoleInfo->ScreenAttrib,
+ ConsoleInfo->PopupAttrib);
}
else // if (GetType(ActiveBuffer) == GRAPHICS_BUFFER)
{