This is basically a no-op to make the following fix simpler
Signed-off-by: Fabian Maurer dark.shadow4@web.de --- v2: Styling fixes --- dlls/riched20/editor.c | 333 ++++++++++++++++++++++------------------- 1 file changed, 176 insertions(+), 157 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 99c87bf61d..79c9636a7f 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2427,6 +2427,181 @@ static void ME_UpdateSelectionLinkAttribute(ME_TextEditor *editor) ME_UpdateLinkAttribute(editor, &start, nChars); }
+static BOOL handle_enter(ME_TextEditor *editor) +{ + BOOL ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000; + BOOL shift_is_down = GetKeyState(VK_SHIFT) & 0x8000; + + if (editor->bDialogMode) + { + if (ctrl_is_down) + return TRUE; + + if (!(editor->styleFlags & ES_WANTRETURN)) + { + if (editor->hwndParent) + { + DWORD dw; + dw = SendMessageW(editor->hwndParent, DM_GETDEFID, 0, 0); + if (HIWORD(dw) == DC_HASDEFID) + { + HWND hwDefCtrl = GetDlgItem(editor->hwndParent, LOWORD(dw)); + if (hwDefCtrl) + { + SendMessageW(editor->hwndParent, WM_NEXTDLGCTL, (WPARAM)hwDefCtrl, TRUE); + PostMessageW(hwDefCtrl, WM_KEYDOWN, VK_RETURN, 0); + } + } + } + return TRUE; + } + } + + if (editor->styleFlags & ES_MULTILINE) + { + static const WCHAR endl = '\r'; + static const WCHAR endlv10[] = {'\r','\n'}; + ME_Cursor cursor = editor->pCursors[0]; + ME_DisplayItem *para = cursor.pPara; + int from, to; + ME_Style *style, *eop_style; + + if (editor->styleFlags & ES_READONLY) + { + MessageBeep(MB_ICONERROR); + return TRUE; + } + + ME_GetSelectionOfs(editor, &from, &to); + if (editor->nTextLimit > ME_GetTextLength(editor) - (to-from)) + { + if (!editor->bEmulateVersion10) /* v4.1 */ + { + if (para->member.para.nFlags & MEPF_ROWEND) + { + /* Add a new table row after this row. */ + para = ME_AppendTableRow(editor, para); + para = para->member.para.next_para; + editor->pCursors[0].pPara = para; + editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); + editor->pCursors[0].nOffset = 0; + editor->pCursors[1] = editor->pCursors[0]; + ME_CommitUndo(editor); + ME_CheckTablesForCorruption(editor); + ME_UpdateRepaint(editor, FALSE); + return TRUE; + } + else if (para == editor->pCursors[1].pPara && + cursor.nOffset + cursor.pRun->member.run.nCharOfs == 0 && + para->member.para.prev_para->member.para.nFlags & MEPF_ROWSTART && + !para->member.para.prev_para->member.para.nCharOfs) + { + /* Insert a newline before the table. */ + para = para->member.para.prev_para; + para->member.para.nFlags &= ~MEPF_ROWSTART; + editor->pCursors[0].pPara = para; + editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); + editor->pCursors[1] = editor->pCursors[0]; + ME_InsertTextFromCursor(editor, 0, &endl, 1, + editor->pCursors[0].pRun->member.run.style); + para = editor->pBuffer->pFirst->member.para.next_para; + ME_SetDefaultParaFormat(editor, ¶->member.para.fmt); + para->member.para.nFlags = 0; + mark_para_rewrap(editor, para); + editor->pCursors[0].pPara = para; + editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); + editor->pCursors[1] = editor->pCursors[0]; + para->member.para.next_para->member.para.nFlags |= MEPF_ROWSTART; + ME_CommitCoalescingUndo(editor); + ME_CheckTablesForCorruption(editor); + ME_UpdateRepaint(editor, FALSE); + return TRUE; + } + } + else /* v1.0 - 3.0 */ + { + ME_DisplayItem *para = cursor.pPara; + if (ME_IsInTable(para)) + { + if (cursor.pRun->member.run.nFlags & MERF_ENDPARA) + { + if (from == to) + { + ME_ContinueCoalescingTransaction(editor); + para = ME_AppendTableRow(editor, para); + editor->pCursors[0].pPara = para; + editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); + editor->pCursors[0].nOffset = 0; + editor->pCursors[1] = editor->pCursors[0]; + ME_CommitCoalescingUndo(editor); + ME_UpdateRepaint(editor, FALSE); + return TRUE; + } + } + else + { + ME_ContinueCoalescingTransaction(editor); + if (cursor.pRun->member.run.nCharOfs + cursor.nOffset == 0 && + !ME_IsInTable(para->member.para.prev_para)) + { + /* Insert newline before table */ + cursor.pRun = ME_FindItemBack(para, diRun); + if (cursor.pRun) + { + editor->pCursors[0].pRun = cursor.pRun; + editor->pCursors[0].pPara = para->member.para.prev_para; + } + editor->pCursors[0].nOffset = 0; + editor->pCursors[1] = editor->pCursors[0]; + ME_InsertTextFromCursor(editor, 0, &endl, 1, + editor->pCursors[0].pRun->member.run.style); + } + else + { + editor->pCursors[1] = editor->pCursors[0]; + para = ME_AppendTableRow(editor, para); + editor->pCursors[0].pPara = para; + editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); + editor->pCursors[0].nOffset = 0; + editor->pCursors[1] = editor->pCursors[0]; + } + ME_CommitCoalescingUndo(editor); + ME_UpdateRepaint(editor, FALSE); + return TRUE; + } + } + } + + style = ME_GetInsertStyle(editor, 0); + + /* Normally the new eop style is the insert style, however in a list it is copied from the existing + eop style (this prevents the list label style changing when the new eop is inserted). + No extra ref is taken here on eop_style. */ + if (para->member.para.fmt.wNumbering) + eop_style = para->member.para.eop_run->style; + else + eop_style = style; + ME_ContinueCoalescingTransaction(editor); + if (shift_is_down) + ME_InsertEndRowFromCursor(editor, 0); + else + if (!editor->bEmulateVersion10) + ME_InsertTextFromCursor(editor, 0, &endl, 1, eop_style); + else + ME_InsertTextFromCursor(editor, 0, endlv10, 2, eop_style); + ME_CommitCoalescingUndo(editor); + SetCursor(NULL); + + ME_UpdateSelectionLinkAttribute(editor); + ME_UpdateRepaint(editor, FALSE); + ME_SaveTempStyle(editor, style); /* set the temp insert style for the new para */ + ME_ReleaseStyle(style); + } + return TRUE; + } + return FALSE; +} + static BOOL ME_KeyDown(ME_TextEditor *editor, WORD nKey) { @@ -2493,163 +2668,7 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey) ME_SendRequestResize(editor, FALSE); return TRUE; case VK_RETURN: - if (editor->bDialogMode) - { - if (ctrl_is_down) - return TRUE; - - if (!(editor->styleFlags & ES_WANTRETURN)) - { - if (editor->hwndParent) - { - DWORD dw; - dw = SendMessageW(editor->hwndParent, DM_GETDEFID, 0, 0); - if (HIWORD(dw) == DC_HASDEFID) - { - HWND hwDefCtrl = GetDlgItem(editor->hwndParent, LOWORD(dw)); - if (hwDefCtrl) - { - SendMessageW(editor->hwndParent, WM_NEXTDLGCTL, (WPARAM)hwDefCtrl, TRUE); - PostMessageW(hwDefCtrl, WM_KEYDOWN, VK_RETURN, 0); - } - } - } - return TRUE; - } - } - - if (editor->styleFlags & ES_MULTILINE) - { - static const WCHAR endl = '\r'; - static const WCHAR endlv10[] = {'\r','\n'}; - ME_Cursor cursor = editor->pCursors[0]; - ME_DisplayItem *para = cursor.pPara; - int from, to; - ME_Style *style, *eop_style; - - if (editor->styleFlags & ES_READONLY) { - MessageBeep(MB_ICONERROR); - return TRUE; - } - - ME_GetSelectionOfs(editor, &from, &to); - if (editor->nTextLimit > ME_GetTextLength(editor) - (to-from)) - { - if (!editor->bEmulateVersion10) { /* v4.1 */ - if (para->member.para.nFlags & MEPF_ROWEND) { - /* Add a new table row after this row. */ - para = ME_AppendTableRow(editor, para); - para = para->member.para.next_para; - editor->pCursors[0].pPara = para; - editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); - editor->pCursors[0].nOffset = 0; - editor->pCursors[1] = editor->pCursors[0]; - ME_CommitUndo(editor); - ME_CheckTablesForCorruption(editor); - ME_UpdateRepaint(editor, FALSE); - return TRUE; - } - else if (para == editor->pCursors[1].pPara && - cursor.nOffset + cursor.pRun->member.run.nCharOfs == 0 && - para->member.para.prev_para->member.para.nFlags & MEPF_ROWSTART && - !para->member.para.prev_para->member.para.nCharOfs) - { - /* Insert a newline before the table. */ - para = para->member.para.prev_para; - para->member.para.nFlags &= ~MEPF_ROWSTART; - editor->pCursors[0].pPara = para; - editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); - editor->pCursors[1] = editor->pCursors[0]; - ME_InsertTextFromCursor(editor, 0, &endl, 1, - editor->pCursors[0].pRun->member.run.style); - para = editor->pBuffer->pFirst->member.para.next_para; - ME_SetDefaultParaFormat(editor, ¶->member.para.fmt); - para->member.para.nFlags = 0; - mark_para_rewrap(editor, para); - editor->pCursors[0].pPara = para; - editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); - editor->pCursors[1] = editor->pCursors[0]; - para->member.para.next_para->member.para.nFlags |= MEPF_ROWSTART; - ME_CommitCoalescingUndo(editor); - ME_CheckTablesForCorruption(editor); - ME_UpdateRepaint(editor, FALSE); - return TRUE; - } - } else { /* v1.0 - 3.0 */ - ME_DisplayItem *para = cursor.pPara; - if (ME_IsInTable(para)) - { - if (cursor.pRun->member.run.nFlags & MERF_ENDPARA) - { - if (from == to) { - ME_ContinueCoalescingTransaction(editor); - para = ME_AppendTableRow(editor, para); - editor->pCursors[0].pPara = para; - editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); - editor->pCursors[0].nOffset = 0; - editor->pCursors[1] = editor->pCursors[0]; - ME_CommitCoalescingUndo(editor); - ME_UpdateRepaint(editor, FALSE); - return TRUE; - } - } else { - ME_ContinueCoalescingTransaction(editor); - if (cursor.pRun->member.run.nCharOfs + cursor.nOffset == 0 && - !ME_IsInTable(para->member.para.prev_para)) - { - /* Insert newline before table */ - cursor.pRun = ME_FindItemBack(para, diRun); - if (cursor.pRun) { - editor->pCursors[0].pRun = cursor.pRun; - editor->pCursors[0].pPara = para->member.para.prev_para; - } - editor->pCursors[0].nOffset = 0; - editor->pCursors[1] = editor->pCursors[0]; - ME_InsertTextFromCursor(editor, 0, &endl, 1, - editor->pCursors[0].pRun->member.run.style); - } else { - editor->pCursors[1] = editor->pCursors[0]; - para = ME_AppendTableRow(editor, para); - editor->pCursors[0].pPara = para; - editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun); - editor->pCursors[0].nOffset = 0; - editor->pCursors[1] = editor->pCursors[0]; - } - ME_CommitCoalescingUndo(editor); - ME_UpdateRepaint(editor, FALSE); - return TRUE; - } - } - } - - style = ME_GetInsertStyle(editor, 0); - - /* Normally the new eop style is the insert style, however in a list it is copied from the existing - eop style (this prevents the list label style changing when the new eop is inserted). - No extra ref is taken here on eop_style. */ - if (para->member.para.fmt.wNumbering) - eop_style = para->member.para.eop_run->style; - else - eop_style = style; - ME_ContinueCoalescingTransaction(editor); - if (shift_is_down) - ME_InsertEndRowFromCursor(editor, 0); - else - if (!editor->bEmulateVersion10) - ME_InsertTextFromCursor(editor, 0, &endl, 1, eop_style); - else - ME_InsertTextFromCursor(editor, 0, endlv10, 2, eop_style); - ME_CommitCoalescingUndo(editor); - SetCursor(NULL); - - ME_UpdateSelectionLinkAttribute(editor); - ME_UpdateRepaint(editor, FALSE); - ME_SaveTempStyle(editor, style); /* set the temp insert style for the new para */ - ME_ReleaseStyle(style); - } - return TRUE; - } - break; + return handle_enter(editor); case VK_ESCAPE: if (editor->bDialogMode && editor->hwndParent) PostMessageW(editor->hwndParent, WM_CLOSE, 0, 0);
This is basically a no-op to make the tests and the following additions simpler
Signed-off-by: Fabian Maurer dark.shadow4@web.de --- v2: Move out "expected" --- dlls/riched20/tests/editor.c | 54 ++++++++++++++---------------------- dlls/riched32/tests/editor.c | 54 ++++++++++++++---------------------- 2 files changed, 42 insertions(+), 66 deletions(-)
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 035869e134..b7010b0a13 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -8259,6 +8259,14 @@ static void test_EM_FINDWORDBREAK_A(void) DestroyWindow(hwndRichEdit); }
+static void format_test_result(char *target, const char *src) +{ + int i; + for (i = 0; i < strlen(src); i++) + sprintf(target + 2*i, "%02x", src[i] & 0xFF); + target[2*i] = 0; +} + /* * This test attempts to show the effect of enter on a richedit * control v1.0 inserts CRLF whereas for higher versions it only @@ -8285,15 +8293,13 @@ static void test_enter(void) char expectedbuf[1024]; char resultbuf[1024]; HWND hwndRichEdit = new_richedit(NULL); - UINT i,j; + UINT i; + char buf[1024] = {0}; + GETTEXTEX getText = {sizeof(buf)}; + LRESULT result; + const char *expected;
for (i = 0; i < ARRAY_SIZE(testenteritems); i++) { - - char buf[1024] = {0}; - LRESULT result; - GETTEXTEX getText; - const char *expected; - /* Set the text to the initial text */ result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)testenteritems[i].initialtext); ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result); @@ -8307,12 +8313,8 @@ static void test_enter(void) result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buf); expected = testenteritems[i].expectedwmtext;
- resultbuf[0]=0x00; - for (j = 0; j < (UINT)result; j++) - sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF); - expectedbuf[0] = '\0'; - for (j = 0; j < strlen(expected); j++) - sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] & 0xFF); + format_test_result(resultbuf, buf); + format_test_result(expectedbuf, expected);
result = strcmp(expected, buf); ok (result == 0, @@ -8320,21 +8322,14 @@ static void test_enter(void) i, resultbuf, expectedbuf);
/* 2. Retrieve with EM_GETTEXTEX, GT_DEFAULT */ - getText.cb = sizeof(buf); getText.flags = GT_DEFAULT; - getText.codepage = CP_ACP; - getText.lpDefaultChar = NULL; - getText.lpUsedDefChar = NULL; + getText.codepage = CP_ACP; buf[0] = 0x00; result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf); expected = testenteritems[i].expectedemtext;
- resultbuf[0]=0x00; - for (j = 0; j < (UINT)result; j++) - sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF); - expectedbuf[0] = '\0'; - for (j = 0; j < strlen(expected); j++) - sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] & 0xFF); + format_test_result(resultbuf, buf); + format_test_result(expectedbuf, expected);
result = strcmp(expected, buf); ok (result == 0, @@ -8342,21 +8337,14 @@ static void test_enter(void) i, resultbuf, expectedbuf);
/* 3. Retrieve with EM_GETTEXTEX, GT_USECRLF */ - getText.cb = sizeof(buf); getText.flags = GT_USECRLF; - getText.codepage = CP_ACP; - getText.lpDefaultChar = NULL; - getText.lpUsedDefChar = NULL; + getText.codepage = CP_ACP; buf[0] = 0x00; result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf); expected = testenteritems[i].expectedemtextcrlf;
- resultbuf[0]=0x00; - for (j = 0; j < (UINT)result; j++) - sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF); - expectedbuf[0] = '\0'; - for (j = 0; j < strlen(expected); j++) - sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] & 0xFF); + format_test_result(resultbuf, buf); + format_test_result(expectedbuf, expected);
result = strcmp(expected, buf); ok (result == 0, diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c index 7751d2b402..e7e8fc8433 100644 --- a/dlls/riched32/tests/editor.c +++ b/dlls/riched32/tests/editor.c @@ -1149,6 +1149,14 @@ static void simulate_typing_characters(HWND hwnd, const char* szChars) } }
+static void format_test_result(char *target, const char *src) +{ + int i; + for (i = 0; i < strlen(src); i++) + sprintf(target + 2*i, "%02x", src[i] & 0xFF); + target[2*i] = 0; +} + /* * This test attempts to show the effect of enter on a richedit * control v1.0 inserts CRLF whereas for higher versions it only @@ -1173,15 +1181,13 @@ static void test_enter(void) char expectedbuf[1024]; char resultbuf[1024]; HWND hwndRichEdit = new_richedit(NULL); - UINT i,j; + UINT i; + char buf[1024] = {0}; + GETTEXTEX getText = {sizeof(buf)}; + LRESULT result; + const char *expected;
for (i = 0; i < ARRAY_SIZE(testenteritems); i++) { - - char buf[1024] = {0}; - LRESULT result; - GETTEXTEX getText; - const char *expected; - /* Set the text to the initial text */ result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)testenteritems[i].initialtext); ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result); @@ -1195,12 +1201,8 @@ static void test_enter(void) result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buf); expected = testenteritems[i].expectedtext;
- resultbuf[0]=0x00; - for (j = 0; j < (UINT)result; j++) - sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF); - expectedbuf[0] = '\0'; - for (j = 0; j < strlen(expected); j++) - sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] & 0xFF); + format_test_result(resultbuf, buf); + format_test_result(expectedbuf, expected);
result = strcmp(expected, buf); ok (result == 0, @@ -1208,21 +1210,14 @@ static void test_enter(void) i, resultbuf, expectedbuf);
/* 2. Retrieve with EM_GETTEXTEX, GT_DEFAULT */ - getText.cb = sizeof(buf); getText.flags = GT_DEFAULT; - getText.codepage = CP_ACP; - getText.lpDefaultChar = NULL; - getText.lpUsedDefChar = NULL; + getText.codepage = CP_ACP; buf[0] = 0x00; result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf); expected = testenteritems[i].expectedtext;
- resultbuf[0]=0x00; - for (j = 0; j < (UINT)result; j++) - sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF); - expectedbuf[0] = '\0'; - for (j = 0; j < strlen(expected); j++) - sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] & 0xFF); + format_test_result(resultbuf, buf); + format_test_result(expectedbuf, expected);
result = strcmp(expected, buf); ok (result == 0 || broken(buf[0]==0x00 /* WinNT4 */), @@ -1230,21 +1225,14 @@ static void test_enter(void) i, resultbuf, expectedbuf);
/* 3. Retrieve with EM_GETTEXTEX, GT_USECRLF */ - getText.cb = sizeof(buf); getText.flags = GT_USECRLF; - getText.codepage = CP_ACP; - getText.lpDefaultChar = NULL; - getText.lpUsedDefChar = NULL; + getText.codepage = CP_ACP; buf[0] = 0x00; result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf); expected = testenteritems[i].expectedtext;
- resultbuf[0]=0x00; - for (j = 0; j < (UINT)result; j++) - sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF); - expectedbuf[0] = '\0'; - for (j = 0; j < strlen(expected); j++) - sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] & 0xFF); + format_test_result(resultbuf, buf); + format_test_result(expectedbuf, expected);
result = strcmp(expected, buf); ok (result == 0 || broken(buf[0]==0x00 /* WinNT4 */),
This fixes an old regression when VK_RETURN handling was implemented
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=23282 Signed-off-by: Fabian Maurer dark.shadow4@web.de --- v2: test return of EM_GETTEXTEX --- dlls/riched20/editor.c | 7 ++++++- dlls/riched20/tests/editor.c | 29 +++++++++++++++++++++++++++++ dlls/riched32/tests/editor.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 79c9636a7f..fc7d354796 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2668,7 +2668,9 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey) ME_SendRequestResize(editor, FALSE); return TRUE; case VK_RETURN: - return handle_enter(editor); + if (!editor->bEmulateVersion10) + return handle_enter(editor); + break; case VK_ESCAPE: if (editor->bDialogMode && editor->hwndParent) PostMessageW(editor->hwndParent, WM_CLOSE, 0, 0); @@ -2737,6 +2739,9 @@ static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode, { WCHAR wstr;
+ if (editor->bEmulateVersion10 && charCode == '\r') + handle_enter(editor); + if (editor->bMouseCaptured) return 0;
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index b7010b0a13..41c44774c7 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -8273,6 +8273,7 @@ static void format_test_result(char *target, const char *src) * inserts CR. If shows that EM_GETTEXTEX with GT_USECRLF == WM_GETTEXT * and also shows that GT_USECRLF has no effect in richedit 1.0, but * does for higher. The same test is cloned in riched32 and riched20. + * Also shows the difference between WM_CHAR/WM_KEYDOWN in v1.0 and higher versions */ static void test_enter(void) { @@ -8352,6 +8353,34 @@ static void test_enter(void) i, resultbuf, expectedbuf); }
+ /* Show that WM_CHAR is handled differently from WM_KEYDOWN */ + getText.flags = GT_DEFAULT; + getText.codepage = CP_ACP; + + result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)""); + ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result); + SendMessageW(hwndRichEdit, WM_CHAR, 'T', 0); + SendMessageW(hwndRichEdit, WM_KEYDOWN, VK_RETURN, 0); + + result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf); + ok(result == 2, "Got %d\n", (int)result); + format_test_result(resultbuf, buf); + format_test_result(expectedbuf, "T\r"); + result = strcmp(resultbuf, expectedbuf); + ok (result == 0, "[%d] EM_GETTEXTEX, GT_DEFAULT unexpected '%s', expected '%s'\n", i, resultbuf, expectedbuf); + + result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)""); + ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result); + SendMessageW(hwndRichEdit, WM_CHAR, 'T', 0); + SendMessageW(hwndRichEdit, WM_CHAR, '\r', 0); + + result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf); + ok(result == 1, "Got %d\n", (int)result); + format_test_result(resultbuf, buf); + format_test_result(expectedbuf, "T"); + result = strcmp(resultbuf, expectedbuf); + ok (result == 0, "[%d] EM_GETTEXTEX, GT_DEFAULT unexpected '%s', expected '%s'\n", i, resultbuf, expectedbuf); + DestroyWindow(hwndRichEdit); }
diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c index e7e8fc8433..5335a88ebd 100644 --- a/dlls/riched32/tests/editor.c +++ b/dlls/riched32/tests/editor.c @@ -1163,6 +1163,7 @@ static void format_test_result(char *target, const char *src) * inserts CR. If shows that EM_GETTEXTEX with GT_USECRLF == WM_GETTEXT * and also shows that GT_USECRLF has no effect in richedit 1.0, but * does for higher. The same test is cloned in riched32 and riched20. + * Also shows the difference between WM_CHAR/WM_KEYDOWN in v1.0 and higher versions */ static void test_enter(void) { @@ -1240,6 +1241,34 @@ static void test_enter(void) i, resultbuf, expectedbuf); }
+ /* Show that WM_CHAR is handled differently from WM_KEYDOWN */ + getText.flags = GT_DEFAULT; + getText.codepage = CP_ACP; + + result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)""); + ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result); + SendMessageW(hwndRichEdit, WM_CHAR, 'T', 0); + SendMessageW(hwndRichEdit, WM_KEYDOWN, VK_RETURN, 0); + + result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf); + ok(result == 1, "Got %d\n", (int)result); + format_test_result(resultbuf, buf); + format_test_result(expectedbuf, "T"); + result = strcmp(resultbuf, expectedbuf); + ok (result == 0, "[%d] EM_GETTEXTEX, GT_DEFAULT unexpected '%s', expected '%s'\n", i, resultbuf, expectedbuf); + + result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)""); + ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result); + SendMessageW(hwndRichEdit, WM_CHAR, 'T', 0); + SendMessageW(hwndRichEdit, WM_CHAR, '\r', 0); + + SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf); + ok(result == 1, "Got %d\n", (int)result); + format_test_result(resultbuf, buf); + format_test_result(expectedbuf, "T\r\n"); + result = strcmp(resultbuf, expectedbuf); + ok (result == 0, "[%d] EM_GETTEXTEX, GT_DEFAULT unexpected '%s', expected '%s'\n", i, resultbuf, expectedbuf); + DestroyWindow(hwndRichEdit); }
On Mon, Dec 10, 2018 at 09:27:02PM +0100, Fabian Maurer wrote:
This is basically a no-op to make the following fix simpler
Signed-off-by: Fabian Maurer dark.shadow4@web.de
v2: Styling fixes
I sent in v3 of this patch-set with a slight change in [3/3] and a few small whitespace changes.
Huw.