Module: wine Branch: master Commit: e8aa9dee561979ac8fd0b3770f535120f201b136 URL: http://source.winehq.org/git/wine.git/?a=commit;h=e8aa9dee561979ac8fd0b3770f...
Author: Alex Villacís Lasso a_villacis@palosanto.com Date: Sat Apr 26 20:37:50 2008 -0500
richedit: Modify ME_GetTextW() to honor CR and LF encodings.
ME_GetTextLengthEx should ignore GTL_USECRLF in 1.0 emulation mode.
---
dlls/riched20/caret.c | 4 +++- dlls/riched20/editor.c | 31 +++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index 56cd2b1..a8e51db 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -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) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 01502bf..4ba23a5 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -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