Huw Davies : riched20: Move handling of EM_SETCHARFORMAT to a helper function.

Alexandre Julliard julliard at winehq.org
Thu Aug 15 14:50:47 CDT 2019


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

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu Aug 15 11:06:35 2019 +0100

riched20: Move handling of EM_SETCHARFORMAT to a helper function.

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

---

 dlls/riched20/editor.c | 91 ++++++++++++++++++++++++++++----------------------
 1 file changed, 51 insertions(+), 40 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 1b78eab..d0034fc 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -3532,6 +3532,56 @@ static LRESULT ME_WmCreate(ME_TextEditor *editor, LPARAM lParam, BOOL unicode)
   return 0;
 }
 
+static LRESULT handle_EM_SETCHARFORMAT( ME_TextEditor *editor, WPARAM flags, const CHARFORMAT2W *fmt_in )
+{
+    CHARFORMAT2W fmt;
+    BOOL changed = TRUE;
+    ME_Cursor start, end;
+
+    if (!cfany_to_cf2w( &fmt, fmt_in )) return 0;
+
+    if (flags & SCF_ALL)
+    {
+        if (editor->mode & TM_PLAINTEXT)
+        {
+            ME_SetDefaultCharFormat( editor, &fmt );
+        }
+        else
+        {
+            ME_SetCursorToStart( editor, &start );
+            ME_SetCharFormat( editor, &start, NULL, &fmt );
+            editor->nModifyStep = 1;
+        }
+    }
+    else if (flags & SCF_SELECTION)
+    {
+        if (editor->mode & TM_PLAINTEXT) return 0;
+        if (flags & SCF_WORD)
+        {
+            end = editor->pCursors[0];
+            ME_MoveCursorWords( editor, &end, +1 );
+            start = end;
+            ME_MoveCursorWords( editor, &start, -1 );
+            ME_SetCharFormat( editor, &start, &end, &fmt );
+        }
+        changed = ME_IsSelection( editor );
+        ME_SetSelectionCharFormat( editor, &fmt );
+        if (changed) editor->nModifyStep = 1;
+    }
+    else /* SCF_DEFAULT */
+    {
+        ME_SetDefaultCharFormat( editor, &fmt );
+    }
+
+    ME_CommitUndo( editor );
+    if (changed)
+    {
+        ME_WrapMarkedParagraphs( editor );
+        ME_UpdateScrollBar( editor );
+        ME_Repaint( editor );
+    }
+    return 1;
+}
 
 #define UNSUPPORTED_MSG(e) \
   case e:                  \
@@ -3933,46 +3983,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
   case EM_GETEVENTMASK:
     return editor->nEventMask;
   case EM_SETCHARFORMAT:
-  {
-    CHARFORMAT2W p;
-    BOOL bRepaint = TRUE;
-    if (!cfany_to_cf2w(&p, (CHARFORMAT2W *)lParam))
-      return 0;
-    if (wParam & SCF_ALL) {
-      if (editor->mode & TM_PLAINTEXT) {
-        ME_SetDefaultCharFormat(editor, &p);
-      } else {
-        ME_Cursor start;
-        ME_SetCursorToStart(editor, &start);
-        ME_SetCharFormat(editor, &start, NULL, &p);
-        editor->nModifyStep = 1;
-      }
-    } else if (wParam & SCF_SELECTION) {
-      if (editor->mode & TM_PLAINTEXT)
-        return 0;
-      if (wParam & SCF_WORD) {
-        ME_Cursor start;
-        ME_Cursor end = editor->pCursors[0];
-        ME_MoveCursorWords(editor, &end, +1);
-        start = end;
-        ME_MoveCursorWords(editor, &start, -1);
-        ME_SetCharFormat(editor, &start, &end, &p);
-      }
-      bRepaint = ME_IsSelection(editor);
-      ME_SetSelectionCharFormat(editor, &p);
-      if (bRepaint) editor->nModifyStep = 1;
-    } else { /* SCF_DEFAULT */
-      ME_SetDefaultCharFormat(editor, &p);
-    }
-    ME_CommitUndo(editor);
-    if (bRepaint)
-    {
-      ME_WrapMarkedParagraphs(editor);
-      ME_UpdateScrollBar(editor);
-      ME_Repaint(editor);
-    }
-    return 1;
-  }
+    return handle_EM_SETCHARFORMAT( editor, wParam, (CHARFORMAT2W *)lParam );
   case EM_GETCHARFORMAT:
   {
     CHARFORMAT2W tmp, *dst = (CHARFORMAT2W *)lParam;




More information about the wine-cvs mailing list