Commit 6901e0ce authored by Dylan Smith's avatar Dylan Smith Committed by Alexandre Julliard

richedit: Use ME_EnsureVisible to implement EM_SCROLLCARET.

The code for the ME_EnsureVisible function does exactly what EM_SCROLLCARET does, yet this code is duplicated in order to handle this message. It is simpler to just use the existing function to implement the message, and avoid internally sending the EM_SCROLLCARET when this function is available.
parent 098f2f23
......@@ -1177,16 +1177,10 @@ void ME_MouseMove(ME_TextEditor *editor, int x, int y)
memcmp(&editor->pCursors[1], &editor->pCursors[3], sizeof(ME_Cursor)))
{
/* The scroll the cursor towards the other end, since it was the one
* extended by ME_ExtendAnchorSelection
*/
ME_Cursor tmpCursor = editor->pCursors[0];
editor->pCursors[0] = editor->pCursors[1];
editor->pCursors[1] = tmpCursor;
SendMessageW(editor->hWnd, EM_SCROLLCARET, 0, 0);
editor->pCursors[1] = editor->pCursors[0];
editor->pCursors[0] = tmpCursor;
* extended by ME_ExtendAnchorSelection */
ME_EnsureVisible(editor, editor->pCursors[1].pRun);
} else {
SendMessageW(editor->hWnd, EM_SCROLLCARET, 0, 0);
ME_EnsureVisible(editor, editor->pCursors[0].pRun);
}
ME_InvalidateSelection(editor);
......
......@@ -3064,23 +3064,8 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
return len;
}
case EM_SCROLLCARET:
{
int top, bottom; /* row's edges relative to document top */
int nPos;
ME_DisplayItem *para, *row;
nPos = ME_GetYScrollPos(editor);
row = ME_RowStart(editor->pCursors[0].pRun);
para = ME_GetParagraph(row);
top = para->member.para.pt.y + row->member.row.pt.y;
bottom = top + row->member.row.nHeight;
if (top < nPos) /* caret above window */
ME_ScrollAbs(editor, top);
else if (nPos + editor->sizeWindow.cy < bottom) /*below*/
ME_ScrollAbs(editor, bottom - editor->sizeWindow.cy);
ME_EnsureVisible(editor, editor->pCursors[0].pRun);
return 0;
}
case WM_SETFONT:
{
LOGFONTW lf;
......
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