riched20: Handle EM_GETSELTEXT's unicode conversion in the host.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e4c38944d8
commit
dc6434959e
|
@ -2132,22 +2132,11 @@ static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText)
|
|||
}
|
||||
}
|
||||
|
||||
static int ME_GetTextRange(ME_TextEditor *editor, WCHAR *strText,
|
||||
const ME_Cursor *start, int nLen, BOOL unicode)
|
||||
static int get_text_range( ME_TextEditor *editor, WCHAR *buffer,
|
||||
const ME_Cursor *start, int len )
|
||||
{
|
||||
if (!strText) return 0;
|
||||
if (unicode) {
|
||||
return ME_GetTextW(editor, strText, INT_MAX, start, nLen, FALSE, FALSE);
|
||||
} else {
|
||||
int nChars;
|
||||
WCHAR *p = heap_alloc((nLen+1) * sizeof(*p));
|
||||
if (!p) return 0;
|
||||
nChars = ME_GetTextW(editor, p, nLen, start, nLen, FALSE, FALSE);
|
||||
WideCharToMultiByte(CP_ACP, 0, p, nChars+1, (char *)strText,
|
||||
nLen+1, NULL, NULL);
|
||||
heap_free(p);
|
||||
return nChars;
|
||||
}
|
||||
if (!buffer) return 0;
|
||||
return ME_GetTextW( editor, buffer, INT_MAX, start, len, FALSE, FALSE );
|
||||
}
|
||||
|
||||
int set_selection( ME_TextEditor *editor, int to, int from )
|
||||
|
@ -3991,8 +3980,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
|
|||
{
|
||||
int nFrom, nTo, nStartCur = ME_GetSelectionOfs(editor, &nFrom, &nTo);
|
||||
ME_Cursor *from = &editor->pCursors[nStartCur];
|
||||
return ME_GetTextRange(editor, (WCHAR *)lParam, from,
|
||||
nTo - nFrom, unicode);
|
||||
return get_text_range( editor, (WCHAR *)lParam, from, nTo - nFrom );
|
||||
}
|
||||
case EM_GETSCROLLPOS:
|
||||
{
|
||||
|
@ -4021,7 +4009,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
|
|||
if (nStart >= nEnd) return 0;
|
||||
|
||||
cursor_from_char_ofs( editor, nStart, &start );
|
||||
return ME_GetTextRange( editor, rng->lpstrText, &start, nEnd - nStart, TRUE );
|
||||
return get_text_range( editor, rng->lpstrText, &start, nEnd - nStart );
|
||||
}
|
||||
case EM_GETLINE:
|
||||
{
|
||||
|
|
|
@ -1828,8 +1828,8 @@ static void test_EM_GETSELTEXT(void)
|
|||
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"abcdef\x8e\xf0ghijk");
|
||||
SendMessageA(hwndRichEdit, EM_SETSEL, 4, 8);
|
||||
result = SendMessageA(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer);
|
||||
todo_wine ok(result == 5, "EM_GETSELTEXT returned %ld\n", result);
|
||||
todo_wine ok(!strcmp("ef\x8e\xf0g", buffer), "EM_GETSELTEXT filled %s\n", buffer);
|
||||
ok(result == 5, "EM_GETSELTEXT returned %ld\n", result);
|
||||
ok(!strcmp("ef\x8e\xf0g", buffer), "EM_GETSELTEXT filled %s\n", buffer);
|
||||
}
|
||||
|
||||
DestroyWindow(hwndRichEdit);
|
||||
|
|
|
@ -902,6 +902,20 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
|
|||
else hr = get_lineA( host->text_srv, wparam, lparam, &res );
|
||||
break;
|
||||
|
||||
case EM_GETSELTEXT:
|
||||
{
|
||||
TEXTRANGEA range;
|
||||
|
||||
if (unicode) hr = ITextServices_TxSendMessage( host->text_srv, msg, wparam, lparam, &res );
|
||||
else
|
||||
{
|
||||
ITextServices_TxSendMessage( host->text_srv, EM_EXGETSEL, 0, (LPARAM)&range.chrg, &res );
|
||||
range.lpstrText = (char *)lparam;
|
||||
range.lpstrText[0] = '\0';
|
||||
hr = get_text_rangeA( host, &range, &res );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_GETTEXT:
|
||||
{
|
||||
GETTEXTEX params;
|
||||
|
|
|
@ -623,7 +623,7 @@ static void test_EM_GETSELTEXT(void)
|
|||
SendMessageA(hwndRichEdit, EM_SETSEL, 4, 8);
|
||||
result = SendMessageA(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer);
|
||||
ok(result == 4, "EM_GETSELTEXT returned %ld\n", result);
|
||||
todo_wine ok(!strcmp("ef\x8e\xf0", buffer), "EM_GETSELTEXT filled %s\n", buffer);
|
||||
ok(!strcmp("ef\x8e\xf0", buffer), "EM_GETSELTEXT filled %s\n", buffer);
|
||||
}
|
||||
|
||||
DestroyWindow(hwndRichEdit);
|
||||
|
@ -1362,7 +1362,7 @@ static void test_EM_EXSETSEL(void)
|
|||
result = SendMessageA(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM)&cr);
|
||||
todo_wine ok(result == 7, "EM_EXSETSEL return %ld expected 7\n", result);
|
||||
result = SendMessageA(hwndRichEdit, EM_GETSELTEXT, sizeof(bufA), (LPARAM)bufA);
|
||||
todo_wine ok(!strcmp(bufA, "ef\x8e\xf0"), "EM_GETSELTEXT return incorrect string\n");
|
||||
ok(!strcmp(bufA, "ef\x8e\xf0"), "EM_GETSELTEXT return incorrect string\n");
|
||||
SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr);
|
||||
ok(cr.cpMin == 4, "Selection start incorrectly: %d expected 4\n", cr.cpMin);
|
||||
ok(cr.cpMax == 8, "Selection end incorrectly: %d expected 8\n", cr.cpMax);
|
||||
|
@ -1421,7 +1421,7 @@ static void test_EM_SETSEL(void)
|
|||
result = SendMessageA(hwndRichEdit, EM_SETSEL, 4, 8);
|
||||
todo_wine ok(result == 7, "EM_SETSEL return %ld expected 7\n", result);
|
||||
result = SendMessageA(hwndRichEdit, EM_GETSELTEXT, sizeof(buffA), (LPARAM)buffA);
|
||||
todo_wine ok(!strcmp(buffA, "ef\x8e\xf0"), "EM_GETSELTEXT return incorrect string\n");
|
||||
ok(!strcmp(buffA, "ef\x8e\xf0"), "EM_GETSELTEXT return incorrect string\n");
|
||||
result = SendMessageA(hwndRichEdit, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
|
||||
ok(sel_start == 4, "Selection start incorrectly: %d expected 4\n", sel_start);
|
||||
ok(sel_end == 8, "Selection end incorrectly: %d expected 8\n", sel_end);
|
||||
|
|
Loading…
Reference in New Issue