From 28c2eb96831f1e6088e4b498f8125b050585dd3b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 5 Sep 2023 15:35:12 +0300 Subject: SRMM: quoting unification --- plugins/Scriver/src/msgdialog.cpp | 45 +++++---------------------------------- plugins/Scriver/src/msglog.cpp | 3 --- 2 files changed, 5 insertions(+), 43 deletions(-) (limited to 'plugins/Scriver/src') diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 1e2f63cbb6..22bd7c8a08 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -25,42 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ///////////////////////////////////////////////////////////////////////////////////////// -static CMStringW GetQuotedTextW(wchar_t *text) -{ - CMStringW res; - bool newLine = true; - bool wasCR = false; - for (; *text; text++) { - if (*text == '\r') { - wasCR = newLine = true; - res.AppendChar('\r'); - if (text[1] != '\n') - res.AppendChar('\n'); - } - else if (*text == '\n') { - newLine = true; - if (!wasCR) - res.AppendChar('\r'); - - res.AppendChar('\n'); - wasCR = false; - } - else { - if (newLine) { - res.AppendChar('>'); - res.AppendChar(' '); - } - wasCR = newLine = false; - res.AppendChar(*text); - } - } - res.AppendChar('\r'); - res.AppendChar('\n'); - return res; -} - -///////////////////////////////////////////////////////////////////////////////////////// - static INT_PTR CALLBACK ConfirmSendAllDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM) { switch (msg) { @@ -412,7 +376,8 @@ void CMsgDialog::onClick_UserMenu(CCtrlButton *pButton) void CMsgDialog::onClick_Quote(CCtrlButton*) { - if (m_hDbEventLast == 0) + MEVENT hDbEventLast = db_event_last(m_hContact); + if (!hDbEventLast) return; SETTEXTEX st; @@ -421,19 +386,19 @@ void CMsgDialog::onClick_Quote(CCtrlButton*) wchar_t *buffer = m_pLog->GetSelection(); if (buffer != nullptr) { - CMStringW quotedBuffer(GetQuotedTextW(buffer)); + CMStringW quotedBuffer(Srmm_Quote(buffer)); m_message.SendMsg(EM_SETTEXTEX, (WPARAM)&st, (LPARAM)quotedBuffer.c_str()); mir_free(buffer); } else { - DB::EventInfo dbei(m_hDbEventLast); + DB::EventInfo dbei(hDbEventLast); if (!dbei) return; if (DbEventIsMessageOrCustom(dbei)) { buffer = DbEvent_GetTextW(&dbei, CP_ACP); if (buffer != nullptr) { - CMStringW quotedBuffer(GetQuotedTextW(buffer)); + CMStringW quotedBuffer(Srmm_Quote(buffer)); m_message.SendMsg(EM_SETTEXTEX, (WPARAM)&st, (LPARAM)quotedBuffer.c_str()); mir_free(buffer); } diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index c653e4f93a..d747909527 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -580,7 +580,6 @@ public: RtfLogStreamData streamData = {}; streamData.hContact = m_pDlg.m_hContact; streamData.hDbEvent = hDbEventFirst; - streamData.hDbEventLast = m_pDlg.m_hDbEventLast; streamData.pLog = this; streamData.eventsToInsert = count; streamData.isFirst = bAppend ? m_rtf.GetRichTextLength() == 0 : 1; @@ -656,8 +655,6 @@ public: ScrollToBottom(); RedrawWindow(m_rtf.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW); } - - m_pDlg.m_hDbEventLast = streamData.hDbEventLast; } //////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3