- Selection info is per-terminal.
- Lock the console only when needed.

svn path=/trunk/; revision=62864
This commit is contained in:
Hermès Bélusca-Maïto 2014-04-22 03:44:13 +00:00
parent fefde4e142
commit 66bad13542
13 changed files with 185 additions and 172 deletions

View file

@ -575,11 +575,6 @@ ConDrvInitConsole(OUT PHANDLE NewConsoleHandle,
Console->LineInsertToggle = Console->InsertMode; Console->LineInsertToggle = Console->InsertMode;
// LineWakeupMask // LineWakeupMask
// FIXME: This is terminal-specific !! VV
RtlZeroMemory(&Console->Selection, sizeof(CONSOLE_SELECTION_INFO));
Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
// dwSelectionCursor
/* Set-up the code page */ /* Set-up the code page */
Console->CodePage = Console->OutputCodePage = ConsoleInfo->CodePage; Console->CodePage = Console->OutputCodePage = ConsoleInfo->CodePage;

View file

@ -116,6 +116,13 @@ DummyGetLargestConsoleWindowSize(IN OUT PFRONTEND This,
{ {
} }
static BOOL NTAPI
DummyGetSelectionInfo(IN OUT PFRONTEND This,
PCONSOLE_SELECTION_INFO pSelectionInfo)
{
return TRUE;
}
static BOOL NTAPI static BOOL NTAPI
DummySetPalette(IN OUT PFRONTEND This, DummySetPalette(IN OUT PFRONTEND This,
HPALETTE PaletteHandle, HPALETTE PaletteHandle,
@ -183,6 +190,7 @@ static FRONTEND_VTBL DummyVtbl =
DummyChangeIcon, DummyChangeIcon,
DummyGetConsoleWindowHandle, DummyGetConsoleWindowHandle,
DummyGetLargestConsoleWindowSize, DummyGetLargestConsoleWindowSize,
DummyGetSelectionInfo,
DummySetPalette, DummySetPalette,
DummyGetDisplayMode, DummyGetDisplayMode,
DummySetDisplayMode, DummySetDisplayMode,

View file

@ -308,14 +308,13 @@ CSR_API(SrvGetConsoleSelectionInfo)
PCONSOLE Console; PCONSOLE Console;
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE); Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
if (NT_SUCCESS(Status)) if (!NT_SUCCESS(Status)) return Status;
{
memset(&GetSelectionInfoRequest->Info, 0, sizeof(CONSOLE_SELECTION_INFO));
if (Console->Selection.dwFlags != 0)
GetSelectionInfoRequest->Info = Console->Selection;
ConSrvReleaseConsole(Console, TRUE);
}
Status = (TermGetSelectionInfo(Console, &GetSelectionInfoRequest->Info)
? STATUS_SUCCESS
: STATUS_UNSUCCESSFUL);
ConSrvReleaseConsole(Console, TRUE);
return Status; return Status;
} }

View file

@ -266,11 +266,15 @@ SendMenuEvent(PCONSOLE Console, UINT CmdId)
{ {
INPUT_RECORD er; INPUT_RECORD er;
DPRINT1("Menu item ID: %d\n", CmdId);
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
er.EventType = MENU_EVENT; er.EventType = MENU_EVENT;
er.Event.MenuEvent.dwCommandId = CmdId; er.Event.MenuEvent.dwCommandId = CmdId;
DPRINT("Menu item ID: %d\n", CmdId);
ConioProcessInputEvent(Console, &er); ConioProcessInputEvent(Console, &er);
LeaveCriticalSection(&Console->Lock);
} }
static VOID static VOID
@ -283,36 +287,34 @@ UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD coord);
static VOID static VOID
Mark(PGUI_CONSOLE_DATA GuiData) Mark(PGUI_CONSOLE_DATA GuiData)
{ {
PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer; PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
/* Clear the old selection */ /* Clear the old selection */
// UpdateSelection(GuiData, NULL); // UpdateSelection(GuiData, NULL);
Console->Selection.dwFlags = CONSOLE_NO_SELECTION; GuiData->Selection.dwFlags = CONSOLE_NO_SELECTION;
/* Restart a new selection */ /* Restart a new selection */
Console->dwSelectionCursor.X = ActiveBuffer->ViewOrigin.X; GuiData->dwSelectionCursor.X = ActiveBuffer->ViewOrigin.X;
Console->dwSelectionCursor.Y = ActiveBuffer->ViewOrigin.Y; GuiData->dwSelectionCursor.Y = ActiveBuffer->ViewOrigin.Y;
Console->Selection.dwSelectionAnchor = Console->dwSelectionCursor; GuiData->Selection.dwSelectionAnchor = GuiData->dwSelectionCursor;
UpdateSelection(GuiData, &Console->Selection.dwSelectionAnchor); UpdateSelection(GuiData, &GuiData->Selection.dwSelectionAnchor);
} }
static VOID static VOID
SelectAll(PGUI_CONSOLE_DATA GuiData) SelectAll(PGUI_CONSOLE_DATA GuiData)
{ {
PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer; PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
/* Clear the old selection */ /* Clear the old selection */
// UpdateSelection(GuiData, NULL); // UpdateSelection(GuiData, NULL);
Console->Selection.dwFlags = CONSOLE_NO_SELECTION; GuiData->Selection.dwFlags = CONSOLE_NO_SELECTION;
/* /*
* The selection area extends to the whole screen buffer's width. * The selection area extends to the whole screen buffer's width.
*/ */
Console->Selection.dwSelectionAnchor.X = 0; GuiData->Selection.dwSelectionAnchor.X = 0;
Console->Selection.dwSelectionAnchor.Y = 0; GuiData->Selection.dwSelectionAnchor.Y = 0;
Console->dwSelectionCursor.X = ActiveBuffer->ScreenBufferSize.X - 1; GuiData->dwSelectionCursor.X = ActiveBuffer->ScreenBufferSize.X - 1;
/* /*
* Determine whether the selection must extend to just some part * Determine whether the selection must extend to just some part
@ -325,19 +327,19 @@ SelectAll(PGUI_CONSOLE_DATA GuiData)
* We select all the characters from the first line * We select all the characters from the first line
* to the line where the cursor is positioned. * to the line where the cursor is positioned.
*/ */
Console->dwSelectionCursor.Y = ActiveBuffer->CursorPosition.Y; GuiData->dwSelectionCursor.Y = ActiveBuffer->CursorPosition.Y;
} }
else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */ else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
{ {
/* /*
* We select all the screen buffer area. * We select all the screen buffer area.
*/ */
Console->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1; GuiData->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
} }
/* Restart a new selection */ /* Restart a new selection */
Console->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION; GuiData->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION;
UpdateSelection(GuiData, &Console->dwSelectionCursor); UpdateSelection(GuiData, &GuiData->dwSelectionCursor);
} }
static LRESULT static LRESULT
@ -346,12 +348,6 @@ OnCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
LRESULT Ret = TRUE; LRESULT Ret = TRUE;
PCONSOLE Console = GuiData->Console; PCONSOLE Console = GuiData->Console;
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
{
Ret = FALSE;
goto Quit;
}
/* /*
* In case the selected menu item belongs to the user-reserved menu id range, * In case the selected menu item belongs to the user-reserved menu id range,
* send to him a menu event and return directly. The user must handle those * send to him a menu event and return directly. The user must handle those
@ -360,7 +356,7 @@ OnCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
if (GuiData->CmdIdLow <= (UINT)wParam && (UINT)wParam <= GuiData->CmdIdHigh) if (GuiData->CmdIdLow <= (UINT)wParam && (UINT)wParam <= GuiData->CmdIdHigh)
{ {
SendMenuEvent(Console, (UINT)wParam); SendMenuEvent(Console, (UINT)wParam);
goto Unlock_Quit; goto Quit;
} }
/* ... otherwise, perform actions. */ /* ... otherwise, perform actions. */
@ -403,8 +399,6 @@ OnCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
break; break;
} }
Unlock_Quit:
LeaveCriticalSection(&Console->Lock);
Quit: Quit:
if (!Ret) if (!Ret)
Ret = DefWindowProcW(GuiData->hWindow, WM_SYSCOMMAND, wParam, lParam); Ret = DefWindowProcW(GuiData->hWindow, WM_SYSCOMMAND, wParam, lParam);
@ -643,12 +637,12 @@ OnFocus(PGUI_CONSOLE_DATA GuiData, BOOL SetFocus)
er.Event.FocusEvent.bSetFocus = SetFocus; er.Event.FocusEvent.bSetFocus = SetFocus;
ConioProcessInputEvent(Console, &er); ConioProcessInputEvent(Console, &er);
LeaveCriticalSection(&Console->Lock);
if (SetFocus) if (SetFocus)
DPRINT1("TODO: Create console caret\n"); DPRINT1("TODO: Create console caret\n");
else else
DPRINT1("TODO: Destroy console caret\n"); DPRINT1("TODO: Destroy console caret\n");
LeaveCriticalSection(&Console->Lock);
} }
static VOID static VOID
@ -671,7 +665,7 @@ UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD coord)
PCONSOLE Console = GuiData->Console; PCONSOLE Console = GuiData->Console;
RECT oldRect; RECT oldRect;
SmallRectToRect(GuiData, &oldRect, &Console->Selection.srSelection); SmallRectToRect(GuiData, &oldRect, &GuiData->Selection.srSelection);
if (coord != NULL) if (coord != NULL)
{ {
@ -679,16 +673,16 @@ UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD coord)
SMALL_RECT rc; SMALL_RECT rc;
/* Exchange left/top with right/bottom if required */ /* Exchange left/top with right/bottom if required */
rc.Left = min(Console->Selection.dwSelectionAnchor.X, coord->X); rc.Left = min(GuiData->Selection.dwSelectionAnchor.X, coord->X);
rc.Top = min(Console->Selection.dwSelectionAnchor.Y, coord->Y); rc.Top = min(GuiData->Selection.dwSelectionAnchor.Y, coord->Y);
rc.Right = max(Console->Selection.dwSelectionAnchor.X, coord->X); rc.Right = max(GuiData->Selection.dwSelectionAnchor.X, coord->X);
rc.Bottom = max(Console->Selection.dwSelectionAnchor.Y, coord->Y); rc.Bottom = max(GuiData->Selection.dwSelectionAnchor.Y, coord->Y);
SmallRectToRect(GuiData, &newRect, &rc); SmallRectToRect(GuiData, &newRect, &rc);
if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY) if (GuiData->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
{ {
if (memcmp(&rc, &Console->Selection.srSelection, sizeof(SMALL_RECT)) != 0) if (memcmp(&rc, &GuiData->Selection.srSelection, sizeof(SMALL_RECT)) != 0)
{ {
HRGN rgn1, rgn2; HRGN rgn1, rgn2;
@ -712,22 +706,22 @@ UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD coord)
InvalidateRect(GuiData->hWindow, &newRect, FALSE); InvalidateRect(GuiData->hWindow, &newRect, FALSE);
} }
Console->Selection.dwFlags |= CONSOLE_SELECTION_NOT_EMPTY; GuiData->Selection.dwFlags |= CONSOLE_SELECTION_NOT_EMPTY;
Console->Selection.srSelection = rc; GuiData->Selection.srSelection = rc;
Console->dwSelectionCursor = *coord; GuiData->dwSelectionCursor = *coord;
if ((Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) == 0) if ((GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) == 0)
{ {
LPWSTR SelectionType, WindowTitle = NULL; LPWSTR SelectionType, WindowTitle = NULL;
SIZE_T Length = 0; SIZE_T Length = 0;
/* Clear the old selection */ /* Clear the old selection */
if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY) if (GuiData->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
{ {
InvalidateRect(GuiData->hWindow, &oldRect, FALSE); InvalidateRect(GuiData->hWindow, &oldRect, FALSE);
} }
if (Console->Selection.dwFlags & CONSOLE_MOUSE_SELECTION) if (GuiData->Selection.dwFlags & CONSOLE_MOUSE_SELECTION)
{ {
SelectionType = L"Selection - "; SelectionType = L"Selection - ";
} }
@ -743,19 +737,19 @@ UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD coord)
SetWindowText(GuiData->hWindow, WindowTitle); SetWindowText(GuiData->hWindow, WindowTitle);
ConsoleFreeHeap(WindowTitle); ConsoleFreeHeap(WindowTitle);
Console->Selection.dwFlags |= CONSOLE_SELECTION_IN_PROGRESS; GuiData->Selection.dwFlags |= CONSOLE_SELECTION_IN_PROGRESS;
ConioPause(Console, PAUSED_FROM_SELECTION); ConioPause(Console, PAUSED_FROM_SELECTION);
} }
} }
else else
{ {
/* Clear the selection */ /* Clear the selection */
if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY) if (GuiData->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
{ {
InvalidateRect(GuiData->hWindow, &oldRect, FALSE); InvalidateRect(GuiData->hWindow, &oldRect, FALSE);
} }
Console->Selection.dwFlags = CONSOLE_NO_SELECTION; GuiData->Selection.dwFlags = CONSOLE_NO_SELECTION;
ConioUnpause(Console, PAUSED_FROM_SELECTION); ConioUnpause(Console, PAUSED_FROM_SELECTION);
SetWindowText(GuiData->hWindow, Console->Title.Buffer); SetWindowText(GuiData->hWindow, Console->Title.Buffer);
@ -777,17 +771,10 @@ GuiPaintGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer,
static VOID static VOID
OnPaint(PGUI_CONSOLE_DATA GuiData) OnPaint(PGUI_CONSOLE_DATA GuiData)
{ {
BOOL Success = TRUE;
PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER ActiveBuffer; PCONSOLE_SCREEN_BUFFER ActiveBuffer;
PAINTSTRUCT ps; PAINTSTRUCT ps;
RECT rcPaint; RECT rcPaint;
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
{
Success = FALSE;
goto Quit;
}
ActiveBuffer = GuiData->ActiveBuffer; ActiveBuffer = GuiData->ActiveBuffer;
BeginPaint(GuiData->hWindow, &ps); BeginPaint(GuiData->hWindow, &ps);
@ -820,9 +807,9 @@ OnPaint(PGUI_CONSOLE_DATA GuiData)
rcPaint.top, rcPaint.top,
SRCCOPY); SRCCOPY);
if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY) if (GuiData->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
{ {
SmallRectToRect(GuiData, &rcPaint, &Console->Selection.srSelection); SmallRectToRect(GuiData, &rcPaint, &GuiData->Selection.srSelection);
/* Invert the selection */ /* Invert the selection */
if (IntersectRect(&rcPaint, &ps.rcPaint, &rcPaint)) if (IntersectRect(&rcPaint, &ps.rcPaint, &rcPaint))
@ -835,12 +822,6 @@ OnPaint(PGUI_CONSOLE_DATA GuiData)
} }
EndPaint(GuiData->hWindow, &ps); EndPaint(GuiData->hWindow, &ps);
Quit:
if (Success)
LeaveCriticalSection(&Console->Lock);
else
DefWindowProcW(GuiData->hWindow, WM_PAINT, 0, 0);
return; return;
} }
@ -898,7 +879,7 @@ OnKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
ActiveBuffer = GuiData->ActiveBuffer; ActiveBuffer = GuiData->ActiveBuffer;
if (Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) if (GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS)
{ {
WORD VirtualKeyCode = LOWORD(wParam); WORD VirtualKeyCode = LOWORD(wParam);
@ -918,7 +899,7 @@ OnKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
goto Quit; goto Quit;
} }
if ((Console->Selection.dwFlags & CONSOLE_MOUSE_SELECTION) == 0) if ((GuiData->Selection.dwFlags & CONSOLE_MOUSE_SELECTION) == 0)
{ {
/* Keyboard selection mode */ /* Keyboard selection mode */
BOOL Interpreted = FALSE; BOOL Interpreted = FALSE;
@ -929,8 +910,8 @@ OnKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
case VK_LEFT: case VK_LEFT:
{ {
Interpreted = TRUE; Interpreted = TRUE;
if (Console->dwSelectionCursor.X > 0) if (GuiData->dwSelectionCursor.X > 0)
Console->dwSelectionCursor.X--; GuiData->dwSelectionCursor.X--;
break; break;
} }
@ -938,8 +919,8 @@ OnKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
case VK_RIGHT: case VK_RIGHT:
{ {
Interpreted = TRUE; Interpreted = TRUE;
if (Console->dwSelectionCursor.X < ActiveBuffer->ScreenBufferSize.X - 1) if (GuiData->dwSelectionCursor.X < ActiveBuffer->ScreenBufferSize.X - 1)
Console->dwSelectionCursor.X++; GuiData->dwSelectionCursor.X++;
break; break;
} }
@ -947,8 +928,8 @@ OnKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
case VK_UP: case VK_UP:
{ {
Interpreted = TRUE; Interpreted = TRUE;
if (Console->dwSelectionCursor.Y > 0) if (GuiData->dwSelectionCursor.Y > 0)
Console->dwSelectionCursor.Y--; GuiData->dwSelectionCursor.Y--;
break; break;
} }
@ -956,8 +937,8 @@ OnKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
case VK_DOWN: case VK_DOWN:
{ {
Interpreted = TRUE; Interpreted = TRUE;
if (Console->dwSelectionCursor.Y < ActiveBuffer->ScreenBufferSize.Y - 1) if (GuiData->dwSelectionCursor.Y < ActiveBuffer->ScreenBufferSize.Y - 1)
Console->dwSelectionCursor.Y++; GuiData->dwSelectionCursor.Y++;
break; break;
} }
@ -965,24 +946,24 @@ OnKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
case VK_HOME: case VK_HOME:
{ {
Interpreted = TRUE; Interpreted = TRUE;
Console->dwSelectionCursor.X = 0; GuiData->dwSelectionCursor.X = 0;
Console->dwSelectionCursor.Y = 0; GuiData->dwSelectionCursor.Y = 0;
break; break;
} }
case VK_END: case VK_END:
{ {
Interpreted = TRUE; Interpreted = TRUE;
Console->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1; GuiData->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
break; break;
} }
case VK_PRIOR: case VK_PRIOR:
{ {
Interpreted = TRUE; Interpreted = TRUE;
Console->dwSelectionCursor.Y -= ActiveBuffer->ViewSize.Y; GuiData->dwSelectionCursor.Y -= ActiveBuffer->ViewSize.Y;
if (Console->dwSelectionCursor.Y < 0) if (GuiData->dwSelectionCursor.Y < 0)
Console->dwSelectionCursor.Y = 0; GuiData->dwSelectionCursor.Y = 0;
break; break;
} }
@ -990,9 +971,9 @@ OnKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
case VK_NEXT: case VK_NEXT:
{ {
Interpreted = TRUE; Interpreted = TRUE;
Console->dwSelectionCursor.Y += ActiveBuffer->ViewSize.Y; GuiData->dwSelectionCursor.Y += ActiveBuffer->ViewSize.Y;
if (Console->dwSelectionCursor.Y >= ActiveBuffer->ScreenBufferSize.Y) if (GuiData->dwSelectionCursor.Y >= ActiveBuffer->ScreenBufferSize.Y)
Console->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1; GuiData->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
break; break;
} }
@ -1004,9 +985,9 @@ OnKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
if (Interpreted) if (Interpreted)
{ {
if (!MajPressed) if (!MajPressed)
Console->Selection.dwSelectionAnchor = Console->dwSelectionCursor; GuiData->Selection.dwSelectionAnchor = GuiData->dwSelectionCursor;
UpdateSelection(GuiData, &Console->dwSelectionCursor); UpdateSelection(GuiData, &GuiData->dwSelectionCursor);
} }
else if (!IsSystemKey(VirtualKeyCode)) else if (!IsSystemKey(VirtualKeyCode))
{ {
@ -1032,7 +1013,7 @@ OnKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
} }
} }
if ((Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) == 0) if ((GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) == 0)
{ {
MSG Message; MSG Message;
@ -1265,7 +1246,7 @@ OnMouse(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
goto Quit; goto Quit;
} }
if ( (Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) || if ( (GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) ||
(Console->QuickEdit) ) (Console->QuickEdit) )
{ {
switch (msg) switch (msg)
@ -1274,13 +1255,13 @@ OnMouse(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
/* Clear the old selection */ /* Clear the old selection */
// UpdateSelection(GuiData, NULL); // UpdateSelection(GuiData, NULL);
Console->Selection.dwFlags = CONSOLE_NO_SELECTION; GuiData->Selection.dwFlags = CONSOLE_NO_SELECTION;
/* Restart a new selection */ /* Restart a new selection */
Console->Selection.dwSelectionAnchor = PointToCoord(GuiData, lParam); GuiData->Selection.dwSelectionAnchor = PointToCoord(GuiData, lParam);
SetCapture(GuiData->hWindow); SetCapture(GuiData->hWindow);
Console->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION | CONSOLE_MOUSE_DOWN; GuiData->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION | CONSOLE_MOUSE_DOWN;
UpdateSelection(GuiData, &Console->Selection.dwSelectionAnchor); UpdateSelection(GuiData, &GuiData->Selection.dwSelectionAnchor);
break; break;
} }
@ -1289,10 +1270,10 @@ OnMouse(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
// COORD c; // COORD c;
if (!(Console->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break; if (!(GuiData->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break;
// c = PointToCoord(GuiData, lParam); // c = PointToCoord(GuiData, lParam);
Console->Selection.dwFlags &= ~CONSOLE_MOUSE_DOWN; GuiData->Selection.dwFlags &= ~CONSOLE_MOUSE_DOWN;
// UpdateSelection(GuiData, &c); // UpdateSelection(GuiData, &c);
ReleaseCapture(); ReleaseCapture();
@ -1338,11 +1319,11 @@ OnMouse(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
* Update the selection started with the single * Update the selection started with the single
* left-click that preceded this double-click. * left-click that preceded this double-click.
*/ */
Console->Selection.dwSelectionAnchor = cL; GuiData->Selection.dwSelectionAnchor = cL;
Console->dwSelectionCursor = cR; GuiData->dwSelectionCursor = cR;
Console->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION | CONSOLE_MOUSE_DOWN; GuiData->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION | CONSOLE_MOUSE_DOWN;
UpdateSelection(GuiData, &Console->dwSelectionCursor); UpdateSelection(GuiData, &GuiData->dwSelectionCursor);
/* Ignore the next mouse move signal */ /* Ignore the next mouse move signal */
GuiData->IgnoreNextMouseSignal = TRUE; GuiData->IgnoreNextMouseSignal = TRUE;
@ -1354,7 +1335,7 @@ OnMouse(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
case WM_RBUTTONDBLCLK: case WM_RBUTTONDBLCLK:
{ {
if (!(Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)) if (!(GuiData->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY))
{ {
Paste(GuiData); Paste(GuiData);
} }
@ -1373,7 +1354,7 @@ OnMouse(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
COORD c; COORD c;
if (!(wParam & MK_LBUTTON)) break; if (!(wParam & MK_LBUTTON)) break;
if (!(Console->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break; if (!(GuiData->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break;
c = PointToCoord(GuiData, lParam); /* TODO: Scroll buffer to bring c into view */ c = PointToCoord(GuiData, lParam); /* TODO: Scroll buffer to bring c into view */
UpdateSelection(GuiData, &c); UpdateSelection(GuiData, &c);
@ -1674,11 +1655,8 @@ OnSize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
static VOID static VOID
OnMove(PGUI_CONSOLE_DATA GuiData) OnMove(PGUI_CONSOLE_DATA GuiData)
{ {
PCONSOLE Console = GuiData->Console;
RECT rcWnd; RECT rcWnd;
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
// TODO: Simplify the code. // TODO: Simplify the code.
// See: GuiConsoleNotifyWndProc() PM_CREATE_CONSOLE. // See: GuiConsoleNotifyWndProc() PM_CREATE_CONSOLE.
@ -1686,8 +1664,6 @@ OnMove(PGUI_CONSOLE_DATA GuiData)
GetWindowRect(GuiData->hWindow, &rcWnd); GetWindowRect(GuiData->hWindow, &rcWnd);
GuiData->GuiInfo.WindowOrigin.x = rcWnd.left; GuiData->GuiInfo.WindowOrigin.x = rcWnd.left;
GuiData->GuiInfo.WindowOrigin.y = rcWnd.top; GuiData->GuiInfo.WindowOrigin.y = rcWnd.top;
LeaveCriticalSection(&Console->Lock);
} }
/* /*
@ -2042,20 +2018,16 @@ ConWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
/* Enable or disable the Copy and Paste items */ /* Enable or disable the Copy and Paste items */
EnableMenuItem(hMenu, ID_SYSTEM_EDIT_COPY , MF_BYCOMMAND | EnableMenuItem(hMenu, ID_SYSTEM_EDIT_COPY , MF_BYCOMMAND |
((Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) && ((GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) &&
(Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY) ? MF_ENABLED : MF_GRAYED)); (GuiData->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY) ? MF_ENABLED : MF_GRAYED));
// FIXME: Following whether the active screen buffer is text-mode // FIXME: Following whether the active screen buffer is text-mode
// or graphics-mode, search for CF_UNICODETEXT or CF_BITMAP formats. // or graphics-mode, search for CF_UNICODETEXT or CF_BITMAP formats.
EnableMenuItem(hMenu, ID_SYSTEM_EDIT_PASTE, MF_BYCOMMAND | EnableMenuItem(hMenu, ID_SYSTEM_EDIT_PASTE, MF_BYCOMMAND |
(!(Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) && (!(GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) &&
IsClipboardFormatAvailable(CF_UNICODETEXT) ? MF_ENABLED : MF_GRAYED)); IsClipboardFormatAvailable(CF_UNICODETEXT) ? MF_ENABLED : MF_GRAYED));
} }
if (ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) SendMenuEvent(Console, WM_INITMENU);
{
SendMenuEvent(Console, WM_INITMENU);
LeaveCriticalSection(&Console->Lock);
}
break; break;
} }
@ -2063,11 +2035,7 @@ ConWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
if (HIWORD(wParam) == 0xFFFF) // Allow all the menu flags if (HIWORD(wParam) == 0xFFFF) // Allow all the menu flags
{ {
if (ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) SendMenuEvent(Console, WM_MENUSELECT);
{
SendMenuEvent(Console, WM_MENUSELECT);
LeaveCriticalSection(&Console->Lock);
}
} }
break; break;
} }
@ -2170,11 +2138,7 @@ ConWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
case PM_APPLY_CONSOLE_INFO: case PM_APPLY_CONSOLE_INFO:
{ {
if (ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) GuiApplyUserSettings(GuiData, (HANDLE)wParam, (BOOL)lParam);
{
GuiApplyUserSettings(GuiData, (HANDLE)wParam, (BOOL)lParam);
LeaveCriticalSection(&Console->Lock);
}
break; break;
} }

View file

@ -63,6 +63,8 @@ typedef struct _GUI_CONSOLE_DATA
PCONSOLE Console; /* Pointer to the owned console */ PCONSOLE Console; /* Pointer to the owned console */
PCONSOLE_SCREEN_BUFFER ActiveBuffer; /* Pointer to the active screen buffer (then maybe the previous Console member is redundant?? Or not...) */ PCONSOLE_SCREEN_BUFFER ActiveBuffer; /* Pointer to the active screen buffer (then maybe the previous Console member is redundant?? Or not...) */
CONSOLE_SELECTION_INFO Selection; /* Contains information about the selection */
COORD dwSelectionCursor; /* Selection cursor position, most of the time different from Selection.dwSelectionAnchor */
GUI_CONSOLE_INFO GuiInfo; /* GUI terminal settings */ GUI_CONSOLE_INFO GuiInfo; /* GUI terminal settings */
} GUI_CONSOLE_DATA, *PGUI_CONSOLE_DATA; } GUI_CONSOLE_DATA, *PGUI_CONSOLE_DATA;

View file

@ -25,8 +25,6 @@ GuiCopyFromGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer,
* This function supposes that the system clipboard was opened. * This function supposes that the system clipboard was opened.
*/ */
PCONSOLE Console = Buffer->Header.Console;
HDC hMemDC; HDC hMemDC;
HBITMAP hBitmapTarget, hBitmapOld; HBITMAP hBitmapTarget, hBitmapOld;
HPALETTE hPalette, hPaletteOld; HPALETTE hPalette, hPaletteOld;
@ -34,13 +32,13 @@ GuiCopyFromGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer,
if (Buffer->BitMap == NULL) return; if (Buffer->BitMap == NULL) return;
selWidth = Console->Selection.srSelection.Right - Console->Selection.srSelection.Left + 1; selWidth = GuiData->Selection.srSelection.Right - GuiData->Selection.srSelection.Left + 1;
selHeight = Console->Selection.srSelection.Bottom - Console->Selection.srSelection.Top + 1; selHeight = GuiData->Selection.srSelection.Bottom - GuiData->Selection.srSelection.Top + 1;
DPRINT1("Selection is (%d|%d) to (%d|%d)\n", DPRINT1("Selection is (%d|%d) to (%d|%d)\n",
Console->Selection.srSelection.Left, GuiData->Selection.srSelection.Left,
Console->Selection.srSelection.Top, GuiData->Selection.srSelection.Top,
Console->Selection.srSelection.Right, GuiData->Selection.srSelection.Right,
Console->Selection.srSelection.Bottom); GuiData->Selection.srSelection.Bottom);
hMemDC = CreateCompatibleDC(GuiData->hMemDC); hMemDC = CreateCompatibleDC(GuiData->hMemDC);
if (hMemDC == NULL) return; if (hMemDC == NULL) return;
@ -74,8 +72,8 @@ GuiCopyFromGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer,
StretchDIBits(hMemDC, StretchDIBits(hMemDC,
0, 0, 0, 0,
selWidth, selHeight, selWidth, selHeight,
Console->Selection.srSelection.Left, GuiData->Selection.srSelection.Left,
Console->Selection.srSelection.Top, GuiData->Selection.srSelection.Top,
selWidth, selHeight, selWidth, selHeight,
Buffer->BitMap, Buffer->BitMap,
Buffer->BitMapInfo, Buffer->BitMapInfo,
@ -87,8 +85,8 @@ GuiCopyFromGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer,
0, 0, 0, 0,
selWidth, selHeight, selWidth, selHeight,
/* 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 */
Console->Selection.srSelection.Left, GuiData->Selection.srSelection.Left,
Console->Selection.srSelection.Top, GuiData->Selection.srSelection.Top,
0, 0,
Buffer->ScreenBufferSize.Y, // == Buffer->BitMapInfo->bmiHeader.biHeight Buffer->ScreenBufferSize.Y, // == Buffer->BitMapInfo->bmiHeader.biHeight
Buffer->BitMap, Buffer->BitMap,
@ -128,8 +126,13 @@ GuiPaintGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer,
PRECT rcView, PRECT rcView,
PRECT rcFramebuffer) PRECT rcFramebuffer)
{ {
PCONSOLE Console = Buffer->Header.Console;
// ASSERT(Console == GuiData->Console);
if (Buffer->BitMap == NULL) return; if (Buffer->BitMap == NULL) return;
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
rcFramebuffer->left = Buffer->ViewOrigin.X * 1 + rcView->left; rcFramebuffer->left = Buffer->ViewOrigin.X * 1 + rcView->left;
rcFramebuffer->top = Buffer->ViewOrigin.Y * 1 + rcView->top; rcFramebuffer->top = Buffer->ViewOrigin.Y * 1 + rcView->top;
rcFramebuffer->right = Buffer->ViewOrigin.X * 1 + rcView->right; rcFramebuffer->right = Buffer->ViewOrigin.X * 1 + rcView->right;
@ -160,6 +163,8 @@ GuiPaintGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer,
/* Release the mutex */ /* Release the mutex */
NtReleaseMutant(Buffer->Mutex, NULL); NtReleaseMutant(Buffer->Mutex, NULL);
LeaveCriticalSection(&Console->Lock);
} }
/* EOF */ /* EOF */

View file

@ -238,6 +238,8 @@ GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData,
DPRINT("GuiConsoleShowConsoleProperties entered\n"); DPRINT("GuiConsoleShowConsoleProperties entered\n");
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
/* /*
* Create a memory section to share with the applet, and map it. * Create a memory section to share with the applet, and map it.
*/ */
@ -253,7 +255,7 @@ GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("Error: Impossible to create a shared section ; Status = %lu\n", Status); DPRINT1("Error: Impossible to create a shared section ; Status = %lu\n", Status);
return; goto Quit;
} }
Status = NtMapViewOfSection(hSection, Status = NtMapViewOfSection(hSection,
@ -269,8 +271,7 @@ GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("Error: Impossible to map the shared section ; Status = %lu\n", Status); DPRINT1("Error: Impossible to map the shared section ; Status = %lu\n", Status);
NtClose(hSection); goto Quit;
return;
} }
@ -408,11 +409,13 @@ GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData,
Quit: Quit:
/* We have finished, close the section handle */ /* We have finished, close the section handle */
NtClose(hSection); if (hSection) NtClose(hSection);
LeaveCriticalSection(&Console->Lock);
return; return;
} }
NTSTATUS VOID
GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData, GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData,
HANDLE hClientSection, HANDLE hClientSection,
BOOL SaveSettings) BOOL SaveSettings)
@ -427,6 +430,8 @@ GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData,
PTERMINAL_INFO TermInfo = NULL; PTERMINAL_INFO TermInfo = NULL;
PGUI_CONSOLE_INFO GuiInfo = NULL; PGUI_CONSOLE_INFO GuiInfo = NULL;
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
/* Get the console leader process, our client */ /* Get the console leader process, our client */
ProcessData = ConDrvGetConsoleLeaderProcess(Console); ProcessData = ConDrvGetConsoleLeaderProcess(Console);
@ -439,7 +444,7 @@ GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("Error when mapping client handle, Status = %lu\n", Status); DPRINT1("Error when mapping client handle, Status = %lu\n", Status);
return Status; goto Quit;
} }
/* Get a view of the shared section */ /* Get a view of the shared section */
@ -456,8 +461,7 @@ GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("Error when mapping view of file, Status = %lu\n", Status); DPRINT1("Error when mapping view of file, Status = %lu\n", Status);
NtClose(hSection); goto Quit;
return Status;
} }
_SEH2_TRY _SEH2_TRY
@ -530,9 +534,14 @@ GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData,
Quit: Quit:
/* Finally, close the section and return */ /* Finally, close the section and return */
NtUnmapViewOfSection(NtCurrentProcess(), pConInfo); if (hSection)
NtClose(hSection); {
return Status; NtUnmapViewOfSection(NtCurrentProcess(), pConInfo);
NtClose(hSection);
}
LeaveCriticalSection(&Console->Lock);
return;
} }
/* EOF */ /* EOF */

View file

@ -55,7 +55,7 @@ GuiConsoleGetDefaultSettings(IN OUT PGUI_CONSOLE_INFO TermInfo,
VOID VOID
GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData, GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData,
BOOL Defaults); BOOL Defaults);
NTSTATUS VOID
GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData, GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData,
HANDLE hClientSection, HANDLE hClientSection,
BOOL SaveSettings); BOOL SaveSettings);

View file

@ -532,6 +532,10 @@ GuiInitFrontEnd(IN OUT PFRONTEND This,
/* There is no user-reserved menu id range by default */ /* There is no user-reserved menu id range by default */
GuiData->CmdIdLow = GuiData->CmdIdHigh = 0; GuiData->CmdIdLow = GuiData->CmdIdHigh = 0;
/* Initialize the selection */
RtlZeroMemory(&GuiData->Selection, sizeof(CONSOLE_SELECTION_INFO));
GuiData->Selection.dwFlags = CONSOLE_NO_SELECTION;
/* /*
* We need to wait until the GUI has been fully initialized * We need to wait until the GUI has been fully initialized
* to retrieve custom settings i.e. WindowSize etc... * to retrieve custom settings i.e. WindowSize etc...
@ -938,6 +942,21 @@ GuiGetLargestConsoleWindowSize(IN OUT PFRONTEND This,
pSize->Y = (SHORT)(height / (int)HeightUnit) /* HACK */ + 1; pSize->Y = (SHORT)(height / (int)HeightUnit) /* HACK */ + 1;
} }
static BOOL NTAPI
GuiGetSelectionInfo(IN OUT PFRONTEND This,
PCONSOLE_SELECTION_INFO pSelectionInfo)
{
PGUI_CONSOLE_DATA GuiData = This->Data;
if (pSelectionInfo == NULL) return FALSE;
ZeroMemory(pSelectionInfo, sizeof(CONSOLE_SELECTION_INFO));
if (GuiData->Selection.dwFlags != CONSOLE_NO_SELECTION)
RtlCopyMemory(pSelectionInfo, &GuiData->Selection, sizeof(CONSOLE_SELECTION_INFO));
return TRUE;
}
static BOOL NTAPI static BOOL NTAPI
GuiSetPalette(IN OUT PFRONTEND This, GuiSetPalette(IN OUT PFRONTEND This,
HPALETTE PaletteHandle, HPALETTE PaletteHandle,
@ -1084,6 +1103,7 @@ static FRONTEND_VTBL GuiVtbl =
GuiChangeIcon, GuiChangeIcon,
GuiGetConsoleWindowHandle, GuiGetConsoleWindowHandle,
GuiGetLargestConsoleWindowSize, GuiGetLargestConsoleWindowSize,
GuiGetSelectionInfo,
GuiSetPalette, GuiSetPalette,
GuiGetDisplayMode, GuiGetDisplayMode,
GuiSetDisplayMode, GuiSetDisplayMode,

View file

@ -20,7 +20,7 @@
/* FUNCTIONS ******************************************************************/ /* FUNCTIONS ******************************************************************/
COLORREF RGBFromAttrib2(PCONSOLE Console, WORD Attribute) COLORREF PaletteRGBFromAttrib(PCONSOLE Console, WORD Attribute)
{ {
HPALETTE hPalette = Console->ActiveBuffer->PaletteHandle; HPALETTE hPalette = Console->ActiveBuffer->PaletteHandle;
PALETTEENTRY pe; PALETTEENTRY pe;
@ -39,8 +39,6 @@ GuiCopyFromTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
* This function supposes that the system clipboard was opened. * This function supposes that the system clipboard was opened.
*/ */
PCONSOLE Console = Buffer->Header.Console;
/* /*
* Pressing the Shift key while copying text, allows us to copy * Pressing the Shift key while copying text, allows us to copy
* text without newline characters (inline-text copy mode). * text without newline characters (inline-text copy mode).
@ -53,13 +51,13 @@ GuiCopyFromTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
ULONG selWidth, selHeight; ULONG selWidth, selHeight;
ULONG xPos, yPos, size; ULONG xPos, yPos, size;
selWidth = Console->Selection.srSelection.Right - Console->Selection.srSelection.Left + 1; selWidth = GuiData->Selection.srSelection.Right - GuiData->Selection.srSelection.Left + 1;
selHeight = Console->Selection.srSelection.Bottom - Console->Selection.srSelection.Top + 1; selHeight = GuiData->Selection.srSelection.Bottom - GuiData->Selection.srSelection.Top + 1;
DPRINT("Selection is (%d|%d) to (%d|%d)\n", DPRINT("Selection is (%d|%d) to (%d|%d)\n",
Console->Selection.srSelection.Left, GuiData->Selection.srSelection.Left,
Console->Selection.srSelection.Top, GuiData->Selection.srSelection.Top,
Console->Selection.srSelection.Right, GuiData->Selection.srSelection.Right,
Console->Selection.srSelection.Bottom); GuiData->Selection.srSelection.Bottom);
#ifdef IS_WHITESPACE #ifdef IS_WHITESPACE
#undef IS_WHITESPACE #undef IS_WHITESPACE
@ -99,8 +97,8 @@ GuiCopyFromTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
ULONG length = selWidth; ULONG length = selWidth;
ptr = ConioCoordToPointer(Buffer, ptr = ConioCoordToPointer(Buffer,
Console->Selection.srSelection.Left, GuiData->Selection.srSelection.Left,
Console->Selection.srSelection.Top + yPos); GuiData->Selection.srSelection.Top + yPos);
/* Trim whitespace from the right */ /* Trim whitespace from the right */
while (length > 0) while (length > 0)
@ -230,6 +228,8 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
if (Buffer->Buffer == NULL) return; if (Buffer->Buffer == NULL) return;
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
rcFramebuffer->left = Buffer->ViewOrigin.X * GuiData->CharWidth + rcView->left; rcFramebuffer->left = Buffer->ViewOrigin.X * GuiData->CharWidth + rcView->left;
rcFramebuffer->top = Buffer->ViewOrigin.Y * GuiData->CharHeight + rcView->top; rcFramebuffer->top = Buffer->ViewOrigin.Y * GuiData->CharHeight + rcView->top;
rcFramebuffer->right = Buffer->ViewOrigin.X * GuiData->CharWidth + rcView->right; rcFramebuffer->right = Buffer->ViewOrigin.X * GuiData->CharWidth + rcView->right;
@ -245,8 +245,8 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
LastAttribute = ConioCoordToPointer(Buffer, LeftChar, TopLine)->Attributes; LastAttribute = ConioCoordToPointer(Buffer, LeftChar, TopLine)->Attributes;
SetTextColor(GuiData->hMemDC, RGBFromAttrib2(Console, TextAttribFromAttrib(LastAttribute))); SetTextColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, TextAttribFromAttrib(LastAttribute)));
SetBkColor(GuiData->hMemDC, RGBFromAttrib2(Console, BkgdAttribFromAttrib(LastAttribute))); SetBkColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, BkgdAttribFromAttrib(LastAttribute)));
OldFont = SelectObject(GuiData->hMemDC, GuiData->Font); OldFont = SelectObject(GuiData->hMemDC, GuiData->Font);
@ -275,8 +275,8 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
Attribute = From->Attributes; Attribute = From->Attributes;
if (Attribute != LastAttribute) if (Attribute != LastAttribute)
{ {
SetTextColor(GuiData->hMemDC, RGBFromAttrib2(Console, TextAttribFromAttrib(Attribute))); SetTextColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, TextAttribFromAttrib(Attribute)));
SetBkColor(GuiData->hMemDC, RGBFromAttrib2(Console, BkgdAttribFromAttrib(Attribute))); SetBkColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, BkgdAttribFromAttrib(Attribute)));
LastAttribute = Attribute; LastAttribute = Attribute;
} }
} }
@ -308,7 +308,7 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
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) Attribute = Buffer->ScreenDefaultAttrib;
CursorBrush = CreateSolidBrush(RGBFromAttrib2(Console, TextAttribFromAttrib(Attribute))); CursorBrush = CreateSolidBrush(PaletteRGBFromAttrib(Console, TextAttribFromAttrib(Attribute)));
OldBrush = SelectObject(GuiData->hMemDC, CursorBrush); OldBrush = SelectObject(GuiData->hMemDC, CursorBrush);
PatBlt(GuiData->hMemDC, PatBlt(GuiData->hMemDC,
@ -323,6 +323,8 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
} }
SelectObject(GuiData->hMemDC, OldFont); SelectObject(GuiData->hMemDC, OldFont);
LeaveCriticalSection(&Console->Lock);
} }
/* EOF */ /* EOF */

View file

@ -746,6 +746,13 @@ TuiGetLargestConsoleWindowSize(IN OUT PFRONTEND This,
*pSize = PhysicalConsoleSize; *pSize = PhysicalConsoleSize;
} }
static BOOL NTAPI
TuiGetSelectionInfo(IN OUT PFRONTEND This,
PCONSOLE_SELECTION_INFO pSelectionInfo)
{
return TRUE;
}
static BOOL NTAPI static BOOL NTAPI
TuiSetPalette(IN OUT PFRONTEND This, TuiSetPalette(IN OUT PFRONTEND This,
HPALETTE PaletteHandle, HPALETTE PaletteHandle,
@ -813,6 +820,7 @@ static FRONTEND_VTBL TuiVtbl =
TuiChangeIcon, TuiChangeIcon,
TuiGetConsoleWindowHandle, TuiGetConsoleWindowHandle,
TuiGetLargestConsoleWindowSize, TuiGetLargestConsoleWindowSize,
TuiGetSelectionInfo,
TuiSetPalette, TuiSetPalette,
TuiGetDisplayMode, TuiGetDisplayMode,
TuiSetDisplayMode, TuiSetDisplayMode,

View file

@ -228,6 +228,8 @@ typedef struct _FRONTEND_VTBL
HWND (NTAPI *GetConsoleWindowHandle)(IN OUT PFRONTEND This); HWND (NTAPI *GetConsoleWindowHandle)(IN OUT PFRONTEND This);
VOID (NTAPI *GetLargestConsoleWindowSize)(IN OUT PFRONTEND This, VOID (NTAPI *GetLargestConsoleWindowSize)(IN OUT PFRONTEND This,
PCOORD pSize); PCOORD pSize);
BOOL (NTAPI *GetSelectionInfo)(IN OUT PFRONTEND This,
PCONSOLE_SELECTION_INFO pSelectionInfo);
BOOL (NTAPI *SetPalette)(IN OUT PFRONTEND This, BOOL (NTAPI *SetPalette)(IN OUT PFRONTEND This,
HPALETTE PaletteHandle, HPALETTE PaletteHandle,
UINT PaletteUsage); UINT PaletteUsage);
@ -305,9 +307,6 @@ typedef struct _CONSOLE
BOOLEAN InsertMode; BOOLEAN InsertMode;
UINT CodePage; UINT CodePage;
CONSOLE_SELECTION_INFO Selection; /* Contains information about the selection */
COORD dwSelectionCursor; /* Selection cursor position, most of the time different from Selection.dwSelectionAnchor */
/******************************* Screen buffers *******************************/ /******************************* Screen buffers *******************************/
LIST_ENTRY BufferList; /* List of all screen buffers for this console */ LIST_ENTRY BufferList; /* List of all screen buffers for this console */
PCONSOLE_SCREEN_BUFFER ActiveBuffer; /* Pointer to currently active screen buffer */ PCONSOLE_SCREEN_BUFFER ActiveBuffer; /* Pointer to currently active screen buffer */

View file

@ -38,6 +38,8 @@
(Console)->TermIFace.Vtbl->GetConsoleWindowHandle(&(Console)->TermIFace) (Console)->TermIFace.Vtbl->GetConsoleWindowHandle(&(Console)->TermIFace)
#define TermGetLargestConsoleWindowSize(Console, pSize) \ #define TermGetLargestConsoleWindowSize(Console, pSize) \
(Console)->TermIFace.Vtbl->GetLargestConsoleWindowSize(&(Console)->TermIFace, (pSize)) (Console)->TermIFace.Vtbl->GetLargestConsoleWindowSize(&(Console)->TermIFace, (pSize))
#define TermGetSelectionInfo(Console, pSelectionInfo) \
(Console)->TermIFace.Vtbl->GetSelectionInfo(&(Console)->TermIFace, (pSelectionInfo))
#define TermSetPalette(Console, PaletteHandle, PaletteUsage) \ #define TermSetPalette(Console, PaletteHandle, PaletteUsage) \
(Console)->TermIFace.Vtbl->SetPalette(&(Console)->TermIFace, (PaletteHandle), (PaletteUsage)) (Console)->TermIFace.Vtbl->SetPalette(&(Console)->TermIFace, (PaletteHandle), (PaletteUsage))
#define TermGetDisplayMode(Console) \ #define TermGetDisplayMode(Console) \