Huw Davies : riched20: Use paragraph and run ptrs in InsertTextFromCursor().

Alexandre Julliard julliard at winehq.org
Tue Oct 13 15:42:03 CDT 2020


Module: wine
Branch: master
Commit: 468609ae7be64627d2dd78dd94afb6a29b29b604
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=468609ae7be64627d2dd78dd94afb6a29b29b604

Author: Huw Davies <huw at codeweavers.com>
Date:   Tue Oct 13 11:16:33 2020 +0100

riched20: Use paragraph and run ptrs in InsertTextFromCursor().

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/riched20/caret.c  | 24 ++++++++++++------------
 dlls/riched20/editor.h |  1 +
 dlls/riched20/para.c   |  5 +++++
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index 69963e6691..2fe057cdbd 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -579,7 +579,8 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
       ME_InternalInsertTextFromCursor(editor, nCursor, &tab, 1, style, MERF_TAB);
       pos++;
     } else { /* handle EOLs */
-      ME_DisplayItem *tp, *end_run, *run, *prev;
+      ME_Run *end_run, *run, *prev;
+      ME_Paragraph *new_para;
       int eol_len = 0;
 
       /* Check if new line is allowed for this control */
@@ -619,31 +620,30 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
 
         if (p->nOffset == p->pRun->member.run.len)
         {
-           run = ME_FindItemFwd( p->pRun, diRun );
-           if (!run) run = p->pRun;
+           run = run_next( &p->pRun->member.run );
+           if (!run) run = &p->pRun->member.run;
         }
         else
         {
           if (p->nOffset) ME_SplitRunSimple(editor, p);
-          run = p->pRun;
+          run = &p->pRun->member.run;
         }
 
-        tp = ME_SplitParagraph(editor, run, style, eol_str, eol_len, 0);
-
-        end_run = ME_FindItemBack(tp, diRun);
+        new_para = &ME_SplitParagraph( editor, run_get_di( run ), style, eol_str, eol_len, 0 )->member.para;
+        end_run = para_end_run( para_prev( new_para ) );
 
         /* Move any cursors that were at the end of the previous run to the beginning of the new para */
-        prev = ME_FindItemBack( end_run, diRun );
+        prev = run_prev( end_run );
         if (prev)
         {
           int i;
           for (i = 0; i < editor->nCursors; i++)
           {
-            if (editor->pCursors[i].pRun == prev &&
-                editor->pCursors[i].nOffset == prev->member.run.len)
+            if (editor->pCursors[i].pRun == run_get_di( prev ) &&
+                editor->pCursors[i].nOffset == prev->len)
             {
-              editor->pCursors[i].pPara = tp;
-              editor->pCursors[i].pRun = run;
+              editor->pCursors[i].pPara = para_get_di( new_para );
+              editor->pCursors[i].pRun = run_get_di( run );
               editor->pCursors[i].nOffset = 0;
             }
           }
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 6c45a3c6b5..6b97a01f82 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -214,6 +214,7 @@ void para_mark_remove( ME_TextEditor *editor, ME_Paragraph *para ) DECLSPEC_HIDD
 ME_Paragraph *para_next( ME_Paragraph *para ) DECLSPEC_HIDDEN;
 ME_Paragraph *para_prev( ME_Paragraph *para ) DECLSPEC_HIDDEN;
 ME_Run *para_first_run( ME_Paragraph *para ) DECLSPEC_HIDDEN;
+ME_Run *para_end_run( ME_Paragraph *para ) DECLSPEC_HIDDEN;
 static inline ME_DisplayItem *para_get_di(ME_Paragraph *para)
 {
     return (ME_DisplayItem *)((ptrdiff_t)para - offsetof(ME_DisplayItem, member));
diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c
index 0f8b76f76d..1ae7caad61 100644
--- a/dlls/riched20/para.c
+++ b/dlls/riched20/para.c
@@ -116,6 +116,11 @@ ME_Run *para_first_run( ME_Paragraph *para )
     return NULL;
 }
 
+ME_Run *para_end_run( ME_Paragraph *para )
+{
+    return para->eop_run;
+}
+
 void ME_MakeFirstParagraph(ME_TextEditor *editor)
 {
   static const WCHAR cr_lf[] = {'\r','\n',0};




More information about the wine-cvs mailing list