diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index 8181f0a385f..24b37589ca2 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -41,6 +41,38 @@ int ME_GetTextLength(ME_TextEditor *editor) return ME_CharOfsFromRunOfs(editor, ME_FindItemBack(editor->pBuffer->pLast, diRun), 0); } + +int ME_GetTextLengthEx(ME_TextEditor *editor, GETTEXTLENGTHEX *how) +{ + int length; + + if (how->flags & GTL_PRECISE && how->flags & GTL_CLOSE) + return E_INVALIDARG; + if (how->flags & GTL_NUMCHARS && how->flags & GTL_NUMBYTES) + return E_INVALIDARG; + + length = ME_GetTextLength(editor); + + if (how->flags & GTL_USECRLF) + length += editor->nParagraphs; + + if (how->flags & GTL_NUMBYTES) + { + CPINFO cpinfo; + + if (how->codepage == 1200) + return length * 2; + if (how->flags & GTL_PRECISE) + FIXME("GTL_PRECISE flag unsupported. Using GTL_CLOSE\n"); + if (GetCPInfo(how->codepage, &cpinfo)) + return length * cpinfo.MaxCharSize; + ERR("Invalid codepage %u\n", how->codepage); + return E_INVALIDARG; + } + return length; +} + + void ME_SetSelection(ME_TextEditor *editor, int from, int to) { if (from == 0 && to == -1) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 4be3ef4e556..0e4d2b7a11a 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -65,7 +65,7 @@ - EM_GETSCROLLPOS 3.0 ! - EM_GETTHUMB - EM_GETTEXTEX 2.0 - - EM_GETTEXTLENGTHEX + + EM_GETTEXTLENGTHEX (GTL_PRECISE unimplemented) - EM_GETTEXTMODE 2.0 ? + EM_GETTEXTRANGE (ANSI&Unicode) - EM_GETTYPOGRAPHYOPTIONS 3.0 @@ -846,7 +846,6 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP UNSUPPORTED_MSG(EM_GETREDONAME) UNSUPPORTED_MSG(EM_GETSCROLLPOS) UNSUPPORTED_MSG(EM_GETTEXTEX) - UNSUPPORTED_MSG(EM_GETTEXTLENGTHEX) UNSUPPORTED_MSG(EM_GETTEXTMODE) UNSUPPORTED_MSG(EM_GETTYPOGRAPHYOPTIONS) UNSUPPORTED_MSG(EM_GETUNDONAME) @@ -1175,6 +1174,8 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP } case WM_GETTEXTLENGTH: return ME_GetTextLength(editor); + case EM_GETTEXTLENGTHEX: + return ME_GetTextLengthEx(editor, (GETTEXTLENGTHEX *)wParam); case WM_GETTEXT: { TEXTRANGEW tr; /* W and A differ only by rng->lpstrText */ diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index 3a01127bd60..a0eab82c3c9 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -160,6 +160,7 @@ void ME_SendSelChange(ME_TextEditor *editor); void ME_InsertGraphicsFromCursor(ME_TextEditor *editor, int nCursor); void ME_InternalDeleteText(ME_TextEditor *editor, int nOfs, int nChars); int ME_GetTextLength(ME_TextEditor *editor); +int ME_GetTextLengthEx(ME_TextEditor *editor, GETTEXTLENGTHEX *how); ME_Style *ME_GetSelectionInsertStyle(ME_TextEditor *editor); BOOL ME_UpdateSelection(ME_TextEditor *editor, ME_Cursor *pTempCursor);