diff options
author | George Hazan <george.hazan@gmail.com> | 2023-09-05 15:35:12 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-09-05 15:35:12 +0300 |
commit | 28c2eb96831f1e6088e4b498f8125b050585dd3b (patch) | |
tree | 2bff3cbedb270fdba4288c0eacf2b5381a77b4c9 /plugins/TabSRMM/src/msgdialog.cpp | |
parent | a074799eaf3218c979fa07d8a76525aa0ec7b9fd (diff) |
SRMM: quoting unification
Diffstat (limited to 'plugins/TabSRMM/src/msgdialog.cpp')
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index c89031d2bd..a5f22c0b82 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -908,43 +908,40 @@ void CMsgDialog::onClick_Add(CCtrlButton*) void CMsgDialog::onClick_Quote(CCtrlButton*)
{
- SETTEXTEX stx = { ST_SELECTION, 1200 };
+ CMStringW szQuoted;
+ int iOutputWidth = M.GetDword("quoteLineLength", 64);
wchar_t *selected = m_pLog->GetSelection();
- if (selected != nullptr) {
- ptrW szQuoted(QuoteText(selected));
- m_message.SendMsg(EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)szQuoted);
- return;
- }
+ if (selected != nullptr)
+ szQuoted = Srmm_Quote(selected, iOutputWidth);
+ else {
+ MEVENT hDBEvent = db_event_last(m_hContact);
+ if (hDBEvent == 0)
+ return;
- MEVENT hDBEvent = db_event_last(m_hContact);
- if (hDBEvent == 0)
- return;
+ if (m_iLogMode == WANT_BUILTIN_LOG) {
+ CHARRANGE sel;
+ LOG()->WndProc(EM_EXGETSEL, 0, (LPARAM)&sel);
+ if (sel.cpMin != sel.cpMax) {
+ ptrA szFromStream(LOG()->GetRichTextRtf(true, true));
+ ptrW converted(mir_utf8decodeW(szFromStream));
+ Utils::FilterEventMarkers(converted);
+ szQuoted = Srmm_Quote(converted, iOutputWidth);
+ }
+ }
- bool bUseSelection = false;
- if (m_iLogMode == WANT_BUILTIN_LOG) {
- CHARRANGE sel;
- LOG()->WndProc(EM_EXGETSEL, 0, (LPARAM)&sel);
- if (sel.cpMin != sel.cpMax) {
- ptrA szFromStream(LOG()->GetRichTextRtf(true, true));
- ptrW converted(mir_utf8decodeW(szFromStream));
- Utils::FilterEventMarkers(converted);
- m_message.SendMsg(EM_SETTEXTEX, (WPARAM)&stx, ptrW(QuoteText(converted)));
- bUseSelection = true;
+ if (szQuoted.IsEmpty()) {
+ DB::EventInfo dbei(hDBEvent);
+ if (dbei)
+ szQuoted = Srmm_Quote(ptrW(DbEvent_GetTextW(&dbei, CP_ACP)), iOutputWidth);
}
}
- if (!bUseSelection) {
- DB::EventInfo dbei(hDBEvent);
-
- ptrW szConverted(DbEvent_GetTextW(&dbei, CP_ACP));
- if (szConverted != nullptr)
- m_message.SendMsg(EM_SETTEXTEX, (WPARAM)&stx, ptrW(QuoteText(szConverted)));
-
- mir_free(szConverted);
+ if (!szQuoted.IsEmpty()) {
+ SETTEXTEX stx = { ST_SELECTION, 1200 };
+ m_message.SendMsg(EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)szQuoted.c_str());
+ SetFocus(m_message.GetHwnd());
}
-
- SetFocus(m_message.GetHwnd());
}
void CMsgDialog::onClick_CancelAdd(CCtrlButton*)
|