From dbcf2e391c684e8e364e29993a8d7ef93668bad4 Mon Sep 17 00:00:00 2001 From: Matt Finnicum Date: Tue, 23 Jan 2007 13:39:38 -0600 Subject: [PATCH] riched20: Implement EM_LIMITTEXT and some simple tests. --- dlls/riched20/editor.c | 11 ++++++++-- dlls/riched20/tests/editor.c | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 561574fb37f..a06d2f46040 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -77,7 +77,7 @@ - EM_GETWORDWRAPMODE 1.0asian + EM_GETZOOM 3.0 + EM_HIDESELECTION - - EM_LIMITTEXT + + EM_LIMITTEXT (Also called EM_SETLIMITTEXT) + EM_LINEFROMCHAR + EM_LINEINDEX + EM_LINELENGTH @@ -1429,7 +1429,6 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP UNSUPPORTED_MSG(EM_GETTYPOGRAPHYOPTIONS) UNSUPPORTED_MSG(EM_GETUNDONAME) UNSUPPORTED_MSG(EM_GETWORDBREAKPROCEX) - UNSUPPORTED_MSG(EM_LIMITTEXT) /* also known as EM_SETLIMITTEXT */ UNSUPPORTED_MSG(EM_PASTESPECIAL) UNSUPPORTED_MSG(EM_SELECTIONTYPE) UNSUPPORTED_MSG(EM_SETBIDIOPTIONS) @@ -2185,6 +2184,14 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP editor->nTextLimit = (int) lParam; return 0; } + case EM_LIMITTEXT: + { + if (wParam == 0) + editor->nTextLimit = 65536; + else + editor->nTextLimit = (int) wParam; + return 0; + } case EM_GETLIMITTEXT: { return editor->nTextLimit; diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 6bae95bcfb4..f86ca5a7f18 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -2,6 +2,7 @@ * Unit test suite for rich edit control * * Copyright 2006 Google (Thomas Kho) +* Copyright 2007 Matt Finnicum * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -975,6 +976,45 @@ static void test_EM_SETTEXTEX(void) DestroyWindow(hwndRichEdit); } +static void test_EM_LIMITTEXT(void) +{ + int ret; + + HWND hwndRichEdit = new_richedit(NULL); + + /* The main purpose of this test is to demonstrate that the nonsense in MSDN + * about setting the length to -1 for multiline edit controls doesn't happen. + */ + + /* Don't check default gettextlimit case. That's done in other tests */ + + /* Set textlimit to 100 */ + SendMessage (hwndRichEdit, EM_LIMITTEXT, 100, 0); + ret = SendMessage (hwndRichEdit, EM_GETLIMITTEXT, 0, 0); + ok (ret == 100, + "EM_LIMITTEXT: set to 100, returned: %d, expected: 100\n", ret); + + /* Set textlimit to 0 */ + SendMessage (hwndRichEdit, EM_LIMITTEXT, 0, 0); + ret = SendMessage (hwndRichEdit, EM_GETLIMITTEXT, 0, 0); + ok (ret == 65536, + "EM_LIMITTEXT: set to 0, returned: %d, expected: 65536\n", ret); + + /* Set textlimit to -1 */ + SendMessage (hwndRichEdit, EM_LIMITTEXT, -1, 0); + ret = SendMessage (hwndRichEdit, EM_GETLIMITTEXT, 0, 0); + ok (ret == -1, + "EM_LIMITTEXT: set to -1, returned: %d, expected: -1\n", ret); + + /* Set textlimit to -2 */ + SendMessage (hwndRichEdit, EM_LIMITTEXT, -2, 0); + ret = SendMessage (hwndRichEdit, EM_GETLIMITTEXT, 0, 0); + ok (ret == -2, + "EM_LIMITTEXT: set to -2, returned: %d, expected: -2\n", ret); + + DestroyWindow (hwndRichEdit); +} + static void test_EM_EXLIMITTEXT(void) { @@ -1443,6 +1483,7 @@ START_TEST( editor ) test_EM_SETUNDOLIMIT(); test_ES_PASSWORD(); test_EM_SETTEXTEX(); + test_EM_LIMITTEXT(); test_EM_EXLIMITTEXT(); test_EM_GETLIMITTEXT(); test_WM_SETFONT();