diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 3073294bd7b..f7d383c2f10 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2375,7 +2375,7 @@ static BOOL copy_or_cut( ME_TextEditor *editor, BOOL cut ) int start_cursor = ME_GetSelectionOfs( editor, &offs, &count ); ME_Cursor *sel_start = &editor->pCursors[start_cursor]; - if (editor->cPasswordMask) return FALSE; + if (editor->password_char) return FALSE; count -= offs; hr = editor_copy_or_cut( editor, cut, sel_start, count, NULL ); @@ -3041,9 +3041,9 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) else ed->selofs = 0; ed->nSelectionType = stPosition; - ed->cPasswordMask = 0; + ed->password_char = 0; if (ed->props & TXTBIT_USEPASSWORD) - ITextHost_TxGetPasswordChar(texthost, &ed->cPasswordMask); + ITextHost_TxGetPasswordChar( texthost, &ed->password_char ); ed->bWordWrap = (ed->props & TXTBIT_WORDWRAP) && (ed->props & TXTBIT_MULTILINE); @@ -4217,10 +4217,6 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, return 1; return 0; } - case EM_GETPASSWORDCHAR: - { - return editor->cPasswordMask; - } case EM_SETOLECALLBACK: if(editor->lpOleCallback) IRichEditOleCallback_Release(editor->lpOleCallback); @@ -4274,12 +4270,6 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, editor->mode = (editor->mode & ~mask) | changes; return 0; } - case EM_SETPASSWORDCHAR: - { - editor->cPasswordMask = wParam; - ME_RewrapRepaint(editor); - return 0; - } case EM_SETTARGETDEVICE: if (wParam == 0) { diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h index 0273fde4350..df07923548d 100644 --- a/dlls/riched20/editstr.h +++ b/dlls/riched20/editstr.h @@ -416,7 +416,7 @@ typedef struct tagME_TextEditor int mode; BOOL bHideSelection; BOOL AutoURLDetect_bEnable; - WCHAR cPasswordMask; + WCHAR password_char; BOOL bHaveFocus; /*for IME */ int imeStartIndex; diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c index 8ef5ada5855..607ced52089 100644 --- a/dlls/riched20/paint.c +++ b/dlls/riched20/paint.c @@ -333,9 +333,9 @@ static void draw_text( ME_Context *c, ME_Run *run, int x, int y, BOOL selected, && !(CFE_AUTOBACKCOLOR & run->style->fmt.dwEffects) ) ); - if (c->editor->cPasswordMask) + if (c->editor->password_char) { - masked = ME_MakeStringR( c->editor->cPasswordMask, run->len ); + masked = ME_MakeStringR( c->editor->password_char, run->len ); text = masked->szData; } diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c index e099c0be6dc..bc282b20a57 100644 --- a/dlls/riched20/run.c +++ b/dlls/riched20/run.c @@ -543,9 +543,9 @@ int ME_CharFromPointContext(ME_Context *c, int cx, ME_Run *run, BOOL closest, BO return closest ? cp + trailing : cp; } - if (c->editor->cPasswordMask) + if (c->editor->password_char) { - mask_text = ME_MakeStringR( c->editor->cPasswordMask, run->len ); + mask_text = ME_MakeStringR( c->editor->password_char, run->len ); str = mask_text->szData; } else @@ -626,9 +626,9 @@ int ME_PointFromCharContext(ME_Context *c, ME_Run *pRun, int nOffset, BOOL visua if (visual_order && pRun->script_analysis.fRTL) x = pRun->nWidth - x - 1; return x; } - if (c->editor->cPasswordMask) + if (c->editor->password_char) { - mask_text = ME_MakeStringR(c->editor->cPasswordMask, pRun->len); + mask_text = ME_MakeStringR( c->editor->password_char, pRun->len ); str = mask_text->szData; } else @@ -678,9 +678,9 @@ SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run *run, i { size.cx = run->nWidth; } - else if (c->editor->cPasswordMask) + else if (c->editor->password_char) { - ME_String *szMasked = ME_MakeStringR(c->editor->cPasswordMask,nLen); + ME_String *szMasked = ME_MakeStringR( c->editor->password_char, nLen ); ME_GetTextExtent(c, szMasked->szData, nLen,run->style, &size); ME_DestroyString(szMasked); } diff --git a/dlls/riched20/txthost.c b/dlls/riched20/txthost.c index ebccddf65e3..beb2e423089 100644 --- a/dlls/riched20/txthost.c +++ b/dlls/riched20/txthost.c @@ -50,6 +50,7 @@ struct host DWORD props, scrollbars, event_mask; RECT client_rect, set_rect; COLORREF back_colour; + WCHAR password_char; }; static const ITextHostVtbl textHostVtbl; @@ -114,6 +115,7 @@ struct host *host_create( HWND hwnd, CREATESTRUCTW *cs, BOOL emulate_10 ) SetRectEmpty( &texthost->set_rect ); GetClientRect( hwnd, &texthost->client_rect ); texthost->use_back_colour = 0; + texthost->password_char = (texthost->props & TXTBIT_USEPASSWORD) ? '*' : 0; return texthost; } @@ -381,8 +383,10 @@ DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetScrollBars( ITextHost *ifa DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPasswordChar,8) DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetPasswordChar( ITextHost *iface, WCHAR *c ) { - *c = '*'; - return S_OK; + struct host *host = impl_from_ITextHost( iface ); + + *c = host->password_char; + return *c ? S_OK : S_FALSE; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetAcceleratorPos,8) @@ -1058,6 +1062,10 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, else hr = get_lineA( host->text_srv, wparam, lparam, &res ); break; + case EM_GETPASSWORDCHAR: + ITextHost_TxGetPasswordChar( &host->ITextHost_iface, (WCHAR *)&res ); + break; + case EM_GETRECT: hr = ITextHost_TxGetClientRect( &host->ITextHost_iface, (RECT *)lparam ); break; @@ -1208,6 +1216,14 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, hr = set_options( host, wparam, lparam, &res ); break; + case EM_SETPASSWORDCHAR: + if (wparam == host->password_char) break; + host->password_char = wparam; + if (wparam) host->props |= TXTBIT_USEPASSWORD; + else host->props &= ~TXTBIT_USEPASSWORD; + ITextServices_OnTxPropertyBitsChange( host->text_srv, TXTBIT_USEPASSWORD, host->props & TXTBIT_USEPASSWORD ); + break; + case EM_SETREADONLY: { DWORD op = wparam ? ECOOP_OR : ECOOP_AND; diff --git a/dlls/riched20/txtsrv.c b/dlls/riched20/txtsrv.c index 9cf1908b4de..e86a8936531 100644 --- a/dlls/riched20/txtsrv.c +++ b/dlls/riched20/txtsrv.c @@ -390,6 +390,13 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxPropertyBitsChange( ITextServic if (SUCCEEDED( hr )) repaint = TRUE; } + if (mask & TXTBIT_USEPASSWORD) + { + if (bits & TXTBIT_USEPASSWORD) ITextHost_TxGetPasswordChar( services->host, &services->editor->password_char ); + else services->editor->password_char = 0; + repaint = TRUE; + } + if (repaint) ME_RewrapRepaint( services->editor ); return S_OK; diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c index 0ca70b8a8ad..dcda041d773 100644 --- a/dlls/riched20/wrap.c +++ b/dlls/riched20/wrap.c @@ -829,7 +829,7 @@ static void ME_WrapTextParagraph( ME_TextEditor *editor, ME_Context *c, ME_Parag para_num_init( c, para ); /* For now treating all non-password text as complex for better testing */ - if (!c->editor->cPasswordMask /* && + if (!c->editor->password_char /* && ScriptIsComplex( tp->member.para.text->szData, tp->member.para.text->nLen, SIC_COMPLEX ) == S_OK */) { if (SUCCEEDED( itemize_para( c, para ) ))