riched20: Pass the character ptr and string length directly to the break proc helper.

This commit is contained in:
Huw Davies 2013-02-04 09:53:38 +00:00 committed by Alexandre Julliard
parent bf6bb4fc70
commit 48b9ab37ac
3 changed files with 18 additions and 16 deletions

View File

@ -680,19 +680,21 @@ ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
/* Backward movement */
while (TRUE)
{
nOffset = ME_CallWordBreakProc(editor, pRun->member.run.strText,
nOffset, WB_MOVEWORDLEFT);
nOffset = ME_CallWordBreakProc(editor, get_text( &pRun->member.run, 0 ),
pRun->member.run.len, nOffset, WB_MOVEWORDLEFT);
if (nOffset)
break;
pOtherRun = ME_FindItemBack(pRun, diRunOrParagraph);
if (pOtherRun->type == diRun)
{
if (ME_CallWordBreakProc(editor, pOtherRun->member.run.strText,
if (ME_CallWordBreakProc(editor, get_text( &pOtherRun->member.run, 0 ),
pOtherRun->member.run.len,
pOtherRun->member.run.len - 1,
WB_ISDELIMITER)
&& !(pRun->member.run.nFlags & MERF_ENDPARA)
&& !(cursor->pRun == pRun && cursor->nOffset == 0)
&& !ME_CallWordBreakProc(editor, pRun->member.run.strText, 0,
&& !ME_CallWordBreakProc(editor, get_text( &pRun->member.run, 0 ),
pRun->member.run.len, 0,
WB_ISDELIMITER))
break;
pRun = pOtherRun;
@ -724,18 +726,18 @@ ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
while (TRUE)
{
if (last_delim && !ME_CallWordBreakProc(editor, pRun->member.run.strText,
nOffset, WB_ISDELIMITER))
if (last_delim && !ME_CallWordBreakProc(editor, get_text( &pRun->member.run, 0 ),
pRun->member.run.len, nOffset, WB_ISDELIMITER))
break;
nOffset = ME_CallWordBreakProc(editor, pRun->member.run.strText,
nOffset, WB_MOVEWORDRIGHT);
nOffset = ME_CallWordBreakProc(editor, get_text( &pRun->member.run, 0 ),
pRun->member.run.len, nOffset, WB_MOVEWORDRIGHT);
if (nOffset < pRun->member.run.len)
break;
pOtherRun = ME_FindItemFwd(pRun, diRunOrParagraphOrEnd);
if (pOtherRun->type == diRun)
{
last_delim = ME_CallWordBreakProc(editor, pRun->member.run.strText,
nOffset - 1, WB_ISDELIMITER);
last_delim = ME_CallWordBreakProc(editor, get_text( &pRun->member.run, 0 ),
pRun->member.run.len, nOffset - 1, WB_ISDELIMITER);
pRun = pOtherRun;
nOffset = 0;
}

View File

@ -105,7 +105,7 @@ void ME_DestroyString(ME_String *s) DECLSPEC_HIDDEN;
void ME_AppendString(ME_String *s1, const ME_String *s2) DECLSPEC_HIDDEN;
ME_String *ME_VSplitString(ME_String *orig, int nVPos) DECLSPEC_HIDDEN;
int ME_FindNonWhitespaceV(const ME_String *s, int nVChar) DECLSPEC_HIDDEN;
int ME_CallWordBreakProc(ME_TextEditor *editor, ME_String *str, INT start, INT code) DECLSPEC_HIDDEN;
int ME_CallWordBreakProc(ME_TextEditor *editor, WCHAR *str, INT len, INT start, INT code) DECLSPEC_HIDDEN;
void ME_StrDeleteV(ME_String *s, int nVChar, int nChars) DECLSPEC_HIDDEN;
/* smart helpers for A<->W conversions, they reserve/free memory and call MultiByte<->WideChar functions */
LPWSTR ME_ToUnicode(BOOL unicode, LPVOID psz) DECLSPEC_HIDDEN;

View File

@ -180,20 +180,20 @@ ME_WordBreakProc(LPWSTR s, INT start, INT len, INT code)
int
ME_CallWordBreakProc(ME_TextEditor *editor, ME_String *str, INT start, INT code)
ME_CallWordBreakProc(ME_TextEditor *editor, WCHAR *str, INT len, INT start, INT code)
{
if (!editor->pfnWordBreak) {
return ME_WordBreakProc(str->szData, start, str->nLen*sizeof(WCHAR), code);
return ME_WordBreakProc(str, start, len * sizeof(WCHAR), code);
} else if (!editor->bEmulateVersion10) {
/* MSDN lied about the third parameter for EditWordBreakProc being the number
* of characters, it is actually the number of bytes of the string. */
return editor->pfnWordBreak(str->szData, start, str->nLen*sizeof(WCHAR), code);
return editor->pfnWordBreak(str, start, len * sizeof(WCHAR), code);
} else {
int result;
int buffer_size = WideCharToMultiByte(CP_ACP, 0, str->szData, str->nLen,
int buffer_size = WideCharToMultiByte(CP_ACP, 0, str, len,
NULL, 0, NULL, NULL);
char *buffer = heap_alloc(buffer_size);
WideCharToMultiByte(CP_ACP, 0, str->szData, str->nLen,
WideCharToMultiByte(CP_ACP, 0, str, len,
buffer, buffer_size, NULL, NULL);
result = editor->pfnWordBreak((WCHAR*)buffer, start, buffer_size, code);
heap_free(buffer);