From a33e78824264ed11bde0051914a3d4d1e68d44ed Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 18 Sep 2024 19:04:48 +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/src/input.cpp | 6 -- plugins/Scriver/src/msgdialog.cpp | 121 ++++++++++++++++++++------------------ plugins/Scriver/src/msgs.cpp | 5 +- 3 files changed, 67 insertions(+), 65 deletions(-) (limited to 'plugins/Scriver/src') diff --git a/plugins/Scriver/src/input.cpp b/plugins/Scriver/src/input.cpp index e6e64db44d..6c95b288bf 100644 --- a/plugins/Scriver/src/input.cpp +++ b/plugins/Scriver/src/input.cpp @@ -181,12 +181,6 @@ int CMsgDialog::InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP return 0; } - if (wParam == 'I' && isCtrl) // ctrl-i (italics) - return FALSE; - - if (wParam == VK_SPACE && isCtrl) // ctrl-space (paste clean text) - return FALSE; - if (wParam == 'R' && isCtrl && isShift) { // ctrl-shift-r ToggleRtl(); return FALSE; diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index ff8c9b9a98..5fbaf8855d 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -291,62 +291,69 @@ void CMsgDialog::onClick_Ok(CCtrlButton *pButton) if (!pButton->Enabled() || m_hContact == 0) return; - PARAFORMAT2 pf2; - memset(&pf2, 0, sizeof(pf2)); - pf2.cbSize = sizeof(pf2); - pf2.dwMask = PFM_RTLPARA; - m_message.SendMsg(EM_GETPARAFORMAT, 0, (LPARAM)&pf2); - - SendQueue::Item msi = {}; - if (pf2.wEffects & PFE_RTLPARA) - msi.flags |= DBEF_RTL; - - msi.sendBuffer = m_message.GetRichTextRtf(true); - msi.sendBufferSize = (int)mir_strlen(msi.sendBuffer); - if (msi.sendBufferSize == 0) + ptrA streamOut(m_message.GetRichTextRtf(!m_bSendFormat)); + if (streamOut == nullptr) return; - if (Utils_IsRtl(ptrW(mir_utf8decodeW(msi.sendBuffer)))) - msi.flags |= DBEF_RTL; - - // Store messaging history - TCmdList *cmdListNew = tcmdlist_last(cmdList); - while (cmdListNew != nullptr && cmdListNew->temporary) { - cmdList = tcmdlist_remove(cmdList, cmdListNew); - cmdListNew = tcmdlist_last(cmdList); - } - if (msi.sendBuffer != nullptr) - cmdList = tcmdlist_append(cmdList, mir_strdup(rtrim(msi.sendBuffer)), 20, FALSE); + CMStringW wszText(ptrW(mir_utf8decodeW(streamOut))); + if (wszText.IsEmpty()) + return; - cmdListCurrent = nullptr; + if (m_bSendFormat) + DoRtfToTags(wszText); + wszText.TrimRight(); if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON) NotifyTyping(PROTOTYPE_SELFTYPING_OFF); - m_message.SetText(L""); - m_btnOk.Disable(); - if (g_plugin.bAutoMin) - ShowWindow(m_hwndParent, SW_MINIMIZE); - if (isChat()) { - CMStringW ptszText(ptrW(mir_utf8decodeW(msi.sendBuffer))); - DoRtfToTags(ptszText); - ptszText.Trim(); - if (m_si->pMI->bAckMsg) { EnableWindow(m_message.GetHwnd(), FALSE); m_message.SendMsg(EM_SETREADONLY, TRUE, 0); } else m_message.SetText(L""); - Chat_DoEventHook(m_si, GC_USER_MESSAGE, nullptr, ptszText, 0); + Chat_DoEventHook(m_si, GC_USER_MESSAGE, nullptr, wszText, 0); } else { + PARAFORMAT2 pf2; + memset(&pf2, 0, sizeof(pf2)); + pf2.cbSize = sizeof(pf2); + pf2.dwMask = PFM_RTLPARA; + m_message.SendMsg(EM_GETPARAFORMAT, 0, (LPARAM)&pf2); + + SendQueue::Item msi = {}; + if (pf2.wEffects & PFE_RTLPARA) + msi.flags |= DBEF_RTL; + + msi.sendBuffer = mir_utf8encodeW(wszText); + msi.sendBufferSize = (int)mir_strlen(msi.sendBuffer); + + if (Utils_IsRtl(wszText)) + msi.flags |= DBEF_RTL; + + // Store messaging history + TCmdList *cmdListNew = tcmdlist_last(cmdList); + while (cmdListNew != nullptr && cmdListNew->temporary) { + cmdList = tcmdlist_remove(cmdList, cmdListNew); + cmdListNew = tcmdlist_last(cmdList); + } + if (msi.sendBuffer != nullptr) + cmdList = tcmdlist_append(cmdList, mir_strdup(rtrim(msi.sendBuffer)), 20, FALSE); + + cmdListCurrent = nullptr; + if (pButton == nullptr) m_pParent->MessageSend(msi); else MessageSend(msi); } + + m_message.SetText(L""); + m_btnOk.Disable(); + if (g_plugin.bAutoMin) + ShowWindow(m_hwndParent, SW_MINIMIZE); + m_btnCloseQuote.Click(); } @@ -708,12 +715,27 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) return result; switch (msg) { + case EM_ACTIVATE: + SetActiveWindow(m_hwnd); + break; + + case WM_SYSCHAR: + if ((wParam == 's' || wParam == 'S') && (GetKeyState(VK_MENU) & 0x8000)) { + PostMessage(m_hwnd, WM_COMMAND, IDOK, 0); + return 0; + } + break; + + case WM_CONTEXTMENU: + InputAreaContextMenu(m_message.GetHwnd(), wParam, lParam, m_hContact); + return TRUE; + case WM_KEYDOWN: - if (isChat()) { - bool isShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0; - bool isCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0; - bool isAlt = (GetKeyState(VK_MENU) & 0x8000) != 0; + bool isShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0; + bool isCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0; + bool isAlt = (GetKeyState(VK_MENU) & 0x8000) != 0; + if (isChat()) { if (wParam == VK_TAB && isShift && !isCtrl) { // SHIFT-TAB (go to nick list) SetFocus(m_nickList.GetHwnd()); return TRUE; @@ -726,7 +748,7 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) RedrawWindow(m_nickList.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE); return 0; } - + if (wParam != VK_RIGHT && wParam != VK_LEFT) { replaceStrW(m_wszSearchQuery, nullptr); replaceStrW(m_wszSearchResult, nullptr); @@ -753,26 +775,11 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) m_btnChannelMgr.Click(); return TRUE; } - - if (ProcessHotkeys(wParam, isShift, isCtrl, isAlt)) - return TRUE; } - break; - - case EM_ACTIVATE: - SetActiveWindow(m_hwnd); - break; - case WM_SYSCHAR: - if ((wParam == 's' || wParam == 'S') && (GetKeyState(VK_MENU) & 0x8000)) { - PostMessage(m_hwnd, WM_COMMAND, IDOK, 0); - return 0; - } + if (ProcessHotkeys(wParam, isShift, isCtrl, isAlt)) + return TRUE; break; - - case WM_CONTEXTMENU: - InputAreaContextMenu(m_message.GetHwnd(), wParam, lParam, m_hContact); - return TRUE; } return CSuper::WndProc_Message(msg, wParam, lParam); } diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index a111e894bf..c404105eb3 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -394,8 +394,8 @@ int RegisterToolbarIcons(WPARAM, LPARAM) bbd.pwszTooltip = LPGENW("View user's history (Ctrl+H)"); g_plugin.addButton(&bbd); - // chat buttons - bbd.bbbFlags = BBBF_ISPUSHBUTTON | BBBF_ISCHATBUTTON | BBBF_CREATEBYID | BBBF_NOREADONLY; + // format buttons + bbd.bbbFlags = BBBF_ISPUSHBUTTON | BBBF_ISCHATBUTTON | BBBF_ISIMBUTTON | BBBF_CREATEBYID | BBBF_NOREADONLY; bbd.dwButtonID = IDC_SRMM_BOLD; bbd.dwDefPos = 10; bbd.hIcon = g_plugin.getIconHandle(IDI_BBOLD); @@ -431,6 +431,7 @@ int RegisterToolbarIcons(WPARAM, LPARAM) bbd.pwszTooltip = LPGENW("Select a background color for the text (Ctrl+L)"); g_plugin.addButton(&bbd); + // chat buttons bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID; bbd.dwButtonID = IDC_SRMM_CHANMGR; bbd.dwDefPos = 30; -- cgit v1.2.3