[CONSRV]:

Fix console palette setting. For that, we create a console framebuffer on which we draw the different active screen buffers (be they text or graphics), we can change the palette associated to this framebuffer and then we draw the framebuffer on screen.
Console palettes now work !!!!!! @ [TheFlash]

Part 2/2

svn path=/trunk/; revision=60734
This commit is contained in:
Hermès Bélusca-Maïto 2013-10-23 00:12:17 +00:00
parent 8efecdcf15
commit dd2d4349e2
6 changed files with 179 additions and 185 deletions

View file

@ -1340,6 +1340,8 @@ ConDrvSetConsoleWindowInfo(IN PCONSOLE Console,
Buffer->ViewSize.X = CapturedWindowRect.Right - CapturedWindowRect.Left + 1; Buffer->ViewSize.X = CapturedWindowRect.Right - CapturedWindowRect.Left + 1;
Buffer->ViewSize.Y = CapturedWindowRect.Bottom - CapturedWindowRect.Top + 1; Buffer->ViewSize.Y = CapturedWindowRect.Bottom - CapturedWindowRect.Top + 1;
// TermResizeTerminal(Console);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View file

@ -40,7 +40,7 @@ NTSTATUS FASTCALL ConDrvCreateScreenBuffer(OUT PCONSOLE_SCREEN_BUFFER* Buffer,
VOID NTAPI ConioDeleteScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer); VOID NTAPI ConioDeleteScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer);
// VOID FASTCALL ConioSetActiveScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer); // VOID FASTCALL ConioSetActiveScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer);
// PCONSOLE_SCREEN_BUFFER PCONSOLE_SCREEN_BUFFER
// ConDrvGetActiveScreenBuffer(IN PCONSOLE Console); ConDrvGetActiveScreenBuffer(IN PCONSOLE Console);
/* EOF */ /* EOF */

View file

@ -46,11 +46,16 @@ GuiPasteToGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer)
VOID VOID
GuiPaintGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer, GuiPaintGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer,
PGUI_CONSOLE_DATA GuiData, PGUI_CONSOLE_DATA GuiData,
HDC hDC, PRECT rcView,
PRECT rc) PRECT rcFramebuffer)
{ {
if (Buffer->BitMap == NULL) return; if (Buffer->BitMap == NULL) return;
rcFramebuffer->left = Buffer->ViewOrigin.X * 1 + rcView->left;
rcFramebuffer->top = Buffer->ViewOrigin.Y * 1 + rcView->top;
rcFramebuffer->right = Buffer->ViewOrigin.X * 1 + rcView->right;
rcFramebuffer->bottom = Buffer->ViewOrigin.Y * 1 + rcView->bottom;
/* Grab the mutex */ /* Grab the mutex */
NtWaitForSingleObject(Buffer->Mutex, FALSE, NULL); NtWaitForSingleObject(Buffer->Mutex, FALSE, NULL);
@ -59,15 +64,15 @@ GuiPaintGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer,
* the Y-coordinate of the "lower-left corner" of the image, be the DIB * the Y-coordinate of the "lower-left corner" of the image, be the DIB
* in bottom-up or top-down mode. * in bottom-up or top-down mode.
*/ */
SetDIBitsToDevice(hDC, SetDIBitsToDevice(GuiData->hMemDC,
/* Coordinates / size of the repainted rectangle, in the view's frame */ /* Coordinates / size of the repainted rectangle, in the framebuffer's frame */
rc->left, rcFramebuffer->left,
rc->top, rcFramebuffer->top,
rc->right - rc->left, rcFramebuffer->right - rcFramebuffer->left,
rc->bottom - rc->top, rcFramebuffer->bottom - rcFramebuffer->top,
/* Coordinates / size of the corresponding image portion, in the graphics screen-buffer's frame */ /* Coordinates / size of the corresponding image portion, in the graphics screen-buffer's frame */
Buffer->ViewOrigin.X + rc->left, rcFramebuffer->left,
Buffer->ViewOrigin.Y + rc->top, rcFramebuffer->top,
0, 0,
Buffer->ScreenBufferSize.Y, // == Buffer->BitMapInfo->bmiHeader.biHeight Buffer->ScreenBufferSize.Y, // == Buffer->BitMapInfo->bmiHeader.biHeight
Buffer->BitMap, Buffer->BitMap,

View file

@ -41,21 +41,23 @@ typedef struct _GUI_CONSOLE_DATA
{ {
CRITICAL_SECTION Lock; CRITICAL_SECTION Lock;
BOOL WindowSizeLock; BOOL WindowSizeLock;
HANDLE hGuiInitEvent; HANDLE hGuiInitEvent;
POINT OldCursor;
HWND hWindow; /* Handle to the console's window */ POINT OldCursor;
HICON hIcon; /* Handle to the console's icon (big) */
HICON hIconSm; /* Handle to the console's icon (small) */
LONG_PTR WndStyle; LONG_PTR WndStyle;
LONG_PTR WndStyleEx; LONG_PTR WndStyleEx;
BOOL IsWndMax; BOOL IsWndMax;
WINDOWPLACEMENT WndPl; WINDOWPLACEMENT WndPl;
HWND hWindow; /* Handle to the console's window */
HDC hMemDC; /* Memory DC holding the console framebuffer */
HBITMAP hBitmap; /* Console framebuffer */
HPALETTE hSysPalette; /* Handle to the original system palette */ HPALETTE hSysPalette; /* Handle to the original system palette */
HICON hIcon; /* Handle to the console's icon (big) */
HICON hIconSm; /* Handle to the console's icon (small) */
/*** The following may be put per-screen-buffer !! ***/ /*** The following may be put per-screen-buffer !! ***/
HCURSOR hCursor; /* Handle to the mouse cursor */ HCURSOR hCursor; /* Handle to the mouse cursor */
INT MouseCursorRefCount; /* The reference counter associated with the mouse cursor. >= 0 and the cursor is shown; < 0 and the cursor is hidden. */ INT MouseCursorRefCount; /* The reference counter associated with the mouse cursor. >= 0 and the cursor is shown; < 0 and the cursor is hidden. */

View file

@ -250,7 +250,7 @@ GuiConsoleUpdateSelection(PCONSOLE Console, PCOORD coord);
static VOID NTAPI static VOID NTAPI
GuiDrawRegion(IN OUT PFRONTEND This, SMALL_RECT* Region); GuiDrawRegion(IN OUT PFRONTEND This, SMALL_RECT* Region);
static VOID static VOID
GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData); GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData, DWORD WidthUnit, DWORD HeightUnit);
static LRESULT static LRESULT
@ -265,7 +265,6 @@ GuiConsoleHandleSysMenuCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM
Ret = FALSE; Ret = FALSE;
goto Quit; goto Quit;
} }
// ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
ActiveBuffer = GuiData->ActiveBuffer; ActiveBuffer = GuiData->ActiveBuffer;
/* /*
@ -412,16 +411,12 @@ GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData)
} }
static VOID static VOID
GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData) GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData, DWORD WidthUnit, DWORD HeightUnit)
{ {
// PCONSOLE Console = GuiData->Console; PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer;
PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
SCROLLINFO sInfo; SCROLLINFO sInfo;
DWORD Width, Height; DWORD Width, Height;
UINT WidthUnit, HeightUnit;
GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
Width = Buff->ViewSize.X * WidthUnit + Width = Buff->ViewSize.X * WidthUnit +
2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE)); 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE));
@ -551,6 +546,11 @@ GuiConsoleHandleNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
ReleaseDC(GuiData->hWindow, hDC); ReleaseDC(GuiData->hWindow, hDC);
/* Initialize the terminal framebuffer */
GuiData->hMemDC = CreateCompatibleDC(NULL);
GuiData->hBitmap = NULL;
GuiData->hSysPalette = NULL; /* Original system palette */
// FIXME: Keep these instructions here ? /////////////////////////////////// // FIXME: Keep these instructions here ? ///////////////////////////////////
Console->ActiveBuffer->CursorBlinkOn = TRUE; Console->ActiveBuffer->CursorBlinkOn = TRUE;
Console->ActiveBuffer->ForceCursorOff = FALSE; Console->ActiveBuffer->ForceCursorOff = FALSE;
@ -570,8 +570,7 @@ GuiConsoleHandleNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
static VOID static VOID
SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect) SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
{ {
// PCONSOLE Console = GuiData->Console; PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
UINT WidthUnit, HeightUnit; UINT WidthUnit, HeightUnit;
GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit); GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit);
@ -647,13 +646,13 @@ GuiConsoleUpdateSelection(PCONSOLE Console, PCOORD coord)
VOID VOID
GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer, GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
PGUI_CONSOLE_DATA GuiData, PGUI_CONSOLE_DATA GuiData,
HDC hDC, PRECT rcView,
PRECT rc); PRECT rcFramebuffer);
VOID VOID
GuiPaintGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer, GuiPaintGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer,
PGUI_CONSOLE_DATA GuiData, PGUI_CONSOLE_DATA GuiData,
HDC hDC, PRECT rcView,
PRECT rc); PRECT rcFramebuffer);
static VOID static VOID
GuiConsoleHandlePaint(PGUI_CONSOLE_DATA GuiData) GuiConsoleHandlePaint(PGUI_CONSOLE_DATA GuiData)
@ -661,49 +660,54 @@ GuiConsoleHandlePaint(PGUI_CONSOLE_DATA GuiData)
BOOL Success = TRUE; BOOL Success = TRUE;
PCONSOLE Console = GuiData->Console; PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER ActiveBuffer; PCONSOLE_SCREEN_BUFFER ActiveBuffer;
HDC hDC;
PAINTSTRUCT ps; PAINTSTRUCT ps;
RECT rcPaint;
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
{ {
Success = FALSE; Success = FALSE;
goto Quit; goto Quit;
} }
// ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
ActiveBuffer = GuiData->ActiveBuffer; ActiveBuffer = GuiData->ActiveBuffer;
hDC = BeginPaint(GuiData->hWindow, &ps); BeginPaint(GuiData->hWindow, &ps);
if (hDC != NULL && if (ps.hdc != NULL &&
ps.rcPaint.left < ps.rcPaint.right && ps.rcPaint.left < ps.rcPaint.right &&
ps.rcPaint.top < ps.rcPaint.bottom) ps.rcPaint.top < ps.rcPaint.bottom)
{ {
EnterCriticalSection(&GuiData->Lock); EnterCriticalSection(&GuiData->Lock);
/* Compose the current screen-buffer on-memory */
if (GetType(ActiveBuffer) == TEXTMODE_BUFFER) if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
{ {
GuiPaintTextModeBuffer((PTEXTMODE_SCREEN_BUFFER)ActiveBuffer, GuiPaintTextModeBuffer((PTEXTMODE_SCREEN_BUFFER)ActiveBuffer,
GuiData, hDC, &ps.rcPaint); GuiData, &ps.rcPaint, &rcPaint);
} }
else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */ else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
{ {
GuiPaintGraphicsBuffer((PGRAPHICS_SCREEN_BUFFER)ActiveBuffer, GuiPaintGraphicsBuffer((PGRAPHICS_SCREEN_BUFFER)ActiveBuffer,
GuiData, hDC, &ps.rcPaint); GuiData, &ps.rcPaint, &rcPaint);
} }
/* Send it to screen */
BitBlt(ps.hdc,
ps.rcPaint.left,
ps.rcPaint.top,
rcPaint.right - rcPaint.left,
rcPaint.bottom - rcPaint.top,
GuiData->hMemDC,
rcPaint.left,
rcPaint.top,
SRCCOPY);
if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY) if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
{ {
RECT rc; SmallRectToRect(GuiData, &rcPaint, &Console->Selection.srSelection);
SmallRectToRect(GuiData, &rc, &Console->Selection.srSelection);
/* invert the selection */ /* Invert the selection */
if (IntersectRect(&rc, &ps.rcPaint, &rc)) if (IntersectRect(&rcPaint, &ps.rcPaint, &rcPaint))
{ {
PatBlt(hDC, InvertRect(ps.hdc, &rcPaint);
rc.left,
rc.top,
rc.right - rc.left,
rc.bottom - rc.top,
DSTINVERT);
} }
} }
@ -751,7 +755,6 @@ GuiConsoleHandleKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM l
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return; if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
// ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
ActiveBuffer = GuiData->ActiveBuffer; ActiveBuffer = GuiData->ActiveBuffer;
if (Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) if (Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS)
@ -924,14 +927,15 @@ GuiConsoleHandleTimer(PGUI_CONSOLE_DATA GuiData)
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return; if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
Buff = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console); Buff = GuiData->ActiveBuffer;
if (GetType(Buff) == TEXTMODE_BUFFER) if (GetType(Buff) == TEXTMODE_BUFFER)
{ {
GuiInvalidateCell(&Console->TermIFace, Buff->CursorPosition.X, Buff->CursorPosition.Y); GuiInvalidateCell(&Console->TermIFace, Buff->CursorPosition.X, Buff->CursorPosition.Y);
Buff->CursorBlinkOn = !Buff->CursorBlinkOn; Buff->CursorBlinkOn = !Buff->CursorBlinkOn;
if ((GuiData->OldCursor.x != Buff->CursorPosition.X) || (GuiData->OldCursor.y != Buff->CursorPosition.Y)) if ((GuiData->OldCursor.x != Buff->CursorPosition.X) ||
(GuiData->OldCursor.y != Buff->CursorPosition.Y))
{ {
SCROLLINFO xScroll; SCROLLINFO xScroll;
int OldScrollX = -1, OldScrollY = -1; int OldScrollX = -1, OldScrollY = -1;
@ -946,11 +950,14 @@ GuiConsoleHandleTimer(PGUI_CONSOLE_DATA GuiData)
// If we successfully got the info for the horizontal scrollbar // If we successfully got the info for the horizontal scrollbar
if (OldScrollX >= 0) if (OldScrollX >= 0)
{ {
if ((Buff->CursorPosition.X < Buff->ViewOrigin.X) || (Buff->CursorPosition.X >= (Buff->ViewOrigin.X + Buff->ViewSize.X))) if ((Buff->CursorPosition.X < Buff->ViewOrigin.X) ||
(Buff->CursorPosition.X >= (Buff->ViewOrigin.X + Buff->ViewSize.X)))
{ {
// Handle the horizontal scroll bar // Handle the horizontal scroll bar
if (Buff->CursorPosition.X >= Buff->ViewSize.X) NewScrollX = Buff->CursorPosition.X - Buff->ViewSize.X + 1; if (Buff->CursorPosition.X >= Buff->ViewSize.X)
else NewScrollX = 0; NewScrollX = Buff->CursorPosition.X - Buff->ViewSize.X + 1;
else
NewScrollX = 0;
} }
else else
{ {
@ -960,11 +967,14 @@ GuiConsoleHandleTimer(PGUI_CONSOLE_DATA GuiData)
// If we successfully got the info for the vertical scrollbar // If we successfully got the info for the vertical scrollbar
if (OldScrollY >= 0) if (OldScrollY >= 0)
{ {
if ((Buff->CursorPosition.Y < Buff->ViewOrigin.Y) || (Buff->CursorPosition.Y >= (Buff->ViewOrigin.Y + Buff->ViewSize.Y))) if ((Buff->CursorPosition.Y < Buff->ViewOrigin.Y) ||
(Buff->CursorPosition.Y >= (Buff->ViewOrigin.Y + Buff->ViewSize.Y)))
{ {
// Handle the vertical scroll bar // Handle the vertical scroll bar
if (Buff->CursorPosition.Y >= Buff->ViewSize.Y) NewScrollY = Buff->CursorPosition.Y - Buff->ViewSize.Y + 1; if (Buff->CursorPosition.Y >= Buff->ViewSize.Y)
else NewScrollY = 0; NewScrollY = Buff->CursorPosition.Y - Buff->ViewSize.Y + 1;
else
NewScrollY = 0;
} }
else else
{ {
@ -999,6 +1009,7 @@ GuiConsoleHandleTimer(PGUI_CONSOLE_DATA GuiData)
SetScrollInfo(GuiData->hWindow, SB_VERT, &xScroll, TRUE); SetScrollInfo(GuiData->hWindow, SB_VERT, &xScroll, TRUE);
} }
UpdateWindow(GuiData->hWindow); UpdateWindow(GuiData->hWindow);
// InvalidateRect(GuiData->hWindow, NULL, FALSE);
GuiData->OldCursor.x = Buff->CursorPosition.X; GuiData->OldCursor.x = Buff->CursorPosition.X;
GuiData->OldCursor.y = Buff->CursorPosition.Y; GuiData->OldCursor.y = Buff->CursorPosition.Y;
} }
@ -1035,9 +1046,20 @@ GuiConsoleHandleClose(PGUI_CONSOLE_DATA GuiData)
static LRESULT static LRESULT
GuiConsoleHandleNcDestroy(HWND hWnd) GuiConsoleHandleNcDestroy(HWND hWnd)
{ {
PGUI_CONSOLE_DATA GuiData = GuiGetGuiData(hWnd);
KillTimer(hWnd, CONGUI_UPDATE_TIMER); KillTimer(hWnd, CONGUI_UPDATE_TIMER);
GetSystemMenu(hWnd, TRUE); GetSystemMenu(hWnd, TRUE);
if (GuiData)
{
/* Free the terminal framebuffer */
if (GuiData->hMemDC ) DeleteDC(GuiData->hMemDC);
if (GuiData->hBitmap) DeleteObject(GuiData->hBitmap);
// if (GuiData->hSysPalette) DeleteObject(GuiData->hSysPalette);
if (GuiData->Font) DeleteObject(GuiData->Font);
}
/* Free the GuiData registration */ /* Free the GuiData registration */
SetWindowLongPtrW(hWnd, GWLP_USERDATA, (DWORD_PTR)NULL); SetWindowLongPtrW(hWnd, GWLP_USERDATA, (DWORD_PTR)NULL);
@ -1047,8 +1069,7 @@ GuiConsoleHandleNcDestroy(HWND hWnd)
static COORD static COORD
PointToCoord(PGUI_CONSOLE_DATA GuiData, LPARAM lParam) PointToCoord(PGUI_CONSOLE_DATA GuiData, LPARAM lParam)
{ {
// PCONSOLE Console = GuiData->Console; PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
COORD Coord; COORD Coord;
UINT WidthUnit, HeightUnit; UINT WidthUnit, HeightUnit;
@ -1327,7 +1348,7 @@ GuiConsoleCopy(PGUI_CONSOLE_DATA GuiData)
if (OpenClipboard(GuiData->hWindow) == TRUE) if (OpenClipboard(GuiData->hWindow) == TRUE)
{ {
PCONSOLE Console = GuiData->Console; PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console); PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
if (GetType(Buffer) == TEXTMODE_BUFFER) if (GetType(Buffer) == TEXTMODE_BUFFER)
{ {
@ -1354,8 +1375,7 @@ GuiConsolePaste(PGUI_CONSOLE_DATA GuiData)
{ {
if (OpenClipboard(GuiData->hWindow) == TRUE) if (OpenClipboard(GuiData->hWindow) == TRUE)
{ {
// PCONSOLE Console = GuiData->Console; PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
if (GetType(Buffer) == TEXTMODE_BUFFER) if (GetType(Buffer) == TEXTMODE_BUFFER)
{ {
@ -1380,7 +1400,6 @@ GuiConsoleGetMinMaxInfo(PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo)
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return; if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
// ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
ActiveBuffer = GuiData->ActiveBuffer; ActiveBuffer = GuiData->ActiveBuffer;
GetScreenBufferSizeUnits(ActiveBuffer, GuiData, &WidthUnit, &HeightUnit); GetScreenBufferSizeUnits(ActiveBuffer, GuiData, &WidthUnit, &HeightUnit);
@ -1413,7 +1432,7 @@ GuiConsoleResize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
if ((GuiData->WindowSizeLock == FALSE) && if ((GuiData->WindowSizeLock == FALSE) &&
(wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED || wParam == SIZE_MINIMIZED)) (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED || wParam == SIZE_MINIMIZED))
{ {
PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console); PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer;
DWORD windx, windy, charx, chary; DWORD windx, windy, charx, chary;
UINT WidthUnit, HeightUnit; UINT WidthUnit, HeightUnit;
@ -1453,7 +1472,7 @@ GuiConsoleResize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
Buff->ViewSize.Y = (chary <= Buff->ScreenBufferSize.Y) ? chary : Buff->ScreenBufferSize.Y; Buff->ViewSize.Y = (chary <= Buff->ScreenBufferSize.Y) ? chary : Buff->ScreenBufferSize.Y;
} }
GuiConsoleResizeWindow(GuiData); GuiConsoleResizeWindow(GuiData, WidthUnit, HeightUnit);
// Adjust the start of the visible area if we are attempting to show nonexistent areas // Adjust the start of the visible area if we are attempting to show nonexistent areas
if ((Buff->ScreenBufferSize.X - Buff->ViewOrigin.X) < Buff->ViewSize.X) Buff->ViewOrigin.X = Buff->ScreenBufferSize.X - Buff->ViewSize.X; if ((Buff->ScreenBufferSize.X - Buff->ViewOrigin.X) < Buff->ViewSize.X) Buff->ViewOrigin.X = Buff->ScreenBufferSize.X - Buff->ViewSize.X;
@ -1507,7 +1526,7 @@ GuiConsoleHandleScroll(PGUI_CONSOLE_DATA GuiData, UINT uMsg, WPARAM wParam)
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return 0; if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return 0;
Buff = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console); Buff = GuiData->ActiveBuffer;
if (uMsg == WM_HSCROLL) if (uMsg == WM_HSCROLL)
{ {
@ -1595,6 +1614,7 @@ GuiConsoleHandleScroll(PGUI_CONSOLE_DATA GuiData, UINT uMsg, WPARAM wParam)
SetScrollInfo(GuiData->hWindow, fnBar, &sInfo, TRUE); SetScrollInfo(GuiData->hWindow, fnBar, &sInfo, TRUE);
UpdateWindow(GuiData->hWindow); UpdateWindow(GuiData->hWindow);
// InvalidateRect(GuiData->hWindow, NULL, FALSE);
} }
Quit: Quit:
@ -1697,7 +1717,7 @@ GuiConsoleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_PALETTECHANGED: case WM_PALETTECHANGED:
{ {
PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(GuiData->Console); PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
DPRINT1("WM_PALETTECHANGED called\n"); DPRINT1("WM_PALETTECHANGED called\n");
@ -1721,19 +1741,13 @@ GuiConsoleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
// if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) // if (GetType(ActiveBuffer) == GRAPHICS_BUFFER)
if (ActiveBuffer->PaletteHandle) if (ActiveBuffer->PaletteHandle)
{ {
/* Get the Device Context of the console window */
HDC hDC = GetDC(GuiData->hWindow);
DPRINT1("WM_PALETTECHANGED changing palette\n"); DPRINT1("WM_PALETTECHANGED changing palette\n");
/* Specify the use of the system palette */ /* Specify the use of the system palette for the framebuffer */
SetSystemPaletteUse(hDC, ActiveBuffer->PaletteUsage); SetSystemPaletteUse(GuiData->hMemDC, ActiveBuffer->PaletteUsage);
/* Realize the (logical) palette */ /* Realize the (logical) palette */
RealizePalette(hDC); RealizePalette(GuiData->hMemDC);
/* Release the Device Context and return */
ReleaseDC(GuiData->hWindow, hDC);
} }
DPRINT1("WM_PALETTECHANGED quit\n"); DPRINT1("WM_PALETTECHANGED quit\n");
@ -1966,9 +1980,32 @@ GuiConsoleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
case PM_RESIZE_TERMINAL: case PM_RESIZE_TERMINAL:
{ {
PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer;
HDC hDC;
HBITMAP hnew, hold;
DWORD Width, Height;
UINT WidthUnit, HeightUnit;
GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
Width = Buff->ScreenBufferSize.X * WidthUnit ;
Height = Buff->ScreenBufferSize.Y * HeightUnit;
/* Recreate the framebuffer */
hDC = GetDC(GuiData->hWindow);
hnew = CreateCompatibleBitmap(hDC, Width, Height);
ReleaseDC(GuiData->hWindow, hDC);
hold = SelectObject(GuiData->hMemDC, hnew);
if (GuiData->hBitmap)
{
if (hold == GuiData->hBitmap) DeleteObject(GuiData->hBitmap);
}
GuiData->hBitmap = hnew;
/* Resize the window to the user's values */ /* Resize the window to the user's values */
GuiData->WindowSizeLock = TRUE; GuiData->WindowSizeLock = TRUE;
GuiConsoleResizeWindow(GuiData); GuiConsoleResizeWindow(GuiData, WidthUnit, HeightUnit);
GuiData->WindowSizeLock = FALSE; GuiData->WindowSizeLock = FALSE;
break; break;
} }
@ -2063,9 +2100,7 @@ GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
/* Move and resize the window to the user's values */ /* Move and resize the window to the user's values */
/* CAN WE DEADLOCK ?? */ /* CAN WE DEADLOCK ?? */
GuiConsoleMoveWindow(GuiData); GuiConsoleMoveWindow(GuiData);
GuiData->WindowSizeLock = TRUE; SendMessageW(GuiData->hWindow, PM_RESIZE_TERMINAL, 0, 0);
GuiConsoleResizeWindow(GuiData);
GuiData->WindowSizeLock = FALSE;
/* Switch to full-screen mode if necessary */ /* Switch to full-screen mode if necessary */
if (GuiData->GuiInfo.FullScreen) SwitchFullScreen(GuiData, TRUE); if (GuiData->GuiInfo.FullScreen) SwitchFullScreen(GuiData, TRUE);
@ -2423,9 +2458,6 @@ GuiInitFrontEnd(IN OUT PFRONTEND This,
} }
} }
/* Original system palette */
GuiData->hSysPalette = NULL;
/* Mouse is shown by default with its default cursor shape */ /* Mouse is shown by default with its default cursor shape */
GuiData->hCursor = ghDefaultCursor; GuiData->hCursor = ghDefaultCursor;
GuiData->MouseCursorRefCount = 0; GuiData->MouseCursorRefCount = 0;
@ -2511,6 +2543,7 @@ GuiDrawRegion(IN OUT PFRONTEND This,
SmallRectToRect(GuiData, &RegionRect, Region); SmallRectToRect(GuiData, &RegionRect, Region);
/* Do not erase the background: it speeds up redrawing and reduce flickering */ /* Do not erase the background: it speeds up redrawing and reduce flickering */
InvalidateRect(GuiData->hWindow, &RegionRect, FALSE); InvalidateRect(GuiData->hWindow, &RegionRect, FALSE);
/**UpdateWindow(GuiData->hWindow);**/
} }
static VOID NTAPI static VOID NTAPI
@ -2529,7 +2562,7 @@ GuiWriteStream(IN OUT PFRONTEND This,
if (NULL == GuiData || NULL == GuiData->hWindow) return; if (NULL == GuiData || NULL == GuiData->hWindow) return;
Buff = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(GuiData->Console); Buff = GuiData->ActiveBuffer;
if (GetType(Buff) != TEXTMODE_BUFFER) return; if (GetType(Buff) != TEXTMODE_BUFFER) return;
if (0 != ScrolledLines) if (0 != ScrolledLines)
@ -2578,7 +2611,7 @@ GuiSetCursorInfo(IN OUT PFRONTEND This,
{ {
PGUI_CONSOLE_DATA GuiData = This->Data; PGUI_CONSOLE_DATA GuiData = This->Data;
if (/*ConDrvGetActiveScreenBuffer(GuiData->Console)*/GuiData->ActiveBuffer == Buff) if (GuiData->ActiveBuffer == Buff)
{ {
GuiInvalidateCell(This, Buff->CursorPosition.X, Buff->CursorPosition.Y); GuiInvalidateCell(This, Buff->CursorPosition.X, Buff->CursorPosition.Y);
} }
@ -2594,7 +2627,7 @@ GuiSetScreenInfo(IN OUT PFRONTEND This,
{ {
PGUI_CONSOLE_DATA GuiData = This->Data; PGUI_CONSOLE_DATA GuiData = This->Data;
if (/*ConDrvGetActiveScreenBuffer(GuiData->Console)*/GuiData->ActiveBuffer == Buff) if (GuiData->ActiveBuffer == Buff)
{ {
/* Redraw char at old position (remove cursor) */ /* Redraw char at old position (remove cursor) */
GuiInvalidateCell(This, OldCursorX, OldCursorY); GuiInvalidateCell(This, OldCursorX, OldCursorY);
@ -2611,11 +2644,6 @@ GuiResizeTerminal(IN OUT PFRONTEND This)
PGUI_CONSOLE_DATA GuiData = This->Data; PGUI_CONSOLE_DATA GuiData = This->Data;
/* Resize the window to the user's values */ /* Resize the window to the user's values */
// GuiData->WindowSizeLock = TRUE;
// GuiConsoleResizeWindow(GuiData);
// GuiData->WindowSizeLock = FALSE;
// NOTE: This code ^^ causes deadlocks...
PostMessageW(GuiData->hWindow, PM_RESIZE_TERMINAL, 0, 0); PostMessageW(GuiData->hWindow, PM_RESIZE_TERMINAL, 0, 0);
} }
@ -2623,15 +2651,14 @@ static VOID NTAPI
GuiSetActiveScreenBuffer(IN OUT PFRONTEND This) GuiSetActiveScreenBuffer(IN OUT PFRONTEND This)
{ {
PGUI_CONSOLE_DATA GuiData = This->Data; PGUI_CONSOLE_DATA GuiData = This->Data;
PCONSOLE_SCREEN_BUFFER ActiveBuffer; // = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(GuiData->Console); PCONSOLE_SCREEN_BUFFER ActiveBuffer;
HDC hDC;
HPALETTE hPalette; HPALETTE hPalette;
EnterCriticalSection(&GuiData->Lock); EnterCriticalSection(&GuiData->Lock);
GuiData->WindowSizeLock = TRUE; GuiData->WindowSizeLock = TRUE;
InterlockedExchangePointer(&GuiData->ActiveBuffer, InterlockedExchangePointer(&GuiData->ActiveBuffer,
GuiData->Console->ActiveBuffer); ConDrvGetActiveScreenBuffer(GuiData->Console));
GuiData->WindowSizeLock = FALSE; GuiData->WindowSizeLock = FALSE;
LeaveCriticalSection(&GuiData->Lock); LeaveCriticalSection(&GuiData->Lock);
@ -2650,20 +2677,14 @@ GuiSetActiveScreenBuffer(IN OUT PFRONTEND This)
DPRINT1("GuiSetActiveScreenBuffer using palette 0x%p\n", hPalette); DPRINT1("GuiSetActiveScreenBuffer using palette 0x%p\n", hPalette);
/* Get the Device Context of the console window */ /* Set the new palette for the framebuffer */
hDC = GetDC(GuiData->hWindow); SelectPalette(GuiData->hMemDC, hPalette, FALSE);
/* Set the new palette */ /* Specify the use of the system palette for the framebuffer */
SelectPalette(hDC, hPalette, FALSE); SetSystemPaletteUse(GuiData->hMemDC, ActiveBuffer->PaletteUsage);
/* Specify the use of the system palette */
SetSystemPaletteUse(hDC, ActiveBuffer->PaletteUsage);
/* Realize the (logical) palette */ /* Realize the (logical) palette */
RealizePalette(hDC); RealizePalette(GuiData->hMemDC);
/* Release the Device Context */
ReleaseDC(GuiData->hWindow, hDC);
GuiResizeTerminal(This); GuiResizeTerminal(This);
// ConioDrawConsole(Console); // ConioDrawConsole(Console);
@ -2674,7 +2695,6 @@ GuiReleaseScreenBuffer(IN OUT PFRONTEND This,
IN PCONSOLE_SCREEN_BUFFER ScreenBuffer) IN PCONSOLE_SCREEN_BUFFER ScreenBuffer)
{ {
PGUI_CONSOLE_DATA GuiData = This->Data; PGUI_CONSOLE_DATA GuiData = This->Data;
HDC hDC;
/* /*
* If we were notified to release a screen buffer that is not actually * If we were notified to release a screen buffer that is not actually
@ -2690,19 +2710,13 @@ GuiReleaseScreenBuffer(IN OUT PFRONTEND This,
* it ONLY. * it ONLY.
*/ */
/* Get the Device Context of the console window */
hDC = GetDC(GuiData->hWindow);
/* Release the old active palette and set the default one */ /* Release the old active palette and set the default one */
if (GetCurrentObject(hDC, OBJ_PAL) == ScreenBuffer->PaletteHandle) if (GetCurrentObject(GuiData->hMemDC, OBJ_PAL) == ScreenBuffer->PaletteHandle)
{ {
/* Set the new palette */ /* Set the new palette */
SelectPalette(hDC, GuiData->hSysPalette, FALSE); SelectPalette(GuiData->hMemDC, GuiData->hSysPalette, FALSE);
} }
/* Release the Device Context */
ReleaseDC(GuiData->hWindow, hDC);
/* Set the adequate active screen buffer */ /* Set the adequate active screen buffer */
if (ScreenBuffer != GuiData->Console->ActiveBuffer) if (ScreenBuffer != GuiData->Console->ActiveBuffer)
{ {
@ -2842,7 +2856,6 @@ GuiGetLargestConsoleWindowSize(IN OUT PFRONTEND This,
return; return;
} }
// ActiveBuffer = ConDrvGetActiveScreenBuffer(GuiData->Console);
ActiveBuffer = GuiData->ActiveBuffer; ActiveBuffer = GuiData->ActiveBuffer;
if (ActiveBuffer) if (ActiveBuffer)
{ {
@ -2873,54 +2886,26 @@ GuiSetPalette(IN OUT PFRONTEND This,
HPALETTE PaletteHandle, HPALETTE PaletteHandle,
UINT PaletteUsage) UINT PaletteUsage)
{ {
BOOL Success = TRUE;
PGUI_CONSOLE_DATA GuiData = This->Data; PGUI_CONSOLE_DATA GuiData = This->Data;
// PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(GuiData->Console);
HDC hDC;
HPALETTE OldPalette; HPALETTE OldPalette;
DPRINT1("GuiSetPalette checkpt 0\n"); // if (GetType(GuiData->ActiveBuffer) != GRAPHICS_BUFFER) return FALSE;
// if (GetType(ActiveBuffer) != GRAPHICS_BUFFER) return FALSE;
if (PaletteHandle == NULL) return FALSE; if (PaletteHandle == NULL) return FALSE;
DPRINT1("GuiSetPalette checkpt 1\n"); /* Set the new palette for the framebuffer */
OldPalette = SelectPalette(GuiData->hMemDC, PaletteHandle, FALSE);
if (OldPalette == NULL) return FALSE;
/* Get the Device Context of the console window */ /* Specify the use of the system palette for the framebuffer */
hDC = GetDC(GuiData->hWindow); SetSystemPaletteUse(GuiData->hMemDC, PaletteUsage);
DPRINT1("GuiSetPalette calling SelectPalette(0x%p, 0x%p, FALSE)\n", hDC, PaletteHandle);
/* Set the new palette */
OldPalette = SelectPalette(hDC, PaletteHandle, FALSE);
DPRINT1("OldPalette = 0x%p\n", OldPalette);
if (OldPalette == NULL)
{
DPRINT1("SelectPalette failed\n");
Success = FALSE;
goto Quit;
}
DPRINT1("GuiSetPalette checkpt 2\n");
/* Specify the use of the system palette */
SetSystemPaletteUse(hDC, PaletteUsage);
/* Realize the (logical) palette */ /* Realize the (logical) palette */
RealizePalette(hDC); RealizePalette(GuiData->hMemDC);
DPRINT1("GuiData->hSysPalette before == 0x%p\n", GuiData->hSysPalette);
/* Save the original system palette handle */ /* Save the original system palette handle */
if (GuiData->hSysPalette == NULL) GuiData->hSysPalette = OldPalette; if (GuiData->hSysPalette == NULL) GuiData->hSysPalette = OldPalette;
DPRINT1("GuiData->hSysPalette after == 0x%p\n", GuiData->hSysPalette); return TRUE;
Quit:
DPRINT1("GuiSetPalette Quit\n");
/* Release the Device Context and return */
ReleaseDC(GuiData->hWindow, hDC);
return Success;
} }
static ULONG NTAPI static ULONG NTAPI

View file

@ -185,8 +185,8 @@ GuiPasteToTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer)
VOID VOID
GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer, GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
PGUI_CONSOLE_DATA GuiData, PGUI_CONSOLE_DATA GuiData,
HDC hDC, PRECT rcView,
PRECT rc) PRECT rcFramebuffer)
{ {
PCONSOLE Console = Buffer->Header.Console; PCONSOLE Console = Buffer->Header.Console;
// ASSERT(Console == GuiData->Console); // ASSERT(Console == GuiData->Console);
@ -202,20 +202,25 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
if (Buffer->Buffer == NULL) return; if (Buffer->Buffer == NULL) return;
TopLine = rc->top / GuiData->CharHeight + Buffer->ViewOrigin.Y; rcFramebuffer->left = Buffer->ViewOrigin.X * GuiData->CharWidth + rcView->left;
BottomLine = (rc->bottom + (GuiData->CharHeight - 1)) / GuiData->CharHeight - 1 + Buffer->ViewOrigin.Y; rcFramebuffer->top = Buffer->ViewOrigin.Y * GuiData->CharHeight + rcView->top;
LeftChar = rc->left / GuiData->CharWidth + Buffer->ViewOrigin.X; rcFramebuffer->right = Buffer->ViewOrigin.X * GuiData->CharWidth + rcView->right;
RightChar = (rc->right + (GuiData->CharWidth - 1)) / GuiData->CharWidth - 1 + Buffer->ViewOrigin.X; rcFramebuffer->bottom = Buffer->ViewOrigin.Y * GuiData->CharHeight + rcView->bottom;
LeftChar = rcFramebuffer->left / GuiData->CharWidth;
TopLine = rcFramebuffer->top / GuiData->CharHeight;
RightChar = rcFramebuffer->right / GuiData->CharWidth;
BottomLine = rcFramebuffer->bottom / GuiData->CharHeight;
if (RightChar >= Buffer->ScreenBufferSize.X) RightChar = Buffer->ScreenBufferSize.X - 1;
if (BottomLine >= Buffer->ScreenBufferSize.Y) BottomLine = Buffer->ScreenBufferSize.Y - 1;
LastAttribute = ConioCoordToPointer(Buffer, LeftChar, TopLine)->Attributes; LastAttribute = ConioCoordToPointer(Buffer, LeftChar, TopLine)->Attributes;
SetTextColor(hDC, RGBFromAttrib(Console, TextAttribFromAttrib(LastAttribute))); SetTextColor(GuiData->hMemDC, RGBFromAttrib(Console, TextAttribFromAttrib(LastAttribute)));
SetBkColor(hDC, RGBFromAttrib(Console, BkgdAttribFromAttrib(LastAttribute))); SetBkColor(GuiData->hMemDC, RGBFromAttrib(Console, BkgdAttribFromAttrib(LastAttribute)));
if (BottomLine >= Buffer->ScreenBufferSize.Y) BottomLine = Buffer->ScreenBufferSize.Y - 1; OldFont = SelectObject(GuiData->hMemDC, GuiData->Font);
if (RightChar >= Buffer->ScreenBufferSize.X) RightChar = Buffer->ScreenBufferSize.X - 1;
OldFont = SelectObject(hDC, GuiData->Font);
for (Line = TopLine; Line <= BottomLine; Line++) for (Line = TopLine; Line <= BottomLine; Line++)
{ {
@ -232,9 +237,9 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
*/ */
if (From->Attributes != LastAttribute || (Char - Start == sizeof(LineBuffer) / sizeof(WCHAR))) if (From->Attributes != LastAttribute || (Char - Start == sizeof(LineBuffer) / sizeof(WCHAR)))
{ {
TextOutW(hDC, TextOutW(GuiData->hMemDC,
(Start - Buffer->ViewOrigin.X) * GuiData->CharWidth , Start * GuiData->CharWidth,
(Line - Buffer->ViewOrigin.Y) * GuiData->CharHeight, Line * GuiData->CharHeight,
LineBuffer, LineBuffer,
Char - Start); Char - Start);
Start = Char; Start = Char;
@ -242,8 +247,8 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
Attribute = From->Attributes; Attribute = From->Attributes;
if (Attribute != LastAttribute) if (Attribute != LastAttribute)
{ {
SetTextColor(hDC, RGBFromAttrib(Console, TextAttribFromAttrib(Attribute))); SetTextColor(GuiData->hMemDC, RGBFromAttrib(Console, TextAttribFromAttrib(Attribute)));
SetBkColor(hDC, RGBFromAttrib(Console, BkgdAttribFromAttrib(Attribute))); SetBkColor(GuiData->hMemDC, RGBFromAttrib(Console, BkgdAttribFromAttrib(Attribute)));
LastAttribute = Attribute; LastAttribute = Attribute;
} }
} }
@ -251,9 +256,9 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
*(To++) = (From++)->Char.UnicodeChar; *(To++) = (From++)->Char.UnicodeChar;
} }
TextOutW(hDC, TextOutW(GuiData->hMemDC,
(Start - Buffer->ViewOrigin.X) * GuiData->CharWidth , Start * GuiData->CharWidth,
(Line - Buffer->ViewOrigin.Y) * GuiData->CharHeight, Line * GuiData->CharHeight,
LineBuffer, LineBuffer,
RightChar - Start + 1); RightChar - Start + 1);
} }
@ -271,30 +276,25 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
TopLine <= CursorY && CursorY <= BottomLine) TopLine <= CursorY && CursorY <= BottomLine)
{ {
CursorHeight = ConioEffectiveCursorSize(Console, GuiData->CharHeight); CursorHeight = ConioEffectiveCursorSize(Console, GuiData->CharHeight);
Attribute = ConioCoordToPointer(Buffer, Buffer->CursorPosition.X, Buffer->CursorPosition.Y)->Attributes; Attribute = ConioCoordToPointer(Buffer, Buffer->CursorPosition.X, Buffer->CursorPosition.Y)->Attributes;
if (Attribute == DEFAULT_SCREEN_ATTRIB) Attribute = Buffer->ScreenDefaultAttrib;
if (Attribute != DEFAULT_SCREEN_ATTRIB)
{
CursorBrush = CreateSolidBrush(RGBFromAttrib(Console, Attribute)); CursorBrush = CreateSolidBrush(RGBFromAttrib(Console, Attribute));
} OldBrush = SelectObject(GuiData->hMemDC, CursorBrush);
else
{
CursorBrush = CreateSolidBrush(RGBFromAttrib(Console, Buffer->ScreenDefaultAttrib));
}
OldBrush = SelectObject(hDC, CursorBrush); PatBlt(GuiData->hMemDC,
PatBlt(hDC, CursorX * GuiData->CharWidth,
(CursorX - Buffer->ViewOrigin.X) * GuiData->CharWidth, CursorY * GuiData->CharHeight + (GuiData->CharHeight - CursorHeight),
(CursorY - Buffer->ViewOrigin.Y) * GuiData->CharHeight + (GuiData->CharHeight - CursorHeight),
GuiData->CharWidth, GuiData->CharWidth,
CursorHeight, CursorHeight,
PATCOPY); PATCOPY);
SelectObject(hDC, OldBrush); SelectObject(GuiData->hMemDC, OldBrush);
DeleteObject(CursorBrush); DeleteObject(CursorBrush);
} }
} }
SelectObject(hDC, OldFont); SelectObject(GuiData->hMemDC, OldFont);
} }
/* EOF */ /* EOF */