Module: wine
Branch: master
Commit: 61308257f238c2cdd079b0fb1fb35f6bac2127a4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=61308257f238c2cdd079b0fb1…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com>
Date: Tue Jan 27 03:39:23 2009 -0500
richedit: Removed redundant ME_FindItemAtOffset using ME_RunOfsFromCharOfs.
The two functions ME_FindItemAtOffset and ME_RunOfsFromCharOfs were almost
identically used, since ME_FindItemAtOffset was always used to find a run.
The only difference was how they returned the offset within the run for an
end of paragraph run.
For ME_FindItemAtOffset it would return the next run if it was in between \r
and \n. ME_RunOfsFromCharOfs would instead return an nOffset of 0 for end
paragraph runs. This subtle difference introduced bugs, so I decided to
avoid having special case in this function when creating this patch, and
instead let the caller handle this case.
---
dlls/riched20/caret.c | 9 ++++-
dlls/riched20/editor.c | 73 +++++++-----------------------------------
dlls/riched20/editor.h | 1 -
dlls/riched20/run.c | 83 ++++++++++++++++++++---------------------------
dlls/riched20/writer.c | 5 ++-
5 files changed, 57 insertions(+), 114 deletions(-)
Diff: http://source.winehq.org/git/wine.git/?a=commitdiff;h=61308257f238c2cdd079b…
Module: wine
Branch: master
Commit: c94e78a5728ecc8ddde5b1d9f8395b2a11c99256
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c94e78a5728ecc8ddde5b1d9f…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com>
Date: Tue Jan 27 03:39:03 2009 -0500
richedit: Handle case for EM_LINELENGTH when offset is between \r\n.
I found that ME_FindItemAtOffset and ME_CursorFromCharOfs are used
almost identically, except for how they handle a character offset that
is between a carriage return and line feed. In this case
ME_CursorFromCharOfs sets the cursor's run offset to 0, but
ME_FindItemAtOffset instead returns the next run which is what was
causing ME_LINELENGTH to incorrectly return the length of the next
line.
---
dlls/riched20/editor.c | 7 ++++---
dlls/riched32/tests/editor.c | 8 ++------
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index f10dddc..86f89d0 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -3786,7 +3786,8 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
{
ME_DisplayItem *item, *item_end;
int nChars = 0, nThisLineOfs = 0, nNextLineOfs = 0;
-
+ ME_Cursor cursor;
+
if (wParam > ME_GetTextLength(editor))
return 0;
if (wParam == -1)
@@ -3794,8 +3795,8 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
FIXME("EM_LINELENGTH: returning number of unselected characters on lines with selection unsupported.\n");
return 0;
}
- item = ME_FindItemAtOffset(editor, diRun, wParam, NULL);
- item = ME_RowStart(item);
+ ME_CursorFromCharOfs(editor, wParam, &cursor);
+ item = ME_RowStart(cursor.pRun);
nThisLineOfs = ME_CharOfsFromRunOfs(editor, ME_FindItemFwd(item, diRun), 0);
item_end = ME_FindItemFwd(item, diStartRowOrParagraphOrEnd);
if (item_end->type == diStartRow)
diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c
index 113dbd0..7332536 100644
--- a/dlls/riched32/tests/editor.c
+++ b/dlls/riched32/tests/editor.c
@@ -454,12 +454,8 @@ static void test_EM_LINELENGTH(void)
for (i = 0; i < sizeof(offset_test)/sizeof(offset_test[0]); i++) {
result = SendMessage(hwndRichEdit, EM_LINELENGTH, offset_test[i][0], 0);
- if (i == 6)
- todo_wine ok(result == offset_test[i][1], "Length of line at offset %d is %ld, expected %d\n",
- offset_test[i][0], result, offset_test[i][1]);
- else
- ok(result == offset_test[i][1], "Length of line at offset %d is %ld, expected %d\n",
- offset_test[i][0], result, offset_test[i][1]);
+ ok(result == offset_test[i][1], "Length of line at offset %d is %ld, expected %d\n",
+ offset_test[i][0], result, offset_test[i][1]);
}
DestroyWindow(hwndRichEdit);
Module: wine
Branch: master
Commit: 29ddbce2888b268efad21ac4b3d6e269000a7d9b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=29ddbce2888b268efad21ac4b…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com>
Date: Tue Jan 27 03:38:43 2009 -0500
riched32: Modified tests to show paragraph break inconsistency.
Several carriage returns followed by a line break were being handled as
a single paragraph break, when actually native richedit controls may
count this as several line breaks.
---
dlls/riched32/tests/editor.c | 62 +++++++++++++++++++++++++----------------
1 files changed, 38 insertions(+), 24 deletions(-)
diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c
index d5a2149..1fab410 100644
--- a/dlls/riched32/tests/editor.c
+++ b/dlls/riched32/tests/editor.c
@@ -71,19 +71,18 @@ static void test_WM_SETTEXT()
LRESULT result;
/* This test attempts to show that WM_SETTEXT on a riched32 control does not
- attempt to modify the text that is pasted into the control, and should
- return it as is. In particular, \r\r\n is NOT converted, unlike riched20.
- Currently, builtin riched32 mangles solitary \r or \n when not part of
- a \r\n pair.
-
- For riched32, the rules for breaking lines seem to be the following:
- - \r\n is one line break. This is the normal case.
- - \r{0,N}\n is one line break. In particular, \n by itself is a line break.
- - \n{1,N} are that many line breaks.
- - \r with text or other characters (except \n) past it, is a line break. That
- is, a run of \r{N} without a terminating \n is considered N line breaks
- - \r at the end of the text is NOT a line break. This differs from riched20,
- where \r at the end of the text is a proper line break.
+ * attempt to modify the text that is pasted into the control, and should
+ * return it as is. In particular, \r\r\n is NOT converted, unlike riched20.
+ *
+ * For riched32, the rules for breaking lines seem to be the following:
+ * - \r\n is one line break. This is the normal case.
+ * - \r{0,2}\n is one line break. In particular, \n by itself is a line break.
+ * - \r{0,N-1}\r\r\n is N line breaks.
+ * - \n{1,N} are that many line breaks.
+ * - \r with text or other characters (except \n) past it, is a line break. That
+ * is, a run of \r{N} without a terminating \n is considered N line breaks
+ * - \r at the end of the text is NOT a line break. This differs from riched20,
+ * where \r at the end of the text is a proper line break.
*/
#define TEST_SETTEXT(a, b, nlines) \
@@ -357,9 +356,10 @@ static const struct getline_s {
const char *text;
} gl[] = {
{0, 10, "foo bar\r\n"},
- {1, 10, "\n"},
- {2, 10, "bar\n"},
- {3, 10, "\r\n"},
+ {1, 10, "\r"},
+ {2, 10, "\r\r\n"},
+ {3, 10, "bar\n"},
+ {4, 10, "\r\n"},
/* Buffer smaller than line length */
{0, 2, "foo bar\r"},
@@ -374,7 +374,8 @@ static void test_EM_GETLINE(void)
static const int nBuf = 1024;
char dest[1024], origdest[1024];
const char text[] = "foo bar\r\n"
- "\n"
+ "\r"
+ "\r\r\n"
"bar\n";
SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text);
@@ -391,8 +392,12 @@ static void test_EM_GETLINE(void)
/* EM_GETLINE appends a "\r\0" to the end of the line
* nCopied counts up to and including the '\r' */
nCopied = SendMessage(hwndRichEdit, EM_GETLINE, gl[i].line, (LPARAM) dest);
- ok(nCopied == expected_nCopied, "%d: %d!=%d\n", i, nCopied,
- expected_nCopied);
+ if (i >= 1 && i <= 4)
+ todo_wine ok(nCopied == expected_nCopied, "%d: %d!=%d\n", i, nCopied,
+ expected_nCopied);
+ else
+ ok(nCopied == expected_nCopied, "%d: %d!=%d\n", i, nCopied,
+ expected_nCopied);
/* two special cases since a parameter is passed via dest */
if (gl[i].buffer_len == 0)
ok(!dest[0] && !dest[1] && !strncmp(dest+2, origdest+2, nBuf-2),
@@ -402,11 +407,20 @@ static void test_EM_GETLINE(void)
!strncmp(dest+2, origdest+2, nBuf-2), "buffer_len=1\n");
else
{
- ok(!strncmp(dest, gl[i].text, expected_bytes_written),
- "%d: expected_bytes_written=%d\n", i, expected_bytes_written);
- ok(!strncmp(dest + expected_bytes_written, origdest
- + expected_bytes_written, nBuf - expected_bytes_written),
- "%d: expected_bytes_written=%d\n", i, expected_bytes_written);
+ if (i >= 1 && i <= 4)
+ todo_wine ok(!strncmp(dest, gl[i].text, expected_bytes_written),
+ "%d: expected_bytes_written=%d\n", i, expected_bytes_written);
+ else
+ ok(!strncmp(dest, gl[i].text, expected_bytes_written),
+ "%d: expected_bytes_written=%d\n", i, expected_bytes_written);
+ if (i >= 1 && i <= 2)
+ todo_wine ok(!strncmp(dest + expected_bytes_written, origdest
+ + expected_bytes_written, nBuf - expected_bytes_written),
+ "%d: expected_bytes_written=%d\n", i, expected_bytes_written);
+ else
+ ok(!strncmp(dest + expected_bytes_written, origdest
+ + expected_bytes_written, nBuf - expected_bytes_written),
+ "%d: expected_bytes_written=%d\n", i, expected_bytes_written);
}
}