Alex Villacís Lasso : richedit: Implement rule that in 1.0 emulation, a single CR that terminates the text is NOT a line break.

Alexandre Julliard julliard at winehq.org
Tue Apr 29 08:54:47 CDT 2008


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

Author: Alex Villacís Lasso <a_villacis at palosanto.com>
Date:   Sun Apr 27 09:24:15 2008 -0500

richedit: Implement rule that in 1.0 emulation, a single CR that terminates the text is NOT a line break.

Fix riched32 test that now succeed.

---

 dlls/riched20/editor.c       |   18 ++++++++++++++++++
 dlls/riched32/tests/editor.c |    6 +++---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 4b4db9f..3121293 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -2702,12 +2702,30 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
     ME_DisplayItem *item = editor->pBuffer->pFirst->next;
     int nRows = 0;
 
+    ME_DisplayItem *prev_para = NULL, *last_para = NULL;
+
     while (item != editor->pBuffer->pLast)
     {
       assert(item->type == diParagraph);
+      prev_para = ME_FindItemBack(item, diRun);
+      if (prev_para) {
+        assert(prev_para->member.run.nFlags & MERF_ENDPARA);
+      }
       nRows += item->member.para.nRows;
       item = item->member.para.next_para;
     }
+    last_para = ME_FindItemBack(item, diRun);
+    assert(last_para);
+    assert(last_para->member.run.nFlags & MERF_ENDPARA);
+    if (editor->bEmulateVersion10 && prev_para && last_para->member.run.nCharOfs == 0
+        && prev_para->member.run.nCR == 1 && prev_para->member.run.nLF == 0)
+    {
+      /* In 1.0 emulation, the last solitary \r at the very end of the text
+         (if one exists) is NOT a line break.
+         FIXME: this is an ugly hack. This should have a more regular model. */
+      nRows--;
+    }
+
     TRACE("EM_GETLINECOUNT: nRows==%d\n", nRows);
     return max(1, nRows);
   }
diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c
index 70d1558..abecaee 100644
--- a/dlls/riched32/tests/editor.c
+++ b/dlls/riched32/tests/editor.c
@@ -110,8 +110,8 @@ static void test_WM_SETTEXT()
   }
 
   TEST_SETTEXT(TestItem1, TestItem1, 1, 0, 0)
-  TEST_SETTEXT(TestItem2, TestItem2, 1, 0, 1)
-  TEST_SETTEXT(TestItem3, TestItem3, 2, 0, 1)
+  TEST_SETTEXT(TestItem2, TestItem2, 1, 0, 0)
+  TEST_SETTEXT(TestItem3, TestItem3, 2, 0, 0)
   TEST_SETTEXT(TestItem4, TestItem4, 3, 0, 0)
   TEST_SETTEXT(TestItem5, TestItem5, 2, 0, 0)
   TEST_SETTEXT(TestItem6, TestItem6, 3, 0, 0)
@@ -123,7 +123,7 @@ static void test_WM_SETTEXT()
   TEST_SETTEXT(TestItem12, TestItem12, 2, 0, 0)
   TEST_SETTEXT(TestItem13, TestItem13, 3, 0, 0)
   TEST_SETTEXT(TestItem14, TestItem14, 2, 0, 0)
-  TEST_SETTEXT(TestItem15, TestItem15, 3, 0, 1)
+  TEST_SETTEXT(TestItem15, TestItem15, 3, 0, 0)
   TEST_SETTEXT(TestItem16, TestItem16, 4, 0, 0)
 
 #undef TEST_SETTEXT




More information about the wine-cvs mailing list