riched20: Pass the character ptr and string length directly to the break proc helper.
This commit is contained in:
parent
bf6bb4fc70
commit
48b9ab37ac
|
@ -680,19 +680,21 @@ ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
|
||||||
/* Backward movement */
|
/* Backward movement */
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
nOffset = ME_CallWordBreakProc(editor, pRun->member.run.strText,
|
nOffset = ME_CallWordBreakProc(editor, get_text( &pRun->member.run, 0 ),
|
||||||
nOffset, WB_MOVEWORDLEFT);
|
pRun->member.run.len, nOffset, WB_MOVEWORDLEFT);
|
||||||
if (nOffset)
|
if (nOffset)
|
||||||
break;
|
break;
|
||||||
pOtherRun = ME_FindItemBack(pRun, diRunOrParagraph);
|
pOtherRun = ME_FindItemBack(pRun, diRunOrParagraph);
|
||||||
if (pOtherRun->type == diRun)
|
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,
|
pOtherRun->member.run.len - 1,
|
||||||
WB_ISDELIMITER)
|
WB_ISDELIMITER)
|
||||||
&& !(pRun->member.run.nFlags & MERF_ENDPARA)
|
&& !(pRun->member.run.nFlags & MERF_ENDPARA)
|
||||||
&& !(cursor->pRun == pRun && cursor->nOffset == 0)
|
&& !(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))
|
WB_ISDELIMITER))
|
||||||
break;
|
break;
|
||||||
pRun = pOtherRun;
|
pRun = pOtherRun;
|
||||||
|
@ -724,18 +726,18 @@ ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
if (last_delim && !ME_CallWordBreakProc(editor, pRun->member.run.strText,
|
if (last_delim && !ME_CallWordBreakProc(editor, get_text( &pRun->member.run, 0 ),
|
||||||
nOffset, WB_ISDELIMITER))
|
pRun->member.run.len, nOffset, WB_ISDELIMITER))
|
||||||
break;
|
break;
|
||||||
nOffset = ME_CallWordBreakProc(editor, pRun->member.run.strText,
|
nOffset = ME_CallWordBreakProc(editor, get_text( &pRun->member.run, 0 ),
|
||||||
nOffset, WB_MOVEWORDRIGHT);
|
pRun->member.run.len, nOffset, WB_MOVEWORDRIGHT);
|
||||||
if (nOffset < pRun->member.run.len)
|
if (nOffset < pRun->member.run.len)
|
||||||
break;
|
break;
|
||||||
pOtherRun = ME_FindItemFwd(pRun, diRunOrParagraphOrEnd);
|
pOtherRun = ME_FindItemFwd(pRun, diRunOrParagraphOrEnd);
|
||||||
if (pOtherRun->type == diRun)
|
if (pOtherRun->type == diRun)
|
||||||
{
|
{
|
||||||
last_delim = ME_CallWordBreakProc(editor, pRun->member.run.strText,
|
last_delim = ME_CallWordBreakProc(editor, get_text( &pRun->member.run, 0 ),
|
||||||
nOffset - 1, WB_ISDELIMITER);
|
pRun->member.run.len, nOffset - 1, WB_ISDELIMITER);
|
||||||
pRun = pOtherRun;
|
pRun = pOtherRun;
|
||||||
nOffset = 0;
|
nOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ void ME_DestroyString(ME_String *s) DECLSPEC_HIDDEN;
|
||||||
void ME_AppendString(ME_String *s1, const ME_String *s2) 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;
|
ME_String *ME_VSplitString(ME_String *orig, int nVPos) DECLSPEC_HIDDEN;
|
||||||
int ME_FindNonWhitespaceV(const ME_String *s, int nVChar) 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;
|
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 */
|
/* smart helpers for A<->W conversions, they reserve/free memory and call MultiByte<->WideChar functions */
|
||||||
LPWSTR ME_ToUnicode(BOOL unicode, LPVOID psz) DECLSPEC_HIDDEN;
|
LPWSTR ME_ToUnicode(BOOL unicode, LPVOID psz) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -180,20 +180,20 @@ ME_WordBreakProc(LPWSTR s, INT start, INT len, INT code)
|
||||||
|
|
||||||
|
|
||||||
int
|
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) {
|
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) {
|
} else if (!editor->bEmulateVersion10) {
|
||||||
/* MSDN lied about the third parameter for EditWordBreakProc being the number
|
/* MSDN lied about the third parameter for EditWordBreakProc being the number
|
||||||
* of characters, it is actually the number of bytes of the string. */
|
* 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 {
|
} else {
|
||||||
int result;
|
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);
|
NULL, 0, NULL, NULL);
|
||||||
char *buffer = heap_alloc(buffer_size);
|
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);
|
buffer, buffer_size, NULL, NULL);
|
||||||
result = editor->pfnWordBreak((WCHAR*)buffer, start, buffer_size, code);
|
result = editor->pfnWordBreak((WCHAR*)buffer, start, buffer_size, code);
|
||||||
heap_free(buffer);
|
heap_free(buffer);
|
||||||
|
|
Loading…
Reference in New Issue