Module: wine
Branch: master
Commit: ba747f4514a7d5bcc70bf6ea592c53cabe09770d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ba747f4514a7d5bcc70bf6ea5…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com>
Date: Wed Jun 25 11:33:19 2008 -0400
richedit: Fixed the forward word movement bug.
Using Ctrl-RightArrow to move to the start of the next word did not
previously work when at the start of a word. This means that
Ctrl-RightArrow would not work twice in a row since it should move to
the start of the next word.
---
dlls/riched20/string.c | 16 ++-------
dlls/riched20/tests/editor.c | 72 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 76 insertions(+), 12 deletions(-)
diff --git a/dlls/riched20/string.c b/dlls/riched20/string.c
index 2ec0092..84efdbe 100644
--- a/dlls/riched20/string.c
+++ b/dlls/riched20/string.c
@@ -317,18 +317,10 @@ ME_WordBreakProc(LPWSTR s, INT start, INT len, INT code)
return start;
case WB_RIGHT:
case WB_MOVEWORDRIGHT:
- if (start && ME_IsWSpace(s[start - 1]))
- {
- while (start < len && ME_IsWSpace(s[start]))
- start++;
- }
- else
- {
- while (start < len && !ME_IsWSpace(s[start]))
- start++;
- while (start < len && ME_IsWSpace(s[start]))
- start++;
- }
+ while (start < len && !ME_IsWSpace(s[start]))
+ start++;
+ while (start < len && ME_IsWSpace(s[start]))
+ start++;
return start;
}
return 0;
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 2de076e..50b69b8 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -4424,6 +4424,77 @@ static void test_undo_coalescing(void)
DestroyWindow(hwnd);
}
+/* Used to simulate a Ctrl-Arrow Key press. */
+#define SEND_CTRL_EXT_KEY(hwnd, vk, scancode) \
+ keybd_event(VK_CONTROL, 0x1d, 0, 0);\
+ keybd_event(vk, scancode, KEYEVENTF_EXTENDEDKEY, 0);\
+ keybd_event(vk, scancode | 0x80, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, 0);\
+ keybd_event(VK_CONTROL, 0x1d | 0x80, KEYEVENTF_KEYUP, 0); \
+ while (PeekMessage(&msg, hwnd, 0, 0, PM_REMOVE)) { \
+ TranslateMessage(&msg); \
+ DispatchMessage(&msg); \
+ }
+#define SEND_CTRL_LEFT(hwnd) SEND_CTRL_EXT_KEY(hwnd, VK_LEFT, 0x4b)
+#define SEND_CTRL_RIGHT(hwnd) SEND_CTRL_EXT_KEY(hwnd, VK_RIGHT, 0x4d)
+
+static void test_word_movement(){
+ HWND hwnd;
+ int result;
+ int sel_start, sel_end;
+ MSG msg;
+
+ /* multi-line control inserts CR normally */
+ hwnd = new_richedit(NULL);
+
+ SendMessage(hwnd, WM_SETFOCUS, (WPARAM)hwnd, 0);
+ result = SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"one two three");
+ ok (result == TRUE, "Failed to clear the text.\n");
+ SendMessage(hwnd, EM_SETSEL, 0, 0);
+ /* |one two three */
+
+ SEND_CTRL_RIGHT(hwnd)
+ /* one |two three */
+ SendMessage(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
+ ok(sel_start == sel_end, "Selection should be empty\n");
+ ok(sel_start == 4, "Cursur is at %d instead of %d\n", sel_start, 4);
+
+ SEND_CTRL_RIGHT(hwnd)
+ /* one two |three */
+ SendMessage(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
+ ok(sel_start == sel_end, "Selection should be empty\n");
+ ok(sel_start == 9, "Cursur is at %d instead of %d\n", sel_start, 9);
+
+ SEND_CTRL_LEFT(hwnd)
+ /* one |two three */
+ SendMessage(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
+ ok(sel_start == sel_end, "Selection should be empty\n");
+ ok(sel_start == 4, "Cursur is at %d instead of %d\n", sel_start, 4);
+
+ SEND_CTRL_LEFT(hwnd)
+ /* |one two three */
+ SendMessage(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
+ ok(sel_start == sel_end, "Selection should be empty\n");
+ ok(sel_start == 0, "Cursur is at %d instead of %d\n", sel_start, 0);
+
+ SendMessage(hwnd, EM_SETSEL, 8, 8);
+ /* one two | three */
+ SEND_CTRL_RIGHT(hwnd)
+ /* one two |three */
+ SendMessage(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
+ ok(sel_start == sel_end, "Selection should be empty\n");
+ ok(sel_start == 9, "Cursur is at %d instead of %d\n", sel_start, 9);
+
+ SendMessage(hwnd, EM_SETSEL, 11, 11);
+ /* one two th|ree */
+ SEND_CTRL_LEFT(hwnd)
+ /* one two |three */
+ SendMessage(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
+ ok(sel_start == sel_end, "Selection should be empty\n");
+ ok(sel_start == 9, "Cursur is at %d instead of %d\n", sel_start, 9);
+
+ DestroyWindow(hwnd);
+}
+
START_TEST( editor )
{
MSG msg;
@@ -4470,6 +4541,7 @@ START_TEST( editor )
test_EM_AUTOURLDETECT();
test_eventMask();
test_undo_coalescing();
+ test_word_movement();
/* Set the environment variable WINETEST_RICHED20 to keep windows
* responsive and open for 30 seconds. This is useful for debugging.
Module: wine
Branch: master
Commit: 67024f0f3448e970aaa75fa4de546cfd8aa0fc44
URL: http://source.winehq.org/git/wine.git/?a=commit;h=67024f0f3448e970aaa75fa4d…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com>
Date: Wed Jun 25 11:33:13 2008 -0400
richedit: Prevented an assertion error on startup when run on Windows.
The call to GetClientRect returns 0 values for the returned RECT when
called in WM_NCCREATE in on Windows, which ended up causing an assertion
error when Wine's riched20.dll replaces the native version. Moving the
call to WM_CREATE fixes this problem (probably because NCCALCSIZE is
called in between).
---
dlls/riched20/editor.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index b9f41d2..e71c384 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -1666,7 +1666,6 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd) {
ed->mode = TM_RICHTEXT | TM_MULTILEVELUNDO | TM_MULTICODEPAGE;
ed->AutoURLDetect_bEnable = FALSE;
ed->bHaveFocus = FALSE;
- GetClientRect(hWnd, &ed->rcFormat);
for (i=0; i<HFONT_CACHE_SIZE; i++)
{
ed->pFontCache[i].nRefs = 0;
@@ -2934,6 +2933,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
return (wParam >= 0x40000) ? 0 : MAKELONG( pt.x, pt.y );
}
case WM_CREATE:
+ GetClientRect(hWnd, &editor->rcFormat);
if (GetWindowLongW(hWnd, GWL_STYLE) & WS_HSCROLL)
{ /* Squelch the default horizontal scrollbar it would make */
ShowScrollBar(editor->hWnd, SB_HORZ, FALSE);