[PATCH 2/5] riched20: Alter ME_SaveTempStyle() to accept the new style.

Huw Davies huw at codeweavers.com
Wed Oct 5 04:08:25 CDT 2016


Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/riched20/editor.c | 6 +++---
 dlls/riched20/editor.h | 2 +-
 dlls/riched20/style.c  | 9 +++++----
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 4adc74f..7b934fe 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -2392,7 +2392,7 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
           }
 
           style = ME_GetInsertStyle(editor, 0);
-          ME_SaveTempStyle(editor);
+          ME_SaveTempStyle(editor, style);
           ME_ContinueCoalescingTransaction(editor);
           if (shift_is_down)
             ME_InsertEndRowFromCursor(editor, 0);
@@ -2566,7 +2566,7 @@ static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode,
     if(editor->nTextLimit > ME_GetTextLength(editor) - (to-from))
     {
       ME_Style *style = ME_GetInsertStyle(editor, 0);
-      ME_SaveTempStyle(editor);
+      ME_SaveTempStyle(editor, style);
       ME_ContinueCoalescingTransaction(editor);
       ME_InsertTextFromCursor(editor, 0, &wstr, 1, style);
       ME_ReleaseStyle(style);
@@ -4538,7 +4538,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
     ME_Style *style = ME_GetInsertStyle(editor, 0);
     hIMC = ITextHost_TxImmGetContext(editor->texthost);
     ME_DeleteSelection(editor);
-    ME_SaveTempStyle(editor);
+    ME_SaveTempStyle(editor, style);
     if (lParam & (GCS_RESULTSTR|GCS_COMPSTR))
     {
         LPWSTR lpCompStr = NULL;
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index c62b3a4..b0a8a1a 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -76,7 +76,7 @@ ME_Style *ME_ApplyStyle(ME_TextEditor *ed, ME_Style *sSrc, CHARFORMAT2W *style)
 HFONT ME_SelectStyleFont(ME_Context *c, ME_Style *s) DECLSPEC_HIDDEN;
 void ME_UnselectStyleFont(ME_Context *c, ME_Style *s, HFONT hOldFont) DECLSPEC_HIDDEN;
 void ME_InitCharFormat2W(CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN;
-void ME_SaveTempStyle(ME_TextEditor *editor) DECLSPEC_HIDDEN;
+void ME_SaveTempStyle(ME_TextEditor *editor, ME_Style *style) DECLSPEC_HIDDEN;
 void ME_ClearTempStyle(ME_TextEditor *editor) DECLSPEC_HIDDEN;
 void ME_DumpStyleToBuf(CHARFORMAT2W *pFmt, char buf[2048]) DECLSPEC_HIDDEN;
 void ME_DumpStyle(ME_Style *s) DECLSPEC_HIDDEN;
diff --git a/dlls/riched20/style.c b/dlls/riched20/style.c
index 06c0e6f..0d2c16a 100644
--- a/dlls/riched20/style.c
+++ b/dlls/riched20/style.c
@@ -513,12 +513,13 @@ ME_Style *ME_GetInsertStyle(ME_TextEditor *editor, int nCursor)
   }
 }
 
-void ME_SaveTempStyle(ME_TextEditor *editor)
+void ME_SaveTempStyle(ME_TextEditor *editor, ME_Style *style)
 {
   ME_Style *old_style = editor->pBuffer->pCharStyle;
-  editor->pBuffer->pCharStyle = ME_GetInsertStyle(editor, 0);
-  if (old_style)
-    ME_ReleaseStyle(old_style);
+
+  if (style) ME_AddRefStyle( style );
+  editor->pBuffer->pCharStyle = style;
+  if (old_style) ME_ReleaseStyle( old_style );
 }
 
 void ME_ClearTempStyle(ME_TextEditor *editor)
-- 
2.8.2




More information about the wine-patches mailing list