Author: janderwald
Date: Thu Jul 13 01:06:21 2006
New Revision: 23031
URL:
http://svn.reactos.org/svn/reactos?rev=23031&view=rev
Log:
conio.c:
* create a CSRSS_SCREEN_BUFFER object before TuiInit/GuiInit
-> required for variable screen buffer sizes
* improve error handling in CsrCreateScreenBuffer
guiconsole.c:
* directly store WindowSize in CSRSS_CONSOLE struct
* read ScreenBufferSize value from registry and store result in CSRSS_SCREEN_BUFFER
* use default values for ScreenBufferSize / WindowSize
tuiconsole.c:
* set screenbuffer size to size of physical console size in init
Modified:
trunk/reactos/subsystems/win32/csrss/win32csr/conio.c
trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c
trunk/reactos/subsystems/win32/csrss/win32csr/tuiconsole.c
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/conio.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/conio.c (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/conio.c Thu Jul 13 01:06:21 2006
@@ -108,14 +108,13 @@
CsrInitConsoleScreenBuffer(PCSRSS_CONSOLE Console,
PCSRSS_SCREEN_BUFFER Buffer)
{
+ DPRINT("CsrInitConsoleScreenBuffer Size X %d Size Y %d\n", Buffer->MaxX,
Buffer->MaxY);
+
Buffer->Header.Type = CONIO_SCREEN_BUFFER_MAGIC;
Buffer->Header.ReferenceCount = 0;
- Buffer->MaxX = Console->Size.X;
- Buffer->MaxY = Console->Size.Y;
Buffer->ShowX = 0;
Buffer->ShowY = 0;
- //FIXME
- Buffer->Buffer = HeapAlloc(Win32CsrApiHeap, 0, Buffer->MaxX * Buffer->MaxY *
2);
+ Buffer->Buffer = HeapAlloc(Win32CsrApiHeap, HEAP_ZERO_MEMORY, Buffer->MaxX *
Buffer->MaxY * sizeof(WCHAR));
if (NULL == Buffer->Buffer)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -176,37 +175,46 @@
}
Console->PrivateData = NULL;
InitializeCriticalSection(&Console->Header.Lock);
+
GuiMode = DtbgIsDesktopVisible();
- if (! GuiMode)
- {
- Status = TuiInitConsole(Console);
- if (! NT_SUCCESS(Status))
- {
- DPRINT1("Failed to open text-mode console, switching to
gui-mode\n");
- GuiMode = TRUE;
- }
- }
- if (GuiMode)
- {
- Status = GuiInitConsole(Console);
- if (! NT_SUCCESS(Status))
- {
- RtlFreeUnicodeString(&Console->Title);
- DeleteCriticalSection(&Console->Header.Lock);
- CloseHandle(Console->ActiveEvent);
- return Status;
- }
- }
-
- NewBuffer = HeapAlloc(Win32CsrApiHeap, 0, sizeof(CSRSS_SCREEN_BUFFER));
+
+ /* allocate console screen buffer */
+ NewBuffer = HeapAlloc(Win32CsrApiHeap, HEAP_ZERO_MEMORY, sizeof(CSRSS_SCREEN_BUFFER));
+ /* make console active, and insert into console list */
+ Console->ActiveBuffer = (PCSRSS_SCREEN_BUFFER) NewBuffer;
+ /* add a reference count because the buffer is tied to the console */
+ InterlockedIncrement(&Console->ActiveBuffer->Header.ReferenceCount);
if (NULL == NewBuffer)
{
- ConioCleanupConsole(Console);
RtlFreeUnicodeString(&Console->Title);
DeleteCriticalSection(&Console->Header.Lock);
CloseHandle(Console->ActiveEvent);
return STATUS_INSUFFICIENT_RESOURCES;
}
+
+ if (! GuiMode)
+ {
+ Status = TuiInitConsole(Console);
+ if (! NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to open text-mode console, switching to
gui-mode\n");
+ GuiMode = TRUE;
+ }
+ }
+ if (GuiMode)
+ {
+ Status = GuiInitConsole(Console);
+ if (! NT_SUCCESS(Status))
+ {
+ HeapFree(Win32CsrApiHeap,0, NewBuffer);
+ RtlFreeUnicodeString(&Console->Title);
+ DeleteCriticalSection(&Console->Header.Lock);
+ CloseHandle(Console->ActiveEvent);
+ DPRINT1("GuiInitConsole: failed\n");
+ return Status;
+ }
+ }
+
Status = CsrInitConsoleScreenBuffer(Console, NewBuffer);
if (! NT_SUCCESS(Status))
{
@@ -215,12 +223,11 @@
DeleteCriticalSection(&Console->Header.Lock);
CloseHandle(Console->ActiveEvent);
HeapFree(Win32CsrApiHeap, 0, NewBuffer);
+ DPRINT1("CsrInitConsoleScreenBuffer: failed\n");
return Status;
}
- Console->ActiveBuffer = NewBuffer;
- /* add a reference count because the buffer is tied to the console */
- InterlockedIncrement(&Console->ActiveBuffer->Header.ReferenceCount);
- /* make console active, and insert into console list */
+
+
/* copy buffer contents to screen */
ConioDrawConsole(Console);
@@ -2201,24 +2208,38 @@
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
- Buff = HeapAlloc(Win32CsrApiHeap, 0, sizeof(CSRSS_SCREEN_BUFFER));
- if (NULL == Buff)
+ Buff = HeapAlloc(Win32CsrApiHeap, HEAP_ZERO_MEMORY, sizeof(CSRSS_SCREEN_BUFFER));
+
+ if (Buff != NULL)
+ {
+ if (Console->ActiveBuffer)
+ {
+ Buff->MaxX = Console->ActiveBuffer->MaxX;
+ Buff->MaxY = Console->ActiveBuffer->MaxY;
+ }
+
+ if (Buff->MaxX == 0)
+ Buff->MaxX = 80;
+
+ if (Buff->MaxY == 0)
+ Buff->MaxY = 25;
+
+ Status = CsrInitConsoleScreenBuffer(Console, Buff);
+ if(! NT_SUCCESS(Status))
+ {
+ Request->Status = Status;
+ }
+ else
+ {
+ Request->Status = Win32CsrInsertObject(ProcessData,
&Request->Data.CreateScreenBufferRequest.OutputHandle, &Buff->Header);
+ }
+ }
+ else
{
Request->Status = STATUS_INSUFFICIENT_RESOURCES;
}
- Status = CsrInitConsoleScreenBuffer(Console, Buff);
- if(! NT_SUCCESS(Status))
- {
- Request->Status = Status;
- }
- else
- {
- Request->Status = Win32CsrInsertObject(ProcessData,
&Request->Data.CreateScreenBufferRequest.OutputHandle, &Buff->Header);
- }
-
ConioUnlockConsole(Console);
-
return Request->Status;
}
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 Thu Jul 13 01:06:21 2006
@@ -40,7 +40,6 @@
DWORD FullScreen;
DWORD QuickEdit;
DWORD InsertMode;
- DWORD WindowSize;
} GUI_CONSOLE_DATA, *PGUI_CONSOLE_DATA;
#ifndef WM_APP
@@ -215,7 +214,7 @@
return FALSE;
}
static void FASTCALL
-GuiConsoleReadUserSettings(HKEY hKey, PGUI_CONSOLE_DATA GuiData)
+GuiConsoleReadUserSettings(HKEY hKey, PCSRSS_CONSOLE Console, PGUI_CONSOLE_DATA GuiData,
PCSRSS_SCREEN_BUFFER Buffer)
{
DWORD dwNumSubKeys = 0;
DWORD dwIndex;
@@ -274,7 +273,16 @@
}
else if (!wcscmp(szValueName, L"WindowSize"))
{
- GuiData->WindowSize = Value;
+ Console->Size.X = LOWORD(Value);
+ Console->Size.Y = HIWORD(Value);
+ }
+ else if (!wcscmp(szValueName, L"ScreenBufferSize"))
+ {
+ if( Buffer)
+ {
+ Buffer->MaxX = LOWORD(Value);
+ Buffer->MaxY = HIWORD(Value);
+ }
}
else if (!wcscmp(szValueName, L"FullScreen"))
{
@@ -291,7 +299,7 @@
}
}
static VOID FASTCALL
-GuiConsoleUseDefaults(PGUI_CONSOLE_DATA GuiData)
+GuiConsoleUseDefaults(PCSRSS_CONSOLE Console, PGUI_CONSOLE_DATA GuiData,
PCSRSS_SCREEN_BUFFER Buffer)
{
/*
* init guidata with default properties
@@ -299,13 +307,21 @@
wcscpy(GuiData->FontName, L"Bitstream Vera Sans Mono");
GuiData->FontSize = 0x0008000C; // font is 8x12
- GuiData->WindowSize = 0x00190050; // default window size is 25x80
GuiData->FontWeight = FW_NORMAL;
GuiData->CursorSize = 0;
GuiData->HistoryNoDup = FALSE;
GuiData->FullScreen = FALSE;
GuiData->QuickEdit = FALSE;
GuiData->InsertMode = TRUE;
+
+ Console->Size.X = 80;
+ Console->Size.Y = 25;
+
+ if (Buffer)
+ {
+ Buffer->MaxX = 80;
+ Buffer->MaxY = 25;
+ }
}
@@ -328,19 +344,16 @@
return FALSE;
}
- GuiConsoleUseDefaults(GuiData);
+ GuiConsoleUseDefaults(Console, GuiData, Console->ActiveBuffer);
if (Console->ProcessList.Flink != &Console->ProcessList)
{
ProcessData = CONTAINING_RECORD(Console->ProcessList.Flink, CSRSS_PROCESS_DATA,
ProcessEntry);
if (GuiConsoleOpenUserSettings(hWnd, PtrToUlong(ProcessData->ProcessId),
&hKey, KEY_READ))
{
- GuiConsoleReadUserSettings(hKey, GuiData);
+ GuiConsoleReadUserSettings(hKey, Console, GuiData, Console->ActiveBuffer);
RegCloseKey(hKey);
}
}
-
- Console->Size.X = LOWORD(GuiData->WindowSize);
- Console->Size.Y = HIWORD(GuiData->WindowSize);
InitializeCriticalSection(&GuiData->Lock);
@@ -656,37 +669,40 @@
if (Console != NULL && GuiData != NULL &&
Console->ActiveBuffer != NULL)
{
- EnterCriticalSection(&GuiData->Lock);
-
- GuiConsolePaint(Console,
- GuiData,
- hDC,
- &ps.rcPaint);
-
- if (GuiData->Selection.left != -1)
+ if (Console->ActiveBuffer->Buffer != NULL)
{
- RECT rc = GuiData->Selection;
-
- rc.left *= GuiData->CharWidth;
- rc.top *= GuiData->CharHeight;
- rc.right *= GuiData->CharWidth;
- rc.bottom *= GuiData->CharHeight;
-
- /* invert the selection */
- if (IntersectRect(&rc,
- &ps.rcPaint,
- &rc))
+ EnterCriticalSection(&GuiData->Lock);
+
+ GuiConsolePaint(Console,
+ GuiData,
+ hDC,
+ &ps.rcPaint);
+
+ if (GuiData->Selection.left != -1)
{
- PatBlt(hDC,
- rc.left,
- rc.top,
- rc.right - rc.left,
- rc.bottom - rc.top,
- DSTINVERT);
+ RECT rc = GuiData->Selection;
+
+ rc.left *= GuiData->CharWidth;
+ rc.top *= GuiData->CharHeight;
+ rc.right *= GuiData->CharWidth;
+ rc.bottom *= GuiData->CharHeight;
+
+ /* invert the selection */
+ if (IntersectRect(&rc,
+ &ps.rcPaint,
+ &rc))
+ {
+ PatBlt(hDC,
+ rc.left,
+ rc.top,
+ rc.right - rc.left,
+ rc.bottom - rc.top,
+ DSTINVERT);
+ }
}
+
+ LeaveCriticalSection(&GuiData->Lock);
}
-
- LeaveCriticalSection(&GuiData->Lock);
}
EndPaint(hWnd, &ps);
@@ -1563,7 +1579,7 @@
/* wait untill initialization has finished */
WaitForSingleObject(GuiData->hGuiInitEvent, INFINITE);
- DPRINT("received event Console %p GuiData %p X %d Y %d\n", Console,
Console->PrivateData, Console->Size.X, Console->Size.Y);
+ DPRINT1("received event Console %p GuiData %p X %d Y %d\n", Console,
Console->PrivateData, Console->Size.X, Console->Size.Y);
CloseHandle(GuiData->hGuiInitEvent);
GuiData->hGuiInitEvent = NULL;
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/tuiconsole.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/tuiconsole.c (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/tuiconsole.c Thu Jul 13 01:06:21 2006
@@ -242,6 +242,8 @@
Console->Vtbl = &TuiVtbl;
Console->hWindow = (HWND) NULL;
Console->Size = PhysicalConsoleSize;
+ Console->ActiveBuffer->MaxX = PhysicalConsoleSize.X;
+ Console->ActiveBuffer->MaxY = PhysicalConsoleSize.Y;
EnterCriticalSection(&ActiveConsoleLock);
if (NULL != ActiveConsole)