Commit e8aa9dee authored by Alex Villacís Lasso's avatar Alex Villacís Lasso Committed by Alexandre Julliard

richedit: Modify ME_GetTextW() to honor CR and LF encodings.

ME_GetTextLengthEx should ignore GTL_USECRLF in 1.0 emulation mode.
parent d95cbeef
......@@ -57,7 +57,9 @@ int ME_GetTextLengthEx(ME_TextEditor *editor, const GETTEXTLENGTHEX *how)
length = ME_GetTextLength(editor);
if ((GetWindowLongW(editor->hWnd, GWL_STYLE) & ES_MULTILINE) && (how->flags & GTL_USECRLF))
if ((GetWindowLongW(editor->hWnd, GWL_STYLE) & ES_MULTILINE)
&& (how->flags & GTL_USECRLF)
&& !editor->bEmulateVersion10) /* Ignore GTL_USECRLF flag in 1.0 emulation */
length += editor->nParagraphs - 1;
if (how->flags & GTL_NUMBYTES)
......
......@@ -3376,6 +3376,9 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int nStart, int nChars, in
return 0;
}
/* bCRLF flag is only honored in 2.0 and up. 1.0 must always return text verbatim */
if (editor->bEmulateVersion10) bCRLF = 0;
if (nStart)
{
int nLen = ME_StrLen(item->member.run.strText) - nStart;
......@@ -3394,6 +3397,8 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int nStart, int nChars, in
while(nChars && item)
{
int nLen = ME_StrLen(item->member.run.strText);
if (item->member.run.nFlags & MERF_ENDPARA)
nLen = item->member.run.nCR + item->member.run.nLF;
if (nLen > nChars)
nLen = nChars;
......@@ -3406,16 +3411,30 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int nStart, int nChars, in
nLen = 0;
nChars = 0;
} else {
*buffer = '\r';
if (bCRLF)
{
*(++buffer) = '\n';
/* richedit 2.0 case - actual line-break is \r but should report \r\n */
assert(nLen == 1);
*buffer++ = '\r';
*buffer = '\n'; /* Later updated by nLen==1 at the end of the loop */
nWritten++;
}
assert(nLen == 1);
/* our end paragraph consists of 2 characters now */
if (editor->bEmulateVersion10)
nChars--;
else
{
int i, j;
/* richedit 2.0 verbatim has only \r. richedit 1.0 should honor encodings */
i = 0;
while (nChars - i > 0 && i < item->member.run.nCR)
{
buffer[i] = '\r'; i++;
}
j = 0;
while (nChars - i - j > 0 && j < item->member.run.nLF)
{
buffer[i+j] = '\n'; j++;
}
}
}
}
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment