From 6901e0cec7331c768af6b8c11509067b58372a01 Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Mon, 15 Dec 2008 04:31:43 -0500 Subject: [PATCH] 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. --- dlls/riched20/caret.c | 12 +++--------- dlls/riched20/editor.c | 17 +---------------- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index 1780bc074e4..4a3ec8cd40b 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -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); diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 33310a135c4..49f5740ef7d 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -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;