Huw Davies : riched20: Revert to the default paragraph style when all text is deleted.

Alexandre Julliard julliard at winehq.org
Mon Nov 4 13:59:20 CST 2013


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

Author: Huw Davies <huw at codeweavers.com>
Date:   Mon Nov  4 14:23:53 2013 +0000

riched20: Revert to the default paragraph style when all text is deleted.

---

 dlls/riched20/caret.c        |    7 +++++--
 dlls/riched20/tests/editor.c |   37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index b39a8c7..fd7034d 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -284,13 +284,15 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start,
                            int nChars, BOOL bForce)
 {
   ME_Cursor c = *start;
-  int nOfs = ME_GetCursorOfs(start);
+  int nOfs = ME_GetCursorOfs(start), text_len = ME_GetTextLength( editor );
   int shift = 0;
   int totalChars = nChars;
   ME_DisplayItem *start_para;
+  BOOL delete_all = FALSE;
 
   /* Prevent deletion past last end of paragraph run. */
-  nChars = min(nChars, ME_GetTextLength(editor) - nOfs);
+  nChars = min(nChars, text_len - nOfs);
+  if (nChars == text_len) delete_all = TRUE;
   start_para = c.pPara;
 
   if (!bForce)
@@ -424,6 +426,7 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start,
       continue;
     }
   }
+  if (delete_all) ME_SetDefaultParaFormat( start_para->member.para.pFmt );
   return TRUE;
 }
 
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 3abd8d2..8ec5e9f 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -7429,6 +7429,42 @@ static void test_WM_CREATE(void)
     DestroyWindow(rich_edit);
 }
 
+/*******************************************************************
+ * Test that after deleting all of the text, the first paragraph
+ * format reverts to the default.
+ */
+static void test_reset_default_para_fmt( void )
+{
+    HWND richedit = new_richeditW( NULL );
+    PARAFORMAT2 fmt;
+    WORD def_align, new_align;
+
+    memset( &fmt, 0, sizeof(fmt) );
+    fmt.cbSize = sizeof(PARAFORMAT2);
+    fmt.dwMask = -1;
+    SendMessageA( richedit, EM_GETPARAFORMAT, 0, (LPARAM)&fmt );
+    def_align = fmt.wAlignment;
+    new_align = (def_align == PFA_LEFT) ? PFA_RIGHT : PFA_LEFT;
+
+    simulate_typing_characters( richedit, "123" );
+
+    SendMessageA( richedit, EM_SETSEL, 0, -1 );
+    fmt.dwMask = PFM_ALIGNMENT;
+    fmt.wAlignment = new_align;
+    SendMessageA( richedit, EM_SETPARAFORMAT, 0, (LPARAM)&fmt );
+
+    SendMessageA( richedit, EM_GETPARAFORMAT, 0, (LPARAM)&fmt );
+    ok( fmt.wAlignment == new_align, "got %d expect %d\n", fmt.wAlignment, new_align );
+
+    SendMessageA( richedit, EM_SETSEL, 0, -1 );
+    SendMessageA( richedit, WM_CUT, 0, 0 );
+
+    SendMessageA( richedit, EM_GETPARAFORMAT, 0, (LPARAM)&fmt );
+    ok( fmt.wAlignment == def_align, "got %d exppect %d\n", fmt.wAlignment, def_align );
+
+    DestroyWindow( richedit );
+}
+
 START_TEST( editor )
 {
   BOOL ret;
@@ -7490,6 +7526,7 @@ START_TEST( editor )
   test_EM_FINDWORDBREAK_A();
   test_enter();
   test_WM_CREATE();
+  test_reset_default_para_fmt();
 
   /* Set the environment variable WINETEST_RICHED20 to keep windows
    * responsive and open for 30 seconds. This is useful for debugging.




More information about the wine-cvs mailing list