summaryrefslogtreecommitdiff
path: root/plugins/Scriver/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-09-18 19:04:48 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-09-18 19:04:48 +0300
commita33e78824264ed11bde0051914a3d4d1e68d44ed (patch)
treed3d7f470c3a5939c19e88525192b4ebf2afe131d /plugins/Scriver/src
parent66aae3c929b110d9621c649ebaeba2e75dc2a1b9 (diff)
fixes #4675 (Не работают кнопки форматирования в StdMsg/Scriver)
Diffstat (limited to 'plugins/Scriver/src')
-rw-r--r--plugins/Scriver/src/input.cpp6
-rw-r--r--plugins/Scriver/src/msgdialog.cpp121
-rw-r--r--plugins/Scriver/src/msgs.cpp5
3 files changed, 67 insertions, 65 deletions
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;