Huw Davies : riched20: Return a run ptr from the run splitting function.

Alexandre Julliard julliard at winehq.org
Wed Oct 14 15:37:21 CDT 2020


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

Author: Huw Davies <huw at codeweavers.com>
Date:   Wed Oct 14 11:17:14 2020 +0100

riched20: Return a run ptr from the run splitting function.

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

---

 dlls/riched20/caret.c  |  6 ++++--
 dlls/riched20/editor.h |  2 +-
 dlls/riched20/run.c    | 16 ++++++++--------
 dlls/riched20/table.c  |  4 ++--
 dlls/riched20/undo.c   |  4 ++--
 dlls/riched20/wrap.c   |  4 ++--
 6 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index 1c3f4b1652..5f7d52aa4c 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -607,7 +607,9 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
         /* handle special \r\r\n sequence (richedit 2.x and higher only) */
         WCHAR space = ' ';
         ME_InternalInsertTextFromCursor(editor, nCursor, &space, 1, style, 0);
-      } else {
+      }
+      else
+      {
         const WCHAR cr = '\r', *eol_str = str;
 
         if (!editor->bEmulateVersion10)
@@ -625,7 +627,7 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
         }
         else
         {
-          if (p->nOffset) ME_SplitRunSimple(editor, p);
+          if (p->nOffset) run_split( editor, p );
           run = &p->pRun->member.run;
         }
 
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 244010df73..7ae0b5341b 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -132,7 +132,7 @@ int ME_PointFromCharContext(ME_Context *c, ME_Run *pRun, int nOffset, BOOL visua
 int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset, BOOL visual_order) DECLSPEC_HIDDEN;
 BOOL ME_CanJoinRuns(const ME_Run *run1, const ME_Run *run2) DECLSPEC_HIDDEN;
 void run_join( ME_TextEditor *editor, ME_Run *run ) DECLSPEC_HIDDEN;
-ME_DisplayItem *ME_SplitRunSimple(ME_TextEditor *editor, ME_Cursor *cursor) DECLSPEC_HIDDEN;
+ME_Run *run_split( ME_TextEditor *editor, ME_Cursor *cursor ) DECLSPEC_HIDDEN;
 void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run) DECLSPEC_HIDDEN;
 SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run *run, int nLen,
                          int startx, int *pAscent, int *pDescent) DECLSPEC_HIDDEN;
diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c
index 84b851039b..3f550d8d99 100644
--- a/dlls/riched20/run.c
+++ b/dlls/riched20/run.c
@@ -268,12 +268,12 @@ void run_join( ME_TextEditor *editor, ME_Run *run )
 }
 
 /******************************************************************************
- * ME_SplitRunSimple
+ * run_split
  *
  * Does the most basic job of splitting a run into two - it does not
  * update the positions and extents.
  */
-ME_DisplayItem *ME_SplitRunSimple( ME_TextEditor *editor, ME_Cursor *cursor )
+ME_Run *run_split( ME_TextEditor *editor, ME_Cursor *cursor )
 {
     ME_Run *run = &cursor->pRun->member.run, *new_run;
     int i;
@@ -303,7 +303,7 @@ ME_DisplayItem *ME_SplitRunSimple( ME_TextEditor *editor, ME_Cursor *cursor )
         }
     }
     para_mark_rewrap( editor, run->para );
-    return run_get_di( run );
+    return run;
 }
 
 /******************************************************************************
@@ -359,7 +359,7 @@ ME_InsertRunAtCursor(ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style,
     }
     else
     {
-      ME_SplitRunSimple( editor, cursor );
+      run_split( editor, cursor );
       insert_before = cursor->pRun;
     }
   }
@@ -756,12 +756,12 @@ void ME_SetCharFormat(ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, C
     start_run = ME_FindItemFwd( start->pRun, diRun );
   else if (start->nOffset)
   {
-    /* SplitRunSimple may or may not update the cursors, depending on whether they
+    /* run_split() may or may not update the cursors, depending on whether they
      * are selection cursors, but we need to make sure they are valid. */
     int split_offset = start->nOffset;
-    ME_DisplayItem *split_run = ME_SplitRunSimple(editor, start);
+    ME_Run *split_run = run_split( editor, start );
     start_run = start->pRun;
-    if (end && end->pRun == split_run)
+    if (end && &end->pRun->member.run == split_run)
     {
       end->pRun = start->pRun;
       end->nOffset -= split_offset;
@@ -774,7 +774,7 @@ void ME_SetCharFormat(ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, C
       end_run = ME_FindItemFwd( end->pRun, diRun );
     else
     {
-      if (end->nOffset) ME_SplitRunSimple(editor, end);
+      if (end->nOffset) run_split( editor, end );
       end_run = end->pRun;
     }
   }
diff --git a/dlls/riched20/table.c b/dlls/riched20/table.c
index 615145b85e..95b0fb0a8a 100644
--- a/dlls/riched20/table.c
+++ b/dlls/riched20/table.c
@@ -66,8 +66,8 @@ static ME_DisplayItem* ME_InsertEndParaFromCursor(ME_TextEditor *editor,
   ME_Style *pStyle = ME_GetInsertStyle(editor, nCursor);
   ME_DisplayItem *tp;
   ME_Cursor* cursor = &editor->pCursors[nCursor];
-  if (cursor->nOffset)
-    ME_SplitRunSimple(editor, cursor);
+
+  if (cursor->nOffset) run_split( editor, cursor );
 
   tp = ME_SplitParagraph(editor, cursor->pRun, pStyle, eol_str, eol_len, paraFlags);
   ME_ReleaseStyle(pStyle);
diff --git a/dlls/riched20/undo.c b/dlls/riched20/undo.c
index c6b898b2dd..55574dc412 100644
--- a/dlls/riched20/undo.c
+++ b/dlls/riched20/undo.c
@@ -383,9 +383,9 @@ static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo)
     ME_DisplayItem *this_para, *new_para;
     BOOL bFixRowStart;
     int paraFlags = undo->u.split_para.flags & (MEPF_ROWSTART|MEPF_CELL|MEPF_ROWEND);
+
     ME_CursorFromCharOfs(editor, undo->u.split_para.pos, &tmp);
-    if (tmp.nOffset)
-      ME_SplitRunSimple(editor, &tmp);
+    if (tmp.nOffset) run_split( editor, &tmp );
     this_para = tmp.pPara;
     bFixRowStart = this_para->member.para.nFlags & MEPF_ROWSTART;
     if (bFixRowStart)
diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c
index fda1d99557..393b1784d4 100644
--- a/dlls/riched20/wrap.c
+++ b/dlls/riched20/wrap.c
@@ -139,7 +139,7 @@ static ME_Run *split_run_extents( ME_WrapContext *wc, ME_Run *run, int nVChar )
   TRACE("Before split: %s(%d, %d)\n", debugstr_run( run ),
         run->pt.x, run->pt.y);
 
-  ME_SplitRunSimple(editor, &cursor);
+  run_split( editor, &cursor );
 
   run2 = &cursor.pRun->member.run;
   run2->script_analysis = run->script_analysis;
@@ -776,7 +776,7 @@ static HRESULT itemize_para( ME_Context *c, ME_Paragraph *para )
         if (run->nCharOfs + run->len > items[cur_item+1].iCharPos)
         {
             ME_Cursor cursor = {para_get_di( para ), run_get_di( run ), items[cur_item+1].iCharPos - run->nCharOfs};
-            ME_SplitRunSimple( c->editor, &cursor );
+            run_split( c->editor, &cursor );
         }
     }
 




More information about the wine-cvs mailing list