Reactos

[RICHED20] Sync with Wine Staging 4.18. CORE-16441

+307 -352
+40 -28
dll/win32/riched20/caret.c
··· 122 122 return length; 123 123 } 124 124 125 - 126 - int ME_SetSelection(ME_TextEditor *editor, int from, int to) 125 + /****************************************************************** 126 + * set_selection_cursors 127 + * 128 + * Updates the selection cursors. 129 + * 130 + * Note that this does not invalidate either the old or the new selections. 131 + */ 132 + int set_selection_cursors(ME_TextEditor *editor, int from, int to) 127 133 { 128 134 int selectionEnd = 0; 129 135 const int len = ME_GetTextLength(editor); ··· 139 145 { 140 146 ME_SetCursorToStart(editor, &editor->pCursors[1]); 141 147 ME_SetCursorToEnd(editor, &editor->pCursors[0], TRUE); 142 - ME_InvalidateSelection(editor); 143 148 return len + 1; 144 149 } 145 150 ··· 165 170 end --; 166 171 } 167 172 editor->pCursors[1] = editor->pCursors[0]; 168 - ME_Repaint(editor); 169 173 } 170 174 return end; 171 175 } ··· 194 198 { 195 199 ME_SetCursorToEnd(editor, &editor->pCursors[0], FALSE); 196 200 editor->pCursors[1] = editor->pCursors[0]; 197 - ME_InvalidateSelection(editor); 198 201 return len; 199 202 } 200 203 ··· 266 269 return; 267 270 } 268 271 269 - 270 - void 271 - ME_MoveCaret(ME_TextEditor *editor) 272 + void create_caret(ME_TextEditor *editor) 272 273 { 273 274 int x, y, height; 274 275 275 276 ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height); 276 - if(editor->bHaveFocus && !ME_IsSelection(editor)) 277 - { 278 - x = min(x, editor->rcFormat.right-1); 279 - ITextHost_TxCreateCaret(editor->texthost, NULL, 0, height); 280 - ITextHost_TxSetCaretPos(editor->texthost, x, y); 281 - } 277 + ITextHost_TxCreateCaret(editor->texthost, NULL, 0, height); 278 + editor->caret_height = height; 279 + editor->caret_hidden = TRUE; 282 280 } 283 281 282 + void show_caret(ME_TextEditor *editor) 283 + { 284 + ITextHost_TxShowCaret(editor->texthost, TRUE); 285 + editor->caret_hidden = FALSE; 286 + } 284 287 285 - void ME_ShowCaret(ME_TextEditor *ed) 288 + void hide_caret(ME_TextEditor *editor) 286 289 { 287 - ME_MoveCaret(ed); 288 - if(ed->bHaveFocus && !ME_IsSelection(ed)) 289 - ITextHost_TxShowCaret(ed->texthost, TRUE); 290 + /* calls to HideCaret are cumulative; do so only once */ 291 + if (!editor->caret_hidden) 292 + { 293 + ITextHost_TxShowCaret(editor->texthost, FALSE); 294 + editor->caret_hidden = TRUE; 295 + } 290 296 } 291 297 292 - void ME_HideCaret(ME_TextEditor *ed) 298 + void update_caret(ME_TextEditor *editor) 293 299 { 294 - if(!ed->bHaveFocus || ME_IsSelection(ed)) 300 + int x, y, height; 301 + 302 + if (!editor->bHaveFocus) return; 303 + if (!ME_IsSelection(editor)) 295 304 { 296 - ITextHost_TxShowCaret(ed->texthost, FALSE); 297 - DestroyCaret(); 305 + ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height); 306 + if (height != editor->caret_height) create_caret(editor); 307 + x = min(x, editor->rcFormat.right-1); 308 + ITextHost_TxSetCaretPos(editor->texthost, x, y); 309 + show_caret(editor); 298 310 } 311 + else 312 + hide_caret(editor); 299 313 } 300 314 301 315 BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start, ··· 1200 1214 } 1201 1215 } 1202 1216 ME_InvalidateSelection(editor); 1203 - ITextHost_TxShowCaret(editor->texthost, FALSE); 1204 - ME_ShowCaret(editor); 1217 + update_caret(editor); 1205 1218 ME_SendSelChange(editor); 1206 1219 } 1207 1220 ··· 1233 1246 } 1234 1247 1235 1248 ME_InvalidateSelection(editor); 1236 - ITextHost_TxShowCaret(editor->texthost, FALSE); 1237 - ME_ShowCaret(editor); 1249 + update_caret(editor); 1238 1250 ME_SendSelChange(editor); 1239 1251 } 1240 1252 ··· 1627 1639 1628 1640 ME_InvalidateSelection(editor); 1629 1641 ME_Repaint(editor); 1630 - ITextHost_TxShowCaret(editor->texthost, FALSE); 1642 + hide_caret(editor); 1631 1643 ME_EnsureVisible(editor, &tmp_curs); 1632 - ME_ShowCaret(editor); 1644 + update_caret(editor); 1633 1645 ME_SendSelChange(editor); 1634 1646 return success; 1635 1647 }
+4 -1
dll/win32/riched20/context.c
··· 27 27 c->pt.x = 0; 28 28 c->pt.y = 0; 29 29 c->rcView = editor->rcFormat; 30 + c->current_style = NULL; 31 + c->orig_font = NULL; 30 32 if (hDC) { 31 33 c->dpi.cx = GetDeviceCaps(hDC, LOGPIXELSX); 32 34 c->dpi.cy = GetDeviceCaps(hDC, LOGPIXELSY); ··· 41 43 42 44 void ME_DestroyContext(ME_Context *c) 43 45 { 44 - if (c->hDC) ITextHost_TxReleaseDC(c->editor->texthost, c->hDC); 46 + select_style( c, NULL ); 47 + if (c->hDC) ITextHost_TxReleaseDC( c->editor->texthost, c->hDC ); 45 48 }
+99 -82
dll/win32/riched20/editor.c
··· 1128 1128 LPOLECLIENTSITE lpClientSite = NULL; 1129 1129 LPDATAOBJECT lpDataObject = NULL; 1130 1130 LPOLECACHE lpOleCache = NULL; 1131 + LPRICHEDITOLE lpReOle = NULL; 1131 1132 STGMEDIUM stgm; 1132 1133 FORMATETC fm; 1133 1134 CLSID clsid; ··· 1160 1161 } 1161 1162 1162 1163 if (OleCreateDefaultHandler(&CLSID_NULL, NULL, &IID_IOleObject, (void**)&lpObject) == S_OK && 1163 - IRichEditOle_GetClientSite(editor->reOle, &lpClientSite) == S_OK && 1164 + IUnknown_QueryInterface(editor->reOle, &IID_IRichEditOle, (void**)&lpReOle) == S_OK && 1165 + IRichEditOle_GetClientSite(lpReOle, &lpClientSite) == S_OK && 1164 1166 IOleObject_SetClientSite(lpObject, lpClientSite) == S_OK && 1165 1167 IOleObject_GetUserClassID(lpObject, &clsid) == S_OK && 1166 1168 IOleObject_QueryInterface(lpObject, &IID_IOleCache, (void**)&lpOleCache) == S_OK && ··· 1192 1194 if (lpStorage) IStorage_Release(lpStorage); 1193 1195 if (lpDataObject) IDataObject_Release(lpDataObject); 1194 1196 if (lpOleCache) IOleCache_Release(lpOleCache); 1197 + if (lpReOle) IRichEditOle_Release(lpReOle); 1195 1198 1196 1199 return hr; 1197 1200 } ··· 1623 1626 } else { 1624 1627 style = editor->pBuffer->pDefaultStyle; 1625 1628 ME_AddRefStyle(style); 1626 - ME_SetSelection(editor, 0, 0); 1629 + set_selection_cursors(editor, 0, 0); 1627 1630 ME_InternalDeleteText(editor, &editor->pCursors[1], 1628 1631 ME_GetTextLength(editor), FALSE); 1629 1632 from = to = 0; ··· 1757 1760 cf.dwMask = CFM_ALL2; 1758 1761 ME_MoveCursorChars(editor, &lastcharCursor, -1, FALSE); 1759 1762 ME_GetCharFormat(editor, &lastcharCursor, &linebreakCursor, &cf); 1760 - ME_SetSelection(editor, newto, -1); 1763 + set_selection_cursors(editor, newto, -1); 1761 1764 ME_SetSelectionCharFormat(editor, &cf); 1762 - ME_SetSelection(editor, newto, newto); 1765 + set_selection_cursors(editor, newto, newto); 1763 1766 1764 1767 ME_MoveCursorChars(editor, &linebreakCursor, -linebreakSize, FALSE); 1765 1768 ME_GetTextW(editor, lastchar, 2, &linebreakCursor, linebreakSize, FALSE, FALSE); ··· 1782 1785 ERR("EM_STREAMIN without SF_TEXT or SF_RTF\n"); 1783 1786 /* put the cursor at the top */ 1784 1787 if (!(format & SFF_SELECTION)) 1785 - ME_SetSelection(editor, 0, 0); 1788 + set_selection_cursors(editor, 0, 0); 1786 1789 ME_CursorFromCharOfs(editor, from, &start); 1787 1790 ME_UpdateLinkAttribute(editor, &start, to - from); 1788 1791 } ··· 1803 1806 if (!(format & SFF_SELECTION)) { 1804 1807 ME_ClearTempStyle(editor); 1805 1808 } 1806 - ITextHost_TxShowCaret(editor->texthost, FALSE); 1807 - ME_MoveCaret(editor); 1808 - ITextHost_TxShowCaret(editor->texthost, TRUE); 1809 + update_caret(editor); 1809 1810 ME_SendSelChange(editor); 1810 1811 ME_SendRequestResize(editor, FALSE); 1811 1812 ··· 1929 1930 1930 1931 while (pCurItem && ME_CharCompare( *get_text( &pCurItem->member.run, nCurStart + nMatched ), text[nMatched], (flags & FR_MATCHCASE))) 1931 1932 { 1932 - if ((flags & FR_WHOLEWORD) && isalnumW(wLastChar)) 1933 + if ((flags & FR_WHOLEWORD) && iswalnum(wLastChar)) 1933 1934 break; 1934 1935 1935 1936 nMatched++; ··· 1953 1954 else 1954 1955 wNextChar = ' '; 1955 1956 1956 - if (isalnumW(wNextChar)) 1957 + if (iswalnum(wNextChar)) 1957 1958 break; 1958 1959 } 1959 1960 ··· 2013 2014 while (pCurItem && ME_CharCompare( *get_text( &pCurItem->member.run, nCurEnd - nMatched - 1 ), 2014 2015 text[nLen - nMatched - 1], (flags & FR_MATCHCASE) )) 2015 2016 { 2016 - if ((flags & FR_WHOLEWORD) && isalnumW(wLastChar)) 2017 + if ((flags & FR_WHOLEWORD) && iswalnum(wLastChar)) 2017 2018 break; 2018 2019 2019 2020 nMatched++; ··· 2039 2040 else 2040 2041 wPrevChar = ' '; 2041 2042 2042 - if (isalnumW(wPrevChar)) 2043 + if (iswalnum(wPrevChar)) 2043 2044 break; 2044 2045 } 2045 2046 ··· 2150 2151 } 2151 2152 } 2152 2153 2153 - static int handle_EM_EXSETSEL( ME_TextEditor *editor, int to, int from ) 2154 + int set_selection( ME_TextEditor *editor, int to, int from ) 2154 2155 { 2155 2156 int end; 2156 2157 2157 2158 TRACE("%d - %d\n", to, from ); 2158 2159 2159 - ME_InvalidateSelection( editor ); 2160 - end = ME_SetSelection( editor, to, from ); 2161 - ME_InvalidateSelection( editor ); 2162 - ITextHost_TxShowCaret( editor->texthost, FALSE ); 2163 - ME_ShowCaret( editor ); 2160 + if (!editor->bHideSelection) ME_InvalidateSelection( editor ); 2161 + end = set_selection_cursors( editor, to, from ); 2162 + if (!editor->bHideSelection) ME_InvalidateSelection( editor ); 2163 + update_caret( editor ); 2164 2164 ME_SendSelChange( editor ); 2165 2165 2166 2166 return end; ··· 2686 2686 case 'A': 2687 2687 if (ctrl_is_down) 2688 2688 { 2689 - handle_EM_EXSETSEL( editor, 0, -1 ); 2689 + set_selection( editor, 0, -1 ); 2690 2690 return TRUE; 2691 2691 } 2692 2692 break; ··· 3119 3119 ed->bHaveFocus = FALSE; 3120 3120 ed->bDialogMode = FALSE; 3121 3121 ed->bMouseCaptured = FALSE; 3122 + ed->caret_hidden = FALSE; 3123 + ed->caret_height = 0; 3122 3124 for (i=0; i<HFONT_CACHE_SIZE; i++) 3123 3125 { 3124 3126 ed->pFontCache[i].nRefs = 0; ··· 3219 3221 ITextHost_Release(editor->texthost); 3220 3222 if (editor->reOle) 3221 3223 { 3222 - IRichEditOle_Release(editor->reOle); 3224 + IUnknown_Release(editor->reOle); 3223 3225 editor->reOle = NULL; 3224 3226 } 3225 3227 OleUninitialize(); ··· 3530 3532 3531 3533 ME_CommitUndo(editor); 3532 3534 ME_WrapMarkedParagraphs(editor); 3533 - ME_MoveCaret(editor); 3535 + update_caret(editor); 3534 3536 return 0; 3535 3537 } 3536 3538 3539 + static LRESULT handle_EM_SETCHARFORMAT( ME_TextEditor *editor, WPARAM flags, const CHARFORMAT2W *fmt_in ) 3540 + { 3541 + CHARFORMAT2W fmt; 3542 + BOOL changed = TRUE; 3543 + ME_Cursor start, end; 3544 + 3545 + if (!cfany_to_cf2w( &fmt, fmt_in )) return 0; 3546 + 3547 + if (flags & SCF_ALL) 3548 + { 3549 + if (editor->mode & TM_PLAINTEXT) 3550 + { 3551 + ME_SetDefaultCharFormat( editor, &fmt ); 3552 + } 3553 + else 3554 + { 3555 + ME_SetCursorToStart( editor, &start ); 3556 + ME_SetCharFormat( editor, &start, NULL, &fmt ); 3557 + editor->nModifyStep = 1; 3558 + } 3559 + } 3560 + else if (flags & SCF_SELECTION) 3561 + { 3562 + if (editor->mode & TM_PLAINTEXT) return 0; 3563 + if (flags & SCF_WORD) 3564 + { 3565 + end = editor->pCursors[0]; 3566 + ME_MoveCursorWords( editor, &end, +1 ); 3567 + start = end; 3568 + ME_MoveCursorWords( editor, &start, -1 ); 3569 + ME_SetCharFormat( editor, &start, &end, &fmt ); 3570 + } 3571 + changed = ME_IsSelection( editor ); 3572 + ME_SetSelectionCharFormat( editor, &fmt ); 3573 + if (changed) editor->nModifyStep = 1; 3574 + } 3575 + else /* SCF_DEFAULT */ 3576 + { 3577 + ME_SetDefaultCharFormat( editor, &fmt ); 3578 + } 3579 + 3580 + ME_CommitUndo( editor ); 3581 + if (changed) 3582 + { 3583 + ME_WrapMarkedParagraphs( editor ); 3584 + ME_UpdateScrollBar( editor ); 3585 + } 3586 + return 1; 3587 + } 3537 3588 3538 3589 #define UNSUPPORTED_MSG(e) \ 3539 3590 case e: \ ··· 3682 3733 ME_CommitUndo(editor); 3683 3734 ME_WrapMarkedParagraphs(editor); 3684 3735 ME_UpdateScrollBar(editor); 3685 - ME_Repaint(editor); 3686 3736 3687 3737 return TRUE; 3688 3738 } ··· 3750 3800 } 3751 3801 case EM_SETSEL: 3752 3802 { 3753 - return handle_EM_EXSETSEL( editor, wParam, lParam ); 3803 + return set_selection( editor, wParam, lParam ); 3754 3804 } 3755 3805 case EM_SETSCROLLPOS: 3756 3806 { ··· 3775 3825 { 3776 3826 CHARRANGE range = *(CHARRANGE *)lParam; 3777 3827 3778 - return handle_EM_EXSETSEL( editor, range.cpMin, range.cpMax ); 3828 + return set_selection( editor, range.cpMin, range.cpMax ); 3779 3829 } 3780 3830 case EM_SHOWSCROLLBAR: 3781 3831 { ··· 3935 3985 case EM_GETEVENTMASK: 3936 3986 return editor->nEventMask; 3937 3987 case EM_SETCHARFORMAT: 3938 - { 3939 - CHARFORMAT2W p; 3940 - BOOL bRepaint = TRUE; 3941 - if (!cfany_to_cf2w(&p, (CHARFORMAT2W *)lParam)) 3942 - return 0; 3943 - if (wParam & SCF_ALL) { 3944 - if (editor->mode & TM_PLAINTEXT) { 3945 - ME_SetDefaultCharFormat(editor, &p); 3946 - } else { 3947 - ME_Cursor start; 3948 - ME_SetCursorToStart(editor, &start); 3949 - ME_SetCharFormat(editor, &start, NULL, &p); 3950 - editor->nModifyStep = 1; 3951 - } 3952 - } else if (wParam & SCF_SELECTION) { 3953 - if (editor->mode & TM_PLAINTEXT) 3954 - return 0; 3955 - if (wParam & SCF_WORD) { 3956 - ME_Cursor start; 3957 - ME_Cursor end = editor->pCursors[0]; 3958 - ME_MoveCursorWords(editor, &end, +1); 3959 - start = end; 3960 - ME_MoveCursorWords(editor, &start, -1); 3961 - ME_SetCharFormat(editor, &start, &end, &p); 3962 - } 3963 - bRepaint = ME_IsSelection(editor); 3964 - ME_SetSelectionCharFormat(editor, &p); 3965 - if (bRepaint) editor->nModifyStep = 1; 3966 - } else { /* SCF_DEFAULT */ 3967 - ME_SetDefaultCharFormat(editor, &p); 3968 - } 3969 - ME_CommitUndo(editor); 3970 - if (bRepaint) 3971 - { 3972 - ME_WrapMarkedParagraphs(editor); 3973 - ME_UpdateScrollBar(editor); 3974 - ME_Repaint(editor); 3975 - } 3976 - return 1; 3977 - } 3988 + return handle_EM_SETCHARFORMAT( editor, wParam, (CHARFORMAT2W *)lParam ); 3978 3989 case EM_GETCHARFORMAT: 3979 3990 { 3980 3991 CHARFORMAT2W tmp, *dst = (CHARFORMAT2W *)lParam; ··· 3996 4007 BOOL result = ME_SetSelectionParaFormat(editor, (PARAFORMAT2 *)lParam); 3997 4008 ME_WrapMarkedParagraphs(editor); 3998 4009 ME_UpdateScrollBar(editor); 3999 - ME_Repaint(editor); 4000 4010 ME_CommitUndo(editor); 4001 4011 return result; 4002 4012 } ··· 4116 4126 TRACE("WM_SETTEXT - NULL\n"); 4117 4127 ME_SetCursorToStart(editor, &cursor); 4118 4128 ME_UpdateLinkAttribute(editor, &cursor, INT_MAX); 4119 - ME_SetSelection(editor, 0, 0); 4129 + set_selection_cursors(editor, 0, 0); 4120 4130 editor->nModifyStep = 0; 4121 4131 ME_CommitUndo(editor); 4122 4132 ME_EmptyUndoStack(editor); ··· 4512 4522 break; 4513 4523 case WM_SETFOCUS: 4514 4524 editor->bHaveFocus = TRUE; 4515 - ME_ShowCaret(editor); 4525 + create_caret(editor); 4526 + update_caret(editor); 4516 4527 ME_SendOldNotify(editor, EN_SETFOCUS); 4517 4528 if (!editor->bHideSelection && !(editor->styleFlags & ES_NOHIDESEL)) 4518 4529 ME_InvalidateSelection( editor ); ··· 4521 4532 ME_CommitUndo(editor); /* End coalesced undos for typed characters */ 4522 4533 editor->bHaveFocus = FALSE; 4523 4534 editor->wheel_remain = 0; 4524 - ME_HideCaret(editor); 4535 + hide_caret(editor); 4536 + DestroyCaret(); 4525 4537 ME_SendOldNotify(editor, EN_KILLFOCUS); 4526 4538 if (!editor->bHideSelection && !(editor->styleFlags & ES_NOHIDESEL)) 4527 4539 ME_InvalidateSelection( editor ); ··· 4805 4817 HeapFree(GetProcessHeap(), 0, lpCompStr); 4806 4818 4807 4819 if (dwIndex == GCS_COMPSTR) 4808 - ME_SetSelection(editor,editor->imeStartIndex, 4820 + set_selection_cursors(editor,editor->imeStartIndex, 4809 4821 editor->imeStartIndex + dwBufLen/sizeof(WCHAR)); 4810 4822 } 4811 4823 ME_ReleaseStyle(style); ··· 4824 4836 if (!editor->reOle) 4825 4837 if (!CreateIRichEditOle(NULL, editor, (LPVOID *)&editor->reOle)) 4826 4838 return 0; 4827 - *(LPVOID *)lParam = editor->reOle; 4828 - IRichEditOle_AddRef(editor->reOle); 4829 - return 1; 4839 + if (IUnknown_QueryInterface(editor->reOle, &IID_IRichEditOle, (LPVOID *)lParam) == S_OK) 4840 + return 1; 4841 + return 0; 4830 4842 } 4831 4843 case EM_GETPASSWORDCHAR: 4832 4844 { ··· 4975 4987 { 4976 4988 case WM_PAINT: 4977 4989 { 4978 - HDC hDC; 4990 + HDC hdc; 4979 4991 RECT rc; 4980 4992 PAINTSTRUCT ps; 4993 + HBRUSH old_brush; 4981 4994 4982 - hDC = BeginPaint(editor->hWnd, &ps); 4995 + update_caret(editor); 4996 + hdc = BeginPaint(editor->hWnd, &ps); 4983 4997 if (!editor->bEmulateVersion10 || (editor->nEventMask & ENM_UPDATE)) 4984 4998 ME_SendOldNotify(editor, EN_UPDATE); 4999 + old_brush = SelectObject(hdc, editor->hbrBackground); 5000 + 4985 5001 /* Erase area outside of the formatting rectangle */ 4986 5002 if (ps.rcPaint.top < editor->rcFormat.top) 4987 5003 { 4988 5004 rc = ps.rcPaint; 4989 5005 rc.bottom = editor->rcFormat.top; 4990 - FillRect(hDC, &rc, editor->hbrBackground); 5006 + PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); 4991 5007 ps.rcPaint.top = editor->rcFormat.top; 4992 5008 } 4993 5009 if (ps.rcPaint.bottom > editor->rcFormat.bottom) { 4994 5010 rc = ps.rcPaint; 4995 5011 rc.top = editor->rcFormat.bottom; 4996 - FillRect(hDC, &rc, editor->hbrBackground); 5012 + PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); 4997 5013 ps.rcPaint.bottom = editor->rcFormat.bottom; 4998 5014 } 4999 5015 if (ps.rcPaint.left < editor->rcFormat.left) { 5000 5016 rc = ps.rcPaint; 5001 5017 rc.right = editor->rcFormat.left; 5002 - FillRect(hDC, &rc, editor->hbrBackground); 5018 + PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); 5003 5019 ps.rcPaint.left = editor->rcFormat.left; 5004 5020 } 5005 5021 if (ps.rcPaint.right > editor->rcFormat.right) { 5006 5022 rc = ps.rcPaint; 5007 5023 rc.left = editor->rcFormat.right; 5008 - FillRect(hDC, &rc, editor->hbrBackground); 5024 + PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); 5009 5025 ps.rcPaint.right = editor->rcFormat.right; 5010 5026 } 5011 5027 5012 - ME_PaintContent(editor, hDC, &ps.rcPaint); 5028 + ME_PaintContent(editor, hdc, &ps.rcPaint); 5029 + SelectObject(hdc, old_brush); 5013 5030 EndPaint(editor->hWnd, &ps); 5014 5031 return 0; 5015 5032 } ··· 5283 5300 return result; 5284 5301 } 5285 5302 5286 - static int wchar_comp( const void *key, const void *elem ) 5303 + static int __cdecl wchar_comp( const void *key, const void *elem ) 5287 5304 { 5288 5305 return *(const WCHAR *)key - *(const WCHAR *)elem; 5289 5306 } ··· 5332 5349 while (cursor.nOffset < run_len) 5333 5350 { 5334 5351 c = str[cursor.nOffset]; 5335 - if (!isspaceW( c ) && !isurlneutral( c )) 5352 + if (!iswspace( c ) && !isurlneutral( c )) 5336 5353 { 5337 5354 *candidate_min = cursor; 5338 5355 candidateStarted = TRUE; ··· 5352 5369 while (cursor.nOffset < run_len) 5353 5370 { 5354 5371 c = str[cursor.nOffset]; 5355 - if (isspaceW( c )) 5372 + if (iswspace( c )) 5356 5373 { 5357 5374 if (quoted && c != '\r') 5358 5375 {
+9 -10
dll/win32/riched20/editor.h
··· 21 21 #pragma once 22 22 23 23 #include "editstr.h" 24 - #include "wine/unicode.h" 25 24 26 25 struct _RTF_Info; 27 26 ··· 56 55 void ME_ReleaseStyle(ME_Style *item) DECLSPEC_HIDDEN; 57 56 ME_Style *ME_GetInsertStyle(ME_TextEditor *editor, int nCursor) DECLSPEC_HIDDEN; 58 57 ME_Style *ME_ApplyStyle(ME_TextEditor *ed, ME_Style *sSrc, CHARFORMAT2W *style) DECLSPEC_HIDDEN; 59 - HFONT ME_SelectStyleFont(ME_Context *c, ME_Style *s) DECLSPEC_HIDDEN; 60 - void ME_UnselectStyleFont(ME_Context *c, ME_Style *s, HFONT hOldFont) DECLSPEC_HIDDEN; 58 + void select_style(ME_Context *c, ME_Style *s) DECLSPEC_HIDDEN; 61 59 void ME_InitCharFormat2W(CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN; 62 60 void ME_SaveTempStyle(ME_TextEditor *editor, ME_Style *style) DECLSPEC_HIDDEN; 63 61 void ME_ClearTempStyle(ME_TextEditor *editor) DECLSPEC_HIDDEN; ··· 107 105 108 106 static inline int ME_CharCompare(WCHAR a, WCHAR b, int caseSensitive) 109 107 { 110 - return caseSensitive ? (a == b) : (toupperW(a) == toupperW(b)); 108 + return caseSensitive ? (a == b) : (towupper(a) == towupper(b)); 111 109 } 112 110 113 111 /* note: those two really return the first matching offset (starting from EOS)+1 ··· 152 150 153 151 /* caret.c */ 154 152 void ME_SetCursorToStart(ME_TextEditor *editor, ME_Cursor *cursor) DECLSPEC_HIDDEN; 155 - int ME_SetSelection(ME_TextEditor *editor, int from, int to) DECLSPEC_HIDDEN; 153 + int set_selection_cursors(ME_TextEditor *editor, int from, int to) DECLSPEC_HIDDEN; 156 154 BOOL ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs) DECLSPEC_HIDDEN; 157 - void ME_HideCaret(ME_TextEditor *ed) DECLSPEC_HIDDEN; 158 - void ME_ShowCaret(ME_TextEditor *ed) DECLSPEC_HIDDEN; 159 - void ME_MoveCaret(ME_TextEditor *ed) DECLSPEC_HIDDEN; 155 + void hide_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN; 156 + void show_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN; 157 + void update_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN; 158 + void create_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN; 160 159 BOOL ME_CharFromPos(ME_TextEditor *editor, int x, int y, ME_Cursor *cursor, BOOL *isExact) DECLSPEC_HIDDEN; 161 160 void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int clickNum) DECLSPEC_HIDDEN; 162 161 void ME_MouseMove(ME_TextEditor *editor, int x, int y) DECLSPEC_HIDDEN; ··· 241 240 void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) DECLSPEC_HIDDEN; 242 241 void ME_CopyReObject(REOBJECT *dst, const REOBJECT *src, DWORD flags) DECLSPEC_HIDDEN; 243 242 void ME_DeleteReObject(struct re_object *re_object) DECLSPEC_HIDDEN; 244 - void ME_GetITextDocument2OldInterface(IRichEditOle *iface, LPVOID *ppvObj) DECLSPEC_HIDDEN; 245 243 246 244 /* editor.c */ 247 245 ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) DECLSPEC_HIDDEN; ··· 258 256 void ME_StreamInFill(ME_InStream *stream) DECLSPEC_HIDDEN; 259 257 extern BOOL me_debug DECLSPEC_HIDDEN; 260 258 void ME_ReplaceSel(ME_TextEditor *editor, BOOL can_undo, const WCHAR *str, int len) DECLSPEC_HIDDEN; 259 + int set_selection( ME_TextEditor *editor, int to, int from ) DECLSPEC_HIDDEN; 261 260 262 261 /* table.c */ 263 262 BOOL ME_IsInTable(ME_DisplayItem *pItem) DECLSPEC_HIDDEN; ··· 279 278 280 279 /* txthost.c */ 281 280 ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10) DECLSPEC_HIDDEN; 282 - #ifdef __i386__ /* Use wrappers to perform thiscall on i386 */ 281 + #if defined(__i386__) && !defined(__MINGW32__) /* Use wrappers to perform thiscall on i386 */ 283 282 #define TXTHOST_VTABLE(This) (&itextHostStdcallVtbl) 284 283 #else /* __i386__ */ 285 284 #define TXTHOST_VTABLE(This) (This)->lpVtbl
+6 -2
dll/win32/riched20/editstr.h
··· 51 51 #include "wine/heap.h" 52 52 #include "wine/list.h" 53 53 54 - #ifdef __i386__ 54 + #if defined(__i386__) && !defined(__MINGW32__) 55 55 extern const struct ITextHostVtbl itextHostStdcallVtbl DECLSPEC_HIDDEN; 56 56 #endif /* __i386__ */ 57 57 ··· 385 385 { 386 386 HWND hWnd, hwndParent; 387 387 ITextHost *texthost; 388 - IRichEditOle *reOle; 388 + IUnknown *reOle; 389 389 BOOL bEmulateVersion10; 390 390 ME_TextBuffer *pBuffer; 391 391 ME_Cursor *pCursors; ··· 442 442 /* Cache previously set scrollbar info */ 443 443 SCROLLINFO vert_si, horz_si; 444 444 445 + int caret_height; 446 + BOOL caret_hidden; 445 447 BOOL bMouseCaptured; 446 448 int wheel_remain; 447 449 struct list style_list; ··· 455 457 RECT rcView; 456 458 SIZE dpi; 457 459 int nAvailWidth; 460 + ME_Style *current_style; 461 + HFONT orig_font; 458 462 459 463 /* those are valid inside ME_WrapTextParagraph and related */ 460 464 ME_TextEditor *editor;
+20 -30
dll/win32/riched20/paint.c
··· 43 43 44 44 ME_InitContext(&c, editor, hDC); 45 45 SetBkMode(hDC, TRANSPARENT); 46 - ME_MoveCaret(editor); 46 + 47 47 item = editor->pBuffer->pFirst->next; 48 48 /* This context point is an offset for the paragraph positions stored 49 49 * during wrapping. It shouldn't be modified during painting. */ ··· 87 87 IntersectRect(&rc, &rc, rcUpdate); 88 88 89 89 if (!IsRectEmpty(&rc)) 90 - FillRect(hDC, &rc, c.editor->hbrBackground); 90 + PatBlt(hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); 91 91 } 92 92 if (editor->nTotalLength != editor->nLastTotalLength || 93 93 editor->nTotalWidth != editor->nLastTotalWidth) ··· 291 291 { 292 292 COLORREF text_color = get_text_color( c, run->style, selected ); 293 293 COLORREF old_text, old_back; 294 - HFONT old_font = NULL; 295 294 int y_offset = calc_y_offset( c, run->style ); 296 295 static const WCHAR space[1] = {' '}; 297 296 298 - old_font = ME_SelectStyleFont( c, run->style ); 297 + select_style( c, run->style ); 299 298 old_text = SetTextColor( hdc, text_color ); 300 299 if (selected) old_back = SetBkColor( hdc, back_color ); 301 300 ··· 303 302 304 303 if (selected) SetBkColor( hdc, old_back ); 305 304 SetTextColor( hdc, old_text ); 306 - ME_UnselectStyleFont( c, run->style, old_font ); 307 305 308 306 draw_underline( c, run, x, y - y_offset, text_color ); 309 307 } ··· 371 369 int nSelFrom, int nSelTo, int ymin, int cy) 372 370 { 373 371 HDC hDC = c->hDC; 374 - HGDIOBJ hOldFont; 375 372 int yOffset = 0; 376 373 BOOL selected = (nSelFrom < run->len && nSelTo >= 0 377 374 && nSelFrom < nSelTo && !c->editor->bHideSelection && ··· 404 401 } 405 402 } 406 403 407 - hOldFont = ME_SelectStyleFont( c, run->style ); 404 + select_style( c, run->style ); 408 405 409 406 if (sel_rgn) ExtSelectClipRgn( hDC, sel_rgn, RGN_DIFF ); 410 407 ··· 431 428 432 429 if (old_style_selected) 433 430 PatBlt( hDC, sel_rect.left, ymin, sel_rect.right - sel_rect.left, cy, DSTINVERT ); 434 - 435 - ME_UnselectStyleFont(c, run->style, hOldFont); 436 431 } 437 432 438 433 static void ME_DebugWrite(HDC hDC, const POINT *pt, LPCWSTR szText) { ··· 603 598 rc.top = y; 604 599 bounds->top = ME_twips2pointsY(c, para->fmt.dySpaceBefore); 605 600 rc.bottom = y + bounds->top + top_border; 606 - FillRect(c->hDC, &rc, c->editor->hbrBackground); 601 + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); 607 602 } 608 603 609 604 if (para->fmt.dwMask & PFM_SPACEAFTER) ··· 613 608 rc.bottom = y + para->nHeight; 614 609 bounds->bottom = ME_twips2pointsY(c, para->fmt.dySpaceAfter); 615 610 rc.top = rc.bottom - bounds->bottom - bottom_border; 616 - FillRect(c->hDC, &rc, c->editor->hbrBackground); 611 + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); 617 612 } 618 613 619 614 /* Native richedit doesn't support paragraph borders in v1.0 - 4.1, ··· 652 647 rc.right = rc.left + border_width; 653 648 rc.top = y + bounds->top; 654 649 rc.bottom = y + para->nHeight - bounds->bottom; 655 - FillRect(c->hDC, &rc, c->editor->hbrBackground); 650 + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); 656 651 MoveToEx(c->hDC, c->pt.x + pen_width + 1, y + bounds->top + DD(4), NULL); 657 652 LineTo(c->hDC, c->pt.x + pen_width + 1, y + para->nHeight - bounds->bottom - DD(8)); 658 653 } ··· 667 662 rc.right = rc.left + pen_width; 668 663 rc.top = y + bounds->top; 669 664 rc.bottom = y + para->nHeight - bounds->bottom; 670 - FillRect(c->hDC, &rc, c->editor->hbrBackground); 665 + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); 671 666 MoveToEx(c->hDC, rightEdge - 1 - pen_width - 1, y + bounds->top + DD(4), NULL); 672 667 LineTo(c->hDC, rightEdge - 1 - pen_width - 1, y + para->nHeight - bounds->bottom - DD(8)); 673 668 } ··· 731 726 rc.top = top + width; 732 727 width = cell->yTextOffset - width; 733 728 rc.bottom = rc.top + width; 734 - if (width) { 735 - FillRect(c->hDC, &rc, c->editor->hbrBackground); 736 - } 729 + if (width) 730 + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); 737 731 } 738 732 /* Draw cell borders. 739 733 * The order borders are draw in is left, top, bottom, right in order ··· 901 895 static void draw_para_number( ME_Context *c, ME_DisplayItem *p ) 902 896 { 903 897 ME_Paragraph *para = &p->member.para; 904 - HFONT old_font; 905 898 int x, y; 906 899 COLORREF old_text; 907 900 908 901 if (para->fmt.wNumbering) 909 902 { 910 - old_font = ME_SelectStyleFont( c, para->para_num.style ); 903 + select_style( c, para->para_num.style ); 911 904 old_text = SetTextColor( c->hDC, get_text_color( c, para->para_num.style, FALSE ) ); 912 905 913 906 x = c->pt.x + para->para_num.pt.x; ··· 916 909 ExtTextOutW( c->hDC, x, y, 0, NULL, para->para_num.text->szData, para->para_num.text->nLen, NULL ); 917 910 918 911 SetTextColor( c->hDC, old_text ); 919 - ME_UnselectStyleFont( c, para->para_num.style, old_font ); 920 912 } 921 913 } 922 914 ··· 974 966 rc.bottom = y + p->member.row.nHeight; 975 967 } 976 968 visible = RectVisible(c->hDC, &rc); 977 - if (visible) { 978 - FillRect(c->hDC, &rc, c->editor->hbrBackground); 979 - } 969 + if (visible) 970 + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); 980 971 if (bounds.right) 981 972 { 982 973 /* If scrolled to the right past the end of the text, then 983 974 * there may be space to the right of the paragraph border. */ 984 - RECT rcAfterBrdr = rc; 985 - rcAfterBrdr.left = rc.right + bounds.right; 986 - rcAfterBrdr.right = c->rcView.right; 987 - if (RectVisible(c->hDC, &rcAfterBrdr)) 988 - FillRect(c->hDC, &rcAfterBrdr, c->editor->hbrBackground); 975 + RECT after_bdr = rc; 976 + after_bdr.left = rc.right + bounds.right; 977 + after_bdr.right = c->rcView.right; 978 + if (RectVisible(c->hDC, &after_bdr)) 979 + PatBlt(c->hDC, after_bdr.left, after_bdr.top, after_bdr.right - after_bdr.left, 980 + after_bdr.bottom - after_bdr.top, PATCOPY); 989 981 } 990 982 if (me_debug) 991 983 { ··· 1034 1026 rc.top = c->pt.y + para->pt.y + para->nHeight; 1035 1027 rc.bottom = c->pt.y + p->member.cell.pt.y + p->member.cell.nHeight; 1036 1028 if (RectVisible(c->hDC, &rc)) 1037 - { 1038 - FillRect(c->hDC, &rc, c->editor->hbrBackground); 1039 - } 1029 + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); 1040 1030 break; 1041 1031 default: 1042 1032 break;
+3 -4
dll/win32/riched20/para.c
··· 312 312 { 313 313 case PFN_ARABIC: 314 314 default: 315 - p += sprintfW( p, fmtW, num ); 315 + p += swprintf( p, fmtW, num ); 316 316 break; 317 317 318 318 case PFN_LCLETTER: ··· 399 399 static const WCHAR bullet_font[] = {'S','y','m','b','o','l',0}; 400 400 static const WCHAR bullet_str[] = {0xb7, 0}; 401 401 static const WCHAR spaceW[] = {' ', 0}; 402 - HFONT old_font; 403 402 SIZE sz; 404 403 404 + if (!para->fmt.wNumbering) return; 405 405 if (para->para_num.style && para->para_num.text) return; 406 406 407 407 if (!para->para_num.style) ··· 432 432 para->para_num.text = ME_MakeStringConst( bullet_str, 1 ); 433 433 } 434 434 435 - old_font = ME_SelectStyleFont( c, para->para_num.style ); 435 + select_style( c, para->para_num.style ); 436 436 GetTextExtentPointW( c->hDC, para->para_num.text->szData, para->para_num.text->nLen, &sz ); 437 437 para->para_num.width = sz.cx; 438 438 GetTextExtentPointW( c->hDC, spaceW, 1, &sz ); 439 439 para->para_num.width += sz.cx; 440 - ME_UnselectStyleFont( c, para->para_num.style, old_font ); 441 440 } 442 441 443 442 void para_num_clear( struct para_num *pn )
-2
dll/win32/riched20/precomp.h
··· 2 2 #ifndef _RICHED20_PRECOMP_H 3 3 #define _RICHED20_PRECOMP_H 4 4 5 - #include <wine/config.h> 6 - 7 5 #define WIN32_NO_STATUS 8 6 #define _INC_WINDOWS 9 7 #define COM_NO_WINDOWS_H
+23 -34
dll/win32/riched20/richole.c
··· 372 372 case FONT_WEIGHT: 373 373 return left->l == right->l; 374 374 case FONT_NAME: 375 - return !strcmpW(left->str, right->str); 375 + return !wcscmp(left->str, right->str); 376 376 case FONT_POSITION: 377 377 case FONT_SIZE: 378 378 case FONT_SPACING: ··· 1399 1399 else 1400 1400 reobj = cursor.pRun->member.run.reobj; 1401 1401 } 1402 + else if (iob == REO_IOB_SELECTION) 1403 + { 1404 + ME_Cursor *from, *to; 1405 + 1406 + ME_GetSelection(This->editor, &from, &to); 1407 + if (!from->pRun->member.run.reobj) 1408 + return E_INVALIDARG; 1409 + else 1410 + reobj = from->pRun->member.run.reobj; 1411 + } 1402 1412 else 1403 1413 { 1404 1414 if (iob > IRichEditOle_GetObjectCount(me)) ··· 1686 1696 } 1687 1697 1688 1698 /* it's safer not to rely on stored BSTR length */ 1689 - len = strlenW(str); 1699 + len = lstrlenW(str); 1690 1700 cursor = editor->pCursors[0]; 1691 1701 ME_CursorFromCharOfs(editor, This->start, &editor->pCursors[0]); 1692 1702 style = ME_GetInsertStyle(editor, 0); ··· 2027 2037 static void cp2range(ME_TextEditor *editor, LONG *cp1, LONG *cp2) 2028 2038 { 2029 2039 int len = ME_GetTextLength(editor) + 1; 2040 + 2030 2041 *cp1 = max(*cp1, 0); 2031 2042 *cp2 = max(*cp2, 0); 2032 2043 *cp1 = min(*cp1, len); ··· 2146 2157 if (!This->child.reole) 2147 2158 return CO_E_RELEASED; 2148 2159 2149 - ME_SetSelection(This->child.reole->editor, This->start, This->end); 2160 + set_selection(This->child.reole->editor, This->start, This->end); 2150 2161 return S_OK; 2151 2162 } 2152 2163 ··· 2506 2517 ME_CursorFromCharOfs(editor, This->start, &cursor); 2507 2518 ME_GetCursorCoordinates(editor, &cursor, &x, &y, &height); 2508 2519 break; 2520 + case tomEnd: 2521 + ME_CursorFromCharOfs(editor, This->end, &cursor); 2522 + ME_GetCursorCoordinates(editor, &cursor, &x, &y, &height); 2523 + break; 2509 2524 default: 2510 2525 FIXME("bStart value %d not handled\n", value); 2511 2526 return E_NOTIMPL; ··· 2715 2730 { 2716 2731 ITextFontImpl *This = impl_from_ITextFont(iface); 2717 2732 FIXME("(%p)->(%p): stub\n", This, pFont); 2718 - 2719 - if (This->range && !get_range_reole(This->range)) 2720 - return CO_E_RELEASED; 2721 - 2722 2733 return E_NOTIMPL; 2723 2734 } 2724 2735 ··· 2726 2737 { 2727 2738 ITextFontImpl *This = impl_from_ITextFont(iface); 2728 2739 FIXME("(%p)->(%p): stub\n", This, ret); 2729 - 2730 - if (This->range && !get_range_reole(This->range)) 2731 - return CO_E_RELEASED; 2732 - 2733 2740 return E_NOTIMPL; 2734 2741 } 2735 2742 ··· 2737 2744 { 2738 2745 ITextFontImpl *This = impl_from_ITextFont(iface); 2739 2746 FIXME("(%p)->(%p %p): stub\n", This, font, ret); 2740 - 2741 - if (This->range && !get_range_reole(This->range)) 2742 - return CO_E_RELEASED; 2743 - 2744 2747 return E_NOTIMPL; 2745 2748 } 2746 2749 ··· 2914 2917 { 2915 2918 ITextFontImpl *This = impl_from_ITextFont(iface); 2916 2919 FIXME("(%p)->(%p): stub\n", This, value); 2917 - 2918 - if (This->range && !get_range_reole(This->range)) 2919 - return CO_E_RELEASED; 2920 - 2921 2920 return E_NOTIMPL; 2922 2921 } 2923 2922 ··· 2925 2924 { 2926 2925 ITextFontImpl *This = impl_from_ITextFont(iface); 2927 2926 FIXME("(%p)->(%d): stub\n", This, value); 2928 - 2929 - if (This->range && !get_range_reole(This->range)) 2930 - return CO_E_RELEASED; 2931 - 2932 2927 return E_NOTIMPL; 2933 2928 } 2934 2929 ··· 4754 4749 return CO_E_RELEASED; 4755 4750 4756 4751 editor = This->reOle->editor; 4757 - len = strlenW(str); 4752 + len = lstrlenW(str); 4758 4753 ME_GetSelectionOfs(editor, &from, &to); 4759 4754 ME_ReplaceSel(editor, FALSE, str, len); 4760 4755 ··· 4866 4861 ME_GetSelectionOfs(This->reOle->editor, &start, &end); 4867 4862 hr = textrange_setstart(This->reOle, value, &start, &end); 4868 4863 if (hr == S_OK) 4869 - ME_SetSelection(This->reOle->editor, start, end); 4864 + set_selection(This->reOle->editor, start, end); 4870 4865 4871 4866 return hr; 4872 4867 } ··· 4901 4896 ME_GetSelectionOfs(This->reOle->editor, &start, &end); 4902 4897 hr = textrange_setend(This->reOle, value, &start, &end); 4903 4898 if (hr == S_OK) 4904 - ME_SetSelection(This->reOle->editor, start, end); 4899 + set_selection(This->reOle->editor, start, end); 4905 4900 4906 4901 return hr; 4907 4902 } ··· 5020 5015 ME_GetSelectionOfs(This->reOle->editor, &start, &end); 5021 5016 hres = range_Collapse(bStart, &start, &end); 5022 5017 if (SUCCEEDED(hres)) 5023 - ME_SetSelection(This->reOle->editor, start, end); 5018 + set_selection(This->reOle->editor, start, end); 5024 5019 return hres; 5025 5020 } 5026 5021 ··· 5712 5707 reo->outer_unk = outer_unk; 5713 5708 else 5714 5709 reo->outer_unk = &reo->IUnknown_inner; 5715 - *ppvObj = &reo->IRichEditOle_iface; 5710 + *ppvObj = &reo->IUnknown_inner; 5716 5711 5717 5712 return 1; 5718 5713 } ··· 5932 5927 IOleClientSite_AddRef(dst->polesite); 5933 5928 } 5934 5929 } 5935 - 5936 - void ME_GetITextDocument2OldInterface(IRichEditOle *iface, LPVOID *ppvObj) 5937 - { 5938 - IRichEditOleImpl *This = impl_from_IRichEditOle(iface); 5939 - *ppvObj = &This->ITextDocument2Old_iface; 5940 - }
+12 -13
dll/win32/riched20/run.c
··· 464 464 ME_String *mask_text = NULL; 465 465 WCHAR *str; 466 466 int fit = 0; 467 - HGDIOBJ hOldFont; 468 467 SIZE sz, sz2, sz3; 469 468 if (!run->len || cx <= 0) 470 469 return 0; ··· 503 502 else 504 503 str = get_text( run, 0 ); 505 504 506 - hOldFont = ME_SelectStyleFont(c, run->style); 505 + select_style(c, run->style); 507 506 GetTextExtentExPointW(c->hDC, str, run->len, 508 507 cx, &fit, NULL, &sz); 509 508 if (closest && fit != run->len) ··· 516 515 517 516 ME_DestroyString( mask_text ); 518 517 519 - ME_UnselectStyleFont(c, run->style, hOldFont); 520 518 return fit; 521 519 } 522 520 ··· 538 536 */ 539 537 static void ME_GetTextExtent(ME_Context *c, LPCWSTR szText, int nChars, ME_Style *s, SIZE *size) 540 538 { 541 - HGDIOBJ hOldFont; 542 - if (c->hDC) { 543 - hOldFont = ME_SelectStyleFont(c, s); 544 - GetTextExtentPoint32W(c->hDC, szText, nChars, size); 545 - ME_UnselectStyleFont(c, s, hOldFont); 546 - } else { 547 - size->cx = 0; 548 - size->cy = 0; 549 - } 539 + if (c->hDC) 540 + { 541 + select_style( c, s ); 542 + GetTextExtentPoint32W( c->hDC, szText, nChars, size ); 543 + } 544 + else 545 + { 546 + size->cx = 0; 547 + size->cy = 0; 548 + } 550 549 } 551 550 552 551 /****************************************************************************** ··· 867 866 { 868 867 if (!(tmp.dwMask & CFM_FACE)) 869 868 pFmt->dwMask &= ~CFM_FACE; 870 - else if (lstrcmpW(pFmt->szFaceName, tmp.szFaceName) || 869 + else if (wcscmp(pFmt->szFaceName, tmp.szFaceName) || 871 870 pFmt->bPitchAndFamily != tmp.bPitchAndFamily) 872 871 pFmt->dwMask &= ~CFM_FACE; 873 872 }
+75 -56
dll/win32/riched20/style.c
··· 85 85 CopyMemory(t, from, FIELD_OFFSET(CHARFORMATA, szFaceName)); 86 86 WideCharToMultiByte(CP_ACP, 0, from->szFaceName, -1, t->szFaceName, sizeof(t->szFaceName), NULL, NULL); 87 87 t->cbSize = sizeof(*t); /* it was overwritten by CopyMemory */ 88 + t->dwMask &= CFM_ALL; 89 + t->dwEffects &= CFM_EFFECTS; 88 90 return TRUE; 89 91 } 90 92 if (to->cbSize == sizeof(CHARFORMATW)) ··· 92 94 CHARFORMATW *t = (CHARFORMATW *)to; 93 95 CopyMemory(t, from, sizeof(*t)); 94 96 t->cbSize = sizeof(*t); /* it was overwritten by CopyMemory */ 97 + t->dwMask &= CFM_ALL; 98 + t->dwEffects &= CFM_EFFECTS; 95 99 return TRUE; 96 100 } 97 101 if (to->cbSize == sizeof(CHARFORMAT2A)) ··· 348 352 { 349 353 if (memcmp(p1, p2, sizeof(LOGFONTW)-sizeof(p1->lfFaceName))) 350 354 return FALSE; 351 - if (lstrcmpW(p1->lfFaceName, p2->lfFaceName)) 355 + if (wcscmp(p1->lfFaceName, p2->lfFaceName)) 352 356 return FALSE; 353 357 return TRUE; 354 358 } 355 359 356 - HFONT ME_SelectStyleFont(ME_Context *c, ME_Style *s) 357 - { 358 - HFONT hOldFont; 359 - LOGFONTW lf; 360 - int i, nEmpty, nAge = 0x7FFFFFFF; 361 - ME_FontCacheItem *item; 362 - assert(s); 363 - 364 - ME_LogFontFromStyle(c, &lf, s); 365 - 366 - for (i=0; i<HFONT_CACHE_SIZE; i++) 367 - c->editor->pFontCache[i].nAge++; 368 - for (i=0, nEmpty=-1, nAge=0; i<HFONT_CACHE_SIZE; i++) 369 - { 370 - item = &c->editor->pFontCache[i]; 371 - if (!item->nRefs) 372 - { 373 - if (item->nAge > nAge) 374 - nEmpty = i, nAge = item->nAge; 375 - } 376 - if (item->hFont && ME_IsFontEqual(&item->lfSpecs, &lf)) 377 - break; 378 - } 379 - if (i < HFONT_CACHE_SIZE) /* found */ 380 - { 381 - item = &c->editor->pFontCache[i]; 382 - TRACE_(richedit_style)("font reused %d\n", i); 383 - item->nRefs++; 384 - } 385 - else 386 - { 387 - item = &c->editor->pFontCache[nEmpty]; /* this legal even when nEmpty == -1, as we don't dereference it */ 388 - 389 - assert(nEmpty != -1); /* otherwise we leak cache entries or get too many fonts at once*/ 390 - if (item->hFont) { 391 - TRACE_(richedit_style)("font deleted %d\n", nEmpty); 392 - DeleteObject(item->hFont); 393 - item->hFont = NULL; 394 - } 395 - item->hFont = CreateFontIndirectW(&lf); 396 - TRACE_(richedit_style)("font created %d\n", nEmpty); 397 - item->nRefs = 1; 398 - item->lfSpecs = lf; 399 - } 400 - s->font_cache = item; 401 - hOldFont = SelectObject(c->hDC, item->hFont); 402 - /* should be cached too, maybe ? */ 403 - GetTextMetricsW(c->hDC, &s->tm); 404 - return hOldFont; 405 - } 406 - 407 360 static void release_font_cache(ME_FontCacheItem *item) 408 361 { 409 362 if (item->nRefs > 0) ··· 413 366 } 414 367 } 415 368 416 - void ME_UnselectStyleFont(ME_Context *c, ME_Style *s, HFONT hOldFont) 369 + void select_style( ME_Context *c, ME_Style *s ) 417 370 { 418 - SelectObject(c->hDC, hOldFont); 419 - release_font_cache(s->font_cache); 420 - s->font_cache = NULL; 371 + HFONT old_font; 372 + LOGFONTW lf; 373 + int i, empty, age = 0x7FFFFFFF; 374 + ME_FontCacheItem *item; 375 + 376 + if (c->current_style == s) return; 377 + 378 + if (s) 379 + { 380 + ME_LogFontFromStyle( c, &lf, s ); 381 + 382 + for (i = 0; i < HFONT_CACHE_SIZE; i++) 383 + c->editor->pFontCache[i].nAge++; 384 + for (i = 0, empty = -1, age = 0; i < HFONT_CACHE_SIZE; i++) 385 + { 386 + item = &c->editor->pFontCache[i]; 387 + if (!item->nRefs) 388 + { 389 + if (item->nAge > age) 390 + { 391 + empty = i; 392 + age = item->nAge; 393 + } 394 + } 395 + 396 + if (item->hFont && ME_IsFontEqual( &item->lfSpecs, &lf )) 397 + break; 398 + } 399 + 400 + if (i < HFONT_CACHE_SIZE) /* found */ 401 + { 402 + item = &c->editor->pFontCache[i]; 403 + TRACE_(richedit_style)( "font reused %d\n", i ); 404 + item->nRefs++; 405 + } 406 + else 407 + { 408 + assert(empty != -1); 409 + item = &c->editor->pFontCache[empty]; 410 + if (item->hFont) 411 + { 412 + TRACE_(richedit_style)( "font deleted %d\n", empty ); 413 + DeleteObject(item->hFont); 414 + item->hFont = NULL; 415 + } 416 + item->hFont = CreateFontIndirectW( &lf ); 417 + TRACE_(richedit_style)( "font created %d\n", empty ); 418 + item->nRefs = 1; 419 + item->lfSpecs = lf; 420 + } 421 + s->font_cache = item; 422 + old_font = SelectObject( c->hDC, item->hFont ); 423 + GetTextMetricsW( c->hDC, &s->tm ); 424 + if (!c->orig_font) c->orig_font = old_font; 425 + } 426 + else 427 + { 428 + SelectObject( c->hDC, c->orig_font ); 429 + c->orig_font = NULL; 430 + } 431 + 432 + if (c->current_style) 433 + { 434 + release_font_cache( c->current_style->font_cache ); 435 + c->current_style->font_cache = NULL; 436 + } 437 + c->current_style = s; 438 + 439 + return; 421 440 } 422 441 423 442 void ME_DestroyStyle(ME_Style *s)
+1 -2
dll/win32/riched20/table.c
··· 613 613 } 614 614 ME_InvalidateSelection(editor); 615 615 ME_Repaint(editor); 616 - ITextHost_TxShowCaret(editor->texthost, FALSE); 617 - ME_ShowCaret(editor); 616 + update_caret(editor); 618 617 ME_SendSelChange(editor); 619 618 } 620 619
+2 -35
dll/win32/riched20/txthost.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "config.h" 22 - #include "wine/port.h" 23 - 24 21 #define COBJMACROS 25 22 26 23 #include "editor.h" ··· 28 25 #include "richole.h" 29 26 #include "imm.h" 30 27 #include "textserv.h" 28 + #include "wine/asm.h" 31 29 #include "wine/debug.h" 32 30 #include "editstr.h" 33 31 ··· 497 495 *lSelBarWidth = (style & ES_SELECTIONBAR) ? 225 : 0; /* in HIMETRIC */ 498 496 return S_OK; 499 497 } 500 - 501 - 502 - #ifdef __i386__ /* thiscall functions are i386-specific */ 503 - 504 - #define THISCALL(func) (void *) __thiscall_ ## func 505 - #ifdef _MSC_VER 506 - #define DEFINE_THISCALL_WRAPPER(func,args) \ 507 - __declspec(naked) HRESULT __thiscall_##func(void) \ 508 - { \ 509 - __asm pop eax \ 510 - __asm push ecx \ 511 - __asm push eax \ 512 - __asm jmp func \ 513 - } 514 - #else /* _MSC_VER */ 515 - #define DEFINE_THISCALL_WRAPPER(func,args) \ 516 - extern HRESULT __thiscall_ ## func(void); \ 517 - __ASM_GLOBAL_FUNC(__thiscall_ ## func, \ 518 - "popl %eax\n\t" \ 519 - "pushl %ecx\n\t" \ 520 - "pushl %eax\n\t" \ 521 - "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) ) 522 - #endif /* _MSC_VER */ 523 - 524 - #else /* __i386__ */ 525 - 526 - #define THISCALL(func) func 527 - #define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */ 528 - 529 - #endif /* __i386__ */ 530 - 531 498 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetDC,4) 532 499 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxReleaseDC,8) 533 500 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowScrollBar,12) ··· 568 535 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmReleaseContext,8) 569 536 DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSelectionBarWidth,8) 570 537 571 - #ifdef __i386__ /* thiscall functions are i386-specific */ 538 + #if defined(__i386__) && !defined(__MINGW32__) /* thiscall functions are i386-specific */ 572 539 573 540 #define STDCALL(func) (void *) __stdcall_ ## func 574 541 #ifdef _MSC_VER
+3 -37
dll/win32/riched20/txtsrv.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "config.h" 22 - #include "wine/port.h" 23 - 24 21 #define COBJMACROS 25 22 26 23 #include "editor.h" ··· 30 27 #include "tom.h" 31 28 #include "imm.h" 32 29 #include "textserv.h" 30 + #include "wine/asm.h" 33 31 #include "wine/debug.h" 34 32 #include "editstr.h" 35 33 36 - #ifdef __i386__ /* thiscall functions are i386-specific */ 37 - 38 - #define THISCALL(func) (void *) __thiscall_ ## func 39 - #ifdef _MSC_VER 40 - #define DEFINE_THISCALL_WRAPPER(func,args) \ 41 - __declspec(naked) HRESULT __thiscall_##func(void) \ 42 - { \ 43 - __asm pop eax \ 44 - __asm push ecx \ 45 - __asm push eax \ 46 - __asm jmp func \ 47 - } 48 - #else /* _MSC_VER */ 49 - #define DEFINE_THISCALL_WRAPPER(func,args) \ 50 - extern HRESULT __thiscall_ ## func(void); \ 51 - __ASM_GLOBAL_FUNC(__thiscall_ ## func, \ 52 - "popl %eax\n\t" \ 53 - "pushl %ecx\n\t" \ 54 - "pushl %eax\n\t" \ 55 - "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) ) 56 - #endif /* _MSC_VER */ 57 - 58 - #else /* __i386__ */ 59 - 60 - #define THISCALL(func) func 61 - #define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */ 62 - 63 - #endif /* __i386__ */ 64 - 65 34 WINE_DEFAULT_DEBUG_CHANNEL(richedit); 66 35 67 36 typedef struct ITextServicesImpl { ··· 95 64 if (!This->editor->reOle) 96 65 if (!CreateIRichEditOle(This->outer_unk, This->editor, (void **)(&This->editor->reOle))) 97 66 return E_OUTOFMEMORY; 98 - if (IsEqualIID(riid, &IID_ITextDocument) || IsEqualIID(riid, &IID_ITextDocument2Old)) 99 - ME_GetITextDocument2OldInterface(This->editor->reOle, ppv); 100 - else 101 - *ppv = This->editor->reOle; 67 + return IUnknown_QueryInterface(This->editor->reOle, riid, ppv); 102 68 } else { 103 69 *ppv = NULL; 104 70 FIXME("Unknown interface: %s\n", debugstr_guid(riid)); ··· 312 278 ME_InternalDeleteText(This->editor, &cursor, ME_GetTextLength(This->editor), FALSE); 313 279 if(pszText) 314 280 ME_InsertTextFromCursor(This->editor, 0, pszText, -1, This->editor->pBuffer->pDefaultStyle); 315 - ME_SetSelection(This->editor, 0, 0); 281 + set_selection_cursors(This->editor, 0, 0); 316 282 This->editor->nModifyStep = 0; 317 283 OleFlushClipboard(); 318 284 ME_EmptyUndoStack(This->editor);
+1 -4
dll/win32/riched20/wrap.c
··· 65 65 static HRESULT shape_run( ME_Context *c, ME_Run *run ) 66 66 { 67 67 HRESULT hr; 68 - HFONT old_font; 69 68 int i; 70 69 71 70 if (!run->glyphs) ··· 82 81 run->clusters = heap_alloc( run->max_clusters * sizeof(WORD) ); 83 82 } 84 83 85 - old_font = ME_SelectStyleFont( c, run->style ); 84 + select_style( c, run->style ); 86 85 while (1) 87 86 { 88 87 hr = ScriptShape( c->hDC, &run->style->script_cache, get_text( run, 0 ), run->len, run->max_glyphs, ··· 102 101 for (i = 0, run->nWidth = 0; i < run->num_glyphs; i++) 103 102 run->nWidth += run->advances[i]; 104 103 } 105 - 106 - ME_UnselectStyleFont( c, run->style, old_font ); 107 104 108 105 return hr; 109 106 }
+8 -11
dll/win32/riched20/writer.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 19 */ 20 20 21 - #include "config.h" 22 - #include "wine/port.h" 23 - 24 21 #define NONAMELESSUNION 25 22 26 23 #include "editor.h" ··· 123 120 } 124 121 125 122 126 - static BOOL 123 + static BOOL WINAPIV 127 124 ME_StreamOutPrint(ME_OutStream *pStream, const char *format, ...) 128 125 { 129 126 char string[STREAMOUT_BUFFER_SIZE]; /* This is going to be enough */ 130 127 int len; 131 - va_list valist; 128 + __ms_va_list valist; 132 129 133 - va_start(valist, format); 130 + __ms_va_start(valist, format); 134 131 len = vsnprintf(string, sizeof(string), format, valist); 135 - va_end(valist); 136 - 132 + __ms_va_end(valist); 133 + 137 134 return ME_StreamOutMove(pStream, string, len); 138 135 } 139 136 ··· 245 242 { 246 243 for (i = 0; i < stream->nFontTblLen; i++) 247 244 if (table[i].bCharSet == charset 248 - && (table[i].szFaceName == face || !lstrcmpW(table[i].szFaceName, face))) 245 + && (table[i].szFaceName == face || !wcscmp(table[i].szFaceName, face))) 249 246 break; 250 247 251 248 if (i == stream->nFontTblLen && i < STREAMOUT_FONTTBL_SIZE) ··· 270 267 for (i = 0; i < stream->nFontTblLen; i++) 271 268 { 272 269 if (facename == stream->fonttbl[i].szFaceName 273 - || !lstrcmpW(facename, stream->fonttbl[i].szFaceName)) 270 + || !wcscmp(facename, stream->fonttbl[i].szFaceName)) 274 271 if (!(fmt->dwMask & CFM_CHARSET) 275 272 || fmt->bCharSet == stream->fonttbl[i].bCharSet) 276 273 { ··· 841 838 } 842 839 } 843 840 844 - if (strcmpW(old_fmt->szFaceName, fmt->szFaceName) || 841 + if (wcscmp(old_fmt->szFaceName, fmt->szFaceName) || 845 842 old_fmt->bCharSet != fmt->bCharSet) 846 843 { 847 844 if (find_font_in_fonttbl( pStream, fmt, &i ))
+1 -1
media/doc/README.WINE
··· 159 159 dll/win32/query # Synced to WineStaging-4.18 160 160 dll/win32/rasapi32 # Synced to WineStaging-3.3 161 161 dll/win32/resutils # Synced to WineStaging-3.3 162 - dll/win32/riched20 # Synced to WineStaging-4.0 162 + dll/win32/riched20 # Synced to WineStaging-4.18 163 163 dll/win32/riched32 # Synced to WineStaging-3.3 164 164 dll/win32/rpcrt4 # Synced to WineStaging-4.0 165 165 dll/win32/rsabase # Synced to WineStaging-3.3