[PATCH] 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.
Alex Villacís Lasso
alex at karlalex.palosanto.com
Sun Apr 27 09:24:15 CDT 2008
---
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 0e7f68a..d143619 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -2701,13 +2701,31 @@ 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 e34cefc..8badafc 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
--
1.5.4.1
--------------090308010304010406090002--
More information about the wine-patches
mailing list