riched20: implement EM_EXLIMITTEXT, EM_GETLIMITTEXT and tests

kmyers at ucla.edu kmyers at ucla.edu
Wed Mar 1 22:45:46 CST 2006


My name is Ken Myers.  I'm a resident of Los Angeles, CA, USA, and I
currently attend UCLA.  I hereby certify that I wrote this code without
copying from anyone else's sources, and I've never seen any secret
Microsoft source code.

License: LGPL
---

ChangeLog:
	Ken Myers <kmyers at ucla.edu>
	Implemented EM_EXLIMITTEXT and EM_GETLIMITTEXT and their test cases.

---

 caret.c        |    4 ++
 editor.c       |   16 +++++++---
 editstr.h      |    1
 tests/editor.c |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 103 insertions(+), 4 deletions(-)


Index: wine/dlls/riched20/caret.c
===================================================================
RCS file: /home/wine/wine/dlls/riched20/caret.c,v
retrieving revision 1.26
diff -u -p -r1.26 caret.c
--- wine/dlls/riched20/caret.c	4 Feb 2006 17:17:46 -0000	1.26
+++ wine/dlls/riched20/caret.c	2 Mar 2006 04:26:25 -0000
@@ -374,6 +374,9 @@ void ME_InsertTextFromCursor(ME_TextEdit
 {
   const WCHAR *pos;
   ME_Cursor *p = NULL;
+  /* FIXME: is this too slow? */
+  /* Didn't affect performance for WM_SETTEXT (around 50sec/30K) */
+  int freeSpace = editor->nTextLimit - ME_GetTextLength(editor);
 
   assert(style);
 
@@ -384,6 +387,7 @@ void ME_InsertTextFromCursor(ME_TextEdit
   assert(nCursor>=0 && nCursor<editor->nCursors);
   if (len == -1)
     len = lstrlenW(str);
+  len = len < freeSpace ? len : freeSpace;
   while (len)
   {
     pos = str;
Index: wine/dlls/riched20/editor.c
===================================================================
RCS file: /home/wine/wine/dlls/riched20/editor.c,v
retrieving revision 1.101
diff -u -p -r1.101 editor.c
--- wine/dlls/riched20/editor.c	27 Feb 2006 15:35:12 -0000	1.101
+++ wine/dlls/riched20/editor.c	2 Mar 2006 04:26:29 -0000
@@ -32,7 +32,7 @@
   - EM_DISPLAYBAND
   + EM_EMPTYUNDOBUFFER
   + EM_EXGETSEL
-  - EM_EXLIMITTEXT
+  + EM_EXLIMITTEXT
   + EM_EXLINEFROMCHAR
   + EM_EXSETSEL
   + EM_FINDTEXT (only FR_DOWN flag implemented)
@@ -51,7 +51,7 @@
   - EM_GETIMEOPTIONS 1.0asian
   - EM_GETIMESTATUS
   - EM_GETLANGOPTIONS 2.0
-  - EM_GETLIMITTEXT
+  + EM_GETLIMITTEXT
   - EM_GETLINE        
   + EM_GETLINECOUNT   returns number of rows, not of paragraphs
   + EM_GETMODIFY
@@ -1292,7 +1292,6 @@ LRESULT WINAPI RichEditANSIWndProc(HWND 
   
   UNSUPPORTED_MSG(EM_AUTOURLDETECT)
   UNSUPPORTED_MSG(EM_DISPLAYBAND)
-  UNSUPPORTED_MSG(EM_EXLIMITTEXT)
   UNSUPPORTED_MSG(EM_FINDWORDBREAK)
   UNSUPPORTED_MSG(EM_FMTLINES)
   UNSUPPORTED_MSG(EM_FORMATRANGE)
@@ -1302,7 +1301,6 @@ LRESULT WINAPI RichEditANSIWndProc(HWND 
   UNSUPPORTED_MSG(EM_GETIMECOMPMODE)
   /* UNSUPPORTED_MSG(EM_GETIMESTATUS) missing in Wine headers */
   UNSUPPORTED_MSG(EM_GETLANGOPTIONS)
-  UNSUPPORTED_MSG(EM_GETLIMITTEXT)
   UNSUPPORTED_MSG(EM_GETLINE)
   /* UNSUPPORTED_MSG(EM_GETOLEINTERFACE) separate stub */
   UNSUPPORTED_MSG(EM_GETPASSWORDCHAR)
@@ -1952,6 +1950,16 @@ LRESULT WINAPI RichEditANSIWndProc(HWND 
     TRACE("EM_LINELENGTH(%d)==%d\n",wParam, nChars);
     return nChars;
   }
+  case EM_EXLIMITTEXT:
+    if (wParam != 0 || lParam < 0)
+      return 0;
+    if (lParam == 0)
+      editor->nTextLimit = 65536;
+    else
+      editor->nTextLimit = (int) lParam;
+    return 0;
+  case EM_GETLIMITTEXT:
+    return editor->nTextLimit;
   case EM_FINDTEXT:
   {
     FINDTEXTA *ft = (FINDTEXTA *)lParam;
Index: wine/dlls/riched20/editstr.h
===================================================================
RCS file: /home/wine/wine/dlls/riched20/editstr.h,v
retrieving revision 1.26
diff -u -p -r1.26 editstr.h
--- wine/dlls/riched20/editstr.h	27 Feb 2006 15:35:11 -0000	1.26
+++ wine/dlls/riched20/editstr.h	2 Mar 2006 04:26:30 -0000
@@ -309,6 +309,7 @@ typedef struct tagME_TextEditor
   RECT rcFormat;
   BOOL bRedraw;
   int nInvalidOfs;
+  int nTextLimit;
   EDITWORDBREAKPROCW pfnWordBreak;
   LPRICHEDITOLECALLBACK lpOleCallback;
   /*TEXTMODE variable; contains only one of each of the following options:
Index: wine/dlls/riched20/tests/editor.c
===================================================================
RCS file: /home/wine/wine/dlls/riched20/tests/editor.c,v
retrieving revision 1.9
diff -u -p -r1.9 editor.c
--- wine/dlls/riched20/tests/editor.c	27 Feb 2006 15:35:12 -0000	1.9
+++ wine/dlls/riched20/tests/editor.c	2 Mar 2006 04:26:32 -0000
@@ -677,6 +677,90 @@ static void test_EM_SCROLL()
   DestroyWindow(hwndRichEdit);
 }
 
+static void test_EM_EXLIMITTEXT(void)
+{
+  int i, selBegin, selEnd, len1, len2;
+  int BUFSIZE = 1024;
+  char text[BUFSIZE+1];
+  int textlimit = 0; /* multiple of 100 */
+  HWND hwndRichEdit = new_richedit(NULL);
+  
+  i = SendMessage(hwndRichEdit, EM_GETLIMITTEXT, 0, 0);
+  ok(32767 == i, "expected: %d, actual: %d\n", 32767, i); /* default */
+  
+  textlimit = 256000;
+  SendMessage(hwndRichEdit, EM_EXLIMITTEXT, 0, textlimit);
+  i = SendMessage(hwndRichEdit, EM_GETLIMITTEXT, 0, 0);
+  /* set higher */
+  ok(textlimit == i, "expected: %d, actual: %d\n", textlimit, i);
+  
+  textlimit = 1000;
+  SendMessage(hwndRichEdit, EM_EXLIMITTEXT, 0, textlimit);
+  i = SendMessage(hwndRichEdit, EM_GETLIMITTEXT, 0, 0);
+  /* set lower */
+  ok(textlimit == i, "expected: %d, actual: %d\n", textlimit, i);
+  
+  SendMessage(hwndRichEdit, EM_EXLIMITTEXT, 0, 0);
+  i = SendMessage(hwndRichEdit, EM_GETLIMITTEXT, 0, 0);
+  /* default for WParam = 0 */
+  ok(65536 == i, "expected: %d, actual: %d\n", 65536, i);
+ 
+  textlimit = BUFSIZE;
+  memset(text, 'W', textlimit);
+  text[BUFSIZE] = 0;
+  SendMessage(hwndRichEdit, EM_EXLIMITTEXT, 0, textlimit);
+  /* maxed out text */
+  SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text);
+  
+  SendMessage(hwndRichEdit, EM_SETSEL, 0, -1);  /* select everything */
+  SendMessage(hwndRichEdit, EM_GETSEL, (WPARAM)&selBegin, (LPARAM)&selEnd);
+  len1 = selEnd - selBegin;
+  
+  SendMessage(hwndRichEdit, WM_KEYDOWN, VK_BACK, 1);
+  SendMessage(hwndRichEdit, WM_CHAR, VK_BACK, 1);
+  SendMessage(hwndRichEdit, WM_KEYUP, VK_BACK, 1);
+  SendMessage(hwndRichEdit, EM_SETSEL, 0, -1);
+  SendMessage(hwndRichEdit, EM_GETSEL, (WPARAM)&selBegin, (LPARAM)&selEnd);
+  len2 = selEnd - selBegin;
+  
+  ok(len1 == len2, "change expected\n",i);
+  
+  SendMessage(hwndRichEdit, WM_KEYDOWN, 'A', 1);
+  SendMessage(hwndRichEdit, WM_CHAR, 'A', 1);
+  SendMessage(hwndRichEdit, WM_KEYUP, 'A', 1);
+  SendMessage(hwndRichEdit, EM_SETSEL, 0, -1);
+  SendMessage(hwndRichEdit, EM_GETSEL, (WPARAM)&selBegin, (LPARAM)&selEnd);
+  len1 = selEnd - selBegin;
+  
+  ok(len1 == len2, "change expected\n",i);
+  
+  SendMessage(hwndRichEdit, WM_KEYDOWN, 'A', 1);
+  SendMessage(hwndRichEdit, WM_CHAR, 'A', 1);
+  SendMessage(hwndRichEdit, WM_KEYUP, 'A', 1);  /* full; should be no effect */
+  SendMessage(hwndRichEdit, EM_SETSEL, 0, -1);
+  SendMessage(hwndRichEdit, EM_GETSEL, (WPARAM)&selBegin, (LPARAM)&selEnd);
+  len2 = selEnd - selBegin;
+  
+  ok(len1 != len2, "no change expected\n",i);
+
+  DestroyWindow(hwndRichEdit);
+}
+
+static void test_EM_GETLIMITTEXT(void)
+{
+  int i;
+  HWND hwndRichEdit = new_richedit(NULL);
+
+  i = SendMessage(hwndRichEdit, EM_GETLIMITTEXT, 0, 0);
+  ok(32767 == i, "expected: %d, actual: %d\n", 32767, i); /* default value */
+
+  SendMessage(hwndRichEdit, EM_EXLIMITTEXT, 0, 50000);
+  i = SendMessage(hwndRichEdit, EM_GETLIMITTEXT, 0, 0);
+  ok(50000 == i, "expected: %d, actual: %d\n", 50000, i);
+
+  DestroyWindow(hwndRichEdit);
+}
+
 START_TEST( editor )
 {
   MSG msg;
@@ -694,6 +778,8 @@ START_TEST( editor )
   test_TM_PLAINTEXT();
   test_EM_SETOPTIONS();
   test_WM_GETTEXT();
+  test_EM_EXLIMITTEXT();
+  test_EM_GETLIMITTEXT();
 
   /* Set the environment variable WINETEST_RICHED20 to keep windows
    * responsive and open for 30 seconds. This is useful for debugging.



More information about the wine-patches mailing list