riched20: Allow selecting the final end-of-paragraph when using the mouse.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2016-10-04 13:07:35 +01:00 committed by Alexandre Julliard
parent 7eb6837729
commit 304c8320c9
1 changed files with 8 additions and 9 deletions

View File

@ -961,11 +961,13 @@ static BOOL ME_FindRunInRow(ME_TextEditor *editor, ME_DisplayItem *pRow,
* x & y are pixel positions in virtual coordinates into the rich edit control, * x & y are pixel positions in virtual coordinates into the rich edit control,
* so client coordinates must first be adjusted by the scroll position. * so client coordinates must first be adjusted by the scroll position.
* *
* If final_eop is TRUE consider the final end-of-paragraph.
*
* returns TRUE if the result was exactly under the cursor, otherwise returns * returns TRUE if the result was exactly under the cursor, otherwise returns
* FALSE, and result is set to the closest position to the coordinates. * FALSE, and result is set to the closest position to the coordinates.
*/ */
static BOOL ME_FindPixelPos(ME_TextEditor *editor, int x, int y, static BOOL ME_FindPixelPos(ME_TextEditor *editor, int x, int y,
ME_Cursor *result, BOOL *is_eol) ME_Cursor *result, BOOL *is_eol, BOOL final_eop)
{ {
ME_DisplayItem *p = editor->pBuffer->pFirst->member.para.next_para; ME_DisplayItem *p = editor->pBuffer->pFirst->member.para.next_para;
BOOL isExact = TRUE; BOOL isExact = TRUE;
@ -1001,7 +1003,7 @@ static BOOL ME_FindPixelPos(ME_TextEditor *editor, int x, int y,
if (!pp) break; if (!pp) break;
p = pp; p = pp;
} }
if (p == editor->pBuffer->pLast) if (p == editor->pBuffer->pLast && !final_eop)
{ {
/* The position is below the last paragraph, so the last row will be used /* The position is below the last paragraph, so the last row will be used
* rather than the end of the text, so the x position will be used to * rather than the end of the text, so the x position will be used to
@ -1016,10 +1018,7 @@ static BOOL ME_FindPixelPos(ME_TextEditor *editor, int x, int y,
if( p->type == diStartRow ) if( p->type == diStartRow )
return ME_FindRunInRow( editor, p, x, result, is_eol ) && isExact; return ME_FindRunInRow( editor, p, x, result, is_eol ) && isExact;
result->pRun = ME_FindItemBack(p, diRun); ME_SetCursorToEnd(editor, result, TRUE);
result->pPara = ME_GetParagraph(result->pRun);
result->nOffset = 0;
assert(result->pRun->member.run.nFlags & MERF_ENDPARA);
return FALSE; return FALSE;
} }
@ -1047,7 +1046,7 @@ BOOL ME_CharFromPos(ME_TextEditor *editor, int x, int y,
} }
x += editor->horz_si.nPos; x += editor->horz_si.nPos;
y += editor->vert_si.nPos; y += editor->vert_si.nPos;
bResult = ME_FindPixelPos(editor, x, y, cursor, NULL); bResult = ME_FindPixelPos(editor, x, y, cursor, NULL, FALSE);
if (isExact) *isExact = bResult; if (isExact) *isExact = bResult;
return TRUE; return TRUE;
} }
@ -1130,7 +1129,7 @@ void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int clickNum)
is_selection = ME_IsSelection(editor); is_selection = ME_IsSelection(editor);
is_shift = GetKeyState(VK_SHIFT) < 0; is_shift = GetKeyState(VK_SHIFT) < 0;
ME_FindPixelPos(editor, x, y, &editor->pCursors[0], &editor->bCaretAtEnd); ME_FindPixelPos(editor, x, y, &editor->pCursors[0], &editor->bCaretAtEnd, FALSE);
if (x >= editor->rcFormat.left || is_shift) if (x >= editor->rcFormat.left || is_shift)
{ {
@ -1190,7 +1189,7 @@ void ME_MouseMove(ME_TextEditor *editor, int x, int y)
tmp_cursor = editor->pCursors[0]; tmp_cursor = editor->pCursors[0];
/* FIXME: do something with the return value of ME_FindPixelPos */ /* FIXME: do something with the return value of ME_FindPixelPos */
ME_FindPixelPos(editor, x, y, &tmp_cursor, &editor->bCaretAtEnd); ME_FindPixelPos(editor, x, y, &tmp_cursor, &editor->bCaretAtEnd, TRUE);
ME_InvalidateSelection(editor); ME_InvalidateSelection(editor);
editor->pCursors[0] = tmp_cursor; editor->pCursors[0] = tmp_cursor;