Commit abef9da1 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Forbids selecting (for clipboard) areas larger than the actual

screen-buffer size.
parent 1cd00dae
...@@ -612,11 +612,17 @@ static void WCUSER_SetSelection(const struct inner_data* data, HDC hRefDC) ...@@ -612,11 +612,17 @@ static void WCUSER_SetSelection(const struct inner_data* data, HDC hRefDC)
* *
* *
*/ */
static void WCUSER_MoveSelection(struct inner_data* data, COORD c1, COORD c2, BOOL final) static void WCUSER_MoveSelection(struct inner_data* data, COORD c1, COORD c2)
{ {
RECT r; RECT r;
HDC hDC; HDC hDC;
if (c1.X < 0 || c1.X >= data->curcfg.sb_width ||
c2.X < 0 || c2.X >= data->curcfg.sb_width ||
c1.Y < 0 || c1.Y >= data->curcfg.sb_height ||
c2.Y < 0 || c2.Y >= data->curcfg.sb_height)
return;
WCUSER_GetSelectionRect(data, &r); WCUSER_GetSelectionRect(data, &r);
hDC = GetDC(PRIVATE(data)->hWnd); hDC = GetDC(PRIVATE(data)->hWnd);
if (hDC) if (hDC)
...@@ -635,11 +641,6 @@ static void WCUSER_MoveSelection(struct inner_data* data, COORD c1, COORD c2, BO ...@@ -635,11 +641,6 @@ static void WCUSER_MoveSelection(struct inner_data* data, COORD c1, COORD c2, BO
if (PRIVATE(data)->hWnd == GetFocus() && data->curcfg.cursor_visible) if (PRIVATE(data)->hWnd == GetFocus() && data->curcfg.cursor_visible)
ShowCaret(PRIVATE(data)->hWnd); ShowCaret(PRIVATE(data)->hWnd);
} }
if (final)
{
ReleaseCapture();
PRIVATE(data)->has_selection = TRUE;
}
} }
/****************************************************************** /******************************************************************
...@@ -923,37 +924,25 @@ static void WCUSER_HandleSelectionKey(struct inner_data* data, BOOL down, ...@@ -923,37 +924,25 @@ static void WCUSER_HandleSelectionKey(struct inner_data* data, BOOL down,
c1 = PRIVATE(data)->selectPt1; c1 = PRIVATE(data)->selectPt1;
c2 = PRIVATE(data)->selectPt2; c2 = PRIVATE(data)->selectPt2;
c1.X++; c2.X++; c1.X++; c2.X++;
if (c1.X < data->curcfg.sb_width && c2.X < data->curcfg.sb_width) WCUSER_MoveSelection(data, c1, c2);
{
WCUSER_MoveSelection(data, c1, c2, FALSE);
}
break; break;
case VK_LEFT: case VK_LEFT:
c1 = PRIVATE(data)->selectPt1; c1 = PRIVATE(data)->selectPt1;
c2 = PRIVATE(data)->selectPt2; c2 = PRIVATE(data)->selectPt2;
c1.X--; c2.X--; c1.X--; c2.X--;
if (c1.X >= 0 && c2.X >= 0) WCUSER_MoveSelection(data, c1, c2);
{
WCUSER_MoveSelection(data, c1, c2, FALSE);
}
break; break;
case VK_UP: case VK_UP:
c1 = PRIVATE(data)->selectPt1; c1 = PRIVATE(data)->selectPt1;
c2 = PRIVATE(data)->selectPt2; c2 = PRIVATE(data)->selectPt2;
c1.Y--; c2.Y--; c1.Y--; c2.Y--;
if (c1.Y >= 0 && c2.Y >= 0) WCUSER_MoveSelection(data, c1, c2);
{
WCUSER_MoveSelection(data, c1, c2, FALSE);
}
break; break;
case VK_DOWN: case VK_DOWN:
c1 = PRIVATE(data)->selectPt1; c1 = PRIVATE(data)->selectPt1;
c2 = PRIVATE(data)->selectPt2; c2 = PRIVATE(data)->selectPt2;
c1.Y++; c2.Y++; c1.Y++; c2.Y++;
if (c1.X < data->curcfg.sb_height && c2.X < data->curcfg.sb_height) WCUSER_MoveSelection(data, c1, c2);
{
WCUSER_MoveSelection(data, c1, c2, FALSE);
}
break; break;
} }
break; break;
...@@ -964,37 +953,25 @@ static void WCUSER_HandleSelectionKey(struct inner_data* data, BOOL down, ...@@ -964,37 +953,25 @@ static void WCUSER_HandleSelectionKey(struct inner_data* data, BOOL down,
c1 = PRIVATE(data)->selectPt1; c1 = PRIVATE(data)->selectPt1;
c2 = PRIVATE(data)->selectPt2; c2 = PRIVATE(data)->selectPt2;
c2.X++; c2.X++;
if (c2.X < data->curcfg.sb_width) WCUSER_MoveSelection(data, c1, c2);
{
WCUSER_MoveSelection(data, c1, c2, FALSE);
}
break; break;
case VK_LEFT: case VK_LEFT:
c1 = PRIVATE(data)->selectPt1; c1 = PRIVATE(data)->selectPt1;
c2 = PRIVATE(data)->selectPt2; c2 = PRIVATE(data)->selectPt2;
c2.X--; c2.X--;
if (c2.X >= c1.X) WCUSER_MoveSelection(data, c1, c2);
{
WCUSER_MoveSelection(data, c1, c2, FALSE);
}
break; break;
case VK_UP: case VK_UP:
c1 = PRIVATE(data)->selectPt1; c1 = PRIVATE(data)->selectPt1;
c2 = PRIVATE(data)->selectPt2; c2 = PRIVATE(data)->selectPt2;
c2.Y--; c2.Y--;
if (c2.Y >= c1.Y) WCUSER_MoveSelection(data, c1, c2);
{
WCUSER_MoveSelection(data, c1, c2, FALSE);
}
break; break;
case VK_DOWN: case VK_DOWN:
c1 = PRIVATE(data)->selectPt1; c1 = PRIVATE(data)->selectPt1;
c2 = PRIVATE(data)->selectPt2; c2 = PRIVATE(data)->selectPt2;
c2.Y++; c2.Y++;
if (c2.X < data->curcfg.sb_height) WCUSER_MoveSelection(data, c1, c2);
{
WCUSER_MoveSelection(data, c1, c2, FALSE);
}
break; break;
} }
break; break;
...@@ -1137,7 +1114,7 @@ static LRESULT CALLBACK WCUSER_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM ...@@ -1137,7 +1114,7 @@ static LRESULT CALLBACK WCUSER_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
if (GetCapture() == PRIVATE(data)->hWnd && PRIVATE(data)->has_selection && if (GetCapture() == PRIVATE(data)->hWnd && PRIVATE(data)->has_selection &&
(wParam & MK_LBUTTON)) (wParam & MK_LBUTTON))
{ {
WCUSER_MoveSelection(data, PRIVATE(data)->selectPt1, WCUSER_GetCell(data, lParam), FALSE); WCUSER_MoveSelection(data, PRIVATE(data)->selectPt1, WCUSER_GetCell(data, lParam));
} }
} }
else else
...@@ -1151,7 +1128,9 @@ static LRESULT CALLBACK WCUSER_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM ...@@ -1151,7 +1128,9 @@ static LRESULT CALLBACK WCUSER_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
if (GetCapture() == PRIVATE(data)->hWnd && PRIVATE(data)->has_selection && if (GetCapture() == PRIVATE(data)->hWnd && PRIVATE(data)->has_selection &&
(wParam& MK_LBUTTON)) (wParam& MK_LBUTTON))
{ {
WCUSER_MoveSelection(data, PRIVATE(data)->selectPt1, WCUSER_GetCell(data, lParam), TRUE); WCUSER_MoveSelection(data, PRIVATE(data)->selectPt1, WCUSER_GetCell(data, lParam));
ReleaseCapture();
PRIVATE(data)->has_selection = FALSE;
} }
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment