Dylan Smith : richedit: Fixed the call to the EditWordBreakProc.
Alexandre Julliard
julliard at winehq.org
Thu Oct 23 08:38:19 CDT 2008
Module: wine
Branch: master
Commit: 503972980e150f9eda348962f437484d7c9daa43
URL: http://source.winehq.org/git/wine.git/?a=commit;h=503972980e150f9eda348962f437484d7c9daa43
Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date: Thu Oct 23 01:07:31 2008 -0400
richedit: Fixed the call to the EditWordBreakProc.
---
dlls/riched20/string.c | 24 +++++++++++++++++++-----
dlls/riched20/tests/editor.c | 4 ++--
2 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/dlls/riched20/string.c b/dlls/riched20/string.c
index 97b5a67..7da521c 100644
--- a/dlls/riched20/string.c
+++ b/dlls/riched20/string.c
@@ -304,6 +304,8 @@ ME_WordBreakProc(LPWSTR s, INT start, INT len, INT code)
/* FIXME: Native also knows about punctuation */
TRACE("s==%s, start==%d, len==%d, code==%d\n",
debugstr_wn(s, len), start, len, code);
+ /* convert number of bytes to number of characters. */
+ len /= sizeof(WCHAR);
switch (code)
{
case WB_ISDELIMITER:
@@ -330,11 +332,23 @@ ME_WordBreakProc(LPWSTR s, INT start, INT len, INT code)
int
ME_CallWordBreakProc(ME_TextEditor *editor, ME_String *str, INT start, INT code)
{
- /* FIXME: ANSIfy the string when bEmulateVersion10 is TRUE */
- if (!editor->pfnWordBreak)
- return ME_WordBreakProc(str->szData, start, str->nLen, code);
- else
- return editor->pfnWordBreak(str->szData, start, str->nLen, code);
+ if (!editor->pfnWordBreak) {
+ return ME_WordBreakProc(str->szData, start, str->nLen*sizeof(WCHAR), code);
+ } else if (!editor->bEmulateVersion10) {
+ /* MSDN lied about the third parameter for EditWordBreakProc being the number
+ * of characters, it is actually the number of bytes of the string. */
+ return editor->pfnWordBreak(str->szData, start, str->nLen*sizeof(WCHAR), code);
+ } else {
+ int result;
+ int buffer_size = WideCharToMultiByte(CP_ACP, 0, str->szData, str->nLen,
+ NULL, 0, NULL, NULL);
+ char *buffer = (char*)heap_alloc(buffer_size);
+ WideCharToMultiByte(CP_ACP, 0, str->szData, str->nLen,
+ buffer, buffer_size, NULL, NULL);
+ result = editor->pfnWordBreak(str->szData, start, str->nLen, code);
+ heap_free(buffer);
+ return result;
+ }
}
LPWSTR ME_ToUnicode(BOOL unicode, LPVOID psz)
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 9c0a21d..8946ed3 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -5652,7 +5652,7 @@ static void test_word_movement(void)
/* one twoX|three */
SendMessage(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
ok(sel_start == sel_end, "Selection should be empty\n");
- todo_wine ok(sel_start == 8, "Cursor is at %d instead of %d\n", sel_start, 8);
+ ok(sel_start == 8, "Cursor is at %d instead of %d\n", sel_start, 8);
DestroyWindow(hwnd);
@@ -5671,7 +5671,7 @@ static void test_word_movement(void)
/* one twoX|three */
SendMessageW(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
ok(sel_start == sel_end, "Selection should be empty\n");
- todo_wine ok(sel_start == 8, "Cursor is at %d instead of %d\n", sel_start, 8);
+ ok(sel_start == 8, "Cursor is at %d instead of %d\n", sel_start, 8);
DestroyWindow(hwnd);
}
More information about the wine-cvs
mailing list