Author: hbelusca
Date: Tue Apr 22 03:44:13 2014
New Revision: 62864
URL:
http://svn.reactos.org/svn/reactos?rev=62864&view=rev
Log:
[CONSRV]
- Selection info is per-terminal.
- Lock the console only when needed.
Modified:
trunk/reactos/win32ss/user/winsrv/consrv/condrv/console.c
trunk/reactos/win32ss/user/winsrv/consrv/condrv/dummyfrontend.c
trunk/reactos/win32ss/user/winsrv/consrv/frontendctl.c
trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.h
trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/graphics.c
trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guisettings.c
trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guisettings.h
trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/text.c
trunk/reactos/win32ss/user/winsrv/consrv/frontends/tui/tuiterm.c
trunk/reactos/win32ss/user/winsrv/consrv/include/conio.h
trunk/reactos/win32ss/user/winsrv/consrv/include/term.h
Modified: trunk/reactos/win32ss/user/winsrv/consrv/condrv/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/condrv/console.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/condrv/console.c [iso-8859-1] Tue Apr 22
03:44:13 2014
@@ -575,11 +575,6 @@
Console->LineInsertToggle = Console->InsertMode;
// 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 */
Console->CodePage = Console->OutputCodePage = ConsoleInfo->CodePage;
Modified: trunk/reactos/win32ss/user/winsrv/consrv/condrv/dummyfrontend.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/condrv/dummyfrontend.c [iso-8859-1]
(original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/condrv/dummyfrontend.c [iso-8859-1] Tue Apr
22 03:44:13 2014
@@ -114,6 +114,13 @@
DummyGetLargestConsoleWindowSize(IN OUT PFRONTEND This,
PCOORD pSize)
{
+}
+
+static BOOL NTAPI
+DummyGetSelectionInfo(IN OUT PFRONTEND This,
+ PCONSOLE_SELECTION_INFO pSelectionInfo)
+{
+ return TRUE;
}
static BOOL NTAPI
@@ -183,6 +190,7 @@
DummyChangeIcon,
DummyGetConsoleWindowHandle,
DummyGetLargestConsoleWindowSize,
+ DummyGetSelectionInfo,
DummySetPalette,
DummyGetDisplayMode,
DummySetDisplayMode,
Modified: trunk/reactos/win32ss/user/winsrv/consrv/frontendctl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/frontendctl.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/frontendctl.c [iso-8859-1] Tue Apr 22
03:44:13 2014
@@ -308,14 +308,13 @@
PCONSOLE Console;
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
- if (NT_SUCCESS(Status))
- {
- memset(&GetSelectionInfoRequest->Info, 0,
sizeof(CONSOLE_SELECTION_INFO));
- if (Console->Selection.dwFlags != 0)
- GetSelectionInfoRequest->Info = Console->Selection;
- ConSrvReleaseConsole(Console, TRUE);
- }
-
+ if (!NT_SUCCESS(Status)) return Status;
+
+ Status = (TermGetSelectionInfo(Console, &GetSelectionInfoRequest->Info)
+ ? STATUS_SUCCESS
+ : STATUS_UNSUCCESSFUL);
+
+ ConSrvReleaseConsole(Console, TRUE);
return Status;
}
Modified: trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c [iso-8859-1]
(original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c [iso-8859-1] Tue Apr
22 03:44:13 2014
@@ -266,11 +266,15 @@
{
INPUT_RECORD er;
+ DPRINT1("Menu item ID: %d\n", CmdId);
+
+ if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
+
er.EventType = MENU_EVENT;
er.Event.MenuEvent.dwCommandId = CmdId;
-
- DPRINT("Menu item ID: %d\n", CmdId);
ConioProcessInputEvent(Console, &er);
+
+ LeaveCriticalSection(&Console->Lock);
}
static VOID
@@ -283,36 +287,34 @@
static VOID
Mark(PGUI_CONSOLE_DATA GuiData)
{
- PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
/* Clear the old selection */
// UpdateSelection(GuiData, NULL);
- Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
+ GuiData->Selection.dwFlags = CONSOLE_NO_SELECTION;
/* Restart a new selection */
- Console->dwSelectionCursor.X = ActiveBuffer->ViewOrigin.X;
- Console->dwSelectionCursor.Y = ActiveBuffer->ViewOrigin.Y;
- Console->Selection.dwSelectionAnchor = Console->dwSelectionCursor;
- UpdateSelection(GuiData, &Console->Selection.dwSelectionAnchor);
+ GuiData->dwSelectionCursor.X = ActiveBuffer->ViewOrigin.X;
+ GuiData->dwSelectionCursor.Y = ActiveBuffer->ViewOrigin.Y;
+ GuiData->Selection.dwSelectionAnchor = GuiData->dwSelectionCursor;
+ UpdateSelection(GuiData, &GuiData->Selection.dwSelectionAnchor);
}
static VOID
SelectAll(PGUI_CONSOLE_DATA GuiData)
{
- PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
/* Clear the old selection */
// 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.
*/
- Console->Selection.dwSelectionAnchor.X = 0;
- Console->Selection.dwSelectionAnchor.Y = 0;
- Console->dwSelectionCursor.X = ActiveBuffer->ScreenBufferSize.X - 1;
+ GuiData->Selection.dwSelectionAnchor.X = 0;
+ GuiData->Selection.dwSelectionAnchor.Y = 0;
+ GuiData->dwSelectionCursor.X = ActiveBuffer->ScreenBufferSize.X - 1;
/*
* Determine whether the selection must extend to just some part
@@ -325,19 +327,19 @@
* We select all the characters from the first line
* 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) */
{
/*
* 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 */
- Console->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION;
- UpdateSelection(GuiData, &Console->dwSelectionCursor);
+ GuiData->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION;
+ UpdateSelection(GuiData, &GuiData->dwSelectionCursor);
}
static LRESULT
@@ -345,12 +347,6 @@
{
LRESULT Ret = TRUE;
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,
@@ -360,7 +356,7 @@
if (GuiData->CmdIdLow <= (UINT)wParam && (UINT)wParam <=
GuiData->CmdIdHigh)
{
SendMenuEvent(Console, (UINT)wParam);
- goto Unlock_Quit;
+ goto Quit;
}
/* ... otherwise, perform actions. */
@@ -403,8 +399,6 @@
break;
}
-Unlock_Quit:
- LeaveCriticalSection(&Console->Lock);
Quit:
if (!Ret)
Ret = DefWindowProcW(GuiData->hWindow, WM_SYSCOMMAND, wParam, lParam);
@@ -643,12 +637,12 @@
er.Event.FocusEvent.bSetFocus = SetFocus;
ConioProcessInputEvent(Console, &er);
+ LeaveCriticalSection(&Console->Lock);
+
if (SetFocus)
DPRINT1("TODO: Create console caret\n");
else
DPRINT1("TODO: Destroy console caret\n");
-
- LeaveCriticalSection(&Console->Lock);
}
static VOID
@@ -671,7 +665,7 @@
PCONSOLE Console = GuiData->Console;
RECT oldRect;
- SmallRectToRect(GuiData, &oldRect, &Console->Selection.srSelection);
+ SmallRectToRect(GuiData, &oldRect, &GuiData->Selection.srSelection);
if (coord != NULL)
{
@@ -679,16 +673,16 @@
SMALL_RECT rc;
/* Exchange left/top with right/bottom if required */
- rc.Left = min(Console->Selection.dwSelectionAnchor.X, coord->X);
- rc.Top = min(Console->Selection.dwSelectionAnchor.Y, coord->Y);
- rc.Right = max(Console->Selection.dwSelectionAnchor.X, coord->X);
- rc.Bottom = max(Console->Selection.dwSelectionAnchor.Y, coord->Y);
+ rc.Left = min(GuiData->Selection.dwSelectionAnchor.X, coord->X);
+ rc.Top = min(GuiData->Selection.dwSelectionAnchor.Y, coord->Y);
+ rc.Right = max(GuiData->Selection.dwSelectionAnchor.X, coord->X);
+ rc.Bottom = max(GuiData->Selection.dwSelectionAnchor.Y, coord->Y);
SmallRectToRect(GuiData, &newRect, &rc);
- if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
- {
- if (memcmp(&rc, &Console->Selection.srSelection,
sizeof(SMALL_RECT)) != 0)
+ if (GuiData->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
+ {
+ if (memcmp(&rc, &GuiData->Selection.srSelection,
sizeof(SMALL_RECT)) != 0)
{
HRGN rgn1, rgn2;
@@ -712,22 +706,22 @@
InvalidateRect(GuiData->hWindow, &newRect, FALSE);
}
- Console->Selection.dwFlags |= CONSOLE_SELECTION_NOT_EMPTY;
- Console->Selection.srSelection = rc;
- Console->dwSelectionCursor = *coord;
-
- if ((Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) == 0)
+ GuiData->Selection.dwFlags |= CONSOLE_SELECTION_NOT_EMPTY;
+ GuiData->Selection.srSelection = rc;
+ GuiData->dwSelectionCursor = *coord;
+
+ if ((GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) == 0)
{
LPWSTR SelectionType, WindowTitle = NULL;
SIZE_T Length = 0;
/* 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);
}
- if (Console->Selection.dwFlags & CONSOLE_MOUSE_SELECTION)
+ if (GuiData->Selection.dwFlags & CONSOLE_MOUSE_SELECTION)
{
SelectionType = L"Selection - ";
}
@@ -743,19 +737,19 @@
SetWindowText(GuiData->hWindow, WindowTitle);
ConsoleFreeHeap(WindowTitle);
- Console->Selection.dwFlags |= CONSOLE_SELECTION_IN_PROGRESS;
+ GuiData->Selection.dwFlags |= CONSOLE_SELECTION_IN_PROGRESS;
ConioPause(Console, PAUSED_FROM_SELECTION);
}
}
else
{
/* Clear the selection */
- if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
+ if (GuiData->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
{
InvalidateRect(GuiData->hWindow, &oldRect, FALSE);
}
- Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
+ GuiData->Selection.dwFlags = CONSOLE_NO_SELECTION;
ConioUnpause(Console, PAUSED_FROM_SELECTION);
SetWindowText(GuiData->hWindow, Console->Title.Buffer);
@@ -777,17 +771,10 @@
static VOID
OnPaint(PGUI_CONSOLE_DATA GuiData)
{
- BOOL Success = TRUE;
- PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER ActiveBuffer;
PAINTSTRUCT ps;
RECT rcPaint;
- if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
- {
- Success = FALSE;
- goto Quit;
- }
ActiveBuffer = GuiData->ActiveBuffer;
BeginPaint(GuiData->hWindow, &ps);
@@ -820,9 +807,9 @@
rcPaint.top,
SRCCOPY);
- if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
- {
- SmallRectToRect(GuiData, &rcPaint,
&Console->Selection.srSelection);
+ if (GuiData->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
+ {
+ SmallRectToRect(GuiData, &rcPaint,
&GuiData->Selection.srSelection);
/* Invert the selection */
if (IntersectRect(&rcPaint, &ps.rcPaint, &rcPaint))
@@ -834,12 +821,6 @@
LeaveCriticalSection(&GuiData->Lock);
}
EndPaint(GuiData->hWindow, &ps);
-
-Quit:
- if (Success)
- LeaveCriticalSection(&Console->Lock);
- else
- DefWindowProcW(GuiData->hWindow, WM_PAINT, 0, 0);
return;
}
@@ -898,7 +879,7 @@
ActiveBuffer = GuiData->ActiveBuffer;
- if (Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS)
+ if (GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS)
{
WORD VirtualKeyCode = LOWORD(wParam);
@@ -918,7 +899,7 @@
goto Quit;
}
- if ((Console->Selection.dwFlags & CONSOLE_MOUSE_SELECTION) == 0)
+ if ((GuiData->Selection.dwFlags & CONSOLE_MOUSE_SELECTION) == 0)
{
/* Keyboard selection mode */
BOOL Interpreted = FALSE;
@@ -929,8 +910,8 @@
case VK_LEFT:
{
Interpreted = TRUE;
- if (Console->dwSelectionCursor.X > 0)
- Console->dwSelectionCursor.X--;
+ if (GuiData->dwSelectionCursor.X > 0)
+ GuiData->dwSelectionCursor.X--;
break;
}
@@ -938,8 +919,8 @@
case VK_RIGHT:
{
Interpreted = TRUE;
- if (Console->dwSelectionCursor.X <
ActiveBuffer->ScreenBufferSize.X - 1)
- Console->dwSelectionCursor.X++;
+ if (GuiData->dwSelectionCursor.X <
ActiveBuffer->ScreenBufferSize.X - 1)
+ GuiData->dwSelectionCursor.X++;
break;
}
@@ -947,8 +928,8 @@
case VK_UP:
{
Interpreted = TRUE;
- if (Console->dwSelectionCursor.Y > 0)
- Console->dwSelectionCursor.Y--;
+ if (GuiData->dwSelectionCursor.Y > 0)
+ GuiData->dwSelectionCursor.Y--;
break;
}
@@ -956,8 +937,8 @@
case VK_DOWN:
{
Interpreted = TRUE;
- if (Console->dwSelectionCursor.Y <
ActiveBuffer->ScreenBufferSize.Y - 1)
- Console->dwSelectionCursor.Y++;
+ if (GuiData->dwSelectionCursor.Y <
ActiveBuffer->ScreenBufferSize.Y - 1)
+ GuiData->dwSelectionCursor.Y++;
break;
}
@@ -965,24 +946,24 @@
case VK_HOME:
{
Interpreted = TRUE;
- Console->dwSelectionCursor.X = 0;
- Console->dwSelectionCursor.Y = 0;
+ GuiData->dwSelectionCursor.X = 0;
+ GuiData->dwSelectionCursor.Y = 0;
break;
}
case VK_END:
{
Interpreted = TRUE;
- Console->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y
- 1;
+ GuiData->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y
- 1;
break;
}
case VK_PRIOR:
{
Interpreted = TRUE;
- Console->dwSelectionCursor.Y -= ActiveBuffer->ViewSize.Y;
- if (Console->dwSelectionCursor.Y < 0)
- Console->dwSelectionCursor.Y = 0;
+ GuiData->dwSelectionCursor.Y -= ActiveBuffer->ViewSize.Y;
+ if (GuiData->dwSelectionCursor.Y < 0)
+ GuiData->dwSelectionCursor.Y = 0;
break;
}
@@ -990,9 +971,9 @@
case VK_NEXT:
{
Interpreted = TRUE;
- Console->dwSelectionCursor.Y += ActiveBuffer->ViewSize.Y;
- if (Console->dwSelectionCursor.Y >=
ActiveBuffer->ScreenBufferSize.Y)
- Console->dwSelectionCursor.Y =
ActiveBuffer->ScreenBufferSize.Y - 1;
+ GuiData->dwSelectionCursor.Y += ActiveBuffer->ViewSize.Y;
+ if (GuiData->dwSelectionCursor.Y >=
ActiveBuffer->ScreenBufferSize.Y)
+ GuiData->dwSelectionCursor.Y =
ActiveBuffer->ScreenBufferSize.Y - 1;
break;
}
@@ -1004,9 +985,9 @@
if (Interpreted)
{
if (!MajPressed)
- Console->Selection.dwSelectionAnchor =
Console->dwSelectionCursor;
-
- UpdateSelection(GuiData, &Console->dwSelectionCursor);
+ GuiData->Selection.dwSelectionAnchor =
GuiData->dwSelectionCursor;
+
+ UpdateSelection(GuiData, &GuiData->dwSelectionCursor);
}
else if (!IsSystemKey(VirtualKeyCode))
{
@@ -1032,7 +1013,7 @@
}
}
- if ((Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) == 0)
+ if ((GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) == 0)
{
MSG Message;
@@ -1265,7 +1246,7 @@
goto Quit;
}
- if ( (Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) ||
+ if ( (GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) ||
(Console->QuickEdit) )
{
switch (msg)
@@ -1274,13 +1255,13 @@
{
/* Clear the old selection */
// UpdateSelection(GuiData, NULL);
- Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
+ GuiData->Selection.dwFlags = CONSOLE_NO_SELECTION;
/* Restart a new selection */
- Console->Selection.dwSelectionAnchor = PointToCoord(GuiData, lParam);
+ GuiData->Selection.dwSelectionAnchor = PointToCoord(GuiData, lParam);
SetCapture(GuiData->hWindow);
- Console->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION |
CONSOLE_MOUSE_DOWN;
- UpdateSelection(GuiData, &Console->Selection.dwSelectionAnchor);
+ GuiData->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION |
CONSOLE_MOUSE_DOWN;
+ UpdateSelection(GuiData, &GuiData->Selection.dwSelectionAnchor);
break;
}
@@ -1289,10 +1270,10 @@
{
// COORD c;
- if (!(Console->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break;
+ if (!(GuiData->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break;
// c = PointToCoord(GuiData, lParam);
- Console->Selection.dwFlags &= ~CONSOLE_MOUSE_DOWN;
+ GuiData->Selection.dwFlags &= ~CONSOLE_MOUSE_DOWN;
// UpdateSelection(GuiData, &c);
ReleaseCapture();
@@ -1338,11 +1319,11 @@
* Update the selection started with the single
* left-click that preceded this double-click.
*/
- Console->Selection.dwSelectionAnchor = cL;
- Console->dwSelectionCursor = cR;
-
- Console->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION |
CONSOLE_MOUSE_DOWN;
- UpdateSelection(GuiData, &Console->dwSelectionCursor);
+ GuiData->Selection.dwSelectionAnchor = cL;
+ GuiData->dwSelectionCursor = cR;
+
+ GuiData->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION |
CONSOLE_MOUSE_DOWN;
+ UpdateSelection(GuiData, &GuiData->dwSelectionCursor);
/* Ignore the next mouse move signal */
GuiData->IgnoreNextMouseSignal = TRUE;
@@ -1354,7 +1335,7 @@
case WM_RBUTTONDOWN:
case WM_RBUTTONDBLCLK:
{
- if (!(Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY))
+ if (!(GuiData->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY))
{
Paste(GuiData);
}
@@ -1373,7 +1354,7 @@
COORD c;
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 */
UpdateSelection(GuiData, &c);
@@ -1674,10 +1655,7 @@
static VOID
OnMove(PGUI_CONSOLE_DATA GuiData)
{
- PCONSOLE Console = GuiData->Console;
RECT rcWnd;
-
- if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
// TODO: Simplify the code.
// See: GuiConsoleNotifyWndProc() PM_CREATE_CONSOLE.
@@ -1686,8 +1664,6 @@
GetWindowRect(GuiData->hWindow, &rcWnd);
GuiData->GuiInfo.WindowOrigin.x = rcWnd.left;
GuiData->GuiInfo.WindowOrigin.y = rcWnd.top;
-
- LeaveCriticalSection(&Console->Lock);
}
/*
@@ -2042,20 +2018,16 @@
/* Enable or disable the Copy and Paste items */
EnableMenuItem(hMenu, ID_SYSTEM_EDIT_COPY , MF_BYCOMMAND |
- ((Console->Selection.dwFlags &
CONSOLE_SELECTION_IN_PROGRESS) &&
- (Console->Selection.dwFlags &
CONSOLE_SELECTION_NOT_EMPTY) ? MF_ENABLED : MF_GRAYED));
+ ((GuiData->Selection.dwFlags &
CONSOLE_SELECTION_IN_PROGRESS) &&
+ (GuiData->Selection.dwFlags &
CONSOLE_SELECTION_NOT_EMPTY) ? MF_ENABLED : MF_GRAYED));
// FIXME: Following whether the active screen buffer is text-mode
// or graphics-mode, search for CF_UNICODETEXT or CF_BITMAP formats.
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));
}
- if (ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
- {
- SendMenuEvent(Console, WM_INITMENU);
- LeaveCriticalSection(&Console->Lock);
- }
+ SendMenuEvent(Console, WM_INITMENU);
break;
}
@@ -2063,11 +2035,7 @@
{
if (HIWORD(wParam) == 0xFFFF) // Allow all the menu flags
{
- if (ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
- {
- SendMenuEvent(Console, WM_MENUSELECT);
- LeaveCriticalSection(&Console->Lock);
- }
+ SendMenuEvent(Console, WM_MENUSELECT);
}
break;
}
@@ -2170,11 +2138,7 @@
case PM_APPLY_CONSOLE_INFO:
{
- if (ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
- {
- GuiApplyUserSettings(GuiData, (HANDLE)wParam, (BOOL)lParam);
- LeaveCriticalSection(&Console->Lock);
- }
+ GuiApplyUserSettings(GuiData, (HANDLE)wParam, (BOOL)lParam);
break;
}
Modified: trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.h [iso-8859-1]
(original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.h [iso-8859-1] Tue Apr
22 03:44:13 2014
@@ -63,6 +63,8 @@
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...) */
+ 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_DATA, *PGUI_CONSOLE_DATA;
Modified: trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/graphics.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/graphics.c [iso-8859-1]
(original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/graphics.c [iso-8859-1] Tue Apr
22 03:44:13 2014
@@ -25,8 +25,6 @@
* This function supposes that the system clipboard was opened.
*/
- PCONSOLE Console = Buffer->Header.Console;
-
HDC hMemDC;
HBITMAP hBitmapTarget, hBitmapOld;
HPALETTE hPalette, hPaletteOld;
@@ -34,13 +32,13 @@
if (Buffer->BitMap == NULL) return;
- selWidth = Console->Selection.srSelection.Right -
Console->Selection.srSelection.Left + 1;
- selHeight = Console->Selection.srSelection.Bottom -
Console->Selection.srSelection.Top + 1;
+ selWidth = GuiData->Selection.srSelection.Right -
GuiData->Selection.srSelection.Left + 1;
+ selHeight = GuiData->Selection.srSelection.Bottom -
GuiData->Selection.srSelection.Top + 1;
DPRINT1("Selection is (%d|%d) to (%d|%d)\n",
- Console->Selection.srSelection.Left,
- Console->Selection.srSelection.Top,
- Console->Selection.srSelection.Right,
- Console->Selection.srSelection.Bottom);
+ GuiData->Selection.srSelection.Left,
+ GuiData->Selection.srSelection.Top,
+ GuiData->Selection.srSelection.Right,
+ GuiData->Selection.srSelection.Bottom);
hMemDC = CreateCompatibleDC(GuiData->hMemDC);
if (hMemDC == NULL) return;
@@ -74,8 +72,8 @@
StretchDIBits(hMemDC,
0, 0,
selWidth, selHeight,
- Console->Selection.srSelection.Left,
- Console->Selection.srSelection.Top,
+ GuiData->Selection.srSelection.Left,
+ GuiData->Selection.srSelection.Top,
selWidth, selHeight,
Buffer->BitMap,
Buffer->BitMapInfo,
@@ -87,8 +85,8 @@
0, 0,
selWidth, selHeight,
/* Coordinates / size of the corresponding image portion, in the
graphics screen-buffer's frame */
- Console->Selection.srSelection.Left,
- Console->Selection.srSelection.Top,
+ GuiData->Selection.srSelection.Left,
+ GuiData->Selection.srSelection.Top,
0,
Buffer->ScreenBufferSize.Y, // ==
Buffer->BitMapInfo->bmiHeader.biHeight
Buffer->BitMap,
@@ -128,7 +126,12 @@
PRECT rcView,
PRECT rcFramebuffer)
{
+ PCONSOLE Console = Buffer->Header.Console;
+ // ASSERT(Console == GuiData->Console);
+
if (Buffer->BitMap == NULL) return;
+
+ if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
rcFramebuffer->left = Buffer->ViewOrigin.X * 1 + rcView->left;
rcFramebuffer->top = Buffer->ViewOrigin.Y * 1 + rcView->top;
@@ -160,6 +163,8 @@
/* Release the mutex */
NtReleaseMutant(Buffer->Mutex, NULL);
+
+ LeaveCriticalSection(&Console->Lock);
}
/* EOF */
Modified: trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guisettings.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guisettings.c [iso-8859-1]
(original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guisettings.c [iso-8859-1] Tue
Apr 22 03:44:13 2014
@@ -238,6 +238,8 @@
DPRINT("GuiConsoleShowConsoleProperties entered\n");
+ if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
+
/*
* Create a memory section to share with the applet, and map it.
*/
@@ -253,7 +255,7 @@
if (!NT_SUCCESS(Status))
{
DPRINT1("Error: Impossible to create a shared section ; Status =
%lu\n", Status);
- return;
+ goto Quit;
}
Status = NtMapViewOfSection(hSection,
@@ -269,8 +271,7 @@
if (!NT_SUCCESS(Status))
{
DPRINT1("Error: Impossible to map the shared section ; Status = %lu\n",
Status);
- NtClose(hSection);
- return;
+ goto Quit;
}
@@ -408,11 +409,13 @@
Quit:
/* We have finished, close the section handle */
- NtClose(hSection);
+ if (hSection) NtClose(hSection);
+
+ LeaveCriticalSection(&Console->Lock);
return;
}
-NTSTATUS
+VOID
GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData,
HANDLE hClientSection,
BOOL SaveSettings)
@@ -427,6 +430,8 @@
PTERMINAL_INFO TermInfo = NULL;
PGUI_CONSOLE_INFO GuiInfo = NULL;
+ if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
+
/* Get the console leader process, our client */
ProcessData = ConDrvGetConsoleLeaderProcess(Console);
@@ -439,7 +444,7 @@
if (!NT_SUCCESS(Status))
{
DPRINT1("Error when mapping client handle, Status = %lu\n", Status);
- return Status;
+ goto Quit;
}
/* Get a view of the shared section */
@@ -456,8 +461,7 @@
if (!NT_SUCCESS(Status))
{
DPRINT1("Error when mapping view of file, Status = %lu\n", Status);
- NtClose(hSection);
- return Status;
+ goto Quit;
}
_SEH2_TRY
@@ -530,9 +534,14 @@
Quit:
/* Finally, close the section and return */
- NtUnmapViewOfSection(NtCurrentProcess(), pConInfo);
- NtClose(hSection);
- return Status;
+ if (hSection)
+ {
+ NtUnmapViewOfSection(NtCurrentProcess(), pConInfo);
+ NtClose(hSection);
+ }
+
+ LeaveCriticalSection(&Console->Lock);
+ return;
}
/* EOF */
Modified: trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guisettings.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guisettings.h [iso-8859-1]
(original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guisettings.h [iso-8859-1] Tue
Apr 22 03:44:13 2014
@@ -55,7 +55,7 @@
VOID
GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData,
BOOL Defaults);
-NTSTATUS
+VOID
GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData,
HANDLE hClientSection,
BOOL SaveSettings);
Modified: trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c [iso-8859-1]
(original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c [iso-8859-1] Tue Apr
22 03:44:13 2014
@@ -532,6 +532,10 @@
/* There is no user-reserved menu id range by default */
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
* to retrieve custom settings i.e. WindowSize etc...
@@ -936,6 +940,21 @@
pSize->X = (SHORT)(width / (int)WidthUnit ) /* HACK */ + 2;
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
@@ -1084,6 +1103,7 @@
GuiChangeIcon,
GuiGetConsoleWindowHandle,
GuiGetLargestConsoleWindowSize,
+ GuiGetSelectionInfo,
GuiSetPalette,
GuiGetDisplayMode,
GuiSetDisplayMode,
Modified: trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/text.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/text.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/text.c [iso-8859-1] Tue Apr 22
03:44:13 2014
@@ -20,7 +20,7 @@
/* FUNCTIONS ******************************************************************/
-COLORREF RGBFromAttrib2(PCONSOLE Console, WORD Attribute)
+COLORREF PaletteRGBFromAttrib(PCONSOLE Console, WORD Attribute)
{
HPALETTE hPalette = Console->ActiveBuffer->PaletteHandle;
PALETTEENTRY pe;
@@ -39,8 +39,6 @@
* 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
* text without newline characters (inline-text copy mode).
@@ -53,13 +51,13 @@
ULONG selWidth, selHeight;
ULONG xPos, yPos, size;
- selWidth = Console->Selection.srSelection.Right -
Console->Selection.srSelection.Left + 1;
- selHeight = Console->Selection.srSelection.Bottom -
Console->Selection.srSelection.Top + 1;
+ selWidth = GuiData->Selection.srSelection.Right -
GuiData->Selection.srSelection.Left + 1;
+ selHeight = GuiData->Selection.srSelection.Bottom -
GuiData->Selection.srSelection.Top + 1;
DPRINT("Selection is (%d|%d) to (%d|%d)\n",
- Console->Selection.srSelection.Left,
- Console->Selection.srSelection.Top,
- Console->Selection.srSelection.Right,
- Console->Selection.srSelection.Bottom);
+ GuiData->Selection.srSelection.Left,
+ GuiData->Selection.srSelection.Top,
+ GuiData->Selection.srSelection.Right,
+ GuiData->Selection.srSelection.Bottom);
#ifdef IS_WHITESPACE
#undef IS_WHITESPACE
@@ -99,8 +97,8 @@
ULONG length = selWidth;
ptr = ConioCoordToPointer(Buffer,
- Console->Selection.srSelection.Left,
- Console->Selection.srSelection.Top + yPos);
+ GuiData->Selection.srSelection.Left,
+ GuiData->Selection.srSelection.Top + yPos);
/* Trim whitespace from the right */
while (length > 0)
@@ -230,6 +228,8 @@
if (Buffer->Buffer == NULL) return;
+ if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
+
rcFramebuffer->left = Buffer->ViewOrigin.X * GuiData->CharWidth +
rcView->left;
rcFramebuffer->top = Buffer->ViewOrigin.Y * GuiData->CharHeight +
rcView->top;
rcFramebuffer->right = Buffer->ViewOrigin.X * GuiData->CharWidth +
rcView->right;
@@ -245,8 +245,8 @@
LastAttribute = ConioCoordToPointer(Buffer, LeftChar, TopLine)->Attributes;
- SetTextColor(GuiData->hMemDC, RGBFromAttrib2(Console,
TextAttribFromAttrib(LastAttribute)));
- SetBkColor(GuiData->hMemDC, RGBFromAttrib2(Console,
BkgdAttribFromAttrib(LastAttribute)));
+ SetTextColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console,
TextAttribFromAttrib(LastAttribute)));
+ SetBkColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console,
BkgdAttribFromAttrib(LastAttribute)));
OldFont = SelectObject(GuiData->hMemDC, GuiData->Font);
@@ -275,8 +275,8 @@
Attribute = From->Attributes;
if (Attribute != LastAttribute)
{
- SetTextColor(GuiData->hMemDC, RGBFromAttrib2(Console,
TextAttribFromAttrib(Attribute)));
- SetBkColor(GuiData->hMemDC, RGBFromAttrib2(Console,
BkgdAttribFromAttrib(Attribute)));
+ SetTextColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console,
TextAttribFromAttrib(Attribute)));
+ SetBkColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console,
BkgdAttribFromAttrib(Attribute)));
LastAttribute = Attribute;
}
}
@@ -308,7 +308,7 @@
Attribute = ConioCoordToPointer(Buffer, Buffer->CursorPosition.X,
Buffer->CursorPosition.Y)->Attributes;
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);
PatBlt(GuiData->hMemDC,
@@ -323,6 +323,8 @@
}
SelectObject(GuiData->hMemDC, OldFont);
+
+ LeaveCriticalSection(&Console->Lock);
}
/* EOF */
Modified: trunk/reactos/win32ss/user/winsrv/consrv/frontends/tui/tuiterm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/frontends/tui/tuiterm.c [iso-8859-1]
(original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/frontends/tui/tuiterm.c [iso-8859-1] Tue Apr
22 03:44:13 2014
@@ -747,6 +747,13 @@
}
static BOOL NTAPI
+TuiGetSelectionInfo(IN OUT PFRONTEND This,
+ PCONSOLE_SELECTION_INFO pSelectionInfo)
+{
+ return TRUE;
+}
+
+static BOOL NTAPI
TuiSetPalette(IN OUT PFRONTEND This,
HPALETTE PaletteHandle,
UINT PaletteUsage)
@@ -813,6 +820,7 @@
TuiChangeIcon,
TuiGetConsoleWindowHandle,
TuiGetLargestConsoleWindowSize,
+ TuiGetSelectionInfo,
TuiSetPalette,
TuiGetDisplayMode,
TuiSetDisplayMode,
Modified: trunk/reactos/win32ss/user/winsrv/consrv/include/conio.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/include/conio.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/include/conio.h [iso-8859-1] Tue Apr 22
03:44:13 2014
@@ -228,6 +228,8 @@
HWND (NTAPI *GetConsoleWindowHandle)(IN OUT PFRONTEND This);
VOID (NTAPI *GetLargestConsoleWindowSize)(IN OUT PFRONTEND This,
PCOORD pSize);
+ BOOL (NTAPI *GetSelectionInfo)(IN OUT PFRONTEND This,
+ PCONSOLE_SELECTION_INFO pSelectionInfo);
BOOL (NTAPI *SetPalette)(IN OUT PFRONTEND This,
HPALETTE PaletteHandle,
UINT PaletteUsage);
@@ -305,9 +307,6 @@
BOOLEAN InsertMode;
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 *******************************/
LIST_ENTRY BufferList; /* List of all screen buffers for this
console */
PCONSOLE_SCREEN_BUFFER ActiveBuffer; /* Pointer to currently active screen buffer
*/
Modified: trunk/reactos/win32ss/user/winsrv/consrv/include/term.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/include/term.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/include/term.h [iso-8859-1] Tue Apr 22
03:44:13 2014
@@ -38,6 +38,8 @@
(Console)->TermIFace.Vtbl->GetConsoleWindowHandle(&(Console)->TermIFace)
#define TermGetLargestConsoleWindowSize(Console, pSize) \
(Console)->TermIFace.Vtbl->GetLargestConsoleWindowSize(&(Console)->TermIFace,
(pSize))
+#define TermGetSelectionInfo(Console, pSelectionInfo) \
+ (Console)->TermIFace.Vtbl->GetSelectionInfo(&(Console)->TermIFace,
(pSelectionInfo))
#define TermSetPalette(Console, PaletteHandle, PaletteUsage) \
(Console)->TermIFace.Vtbl->SetPalette(&(Console)->TermIFace,
(PaletteHandle), (PaletteUsage))
#define TermGetDisplayMode(Console) \