diff options
-rw-r--r-- | include/m_srmm_int.h | 7 | ||||
-rw-r--r-- | libs/win32/mir_app.lib | bin | 270144 -> 270570 bytes | |||
-rw-r--r-- | libs/win64/mir_app.lib | bin | 269280 -> 269710 bytes | |||
-rw-r--r-- | plugins/Scriver/src/msgdialog.cpp | 45 | ||||
-rw-r--r-- | plugins/Scriver/src/msglog.cpp | 3 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 55 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgother.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgutils.cpp | 54 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgutils.h | 1 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msglog.cpp | 3 | ||||
-rw-r--r-- | src/core/stdmsg/src/msglog.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/srmm_util.cpp | 48 |
14 files changed, 87 insertions, 137 deletions
diff --git a/include/m_srmm_int.h b/include/m_srmm_int.h index bbcd04093f..2d69f7d00f 100644 --- a/include/m_srmm_int.h +++ b/include/m_srmm_int.h @@ -314,7 +314,7 @@ protected: public:
MCONTACT m_hContact;
- MEVENT m_hDbEventFirst, m_hDbEventLast;
+ MEVENT m_hDbEventFirst;
int m_iLogFilterFlags;
bool m_bFilterEnabled, m_bNicklistEnabled;
bool m_bFGSet, m_bBGSet;
@@ -391,4 +391,9 @@ MIR_APP_DLL(void) Srmm_DownloadOfflineFile(MCONTACT hContact, MEVENT hDbEvent, i MIR_APP_DLL(HWND) Srmm_FindWindow(MCONTACT hContact);
MIR_APP_DLL(CMsgDialog*) Srmm_FindDialog(MCONTACT hContact);
+/////////////////////////////////////////////////////////////////////////////////////////
+// quotes a string
+
+MIR_APP_DLL(CMStringW) Srmm_Quote(const wchar_t *pwzsText, int iWrapWidth = -1);
+
#endif // M_MESSAGE_H__
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 45524f0c83..b7c851e16e 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex 7ed07dbdef..9a38a00b1a 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib 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;
}
////////////////////////////////////////////////////////////////////////////////////////
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*)
diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp index badc8c911f..d2deeab39b 100644 --- a/plugins/TabSRMM/src/msgdlgother.cpp +++ b/plugins/TabSRMM/src/msgdlgother.cpp @@ -2376,10 +2376,6 @@ void CMsgDialog::StreamEvents(MEVENT hDbEventFirst, int count, bool bAppend) m_pLog->LogEvents(hDbEventFirst, count, bAppend);
DM_ScrollToBottom(0, 0);
- if (bAppend && hDbEventFirst)
- m_hDbEventLast = hDbEventFirst;
- else
- m_hDbEventLast = db_event_last(m_hContact);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index f3ed376965..452090771b 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -257,60 +257,6 @@ void TSAPI ProcessAvatarChange(HWND hwnd, LPARAM lParam) }
/////////////////////////////////////////////////////////////////////////////////////////
-// return value MUST be mir_free()'d by caller.
-
-wchar_t* TSAPI QuoteText(const wchar_t *text)
-{
- int outChar, lineChar;
- int iCharsPerLine = M.GetDword("quoteLineLength", 64);
-
- size_t bufSize = mir_wstrlen(text) + 23;
- wchar_t *strout = (wchar_t*)mir_alloc(bufSize * sizeof(wchar_t));
- int inChar = 0;
- int justDoneLineBreak = 1;
- for (outChar = 0, lineChar = 0; text[inChar];) {
- if (outChar >= (int)bufSize - 8) {
- bufSize += 20;
- strout = (wchar_t*)mir_realloc(strout, bufSize * sizeof(wchar_t));
- }
- if (justDoneLineBreak && text[inChar] != '\r' && text[inChar] != '\n') {
- strout[outChar++] = '>';
- strout[outChar++] = ' ';
- lineChar = 2;
- }
- if (lineChar == iCharsPerLine && text[inChar] != '\r' && text[inChar] != '\n') {
- int decreasedBy;
- for (decreasedBy = 0; lineChar > 10; lineChar--, inChar--, outChar--, decreasedBy++)
- if (strout[outChar] == ' ' || strout[outChar] == '\t' || strout[outChar] == '-') break;
- if (lineChar <= 10) {
- lineChar += decreasedBy;
- inChar += decreasedBy;
- outChar += decreasedBy;
- }
- else inChar++;
- strout[outChar++] = '\r';
- strout[outChar++] = '\n';
- justDoneLineBreak = 1;
- continue;
- }
- strout[outChar++] = text[inChar];
- lineChar++;
- if (text[inChar] == '\n' || text[inChar] == '\r') {
- if (text[inChar] == '\r' && text[inChar + 1] != '\n')
- strout[outChar++] = '\n';
- justDoneLineBreak = 1;
- lineChar = 0;
- }
- else justDoneLineBreak = 0;
- inChar++;
- }
- strout[outChar++] = '\r';
- strout[outChar++] = '\n';
- strout[outChar] = 0;
- return strout;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
bool IsStringValidLink(wchar_t *pszText)
{
diff --git a/plugins/TabSRMM/src/msgdlgutils.h b/plugins/TabSRMM/src/msgdlgutils.h index b9cd0fd792..bab14bf6a7 100644 --- a/plugins/TabSRMM/src/msgdlgutils.h +++ b/plugins/TabSRMM/src/msgdlgutils.h @@ -34,7 +34,6 @@ void TSAPI AddUnreadContact(MCONTACT hContact);
void TSAPI ProcessAvatarChange(HWND hwnd, LPARAM lParam);
BOOL TSAPI CheckCustomLink(HWND hwndRich, POINT *ptClient, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL bUrlNeeded);
-wchar_t* TSAPI QuoteText(const wchar_t *text);
void TSAPI CutContactName(const wchar_t *szold, wchar_t *sznew, size_t size);
void TSAPI RearrangeTab(HWND hwndDlg, const CMsgDialog *dat, int iMode, BOOL bSavePos);
bool TSAPI IsStatusEvent(int eventType);
diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index dca3a53599..ffbb75e694 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -1191,8 +1191,6 @@ void CLogWindow::LogEvents(MEVENT hDbEventFirst, int count, bool fAppend, DB::Ev m_rtf.SetDraw(false);
StreamRtfEvents(&streamData, true);
- m_pDlg.m_hDbEventLast = streamData.hDbEventLast;
-
if (m_pDlg.m_bRtlText)
m_rtf.SendMsg(EM_SETBKGNDCOLOR, 0, (LOWORD(m_pDlg.m_iLastEventType) & DBEF_SENT)
? (fAppend ? m_pDlg.m_pContainer->m_theme.outbg : m_pDlg.m_pContainer->m_theme.oldoutbg)
@@ -1231,7 +1229,6 @@ void CLogWindow::LogEvents(MEVENT hDbEventFirst, int count, bool fAppend, DB::Ev m_rtf.SetDraw(true);
InvalidateRect(m_rtf.GetHwnd(), nullptr, FALSE);
- EnableWindow(GetDlgItem(m_pDlg.m_hwnd, IDC_QUOTE), m_pDlg.m_hDbEventLast != 0);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index 620f637f29..c0a83c5259 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -486,8 +486,6 @@ public: ScrollToBottom();
RedrawWindow(m_rtf.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
}
-
- m_pDlg.m_hDbEventLast = streamData.hDbEventLast;
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index eef3369c58..d4bd43e373 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -902,3 +902,4 @@ Clist_GroupSaveExpanded @1003 NONAME ?bEnableCustomLogs@Chat@@3V?$CMOption@_N@@A @1019 NONAME
?Srmm_IsCustomLogUsed@@YG_NXZ @1020 NONAME
?IconFlashTime@Clist@@3V?$CMOption@I@@A @1021 NONAME
+?Srmm_Quote@@YG?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@PB_WH@Z @1022 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index cee812529b..9a2dfd3ef0 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -902,3 +902,4 @@ Clist_GroupSaveExpanded @1003 NONAME ?bEnableCustomLogs@Chat@@3V?$CMOption@_N@@A @1019 NONAME
?Srmm_IsCustomLogUsed@@YA_NXZ @1020 NONAME
?IconFlashTime@Clist@@3V?$CMOption@I@@A @1021 NONAME
+?Srmm_Quote@@YA?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@PEB_WH@Z @1022 NONAME
diff --git a/src/mir_app/src/srmm_util.cpp b/src/mir_app/src/srmm_util.cpp index a13af78623..dd69502e34 100644 --- a/src/mir_app/src/srmm_util.cpp +++ b/src/mir_app/src/srmm_util.cpp @@ -260,3 +260,51 @@ MIR_APP_DLL(void) Srmm_SetStatusText(MCONTACT hContact, const wchar_t *wszText, SSTParam param = { hwnd, wszText, hIcon };
CallFunctionSync(sttSetStatusText, ¶m);
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Quote
+
+MIR_APP_DLL(CMStringW) Srmm_Quote(const wchar_t *pwzsText, int iWrapWidth)
+{
+ CMStringW ret;
+
+ if (auto *p = pwzsText) {
+ bool justDoneLineBreak = true;
+ for (int lineChar = 0; *p;) {
+ if (justDoneLineBreak && *p != '\r' && *p != '\n') {
+ ret.AppendChar('>');
+ ret.AppendChar(' ');
+ lineChar = 2;
+ }
+
+ if (lineChar == iWrapWidth && *p != '\r' && *p != '\n') {
+ int decreasedBy = 0;
+ for (int outChar = ret.GetLength() - 1; lineChar > 10; lineChar--, p--, outChar--, decreasedBy++)
+ if (ret[outChar] == ' ' || ret[outChar] == '\t' || ret[outChar] == '-')
+ break;
+
+ if (lineChar <= 10) {
+ lineChar += decreasedBy;
+ p += decreasedBy;
+ }
+ else p++;
+ ret.Append(L"\r\n");
+ justDoneLineBreak = true;
+ continue;
+ }
+ ret.AppendChar(*p);
+ lineChar++;
+ if (*p == '\n' || *p == '\r') {
+ if (*p == '\r' && p[1] != '\n')
+ ret.AppendChar('\n');
+ justDoneLineBreak = 1;
+ lineChar = 0;
+ }
+ else justDoneLineBreak = false;
+ p++;
+ }
+ }
+
+ ret.Append(L"\r\n");
+ return ret;
+}
|