Dylan Smith : richedit: Directly get start and end of text on Ctrl-Home or Ctrl-End.

Alexandre Julliard julliard at winehq.org
Mon Feb 9 10:29:28 CST 2009


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

Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date:   Sat Feb  7 13:20:31 2009 -0500

richedit: Directly get start and end of text on Ctrl-Home or Ctrl-End.

Previously it found the start or end by traversing the linked lists of
run, rows, paragraphs, and cells from the current position of the
cursors.  Clearly it is better to get the start or end directly to make
it a constant time operation.

---

 dlls/riched20/caret.c |   28 +++++++++-------------------
 1 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index 46e16d4..edbdf46 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -1436,32 +1436,26 @@ static void ME_ArrowHome(ME_TextEditor *editor, ME_Cursor *pCursor)
 
 static void ME_ArrowCtrlHome(ME_TextEditor *editor, ME_Cursor *pCursor)
 {
-  ME_DisplayItem *pRow = ME_FindItemBack(pCursor->pRun, diTextStart);
-  if (pRow) {
-    ME_DisplayItem *pRun = ME_FindItemFwd(pRow, diRun);
-    if (pRun) {
-      pCursor->pRun = pRun;
-      pCursor->nOffset = 0;
-    }
-  }
+  pCursor->pRun = ME_FindItemFwd(editor->pBuffer->pFirst, diRun);
+  pCursor->nOffset = 0;
+  editor->bCaretAtEnd = FALSE;
 }
 
 static void ME_ArrowEnd(ME_TextEditor *editor, ME_Cursor *pCursor)
 {
   ME_DisplayItem *pRow;
-  
+
   if (editor->bCaretAtEnd && !pCursor->nOffset)
     return;
-  
+
   pRow = ME_FindItemFwd(pCursor->pRun, diStartRowOrParagraphOrEnd);
   assert(pRow);
   if (pRow->type == diStartRow) {
-    /* FIXME WTF was I thinking about here ? */
     ME_DisplayItem *pRun = ME_FindItemFwd(pRow, diRun);
     assert(pRun);
     pCursor->pRun = pRun;
     pCursor->nOffset = 0;
-    editor->bCaretAtEnd = 1;
+    editor->bCaretAtEnd = TRUE;
     return;
   }
   pCursor->pRun = ME_FindItemBack(pRow, diRun);
@@ -1469,15 +1463,11 @@ static void ME_ArrowEnd(ME_TextEditor *editor, ME_Cursor *pCursor)
   pCursor->nOffset = 0;
   editor->bCaretAtEnd = FALSE;
 }
-      
+
 static void ME_ArrowCtrlEnd(ME_TextEditor *editor, ME_Cursor *pCursor)
 {
-  ME_DisplayItem *p = ME_FindItemFwd(pCursor->pRun, diTextEnd);
-  assert(p);
-  p = ME_FindItemBack(p, diRun);
-  assert(p);
-  assert(p->member.run.nFlags & MERF_ENDPARA);
-  pCursor->pRun = p;
+  pCursor->pRun = ME_FindItemBack(editor->pBuffer->pLast, diRun);
+  assert(pCursor->pRun->member.run.nFlags & MERF_ENDPARA);
   pCursor->nOffset = 0;
   editor->bCaretAtEnd = FALSE;
 }




More information about the wine-cvs mailing list