Commit 3cad256d authored by Alex Villacís Lasso's avatar Alex Villacís Lasso Committed by Alexandre Julliard

richedit: Fix modify step setting in EM_SETCHARFORMAT.

EM_SETCHARFORMAT with wParam==0 sets default char format and does NOT set modify step flag. EM_SETCHARFORMAT with wParam==SCF_SELECTION only sets modify step flag when selection is nonempty. EM_GETMODIFY returns -1, not 1, when modify flag is set. Tests for the above behavior.
parent 1fa39b50
...@@ -2206,7 +2206,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, ...@@ -2206,7 +2206,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
return lColor; return lColor;
} }
case EM_GETMODIFY: case EM_GETMODIFY:
return editor->nModifyStep == 0 ? 0 : 1; return editor->nModifyStep == 0 ? 0 : -1;
case EM_SETMODIFY: case EM_SETMODIFY:
{ {
if (wParam) if (wParam)
...@@ -2249,8 +2249,10 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, ...@@ -2249,8 +2249,10 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
} else if (wParam == SCF_ALL) { } else if (wParam == SCF_ALL) {
if (editor->mode & TM_PLAINTEXT) if (editor->mode & TM_PLAINTEXT)
ME_SetDefaultCharFormat(editor, p); ME_SetDefaultCharFormat(editor, p);
else else {
ME_SetCharFormat(editor, 0, ME_GetTextLength(editor), p); ME_SetCharFormat(editor, 0, ME_GetTextLength(editor), p);
editor->nModifyStep = 1;
}
} else if (editor->mode & TM_PLAINTEXT) { } else if (editor->mode & TM_PLAINTEXT) {
return 0; return 0;
} else { } else {
...@@ -2258,8 +2260,8 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, ...@@ -2258,8 +2260,8 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
ME_GetSelection(editor, &from, &to); ME_GetSelection(editor, &from, &to);
bRepaint = (from != to); bRepaint = (from != to);
ME_SetSelectionCharFormat(editor, p); ME_SetSelectionCharFormat(editor, p);
if (from != to) editor->nModifyStep = 1;
} }
editor->nModifyStep = 1;
ME_CommitUndo(editor); ME_CommitUndo(editor);
if (bRepaint) if (bRepaint)
ME_RewrapRepaint(editor); ME_RewrapRepaint(editor);
......
...@@ -438,6 +438,57 @@ static void test_EM_SETCHARFORMAT(void) ...@@ -438,6 +438,57 @@ static void test_EM_SETCHARFORMAT(void)
(LPARAM) &cf2); (LPARAM) &cf2);
ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc); ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc);
cf2.cbSize = sizeof(CHARFORMAT2);
SendMessage(hwndRichEdit, EM_GETCHARFORMAT, (WPARAM) SCF_DEFAULT,
(LPARAM) &cf2);
/* Test state of modify flag before and after valid EM_SETCHARFORMAT */
cf2.cbSize = sizeof(CHARFORMAT2);
SendMessage(hwndRichEdit, EM_GETCHARFORMAT, (WPARAM) SCF_DEFAULT,
(LPARAM) &cf2);
cf2.dwMask = CFM_ITALIC | cf2.dwMask;
cf2.dwEffects = CFE_ITALIC ^ cf2.dwEffects;
/* wParam==0 is default char format, does not set modify */
SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)NULL);
rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
ok(rc == 0, "Text marked as modified, expected not modified!\n");
rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, 0, (LPARAM) &cf2);
ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc);
rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
ok(rc == 0, "Text marked as modified, expected not modified!\n");
/* wParam==SCF_SELECTION sets modify if nonempty selection */
SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)NULL);
rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
ok(rc == 0, "Text marked as modified, expected not modified!\n");
rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf2);
ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc);
rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
ok(rc == 0, "Text marked as modified, expected not modified!\n");
SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"wine");
rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
ok(rc == 0, "Text marked as modified, expected not modified!\n");
rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf2);
ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc);
rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
ok(rc == 0, "Text marked as modified, expected not modified!\n");
SendMessage(hwndRichEdit, EM_SETSEL, 0, 2);
rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf2);
ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc);
rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
ok(rc == -1, "Text not marked as modified, expected modified! (%d)\n", rc);
/* wParam==SCF_ALL sets modify regardless of whether text is present */
SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)NULL);
rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
ok(rc == 0, "Text marked as modified, expected not modified!\n");
rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, (WPARAM) SCF_ALL, (LPARAM) &cf2);
ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc);
rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
ok(rc == -1, "Text not marked as modified, expected modified! (%d)\n", rc);
DestroyWindow(hwndRichEdit); DestroyWindow(hwndRichEdit);
} }
...@@ -472,10 +523,17 @@ static void test_EM_SETTEXTMODE(void) ...@@ -472,10 +523,17 @@ static void test_EM_SETTEXTMODE(void)
cf2.dwMask = CFM_ITALIC | cf2.dwMask; cf2.dwMask = CFM_ITALIC | cf2.dwMask;
cf2.dwEffects = CFE_ITALIC ^ cf2.dwEffects; cf2.dwEffects = CFE_ITALIC ^ cf2.dwEffects;
rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
ok(rc == 0, "Text marked as modified, expected not modified!\n");
/*EM_SETCHARFORMAT is not yet fully implemented for all WPARAMs in wine; /*EM_SETCHARFORMAT is not yet fully implemented for all WPARAMs in wine;
however, SCF_ALL has been implemented*/ however, SCF_ALL has been implemented*/
rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, (WPARAM) SCF_ALL, (LPARAM) &cf2); rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, (WPARAM) SCF_ALL, (LPARAM) &cf2);
ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc); ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc);
rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
ok(rc == -1, "Text not marked as modified, expected modified! (%d)\n", rc);
SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) "wine"); SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) "wine");
/*Select the string "wine"*/ /*Select the string "wine"*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment