From ccde738e49d3102681ab38c6b3e250e9fb57c8bb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 16 Sep 2024 19:21:57 +0300 Subject: =?UTF-8?q?fixes=20#4675=20(=D0=9D=D0=B5=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=B0=D1=8E=D1=82=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA?= =?UTF-8?q?=D0=B8=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B2=20StdMsg/Scriver)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/Scriver/res/resource.rc | 19 ++-- plugins/Scriver/scriver.vcxproj | 52 +++++++++ plugins/Scriver/scriver.vcxproj.filters | 148 ++++++++++++++++++++++++ plugins/Scriver/src/msgdialog.cpp | 3 +- plugins/Scriver/src/msgoptions.cpp | 4 +- plugins/Scriver/src/msgs.h | 1 + plugins/Scriver/src/msgutils.cpp | 6 + plugins/Scriver/src/resource.h | 2 + plugins/Scriver/src/srmm.cpp | 1 + plugins/Scriver/src/stdafx.h | 2 +- plugins/TabSRMM/src/msgdlgother.cpp | 192 ++------------------------------ plugins/TabSRMM/src/msgs.h | 3 +- 12 files changed, 237 insertions(+), 196 deletions(-) (limited to 'plugins') diff --git a/plugins/Scriver/res/resource.rc b/plugins/Scriver/res/resource.rc index aba7df9289..7f6ef8da39 100644 --- a/plugins/Scriver/res/resource.rc +++ b/plugins/Scriver/res/resource.rc @@ -27,12 +27,12 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL // Dialog // -IDD_OPT_MSGDLG DIALOGEX 2, 0, 304, 147 +IDD_OPT_MSGDLG DIALOGEX 2, 0, 304, 164 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - GROUPBOX "Behavior",IDC_STATIC,0,0,304,143 + GROUPBOX "Behavior",IDC_STATIC,0,0,304,160 CONTROL "Automatically pop up the window when",IDC_AUTOPOPUP, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,12,155,10 CONTROL "Tree1",IDC_POPLIST,"SysTreeView32",TVS_DISABLEDRAGDROP | TVS_NOTOOLTIPS | TVS_NONEVENHEIGHT | WS_BORDER | WS_HSCROLL | WS_TABSTOP,163,12,98,44 @@ -45,10 +45,12 @@ BEGIN CONTROL "Remember unsent messages",IDC_SAVEDRAFTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,103,293,10 CONTROL "Delete temporary contacts on closing",IDC_DELTEMP, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,114,293,10 - LTEXT "Show warning when message has not been received after",IDC_STATIC,6,127,201,8 - EDITTEXT IDC_SECONDS,213,125,35,12,ES_RIGHT | ES_NUMBER - CONTROL "",IDC_SECONDSSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,239,124,11,13 - LTEXT "seconds",IDC_STATIC,253,127,44,8 + CONTROL "Use BBCodes to send format inside messages",IDC_SEND_FORMAT, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,126,293,10 + LTEXT "Show warning when message has not been received after",IDC_STATIC,6,145,201,8 + EDITTEXT IDC_SECONDS,213,143,35,12,ES_RIGHT | ES_NUMBER + CONTROL "",IDC_SECONDSSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,239,143,11,13 + LTEXT "seconds",IDC_STATIC,253,145,44,8 END IDD_OPT_MSGTABS DIALOGEX 2, 0, 304, 230 @@ -220,8 +222,8 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN CONTROL "",IDC_SRMM_LOG,"RichEdit50W",WS_CLIPSIBLINGS | WS_VSCROLL | WS_TABSTOP | 0x844,1,41,181,28,WS_EX_STATICEDGE CONTROL "",IDC_SRMM_MESSAGE,"RichEdit50W",WS_VSCROLL | WS_TABSTOP | 0x1144,0,87,181,13,WS_EX_ACCEPTFILES | WS_EX_STATICEDGE - CONTROL "",IDC_SRMM_QUOTE,"RichEdit50W",ES_AUTOHSCROLL | WS_DISABLED | WS_BORDER | WS_TABSTOP,0,95,235,16 - CONTROL "",IDC_SRMM_CLOSEQUOTE,"MButtonClass", WS_TABSTOP,237,97,16,16 + CONTROL "",IDC_SRMM_QUOTE,"RichEdit50W",WS_DISABLED | WS_BORDER | WS_TABSTOP | 0x80,0,95,235,16 + CONTROL "",IDC_SRMM_CLOSEQUOTE,"MButtonClass",WS_TABSTOP,237,97,16,16 CONTROL "",IDC_SPLITTERX,"Static",SS_ENHMETAFILE,172,23,10,73 CONTROL "",IDC_SPLITTERY,"Static",SS_ENHMETAFILE | WS_CLIPSIBLINGS,0,85,183,2 LISTBOX IDC_SRMM_NICKLIST,182,23,69,73,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | NOT WS_BORDER | WS_VSCROLL | WS_TABSTOP,WS_EX_STATICEDGE @@ -321,6 +323,7 @@ GUIDELINES DESIGNINFO BEGIN IDD_OPT_MSGDLG, DIALOG BEGIN + BOTTOMMARGIN, 147 END IDD_OPT_MSGTABS, DIALOG diff --git a/plugins/Scriver/scriver.vcxproj b/plugins/Scriver/scriver.vcxproj index a92315853a..93f4cd9644 100644 --- a/plugins/Scriver/scriver.vcxproj +++ b/plugins/Scriver/scriver.vcxproj @@ -64,4 +64,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/Scriver/scriver.vcxproj.filters b/plugins/Scriver/scriver.vcxproj.filters index ffe211f657..ac5f862451 100644 --- a/plugins/Scriver/scriver.vcxproj.filters +++ b/plugins/Scriver/scriver.vcxproj.filters @@ -106,4 +106,152 @@ Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + + + Resource Files + + + Resource Files + + \ No newline at end of file diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 47f8893719..69783ba143 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -108,6 +108,7 @@ void CMsgDialog::Init() SetParent(GetParentWindow(m_hContact, isChat())); m_pParent = (ParentWindowData *)GetWindowLongPtr(m_hwndParent, GWLP_USERDATA); + m_bSendFormat = g_plugin.bSendFormat; m_btnOk.OnClick = Callback(this, &CMsgDialog::onClick_Ok); timerType.OnEvent = Callback(this, &CMsgDialog::onType); @@ -329,7 +330,7 @@ void CMsgDialog::onClick_Ok(CCtrlButton *pButton) if (isChat()) { CMStringW ptszText(ptrW(mir_utf8decodeW(msi.sendBuffer))); - g_chatApi.DoRtfToTags(ptszText, 0, nullptr); + DoRtfToTags(ptszText); ptszText.Trim(); if (m_si->pMI->bAckMsg) { diff --git a/plugins/Scriver/src/msgoptions.cpp b/plugins/Scriver/src/msgoptions.cpp index 7e6dddeccb..473929fa5d 100644 --- a/plugins/Scriver/src/msgoptions.cpp +++ b/plugins/Scriver/src/msgoptions.cpp @@ -243,7 +243,7 @@ class CMainOptionsDlg : public CBaseOptionDlg CCtrlSpin spinTimeout; CCtrlCheck chkAutoMin, chkAutoPopup, chkCascade, chkSavePerContact, chkStayMinimized; - CCtrlCheck chkSaveDrafts, chkDelTemp, chkHideContainer; + CCtrlCheck chkSaveDrafts, chkDelTemp, chkHideContainer, chkSendFormat; CCtrlTreeView m_tree; public: @@ -255,6 +255,7 @@ public: chkCascade(this, IDC_CASCADE), chkDelTemp(this, IDC_DELTEMP), chkAutoPopup(this, IDC_AUTOPOPUP), + chkSendFormat(this, IDC_SEND_FORMAT), chkSaveDrafts(this, IDC_SAVEDRAFTS), chkHideContainer(this, IDC_HIDECONTAINERS), chkStayMinimized(this, IDC_STAYMINIMIZED), @@ -264,6 +265,7 @@ public: CreateLink(chkCascade, g_plugin.bCascade); CreateLink(chkAutoMin, g_plugin.bAutoMin); CreateLink(chkAutoPopup, g_plugin.bAutoPopup); + CreateLink(chkSendFormat, g_plugin.bSendFormat); CreateLink(chkSaveDrafts, g_plugin.bSaveDrafts); CreateLink(chkHideContainer, g_plugin.bHideContainer); CreateLink(chkStayMinimized, g_plugin.bStayMinimized); diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index 28ec396099..3a71949364 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -132,6 +132,7 @@ public: void DrawNickList(USERINFO *ui, DRAWITEMSTRUCT *dis) override; void EventAdded(MEVENT, const DB::EventInfo &dbei) override; bool GetFirstEvent() override; + void GetInputFont(LOGFONTW &lf, COLORREF &bg, COLORREF &fg) const override; void LoadSettings() override; void OnOptionsApplied() override; void RemakeLog() override; diff --git a/plugins/Scriver/src/msgutils.cpp b/plugins/Scriver/src/msgutils.cpp index 9167a4f3dd..263afe7da8 100644 --- a/plugins/Scriver/src/msgutils.cpp +++ b/plugins/Scriver/src/msgutils.cpp @@ -170,6 +170,12 @@ bool CMsgDialog::GetFirstEvent() return notifyUnread; } +void CMsgDialog::GetInputFont(LOGFONTW &lf, COLORREF &bg, COLORREF &fg) const +{ + bg = m_clrInputBG; + LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, &lf, &fg); +} + void CMsgDialog::FixTabIcons() { HICON hIcon; diff --git a/plugins/Scriver/src/resource.h b/plugins/Scriver/src/resource.h index 2f97993ce5..7f5bb9ed3d 100644 --- a/plugins/Scriver/src/resource.h +++ b/plugins/Scriver/src/resource.h @@ -127,6 +127,8 @@ #define IDC_NOTIFYTRAY 1607 #define IDC_NOTIFYBALLOON 1608 #define IDC_DELTEMP 1609 +#define IDC_DELTEMP2 1610 +#define IDC_SEND_FORMAT 1610 #define IDC_AVATARSUPPORT 1611 #define IDC_LIMITNAMES 1615 #define IDC_TRANSPARENCY 1616 diff --git a/plugins/Scriver/src/srmm.cpp b/plugins/Scriver/src/srmm.cpp index 242673aefa..268a3bda76 100644 --- a/plugins/Scriver/src/srmm.cpp +++ b/plugins/Scriver/src/srmm.cpp @@ -56,6 +56,7 @@ CMPlugin::CMPlugin() : bAutoClose(SRMM_MODULE, "AutoClose", false), bAutoPopup(SRMM_MODULE, "AutoPopupMsg", false), bSaveDrafts(SRMM_MODULE, "SaveDrafts", false), + bSendFormat(SRMM_MODULE, "SendFormat", false), bTypingUnknown(SRMM_MODULE, "UnknownTyping", false), bHideContainer(SRMM_MODULE, "HideContainers", false), bStayMinimized(SRMM_MODULE, "StayMinimized", false), diff --git a/plugins/Scriver/src/stdafx.h b/plugins/Scriver/src/stdafx.h index 731e44ad23..15de6bab32 100644 --- a/plugins/Scriver/src/stdafx.h +++ b/plugins/Scriver/src/stdafx.h @@ -76,7 +76,7 @@ struct CMPlugin : public PLUGIN CMOption bUseTransparency, bTopmost, bAutoClose, bTypingNew, bTypingUnknown; CMOption bShowTitleBar, bShowStatusBar, bShowToolBar, bShowInfoBar; CMOption bShowAvatar, bShowProgress, bShowIcons, bShowTime, bShowSeconds, bShowDate, bLongDate, bRelativeDate; - CMOption bGroupMessages, bMarkFollowups, bMsgOnNewline, bDrawLines, bHideNames, bIndentText; + CMOption bGroupMessages, bMarkFollowups, bMsgOnNewline, bDrawLines, bHideNames, bIndentText, bSendFormat; CMOption bUseTabs, bLimitTabs, bLimitChatTabs, bLimitNames, bSeparateChats, bTabCloseButton, bHideOneTab, bTabsAtBottom, bSwitchToActive; CMOption bShowTyping, bShowTypingWin, bShowTypingTray, bShowTypingClist, bShowTypingSwitch; CMOption iFlashCount, iHistoryMode; diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp index e94ca1a89d..1317a38f3c 100644 --- a/plugins/TabSRMM/src/msgdlgother.cpp +++ b/plugins/TabSRMM/src/msgdlgother.cpp @@ -185,189 +185,6 @@ void CMsgDialog::DetermineMinHeight() m_pContainer->m_uChildMinHeight = height; } -///////////////////////////////////////////////////////////////////////////////////////// -// convert rich edit code to bbcode (if wanted). Otherwise, strip all RTF formatting -// tags and return plain text - -static wchar_t tszRtfBreaks[] = L" \\\n\r"; - -static void CreateColorMap(const wchar_t *pszText, std::vector &res) -{ - const wchar_t *p1 = wcsstr(pszText, L"\\colortbl"); - if (!p1) - return; - - const wchar_t *pEnd = wcschr(p1, '}'); - - for (const wchar_t *p2 = wcsstr(p1, L"\\red"); p2 && p2 < pEnd; p2 = wcsstr(p1, L"\\red")) { - int iRed, iGreen, iBlue; - if (swscanf(p2, L"\\red%d\\green%d\\blue%d;", &iRed, &iGreen, &iBlue) > 0) - res.push_back(RGB(iRed, iGreen, iBlue)); - - p1 = p2 + 1; - } -} - -BOOL CMsgDialog::DoRtfToTags(CMStringW &pszText) const -{ - if (pszText.IsEmpty()) - return FALSE; - - // used to filter out attributes which are already set for the default message input area font - auto &lf = m_pContainer->m_theme.logFonts[MSGFONTID_MESSAGEAREA]; - - // create an index of colors in the module and map them to - // corresponding colors in the RTF color table - std::vector colorTable; - CreateColorMap(pszText, colorTable); - - // scan the file for rtf commands and remove or parse them - int idx = pszText.Find(L"\\pard"); - if (idx == -1) { - if ((idx = pszText.Find(L"\\ltrpar")) == -1) - return FALSE; - idx += 7; - } - else idx += 5; - - bool bInsideUl = false, bStart = true; - CMStringW res; - - // iterate through all characters, if rtf control character found then take action - for (const wchar_t *p = pszText.GetString() + idx; *p;) { - switch (*p) { - case '\\': - if (p[1] == '\\' || p[1] == '{' || p[1] == '}') { // escaped characters - res.AppendChar(p[1]); - bStart = false; - p += 2; break; - } - if (p[1] == '~') { // non-breaking space - res.AppendChar(0xA0); - bStart = false; - p += 2; break; - } - - if (!wcsncmp(p, L"\\cf", 3)) { // foreground color - COLORREF cr = colorTable[_wtoi(p + 3) - 1]; - if (cr != m_pContainer->m_theme.fontColors[MSGFONTID_MESSAGEAREA]) - res.AppendFormat(L"[color=%08X]", cr); - else if (!bStart) - res.Append(L"[/color]"); - } - else if (!wcsncmp(p, L"\\highlight", 10)) { // background color - COLORREF cr = colorTable[_wtoi(p + 10) - 1]; - if (cr != m_pContainer->m_theme.inputbg) - res.AppendFormat(L"[bkcolor=%08X]", cr); - else if (!bStart) - res.AppendFormat(L"[/bkcolor]"); - } - else if (!wcsncmp(p, L"\\line", 5)) { // soft line break; - res.AppendChar('\n'); - bStart = false; - } - else if (!wcsncmp(p, L"\\endash", 7)) { - res.AppendChar(0x2013); - bStart = false; - } - else if (!wcsncmp(p, L"\\emdash", 7)) { - res.AppendChar(0x2014); - bStart = false; - } - else if (!wcsncmp(p, L"\\bullet", 7)) { - res.AppendChar(0x2022); - bStart = false; - } - else if (!wcsncmp(p, L"\\ldblquote", 10)) { - res.AppendChar(0x201C); - bStart = false; - } - else if (!wcsncmp(p, L"\\rdblquote", 10)) { - res.AppendChar(0x201D); - bStart = false; - } - else if (!wcsncmp(p, L"\\lquote", 7)) { - res.AppendChar(0x2018); - bStart = false; - } - else if (!wcsncmp(p, L"\\rquote", 7)) { - res.AppendChar(0x2019); - bStart = false; - } - else if (!wcsncmp(p, L"\\b", 2)) { //bold - // 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 (!lf.lfItalic && m_bSendFormat) - res.Append((p[2] != '0') ? L"[i]" : L"[/i]"); - } - else if (!wcsncmp(p, L"\\strike", 7)) { // strike-out - if (!lf.lfStrikeOut && m_bSendFormat) - res.Append((p[7] != '0') ? L"[s]" : L"[/s]"); - } - else if (!wcsncmp(p, L"\\ul", 3)) { // underlined - 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; - } - } - } - else if (!wcsncmp(p, L"\\tab", 4)) { // tab - res.AppendChar('\t'); - } - else if (p[1] == '\'') { // special character - if (p[2] != ' ' && p[2] != '\\') { - wchar_t tmp[10]; - - if (p[3] != ' ' && p[3] != '\\') { - wcsncpy(tmp, p + 2, 3); - tmp[3] = 0; - } - else { - wcsncpy(tmp, p + 2, 2); - tmp[2] = 0; - } - - // convert string containing char in hex format to int. - wchar_t *stoppedHere; - res.AppendChar(wcstol(tmp, &stoppedHere, 16)); - bStart = false; - } - } - - p++; // skip initial slash - p += wcscspn(p, tszRtfBreaks); - if (*p == ' ') - p++; - break; - - case '{': // other RTF control characters - case '}': - p++; - break; - - default: // other text that should not be touched - res.AppendChar(*p++); - bStart = false; - break; - } - } - - if (bInsideUl) - res.Append(L"[/u]"); - - pszText = res; - return TRUE; -} - ///////////////////////////////////////////////////////////////////////////////////////// void CMsgDialog::DrawNickList(USERINFO *ui, DRAWITEMSTRUCT *dis) @@ -638,6 +455,15 @@ bool CMsgDialog::GetFirstEvent() return true; } +///////////////////////////////////////////////////////////////////////////////////////// + +void CMsgDialog::GetInputFont(LOGFONTW &lf, COLORREF &bg, COLORREF &fg) const +{ + lf = m_pContainer->m_theme.logFonts[MSGFONTID_MESSAGEAREA]; + fg = m_pContainer->m_theme.fontColors[MSGFONTID_MESSAGEAREA]; + bg = m_pContainer->m_theme.inputbg; +} + ///////////////////////////////////////////////////////////////////////////////////////// // returns != 0 when one of the installed keyboard layouts belongs to an rtl language // used to find out whether we need to configure the message input box for bidirectional mode diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 5e6aefbe58..106ae689b6 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -413,7 +413,6 @@ class CMsgDialog : public CSrmmBaseDialog void AdjustBottomAvatarDisplay(void); bool CalcDynamicAvatarSize(BITMAP *bminfo); void DetermineMinHeight(void); - BOOL DoRtfToTags(CMStringW &pszText) const; int FindRTLLocale(void); void FlashOnClist(MEVENT hEvent, const DB::EventInfo &dbei); void FlashTab(bool bInvertMode); @@ -465,7 +464,6 @@ class CMsgDialog : public CSrmmBaseDialog bool m_bInsertMode, m_bInitMode = true; bool m_bDeferredScroll; bool m_bWasBackgroundCreate; - bool m_bSendFormat; int m_iRealAvatarHeight; int m_iButtonBarReallyNeeds; @@ -591,6 +589,7 @@ public: void DrawNickList(USERINFO *ui, DRAWITEMSTRUCT *dis) override; void EventAdded(MEVENT, const DB::EventInfo &dbei) override; bool GetFirstEvent() override; + void GetInputFont(LOGFONTW &lf, COLORREF &bg, COLORREF &fg) const override; bool IsActive() const override; void LoadSettings() override; void OnOptionsApplied() override; -- cgit v1.2.3