From 66142639448faf340baed0ac857240eb66f9fae2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 12 Sep 2024 16:51:46 +0300 Subject: =?UTF-8?q?fixes=20#4651=20(NewStory+tabSRMM:=20=D0=A4=D0=BE=D1=80?= =?UTF-8?q?=D0=BC=D0=B0=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=B0=20=D0=BF=D0=BE-?= =?UTF-8?q?=D1=80=D0=B0=D0=B7=D0=BD=D0=BE=D0=BC=D1=83=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20=D0=B2=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=D0=B2=D0=B0=D1=82=D0=B0=D1=85=20=D0=B8=20=D1=87=D0=B0=D1=82?= =?UTF-8?q?=D0=B0=D1=85)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/Scriver/src/msgdialog.cpp | 1 - plugins/TabSRMM/src/msgdlgother.cpp | 88 +++++++++++-------------------------- 2 files changed, 26 insertions(+), 63 deletions(-) (limited to 'plugins') diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 8d7b10a6ba..47f8893719 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -331,7 +331,6 @@ void CMsgDialog::onClick_Ok(CCtrlButton *pButton) CMStringW ptszText(ptrW(mir_utf8decodeW(msi.sendBuffer))); g_chatApi.DoRtfToTags(ptszText, 0, nullptr); ptszText.Trim(); - ptszText.Replace(L"%", L"%%"); if (m_si->pMI->bAckMsg) { EnableWindow(m_message.GetHwnd(), FALSE); diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp index e229888c22..edab00d7c3 100644 --- a/plugins/TabSRMM/src/msgdlgother.cpp +++ b/plugins/TabSRMM/src/msgdlgother.cpp @@ -260,7 +260,7 @@ BOOL CMsgDialog::DoRtfToTags(CMStringW &pszText) const } else idx += 5; - bool bInsideColor = false, bInsideUl = false; + bool bInsideUl = false; CMStringW res; // iterate through all characters, if rtf control character found then take action @@ -277,34 +277,21 @@ BOOL CMsgDialog::DoRtfToTags(CMStringW &pszText) const } if (!wcsncmp(p, L"\\cf", 3)) { // foreground color - int iCol = _wtoi(p + 3); - int iInd = RtfColorToIndex(iNumColors, pIndex, iCol); - - if (iCol > 0) { - if (isChat()) { - if (iInd >= 0) { - if (!(res.IsEmpty() && m_pContainer->m_theme.fontColors[MSGFONTID_MESSAGEAREA] == pColors[iInd])) - res.AppendFormat(L"%%c%u", iInd); - } - else if (!res.IsEmpty()) - res.Append(L"%%C"); - } - else res.AppendFormat((iInd >= 0) ? (bInsideColor ? L"[/color][color=%s]" : L"[color=%s]") : (bInsideColor ? L"[/color]" : L""), Utils::rtf_clrs[iInd].szName); - } - - bInsideColor = iInd >= 0; + int iInd = RtfColorToIndex(iNumColors, pIndex, _wtoi(p + 3)); + if (iInd >= 0) + res.AppendFormat(L"[color=%08X]", Utils::rtf_clrs[iInd].clr); + else if (!res.IsEmpty()) + res.Append(L"[/color]"); } else if (!wcsncmp(p, L"\\highlight", 10)) { // background color - if (isChat()) { - int iInd = RtfColorToIndex(iNumColors, pIndex, _wtoi(p + 10)); - if (iInd >= 0) { - // if the entry field is empty & the color passed is the back color, skip it - if (!(res.IsEmpty() && m_pContainer->m_theme.inputbg == pColors[iInd])) - res.AppendFormat(L"%%f%u", iInd); - } - else if (!res.IsEmpty()) - res.AppendFormat(L"%%F"); + int iInd = RtfColorToIndex(iNumColors, pIndex, _wtoi(p + 10)); + if (iInd >= 0) { + // if the entry field is empty & the color passed is the back color, skip it + if (m_pContainer->m_theme.inputbg != pColors[iInd]) + res.AppendFormat(L"[bkcolor=%08X]", Utils::rtf_clrs[iInd].clr); } + else if (!res.IsEmpty()) + res.AppendFormat(L"[/bkcolor]"); } else if (!wcsncmp(p, L"\\line", 5)) { // soft line break; res.AppendChar('\n'); @@ -331,20 +318,12 @@ BOOL CMsgDialog::DoRtfToTags(CMStringW &pszText) const res.AppendChar(0x2019); } else if (!wcsncmp(p, L"\\b", 2)) { //bold - if (isChat()) { - res.Append((p[2] != '0') ? L"%b" : L"%B"); - } - else { - if (!(lf.lfWeight == FW_BOLD)) // only allow bold if the font itself isn't a bold one, otherwise just strip it.. - if (m_bSendFormat) - res.Append((p[2] != '0') ? L"[b]" : L"[/b]"); - } + // only allow bold if the font itself isn't a bold one, otherwise just strip it.. + if (lf.lfWeight != FW_BOLD && m_bSendFormat) + res.Append((p[2] != '0') ? L"[b]" : L"[/b]"); } else if (!wcsncmp(p, L"\\i", 2)) { // italics - if (isChat()) { - res.Append((p[2] != '0') ? L"%i" : L"%I"); - } - else if (!lf.lfItalic && m_bSendFormat) + if (!lf.lfItalic && m_bSendFormat) res.Append((p[2] != '0') ? L"[i]" : L"[/i]"); } else if (!wcsncmp(p, L"\\strike", 7)) { // strike-out @@ -352,20 +331,15 @@ BOOL CMsgDialog::DoRtfToTags(CMStringW &pszText) const res.Append((p[7] != '0') ? L"[s]" : L"[/s]"); } else if (!wcsncmp(p, L"\\ul", 3)) { // underlined - if (isChat()) { - res.Append((p[3] != '0') ? L"%u" : L"%U"); - } - else { - if (!lf.lfUnderline && m_bSendFormat) { - if (p[3] == 0 || wcschr(tszRtfBreaks, p[3])) { - res.Append(L"[u]"); - bInsideUl = true; - } - else if (!wcsncmp(p + 3, L"none", 4)) { - if (bInsideUl) - res.Append(L"[/u]"); - bInsideUl = false; - } + if (!lf.lfUnderline && m_bSendFormat) { + if (p[3] == 0 || wcschr(tszRtfBreaks, p[3])) { + res.Append(L"[u]"); + bInsideUl = true; + } + else if (!wcsncmp(p + 3, L"none", 4)) { + if (bInsideUl) + res.Append(L"[/u]"); + bInsideUl = false; } } } @@ -402,22 +376,12 @@ BOOL CMsgDialog::DoRtfToTags(CMStringW &pszText) const p++; break; - case '%': // double % for stupid chat engine - if (isChat()) - res.Append(L"%%"); - else - res.AppendChar(*p); - p++; - break; - default: // other text that should not be touched res.AppendChar(*p++); break; } } - if (bInsideColor && !isChat()) - res.Append(L"[/color]"); if (bInsideUl) res.Append(L"[/u]"); -- cgit v1.2.3