Clinton Stimpson : riched20: Only WM_CHAR respects text limit.
Alexandre Julliard
julliard at winehq.org
Fri Sep 21 07:23:03 CDT 2007
Module: wine
Branch: master
Commit: f34cb461e7381cf1e871649c750e22fb5ac7452f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f34cb461e7381cf1e871649c750e22fb5ac7452f
Author: Clinton Stimpson <cjstimpson at utwire.net>
Date: Thu Sep 20 15:58:02 2007 -0600
riched20: Only WM_CHAR respects text limit.
---
dlls/riched20/caret.c | 10 +++++++---
dlls/riched20/editor.c | 16 +++++++++++-----
dlls/riched20/tests/editor.c | 12 ------------
3 files changed, 18 insertions(+), 20 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index f5fbf00..47e816c 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -441,7 +441,7 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
{
const WCHAR *pos;
ME_Cursor *p = NULL;
- int freeSpace;
+ int oldLen;
/* FIXME really HERE ? */
if (ME_IsSelection(editor))
@@ -449,7 +449,7 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
/* FIXME: is this too slow? */
/* Didn't affect performance for WM_SETTEXT (around 50sec/30K) */
- freeSpace = editor->nTextLimit - ME_GetTextLength(editor);
+ oldLen = ME_GetTextLength(editor);
/* text operations set modified state */
editor->nModifyStep = 1;
@@ -459,7 +459,11 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
assert(nCursor>=0 && nCursor<editor->nCursors);
if (len == -1)
len = lstrlenW(str);
- len = min(len, freeSpace);
+
+ /* grow the text limit to fit our text */
+ if(editor->nTextLimit < oldLen +len)
+ editor->nTextLimit = oldLen + len;
+
while (len)
{
pos = str;
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 3e1cdf2..dff0b5f 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -2413,11 +2413,17 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
}
if (((unsigned)wstr)>=' ' || wstr=='\r' || wstr=='\t') {
/* FIXME maybe it would make sense to call EM_REPLACESEL instead ? */
- ME_Style *style = ME_GetInsertStyle(editor, 0);
- ME_SaveTempStyle(editor);
- ME_InsertTextFromCursor(editor, 0, &wstr, 1, style);
- ME_ReleaseStyle(style);
- ME_CommitUndo(editor);
+ /* WM_CHAR is restricted to nTextLimit */
+ int from, to;
+ ME_GetSelection(editor, &from, &to);
+ if(editor->nTextLimit > ME_GetTextLength(editor) - (to-from))
+ {
+ ME_Style *style = ME_GetInsertStyle(editor, 0);
+ ME_SaveTempStyle(editor);
+ ME_InsertTextFromCursor(editor, 0, &wstr, 1, style);
+ ME_ReleaseStyle(style);
+ ME_CommitUndo(editor);
+ }
ME_UpdateRepaint(editor);
}
return 0;
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 98b355e..5c00586 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -1116,26 +1116,18 @@ static void test_EM_EXLIMITTEXT(void)
SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text);
SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
i = strlen(buffer);
-todo_wine {
ok(10 == i, "expected 10 chars\n");
-}
i = SendMessage(hwndRichEdit, EM_GETLIMITTEXT, 0, 0);
-todo_wine {
ok(10 == i, "EM_EXLIMITTEXT: expected: %d, actual: %d\n", 10, i);
-}
/* try inserting more text at end */
i = SendMessage(hwndRichEdit, WM_CHAR, 'A', 0);
ok(0 == i, "WM_CHAR wasn't processed");
SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
i = strlen(buffer);
-todo_wine {
ok(10 == i, "expected 10 chars, got %i\n", i);
-}
i = SendMessage(hwndRichEdit, EM_GETLIMITTEXT, 0, 0);
-todo_wine {
ok(10 == i, "EM_EXLIMITTEXT: expected: %d, actual: %d\n", 10, i);
-}
/* try inserting text at beginning */
SendMessage(hwndRichEdit, EM_SETSEL, 0, 0);
@@ -1143,13 +1135,9 @@ todo_wine {
ok(0 == i, "WM_CHAR wasn't processed");
SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
i = strlen(buffer);
-todo_wine {
ok(10 == i, "expected 10 chars, got %i\n", i);
-}
i = SendMessage(hwndRichEdit, EM_GETLIMITTEXT, 0, 0);
-todo_wine {
ok(10 == i, "EM_EXLIMITTEXT: expected: %d, actual: %d\n", 10, i);
-}
/* WM_CHAR is limited */
textlimit = 1;
More information about the wine-cvs
mailing list