From d95e27d5317d3a5cdea011e8459b4c7d427fd415 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 29 Jul 2022 14:01:06 +0300 Subject: =?UTF-8?q?fixes=20#3129=20(tabSRMM:=20=D1=80=D0=B0=D1=81=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=82=D1=8C=20?= =?UTF-8?q?=D0=BE=D0=BF=D1=86=D0=B8=D0=B8=20"=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D1=8F=D1=82=D1=8C=20=D0=B4=D0=B2=D0=BE=D0=B5=D1=82?= =?UTF-8?q?=D0=BE=D1=87=D0=B8=D0=B5/=D1=82=D0=BE=D1=87=D0=BA=D1=83=20?= =?UTF-8?q?=D1=81=20=D0=B7=D0=B0=D0=BF=D1=8F=D1=82=D0=BE=D0=B9"=20(=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=20=D0=B0=D0=B2=D1=82=D0=BE=D0=B7=D0=B0=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D1=88=D0=B5=D0=BD=D0=B8=D0=B8=20=D0=BD=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?)=20=D0=BD=D0=B0=20=D0=B4=D0=B2=D0=BE=D0=B9=D0=BD=D0=BE=D0=B9?= =?UTF-8?q?=20=D0=BA=D0=BB=D0=B8=D0=BA=20=D0=BF=D0=BE=20=D0=BD=D0=B8=D0=BA?= =?UTF-8?q?=D1=83)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/TabSRMM/src/msgdialog.cpp | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'plugins/TabSRMM/src') diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index d2c89a5ec9..3c39fd5db8 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -2407,42 +2407,38 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) CHARRANGE chr; m_message.SendMsg(EM_EXGETSEL, 0, (LPARAM)&chr); - wchar_t tszAplTmpl[] = L"%s:"; - size_t bufSize = mir_wstrlen(tr.lpstrText) + mir_wstrlen(tszAplTmpl) + 3; - wchar_t *tszTmp = (wchar_t *)mir_alloc(bufSize * sizeof(wchar_t)), *tszAppeal = tszTmp; + CMStringW buf(tr.lpstrText); + wchar_t str[2] = { 0, 0 }; TEXTRANGE tr2; - tr2.lpstrText = (LPTSTR)mir_alloc(sizeof(wchar_t) * 2); + tr2.lpstrText = str; + if (chr.cpMin) { // prepend nick with space if needed tr2.chrg.cpMin = chr.cpMin - 1; tr2.chrg.cpMax = chr.cpMin; m_message.SendMsg(EM_GETTEXTRANGE, 0, (LPARAM)&tr2); if (!iswspace(*tr2.lpstrText)) - *tszTmp++ = ' '; - mir_wstrcpy(tszTmp, tr.lpstrText); + buf.Insert(0, ' '); + } + else {// in the beginning of the message window + if (g_Settings.bUseCommaAsColon) + buf.AppendChar(','); + else if (g_Settings.bAddColonToAutoComplete) + buf.AppendChar(':'); } - else // in the beginning of the message window - mir_snwprintf(tszAppeal, bufSize, tszAplTmpl, tr.lpstrText); - size_t st = mir_wstrlen(tszAppeal); if (chr.cpMax != -1) { tr2.chrg.cpMin = chr.cpMax; tr2.chrg.cpMax = chr.cpMax + 1; // if there is no space after selection, // or there is nothing after selection at all... - if (!m_message.SendMsg(EM_GETTEXTRANGE, 0, (LPARAM)&tr2) || !iswspace(*tr2.lpstrText)) { - tszAppeal[st++] = ' '; - tszAppeal[st++] = '\0'; - } + if (!m_message.SendMsg(EM_GETTEXTRANGE, 0, (LPARAM)&tr2) || !iswspace(*tr2.lpstrText)) + buf.AppendChar(' '); } - else { - tszAppeal[st++] = ' '; - tszAppeal[st++] = '\0'; - } - m_message.SendMsg(EM_REPLACESEL, FALSE, (LPARAM)tszAppeal); - mir_free((void *)tr2.lpstrText); - mir_free((void *)tszAppeal); + else buf.AppendChar(' '); + + m_message.SendMsg(EM_REPLACESEL, FALSE, (LPARAM)buf.c_str()); } } SetFocus(m_message.GetHwnd()); -- cgit v1.2.3