Author: janderwald
Date: Sun Sep 2 22:21:36 2007
New Revision: 28779
URL:
http://svn.reactos.org/svn/reactos?rev=28779&view=rev
Log:
- implement screenbuffer resizing(required for console scrolling support)
- still quite buggy :)
Modified:
trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c Sun Sep 2 22:21:36 2007
@@ -1627,13 +1627,51 @@
if (windx != Console->ActiveBuffer->MaxX || windy !=
Console->ActiveBuffer->MaxY)
{
- //
- // TODO
- // resize screen buffer
-
-
- // Console->ActiveBuffer->MaxX = windx;
- // Console->ActiveBuffer->MaxY = windy;
+ BYTE * Buffer = HeapAlloc(Win32CsrApiHeap, 0, windx * windy * 2);
+ if (Buffer)
+ {
+ DWORD Offset = 0;
+ DWORD BufferOffset = 0;
+ USHORT CurrentY;
+ BYTE * OldBuffer;
+ DWORD diff;
+ DWORD value = ((((DWORD)Console->ActiveBuffer->DefaultAttrib) << 16)
| 0x20);
+
+ OldBuffer = Console->ActiveBuffer->Buffer;
+
+ for (CurrentY = 0; CurrentY < min(Console->ActiveBuffer->MaxY, windy);
CurrentY++)
+ {
+ if (windx < Console->ActiveBuffer->MaxX)
+ {
+ /* reduce size */
+ RtlCopyMemory(&Buffer[Offset], &OldBuffer[BufferOffset], windx *
2);
+ Offset += (windx * 2);
+ BufferOffset += (Console->ActiveBuffer->MaxX * 2);
+ }
+ else
+ {
+ /* enlarge size */
+ diff = windx - Console->ActiveBuffer->MaxX;
+
+ RtlCopyMemory(&Buffer[Offset], &OldBuffer[BufferOffset],
Console->ActiveBuffer->MaxX * 2);
+ Offset += (Console->ActiveBuffer->MaxX * 2);
+ /* zero new part of it */
+ memset(&Buffer[Offset], value, (diff * 2));
+ Offset += (diff * 2);
+ BufferOffset += (Console->ActiveBuffer->MaxX * 2);
+ }
+ }
+
+ if (windy > Console->ActiveBuffer->MaxY)
+ {
+ diff = windy - Console->ActiveBuffer->MaxX;
+ memset(&Buffer[Offset], value, diff * 2 * windx);
+ }
+ (void)InterlockedExchangePointer((PVOID volatile
*)Console->ActiveBuffer->Buffer, Buffer);
+ HeapFree(Win32CsrApiHeap, 0, OldBuffer);
+ Console->ActiveBuffer->MaxX = windx;
+ Console->ActiveBuffer->MaxY = windy;
+ }
}
windx = LOWORD(pConInfo->WindowSize);