mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 22:43:01 +00:00
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 svn path=/trunk/; revision=23031
This commit is contained in:
parent
b06a110bee
commit
d94f7c6e2b
3 changed files with 107 additions and 68 deletions
|
@ -108,14 +108,13 @@ static NTSTATUS FASTCALL
|
||||||
CsrInitConsoleScreenBuffer(PCSRSS_CONSOLE Console,
|
CsrInitConsoleScreenBuffer(PCSRSS_CONSOLE Console,
|
||||||
PCSRSS_SCREEN_BUFFER Buffer)
|
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.Type = CONIO_SCREEN_BUFFER_MAGIC;
|
||||||
Buffer->Header.ReferenceCount = 0;
|
Buffer->Header.ReferenceCount = 0;
|
||||||
Buffer->MaxX = Console->Size.X;
|
|
||||||
Buffer->MaxY = Console->Size.Y;
|
|
||||||
Buffer->ShowX = 0;
|
Buffer->ShowX = 0;
|
||||||
Buffer->ShowY = 0;
|
Buffer->ShowY = 0;
|
||||||
//FIXME
|
Buffer->Buffer = HeapAlloc(Win32CsrApiHeap, HEAP_ZERO_MEMORY, Buffer->MaxX * Buffer->MaxY * sizeof(WCHAR));
|
||||||
Buffer->Buffer = HeapAlloc(Win32CsrApiHeap, 0, Buffer->MaxX * Buffer->MaxY * 2);
|
|
||||||
if (NULL == Buffer->Buffer)
|
if (NULL == Buffer->Buffer)
|
||||||
{
|
{
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
@ -176,7 +175,23 @@ CsrInitConsole(PCSRSS_CONSOLE Console)
|
||||||
}
|
}
|
||||||
Console->PrivateData = NULL;
|
Console->PrivateData = NULL;
|
||||||
InitializeCriticalSection(&Console->Header.Lock);
|
InitializeCriticalSection(&Console->Header.Lock);
|
||||||
|
|
||||||
GuiMode = DtbgIsDesktopVisible();
|
GuiMode = DtbgIsDesktopVisible();
|
||||||
|
|
||||||
|
/* 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)
|
||||||
|
{
|
||||||
|
RtlFreeUnicodeString(&Console->Title);
|
||||||
|
DeleteCriticalSection(&Console->Header.Lock);
|
||||||
|
CloseHandle(Console->ActiveEvent);
|
||||||
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
if (! GuiMode)
|
if (! GuiMode)
|
||||||
{
|
{
|
||||||
Status = TuiInitConsole(Console);
|
Status = TuiInitConsole(Console);
|
||||||
|
@ -191,22 +206,15 @@ CsrInitConsole(PCSRSS_CONSOLE Console)
|
||||||
Status = GuiInitConsole(Console);
|
Status = GuiInitConsole(Console);
|
||||||
if (! NT_SUCCESS(Status))
|
if (! NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
HeapFree(Win32CsrApiHeap,0, NewBuffer);
|
||||||
RtlFreeUnicodeString(&Console->Title);
|
RtlFreeUnicodeString(&Console->Title);
|
||||||
DeleteCriticalSection(&Console->Header.Lock);
|
DeleteCriticalSection(&Console->Header.Lock);
|
||||||
CloseHandle(Console->ActiveEvent);
|
CloseHandle(Console->ActiveEvent);
|
||||||
|
DPRINT1("GuiInitConsole: failed\n");
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NewBuffer = HeapAlloc(Win32CsrApiHeap, 0, sizeof(CSRSS_SCREEN_BUFFER));
|
|
||||||
if (NULL == NewBuffer)
|
|
||||||
{
|
|
||||||
ConioCleanupConsole(Console);
|
|
||||||
RtlFreeUnicodeString(&Console->Title);
|
|
||||||
DeleteCriticalSection(&Console->Header.Lock);
|
|
||||||
CloseHandle(Console->ActiveEvent);
|
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
|
||||||
}
|
|
||||||
Status = CsrInitConsoleScreenBuffer(Console, NewBuffer);
|
Status = CsrInitConsoleScreenBuffer(Console, NewBuffer);
|
||||||
if (! NT_SUCCESS(Status))
|
if (! NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -215,12 +223,11 @@ CsrInitConsole(PCSRSS_CONSOLE Console)
|
||||||
DeleteCriticalSection(&Console->Header.Lock);
|
DeleteCriticalSection(&Console->Header.Lock);
|
||||||
CloseHandle(Console->ActiveEvent);
|
CloseHandle(Console->ActiveEvent);
|
||||||
HeapFree(Win32CsrApiHeap, 0, NewBuffer);
|
HeapFree(Win32CsrApiHeap, 0, NewBuffer);
|
||||||
|
DPRINT1("CsrInitConsoleScreenBuffer: failed\n");
|
||||||
return Status;
|
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 */
|
/* copy buffer contents to screen */
|
||||||
ConioDrawConsole(Console);
|
ConioDrawConsole(Console);
|
||||||
|
|
||||||
|
@ -2201,24 +2208,38 @@ CSR_API(CsrCreateScreenBuffer)
|
||||||
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
|
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
|
||||||
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
|
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
|
||||||
|
|
||||||
Buff = HeapAlloc(Win32CsrApiHeap, 0, sizeof(CSRSS_SCREEN_BUFFER));
|
Buff = HeapAlloc(Win32CsrApiHeap, HEAP_ZERO_MEMORY, sizeof(CSRSS_SCREEN_BUFFER));
|
||||||
if (NULL == Buff)
|
|
||||||
|
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;
|
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);
|
ConioUnlockConsole(Console);
|
||||||
|
|
||||||
return Request->Status;
|
return Request->Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ typedef struct GUI_CONSOLE_DATA_TAG
|
||||||
DWORD FullScreen;
|
DWORD FullScreen;
|
||||||
DWORD QuickEdit;
|
DWORD QuickEdit;
|
||||||
DWORD InsertMode;
|
DWORD InsertMode;
|
||||||
DWORD WindowSize;
|
|
||||||
} GUI_CONSOLE_DATA, *PGUI_CONSOLE_DATA;
|
} GUI_CONSOLE_DATA, *PGUI_CONSOLE_DATA;
|
||||||
|
|
||||||
#ifndef WM_APP
|
#ifndef WM_APP
|
||||||
|
@ -215,7 +214,7 @@ GuiConsoleOpenUserSettings(HWND hWnd, DWORD ProcessId, PHKEY hSubKey, REGSAM sam
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
static void FASTCALL
|
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 dwNumSubKeys = 0;
|
||||||
DWORD dwIndex;
|
DWORD dwIndex;
|
||||||
|
@ -274,7 +273,16 @@ GuiConsoleReadUserSettings(HKEY hKey, PGUI_CONSOLE_DATA GuiData)
|
||||||
}
|
}
|
||||||
else if (!wcscmp(szValueName, L"WindowSize"))
|
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"))
|
else if (!wcscmp(szValueName, L"FullScreen"))
|
||||||
{
|
{
|
||||||
|
@ -291,7 +299,7 @@ GuiConsoleReadUserSettings(HKEY hKey, PGUI_CONSOLE_DATA GuiData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static VOID FASTCALL
|
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
|
* init guidata with default properties
|
||||||
|
@ -299,13 +307,21 @@ GuiConsoleUseDefaults(PGUI_CONSOLE_DATA GuiData)
|
||||||
|
|
||||||
wcscpy(GuiData->FontName, L"Bitstream Vera Sans Mono");
|
wcscpy(GuiData->FontName, L"Bitstream Vera Sans Mono");
|
||||||
GuiData->FontSize = 0x0008000C; // font is 8x12
|
GuiData->FontSize = 0x0008000C; // font is 8x12
|
||||||
GuiData->WindowSize = 0x00190050; // default window size is 25x80
|
|
||||||
GuiData->FontWeight = FW_NORMAL;
|
GuiData->FontWeight = FW_NORMAL;
|
||||||
GuiData->CursorSize = 0;
|
GuiData->CursorSize = 0;
|
||||||
GuiData->HistoryNoDup = FALSE;
|
GuiData->HistoryNoDup = FALSE;
|
||||||
GuiData->FullScreen = FALSE;
|
GuiData->FullScreen = FALSE;
|
||||||
GuiData->QuickEdit = FALSE;
|
GuiData->QuickEdit = FALSE;
|
||||||
GuiData->InsertMode = TRUE;
|
GuiData->InsertMode = TRUE;
|
||||||
|
|
||||||
|
Console->Size.X = 80;
|
||||||
|
Console->Size.Y = 25;
|
||||||
|
|
||||||
|
if (Buffer)
|
||||||
|
{
|
||||||
|
Buffer->MaxX = 80;
|
||||||
|
Buffer->MaxY = 25;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -328,20 +344,17 @@ GuiConsoleHandleNcCreate(HWND hWnd, CREATESTRUCTW *Create)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiConsoleUseDefaults(GuiData);
|
GuiConsoleUseDefaults(Console, GuiData, Console->ActiveBuffer);
|
||||||
if (Console->ProcessList.Flink != &Console->ProcessList)
|
if (Console->ProcessList.Flink != &Console->ProcessList)
|
||||||
{
|
{
|
||||||
ProcessData = CONTAINING_RECORD(Console->ProcessList.Flink, CSRSS_PROCESS_DATA, ProcessEntry);
|
ProcessData = CONTAINING_RECORD(Console->ProcessList.Flink, CSRSS_PROCESS_DATA, ProcessEntry);
|
||||||
if (GuiConsoleOpenUserSettings(hWnd, PtrToUlong(ProcessData->ProcessId), &hKey, KEY_READ))
|
if (GuiConsoleOpenUserSettings(hWnd, PtrToUlong(ProcessData->ProcessId), &hKey, KEY_READ))
|
||||||
{
|
{
|
||||||
GuiConsoleReadUserSettings(hKey, GuiData);
|
GuiConsoleReadUserSettings(hKey, Console, GuiData, Console->ActiveBuffer);
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Console->Size.X = LOWORD(GuiData->WindowSize);
|
|
||||||
Console->Size.Y = HIWORD(GuiData->WindowSize);
|
|
||||||
|
|
||||||
InitializeCriticalSection(&GuiData->Lock);
|
InitializeCriticalSection(&GuiData->Lock);
|
||||||
|
|
||||||
GuiData->LineBuffer = (PWCHAR)HeapAlloc(Win32CsrApiHeap, HEAP_ZERO_MEMORY,
|
GuiData->LineBuffer = (PWCHAR)HeapAlloc(Win32CsrApiHeap, HEAP_ZERO_MEMORY,
|
||||||
|
@ -656,37 +669,40 @@ GuiConsoleHandlePaint(HWND hWnd, HDC hDCPaint)
|
||||||
if (Console != NULL && GuiData != NULL &&
|
if (Console != NULL && GuiData != NULL &&
|
||||||
Console->ActiveBuffer != NULL)
|
Console->ActiveBuffer != NULL)
|
||||||
{
|
{
|
||||||
EnterCriticalSection(&GuiData->Lock);
|
if (Console->ActiveBuffer->Buffer != NULL)
|
||||||
|
|
||||||
GuiConsolePaint(Console,
|
|
||||||
GuiData,
|
|
||||||
hDC,
|
|
||||||
&ps.rcPaint);
|
|
||||||
|
|
||||||
if (GuiData->Selection.left != -1)
|
|
||||||
{
|
{
|
||||||
RECT rc = GuiData->Selection;
|
EnterCriticalSection(&GuiData->Lock);
|
||||||
|
|
||||||
rc.left *= GuiData->CharWidth;
|
GuiConsolePaint(Console,
|
||||||
rc.top *= GuiData->CharHeight;
|
GuiData,
|
||||||
rc.right *= GuiData->CharWidth;
|
hDC,
|
||||||
rc.bottom *= GuiData->CharHeight;
|
&ps.rcPaint);
|
||||||
|
|
||||||
/* invert the selection */
|
if (GuiData->Selection.left != -1)
|
||||||
if (IntersectRect(&rc,
|
|
||||||
&ps.rcPaint,
|
|
||||||
&rc))
|
|
||||||
{
|
{
|
||||||
PatBlt(hDC,
|
RECT rc = GuiData->Selection;
|
||||||
rc.left,
|
|
||||||
rc.top,
|
|
||||||
rc.right - rc.left,
|
|
||||||
rc.bottom - rc.top,
|
|
||||||
DSTINVERT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LeaveCriticalSection(&GuiData->Lock);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EndPaint(hWnd, &ps);
|
EndPaint(hWnd, &ps);
|
||||||
|
@ -1563,7 +1579,7 @@ GuiInitConsole(PCSRSS_CONSOLE Console)
|
||||||
|
|
||||||
/* wait untill initialization has finished */
|
/* wait untill initialization has finished */
|
||||||
WaitForSingleObject(GuiData->hGuiInitEvent, INFINITE);
|
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);
|
CloseHandle(GuiData->hGuiInitEvent);
|
||||||
GuiData->hGuiInitEvent = NULL;
|
GuiData->hGuiInitEvent = NULL;
|
||||||
|
|
||||||
|
|
|
@ -242,6 +242,8 @@ TuiInitConsole(PCSRSS_CONSOLE Console)
|
||||||
Console->Vtbl = &TuiVtbl;
|
Console->Vtbl = &TuiVtbl;
|
||||||
Console->hWindow = (HWND) NULL;
|
Console->hWindow = (HWND) NULL;
|
||||||
Console->Size = PhysicalConsoleSize;
|
Console->Size = PhysicalConsoleSize;
|
||||||
|
Console->ActiveBuffer->MaxX = PhysicalConsoleSize.X;
|
||||||
|
Console->ActiveBuffer->MaxY = PhysicalConsoleSize.Y;
|
||||||
|
|
||||||
EnterCriticalSection(&ActiveConsoleLock);
|
EnterCriticalSection(&ActiveConsoleLock);
|
||||||
if (NULL != ActiveConsole)
|
if (NULL != ActiveConsole)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue