riched20: Add a length return parameter to ME_ToUnicode.
This commit is contained in:
parent
dea4f7bc02
commit
1cbdb2aff7
@ -3276,8 +3276,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
|
|||||||
{
|
{
|
||||||
LPWSTR wszText;
|
LPWSTR wszText;
|
||||||
SETTEXTEX *pStruct = (SETTEXTEX *)wParam;
|
SETTEXTEX *pStruct = (SETTEXTEX *)wParam;
|
||||||
size_t len = 0;
|
int from, to, len;
|
||||||
int from, to;
|
|
||||||
ME_Style *style;
|
ME_Style *style;
|
||||||
BOOL bRtf, bUnicode, bSelection;
|
BOOL bRtf, bUnicode, bSelection;
|
||||||
int oldModify = editor->nModifyStep;
|
int oldModify = editor->nModifyStep;
|
||||||
@ -3315,8 +3314,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* FIXME: make use of pStruct->codepage in the to unicode translation */
|
/* FIXME: make use of pStruct->codepage in the to unicode translation */
|
||||||
wszText = lParam ? ME_ToUnicode(bUnicode, (void *)lParam) : NULL;
|
wszText = ME_ToUnicode(bUnicode, (void *)lParam, &len);
|
||||||
len = wszText ? lstrlenW(wszText) : 0;
|
|
||||||
ME_InsertTextFromCursor(editor, 0, wszText, len, style);
|
ME_InsertTextFromCursor(editor, 0, wszText, len, style);
|
||||||
ME_EndToUnicode(bUnicode, wszText);
|
ME_EndToUnicode(bUnicode, wszText);
|
||||||
}
|
}
|
||||||
@ -3505,8 +3503,8 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
|
|||||||
{
|
{
|
||||||
int from, to, nStartCursor;
|
int from, to, nStartCursor;
|
||||||
ME_Style *style;
|
ME_Style *style;
|
||||||
LPWSTR wszText = lParam ? ME_ToUnicode(unicode, (void *)lParam) : NULL;
|
int len = 0;
|
||||||
size_t len = wszText ? lstrlenW(wszText) : 0;
|
LPWSTR wszText = ME_ToUnicode(unicode, (void *)lParam, &len);
|
||||||
TRACE("EM_REPLACESEL - %s\n", debugstr_w(wszText));
|
TRACE("EM_REPLACESEL - %s\n", debugstr_w(wszText));
|
||||||
|
|
||||||
nStartCursor = ME_GetSelectionOfs(editor, &from, &to);
|
nStartCursor = ME_GetSelectionOfs(editor, &from, &to);
|
||||||
@ -3576,9 +3574,10 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LPWSTR wszText = ME_ToUnicode(unicode, (void *)lParam);
|
int textLen;
|
||||||
|
LPWSTR wszText = ME_ToUnicode(unicode, (void *)lParam, &textLen);
|
||||||
TRACE("WM_SETTEXT - %s\n", debugstr_w(wszText)); /* debugstr_w() */
|
TRACE("WM_SETTEXT - %s\n", debugstr_w(wszText)); /* debugstr_w() */
|
||||||
if (lstrlenW(wszText) > 0)
|
if (textLen > 0)
|
||||||
{
|
{
|
||||||
int len = -1;
|
int len = -1;
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ void ME_StrDeleteV(ME_String *s, int nVChar, int nChars) DECLSPEC_HIDDEN;
|
|||||||
BOOL ME_InsertString(ME_String *s, int ofs, const WCHAR *insert, int len) DECLSPEC_HIDDEN;
|
BOOL ME_InsertString(ME_String *s, int ofs, const WCHAR *insert, int len) 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, INT *len) DECLSPEC_HIDDEN;
|
||||||
void ME_EndToUnicode(BOOL unicode, LPVOID psz) DECLSPEC_HIDDEN;
|
void ME_EndToUnicode(BOOL unicode, LPVOID psz) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
static inline int ME_IsWSpace(WCHAR ch)
|
static inline int ME_IsWSpace(WCHAR ch)
|
||||||
|
@ -172,17 +172,24 @@ ME_CallWordBreakProc(ME_TextEditor *editor, WCHAR *str, INT len, INT start, INT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LPWSTR ME_ToUnicode(BOOL unicode, LPVOID psz)
|
LPWSTR ME_ToUnicode(BOOL unicode, LPVOID psz, INT *len)
|
||||||
{
|
{
|
||||||
assert(psz != NULL);
|
*len = 0;
|
||||||
|
if (!psz) return NULL;
|
||||||
|
|
||||||
if (unicode)
|
if (unicode)
|
||||||
|
{
|
||||||
|
*len = lstrlenW(psz);
|
||||||
return psz;
|
return psz;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
WCHAR *tmp;
|
WCHAR *tmp;
|
||||||
int nChars = MultiByteToWideChar(CP_ACP, 0, psz, -1, NULL, 0);
|
int nChars = MultiByteToWideChar(CP_ACP, 0, psz, -1, NULL, 0);
|
||||||
|
|
||||||
|
if(!nChars) return NULL;
|
||||||
|
|
||||||
if((tmp = ALLOC_N_OBJ(WCHAR, nChars)) != NULL)
|
if((tmp = ALLOC_N_OBJ(WCHAR, nChars)) != NULL)
|
||||||
MultiByteToWideChar(CP_ACP, 0, psz, -1, tmp, nChars);
|
*len = MultiByteToWideChar(CP_ACP, 0, psz, -1, tmp, nChars) - 1;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user