Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
efbde389
Commit
efbde389
authored
Jan 19, 2012
by
Jason Edmeades
Committed by
Alexandre Julliard
Jan 23, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
richedit: v1.0 richedit uses CR and LF for enter.
parent
9422c193
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
235 additions
and
2 deletions
+235
-2
editor.c
dlls/riched20/editor.c
+5
-1
editor.c
dlls/riched20/tests/editor.c
+109
-0
editor.c
dlls/riched32/tests/editor.c
+121
-1
No files found.
dlls/riched20/editor.c
View file @
efbde389
...
...
@@ -2180,6 +2180,7 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
ME_DisplayItem
*
para
=
cursor
.
pPara
;
int
from
,
to
;
const
WCHAR
endl
=
'\r'
;
const
WCHAR
endlv10
[]
=
{
'\r'
,
'\n'
};
ME_Style
*
style
;
if
(
editor
->
styleFlags
&
ES_READONLY
)
{
...
...
@@ -2282,7 +2283,10 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
if
(
shift_is_down
)
ME_InsertEndRowFromCursor
(
editor
,
0
);
else
ME_InsertTextFromCursor
(
editor
,
0
,
&
endl
,
1
,
style
);
if
(
!
editor
->
bEmulateVersion10
)
ME_InsertTextFromCursor
(
editor
,
0
,
&
endl
,
1
,
style
);
else
ME_InsertTextFromCursor
(
editor
,
0
,
endlv10
,
2
,
style
);
ME_ReleaseStyle
(
style
);
ME_CommitCoalescingUndo
(
editor
);
SetCursor
(
NULL
);
...
...
dlls/riched20/tests/editor.c
View file @
efbde389
...
...
@@ -7172,6 +7172,114 @@ static void test_EM_FINDWORDBREAK_A(void)
DestroyWindow
(
hwndRichEdit
);
}
/*
* This test attempts to show the effect of enter on a richedit
* control v1.0 inserts CRLF whereas for higher versions it only
* inserts CR. If shows that EM_GETTEXTEX with GT_USECRLF == WM_GETTEXT
* and also shows that GT_USECRLF has no effect in richedit 1.0, but
* does for higher. The same test is cloned in riched32 and riched20.
*/
static
void
test_enter
(
void
)
{
static
const
struct
{
const
char
*
initialtext
;
const
int
cursor
;
const
char
*
expectedwmtext
;
const
char
*
expectedemtext
;
const
char
*
expectedemtextcrlf
;
}
testenteritems
[]
=
{
{
"aaabbb
\r\n
"
,
3
,
"aaa
\r\n
bbb
\r\n
"
,
"aaa
\r
bbb
\r
"
,
"aaa
\r\n
bbb
\r\n
"
},
{
"aaabbb
\r\n
"
,
6
,
"aaabbb
\r\n\r\n
"
,
"aaabbb
\r\r
"
,
"aaabbb
\r\n\r\n
"
},
{
"aa
\r
abbb
\r\n
"
,
7
,
"aa
\r\n
abbb
\r\n\r\n
"
,
"aa
\r
abbb
\r\r
"
,
"aa
\r\n
abbb
\r\n\r\n
"
},
{
"aa
\r
abbb
\r\n
"
,
3
,
"aa
\r\n\r\n
abbb
\r\n
"
,
"aa
\r\r
abbb
\r
"
,
"aa
\r\n\r\n
abbb
\r\n
"
},
{
"aa
\r
abbb
\r\n
"
,
2
,
"aa
\r\n\r\n
abbb
\r\n
"
,
"aa
\r\r
abbb
\r
"
,
"aa
\r\n\r\n
abbb
\r\n
"
}
};
char
expectedbuf
[
1024
];
char
resultbuf
[
1024
];
HWND
hwndRichEdit
=
new_richedit
(
NULL
);
UINT
i
,
j
;
for
(
i
=
0
;
i
<
sizeof
(
testenteritems
)
/
sizeof
(
testenteritems
[
0
]);
i
++
)
{
char
buf
[
1024
]
=
{
0
};
LRESULT
result
;
GETTEXTEX
getText
;
const
char
*
expected
;
/* Set the text to the initial text */
result
=
SendMessage
(
hwndRichEdit
,
WM_SETTEXT
,
0
,
(
LPARAM
)
testenteritems
[
i
].
initialtext
);
ok
(
result
==
1
,
"[%d] WM_SETTEXT returned %ld instead of 1
\n
"
,
i
,
result
);
/* Send Enter */
SendMessage
(
hwndRichEdit
,
EM_SETSEL
,
testenteritems
[
i
].
cursor
,
testenteritems
[
i
].
cursor
);
simulate_typing_characters
(
hwndRichEdit
,
"
\r
"
);
/* 1. Retrieve with WM_GETTEXT */
buf
[
0
]
=
0x00
;
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buf
);
expected
=
testenteritems
[
i
].
expectedwmtext
;
resultbuf
[
0
]
=
0x00
;
for
(
j
=
0
;
j
<
(
UINT
)
result
;
j
++
)
sprintf
(
resultbuf
+
strlen
(
resultbuf
),
"%02x"
,
buf
[
j
]
&
0xFF
);
expectedbuf
[
0
]
=
'\0'
;
for
(
j
=
0
;
j
<
strlen
(
expected
);
j
++
)
sprintf
(
expectedbuf
+
strlen
(
expectedbuf
),
"%02x"
,
expected
[
j
]
&
0xFF
);
result
=
strcmp
(
expected
,
buf
);
ok
(
result
==
0
,
"[%d] WM_GETTEXT unexpected '%s' expected '%s'
\n
"
,
i
,
resultbuf
,
expectedbuf
);
/* 2. Retrieve with EM_GETTEXTEX, GT_DEFAULT */
getText
.
cb
=
sizeof
(
buf
);
getText
.
flags
=
GT_DEFAULT
;
getText
.
codepage
=
CP_ACP
;
getText
.
lpDefaultChar
=
NULL
;
getText
.
lpUsedDefChar
=
NULL
;
buf
[
0
]
=
0x00
;
result
=
SendMessage
(
hwndRichEdit
,
EM_GETTEXTEX
,
(
WPARAM
)
&
getText
,
(
LPARAM
)
buf
);
expected
=
testenteritems
[
i
].
expectedemtext
;
resultbuf
[
0
]
=
0x00
;
for
(
j
=
0
;
j
<
(
UINT
)
result
;
j
++
)
sprintf
(
resultbuf
+
strlen
(
resultbuf
),
"%02x"
,
buf
[
j
]
&
0xFF
);
expectedbuf
[
0
]
=
'\0'
;
for
(
j
=
0
;
j
<
strlen
(
expected
);
j
++
)
sprintf
(
expectedbuf
+
strlen
(
expectedbuf
),
"%02x"
,
expected
[
j
]
&
0xFF
);
result
=
strcmp
(
expected
,
buf
);
ok
(
result
==
0
,
"[%d] EM_GETTEXTEX, GT_DEFAULT unexpected '%s', expected '%s'
\n
"
,
i
,
resultbuf
,
expectedbuf
);
/* 3. Retrieve with EM_GETTEXTEX, GT_USECRLF */
getText
.
cb
=
sizeof
(
buf
);
getText
.
flags
=
GT_USECRLF
;
getText
.
codepage
=
CP_ACP
;
getText
.
lpDefaultChar
=
NULL
;
getText
.
lpUsedDefChar
=
NULL
;
buf
[
0
]
=
0x00
;
result
=
SendMessage
(
hwndRichEdit
,
EM_GETTEXTEX
,
(
WPARAM
)
&
getText
,
(
LPARAM
)
buf
);
expected
=
testenteritems
[
i
].
expectedemtextcrlf
;
resultbuf
[
0
]
=
0x00
;
for
(
j
=
0
;
j
<
(
UINT
)
result
;
j
++
)
sprintf
(
resultbuf
+
strlen
(
resultbuf
),
"%02x"
,
buf
[
j
]
&
0xFF
);
expectedbuf
[
0
]
=
'\0'
;
for
(
j
=
0
;
j
<
strlen
(
expected
);
j
++
)
sprintf
(
expectedbuf
+
strlen
(
expectedbuf
),
"%02x"
,
expected
[
j
]
&
0xFF
);
result
=
strcmp
(
expected
,
buf
);
ok
(
result
==
0
,
"[%d] EM_GETTEXTEX, GT_USECRLF unexpected '%s', expected '%s'
\n
"
,
i
,
resultbuf
,
expectedbuf
);
}
DestroyWindow
(
hwndRichEdit
);
}
START_TEST
(
editor
)
{
BOOL
ret
;
...
...
@@ -7230,6 +7338,7 @@ START_TEST( editor )
test_dialogmode
();
test_EM_FINDWORDBREAK_W
();
test_EM_FINDWORDBREAK_A
();
test_enter
();
/* Set the environment variable WINETEST_RICHED20 to keep windows
* responsive and open for 30 seconds. This is useful for debugging.
...
...
dlls/riched32/tests/editor.c
View file @
efbde389
...
...
@@ -22,7 +22,7 @@
*/
#include <stdarg.h>
#include <stdio.h>
#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
...
...
@@ -1081,6 +1081,125 @@ static void test_autoscroll(void)
DestroyWindow
(
hwnd
);
}
static
void
simulate_typing_characters
(
HWND
hwnd
,
const
char
*
szChars
)
{
int
ret
;
while
(
*
szChars
!=
'\0'
)
{
SendMessageA
(
hwnd
,
WM_KEYDOWN
,
*
szChars
,
1
);
ret
=
SendMessageA
(
hwnd
,
WM_CHAR
,
*
szChars
,
1
);
ok
(
ret
==
0
,
"WM_CHAR('%c') ret=%d
\n
"
,
*
szChars
,
ret
);
SendMessageA
(
hwnd
,
WM_KEYUP
,
*
szChars
,
1
);
szChars
++
;
}
}
/*
* This test attempts to show the effect of enter on a richedit
* control v1.0 inserts CRLF whereas for higher versions it only
* inserts CR. If shows that EM_GETTEXTEX with GT_USECRLF == WM_GETTEXT
* and also shows that GT_USECRLF has no effect in richedit 1.0, but
* does for higher. The same test is cloned in riched32 and riched20.
*/
static
void
test_enter
(
void
)
{
static
const
struct
{
const
char
*
initialtext
;
const
int
cursor
;
const
char
*
expectedtext
;
}
testenteritems
[]
=
{
{
"aaabbb
\r\n
"
,
3
,
"aaa
\r\n
bbb
\r\n
"
},
{
"aaabbb
\r\n
"
,
6
,
"aaabbb
\r\n\r\n
"
},
{
"aa
\r
abbb
\r\n
"
,
7
,
"aa
\r
abbb
\r\n\r\n
"
},
{
"aa
\r
abbb
\r\n
"
,
3
,
"aa
\r\r\n
abbb
\r\n
"
},
{
"aa
\r
abbb
\r\n
"
,
2
,
"aa
\r\n\r
abbb
\r\n
"
}
};
char
expectedbuf
[
1024
];
char
resultbuf
[
1024
];
HWND
hwndRichEdit
=
new_richedit
(
NULL
);
UINT
i
,
j
;
for
(
i
=
0
;
i
<
sizeof
(
testenteritems
)
/
sizeof
(
testenteritems
[
0
]);
i
++
)
{
char
buf
[
1024
]
=
{
0
};
LRESULT
result
;
GETTEXTEX
getText
;
const
char
*
expected
;
/* Set the text to the initial text */
result
=
SendMessage
(
hwndRichEdit
,
WM_SETTEXT
,
0
,
(
LPARAM
)
testenteritems
[
i
].
initialtext
);
ok
(
result
==
1
,
"[%d] WM_SETTEXT returned %ld instead of 1
\n
"
,
i
,
result
);
/* Send Enter */
SendMessage
(
hwndRichEdit
,
EM_SETSEL
,
testenteritems
[
i
].
cursor
,
testenteritems
[
i
].
cursor
);
simulate_typing_characters
(
hwndRichEdit
,
"
\r
"
);
/* 1. Retrieve with WM_GETTEXT */
buf
[
0
]
=
0x00
;
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buf
);
expected
=
testenteritems
[
i
].
expectedtext
;
resultbuf
[
0
]
=
0x00
;
for
(
j
=
0
;
j
<
(
UINT
)
result
;
j
++
)
sprintf
(
resultbuf
+
strlen
(
resultbuf
),
"%02x"
,
buf
[
j
]
&
0xFF
);
expectedbuf
[
0
]
=
'\0'
;
for
(
j
=
0
;
j
<
strlen
(
expected
);
j
++
)
sprintf
(
expectedbuf
+
strlen
(
expectedbuf
),
"%02x"
,
expected
[
j
]
&
0xFF
);
result
=
strcmp
(
expected
,
buf
);
ok
(
result
==
0
,
"[%d] WM_GETTEXT unexpected '%s' expected '%s'
\n
"
,
i
,
resultbuf
,
expectedbuf
);
/* 2. Retrieve with EM_GETTEXTEX, GT_DEFAULT */
getText
.
cb
=
sizeof
(
buf
);
getText
.
flags
=
GT_DEFAULT
;
getText
.
codepage
=
CP_ACP
;
getText
.
lpDefaultChar
=
NULL
;
getText
.
lpUsedDefChar
=
NULL
;
buf
[
0
]
=
0x00
;
result
=
SendMessage
(
hwndRichEdit
,
EM_GETTEXTEX
,
(
WPARAM
)
&
getText
,
(
LPARAM
)
buf
);
expected
=
testenteritems
[
i
].
expectedtext
;
resultbuf
[
0
]
=
0x00
;
for
(
j
=
0
;
j
<
(
UINT
)
result
;
j
++
)
sprintf
(
resultbuf
+
strlen
(
resultbuf
),
"%02x"
,
buf
[
j
]
&
0xFF
);
expectedbuf
[
0
]
=
'\0'
;
for
(
j
=
0
;
j
<
strlen
(
expected
);
j
++
)
sprintf
(
expectedbuf
+
strlen
(
expectedbuf
),
"%02x"
,
expected
[
j
]
&
0xFF
);
result
=
strcmp
(
expected
,
buf
);
ok
(
result
==
0
||
broken
(
buf
[
0
]
==
0x00
/* WinNT4 */
),
"[%d] EM_GETTEXTEX, GT_DEFAULT unexpected '%s', expected '%s'
\n
"
,
i
,
resultbuf
,
expectedbuf
);
/* 3. Retrieve with EM_GETTEXTEX, GT_USECRLF */
getText
.
cb
=
sizeof
(
buf
);
getText
.
flags
=
GT_USECRLF
;
getText
.
codepage
=
CP_ACP
;
getText
.
lpDefaultChar
=
NULL
;
getText
.
lpUsedDefChar
=
NULL
;
buf
[
0
]
=
0x00
;
result
=
SendMessage
(
hwndRichEdit
,
EM_GETTEXTEX
,
(
WPARAM
)
&
getText
,
(
LPARAM
)
buf
);
expected
=
testenteritems
[
i
].
expectedtext
;
resultbuf
[
0
]
=
0x00
;
for
(
j
=
0
;
j
<
(
UINT
)
result
;
j
++
)
sprintf
(
resultbuf
+
strlen
(
resultbuf
),
"%02x"
,
buf
[
j
]
&
0xFF
);
expectedbuf
[
0
]
=
'\0'
;
for
(
j
=
0
;
j
<
strlen
(
expected
);
j
++
)
sprintf
(
expectedbuf
+
strlen
(
expectedbuf
),
"%02x"
,
expected
[
j
]
&
0xFF
);
result
=
strcmp
(
expected
,
buf
);
ok
(
result
==
0
||
broken
(
buf
[
0
]
==
0x00
/* WinNT4 */
),
"[%d] EM_GETTEXTEX, GT_USECRLF unexpected '%s', expected '%s'
\n
"
,
i
,
resultbuf
,
expectedbuf
);
}
DestroyWindow
(
hwndRichEdit
);
}
START_TEST
(
editor
)
{
MSG
msg
;
...
...
@@ -1105,6 +1224,7 @@ START_TEST( editor )
test_word_wrap
();
test_EM_GETOPTIONS
();
test_autoscroll
();
test_enter
();
/* Set the environment variable WINETEST_RICHED32 to keep windows
* responsive and open for 30 seconds. This is useful for debugging.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment