Dylan Smith : richedit: Use ME_EnsureVisible to implement EM_SCROLLCARET.

Alexandre Julliard julliard at winehq.org
Mon Dec 15 08:27:28 CST 2008


Module: wine
Branch: master
Commit: 6901e0cec7331c768af6b8c11509067b58372a01
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6901e0cec7331c768af6b8c11509067b58372a01

Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date:   Mon Dec 15 04:31:43 2008 -0500

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 1780bc0..4a3ec8c 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 33310a1..49f5740 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;




More information about the wine-cvs mailing list