riched20: Fix modification state for several operations.

This commit is contained in:
Clinton Stimpson 2007-01-11 00:46:35 -07:00 committed by Alexandre Julliard
parent bbedf3d096
commit bf86302e19
4 changed files with 9 additions and 12 deletions

View File

@ -435,6 +435,9 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
/* Didn't affect performance for WM_SETTEXT (around 50sec/30K) */
int freeSpace = editor->nTextLimit - ME_GetTextLength(editor);
/* text operations set modified state */
editor->nModifyStep = 1;
assert(style);
/* FIXME really HERE ? */

View File

@ -1639,6 +1639,7 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
size_t len = wszText ? lstrlenW(wszText) : 0;
int from, to;
ME_Style *style;
int oldModify = editor->nModifyStep;
TRACE("EM_SETTEXTEX - %s, flags %d, cp %d\n", debugstr_w(wszText), (int)pStruct->flags, pStruct->codepage);
if (pStruct->codepage != 1200) {
FIXME("EM_SETTEXTEX only supports unicode right now!\n");
@ -1659,7 +1660,10 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
}
ME_CommitUndo(editor);
if (!(pStruct->flags & ST_KEEPUNDO))
{
editor->nModifyStep = oldModify;
ME_EmptyUndoStack(editor);
}
ME_UpdateRepaint(editor);
return len;
}
@ -1690,7 +1694,7 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
case EM_SETMODIFY:
{
if (wParam)
editor->nModifyStep = 0x80000000;
editor->nModifyStep = 1;
else
editor->nModifyStep = 0;
@ -1732,6 +1736,7 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
bRepaint = (from != to);
ME_SetSelectionCharFormat(editor, p);
}
editor->nModifyStep = 1;
ME_CommitUndo(editor);
if (bRepaint)
ME_RewrapRepaint(editor);

View File

@ -1192,10 +1192,8 @@ static void test_EM_GETMODIFY(void)
SendMessage(hwndRichEdit, EM_SETMODIFY, FALSE, 0);
SendMessage(hwndRichEdit, WM_SETFONT, (WPARAM)testFont,(LPARAM) MAKELONG((WORD) TRUE, 0));
result = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
todo_wine {
ok (result == 0,
"EM_GETMODIFY returned non-zero, instead of zero on setting font\n");
}
/* setting text should set modify flag */
SendMessage(hwndRichEdit, EM_SETMODIFY, FALSE, 0);
@ -1207,20 +1205,16 @@ static void test_EM_GETMODIFY(void)
/* undo previous text doesn't reset modify flag */
SendMessage(hwndRichEdit, WM_UNDO, 0, 0);
result = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
todo_wine {
ok (result != 0,
"EM_GETMODIFY returned zero, instead of non-zero on undo after setting text\n");
}
/* set text with no flag to keep undo stack should not set modify flag */
SendMessage(hwndRichEdit, EM_SETMODIFY, FALSE, 0);
setText.flags = 0;
SendMessage(hwndRichEdit, EM_SETTEXTEX, (WPARAM)&setText, (LPARAM)TestItem1);
result = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
todo_wine {
ok (result == 0,
"EM_GETMODIFY returned non-zero, instead of zero when setting text while not keeping undo stack\n");
}
/* WM_SETTEXT doesn't modify */
SendMessage(hwndRichEdit, EM_SETMODIFY, FALSE, 0);
@ -1295,10 +1289,8 @@ static void test_EM_GETMODIFY(void)
pf2.wAlignment = PFA_RIGHT;
SendMessage(hwndRichEdit, EM_SETPARAFORMAT, 0, (LPARAM) &pf2);
result = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
todo_wine {
ok (result == 0,
"EM_GETMODIFY returned zero, instead of non-zero for EM_SETPARAFORMAT\n");
}
/* EM_STREAM */
SendMessage(hwndRichEdit, EM_SETMODIFY, FALSE, 0);

View File

@ -163,7 +163,6 @@ void ME_CommitUndo(ME_TextEditor *editor) {
ME_AddUndoItem(editor, diUndoEndTransaction, NULL);
ME_SendSelChange(editor);
editor->nModifyStep++;
}
void ME_PlayUndoItem(ME_TextEditor *editor, ME_DisplayItem *pItem)
@ -260,7 +259,6 @@ void ME_Undo(ME_TextEditor *editor) {
if (p)
p->prev = NULL;
editor->nUndoMode = nMode;
editor->nModifyStep--;
ME_UpdateRepaint(editor);
}
@ -293,6 +291,5 @@ void ME_Redo(ME_TextEditor *editor) {
if (p)
p->prev = NULL;
editor->nUndoMode = nMode;
editor->nModifyStep++;
ME_UpdateRepaint(editor);
}