From b38f2534004135415ae8d576c7f3bb41785ca7e7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 18 Apr 2023 15:00:44 +0300 Subject: - further group chats unification; - LOGSTREAMDATA / GCLogStreamDataBase removed from g_chatApi; - CRtfLogWindow now in charge of all RTF processing - Srmm_LogStreamCallback is also removed and hidden inside the core --- src/core/stdmsg/src/msglog.cpp | 35 +++++++++++++---------------------- src/core/stdmsg/src/stdafx.h | 1 - 2 files changed, 13 insertions(+), 23 deletions(-) (limited to 'src/core/stdmsg') diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index ba0d25e44a..22486d106c 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -478,21 +478,20 @@ public: ///////////////////////////////////////////////////////////////////////////////////////// - void LogEvents(SESSION_INFO *si, int iStart, bool bRedraw) override + void LogEvents(SESSION_INFO *si, int iStart, bool bAppend) override { if (si == nullptr) return; auto &lin = si->arEvents[iStart]; - if (!bRedraw && si->iType == GCW_CHATROOM && (m_pDlg.m_iLogFilterFlags & lin.iType) == 0) + if (!bAppend && si->iType == GCW_CHATROOM && (m_pDlg.m_iLogFilterFlags & lin.iType) == 0) return; - LOGSTREAMDATA streamData; - memset(&streamData, 0, sizeof(streamData)); - streamData.hwnd = m_rtf.GetHwnd(); + RtfChatLogStreamData streamData; + streamData.pLog = this; streamData.si = si; streamData.iStartEvent = iStart; - streamData.bStripFormat = FALSE; + streamData.bStripFormat = false; bool bFlag = false; @@ -510,19 +509,16 @@ public: if (oldsel.cpMax != oldsel.cpMin) m_rtf.SetDraw(false); - //set the insertion point at the bottom + // set the insertion point at the bottom sel.cpMin = sel.cpMax = m_rtf.GetRichTextLength(); m_rtf.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); // fix for the indent... must be a M$ bug if (sel.cpMax == 0) - bRedraw = TRUE; - - // should the event(s) be appended to the current log - WPARAM wp = bRedraw ? SF_RTF : SFF_SELECTION | SF_RTF; + bAppend = true; - //get the number of pixels per logical inch - if (bRedraw) { + // get the number of pixels per logical inch + if (bAppend) { HDC hdc = GetDC(nullptr); g_chatApi.logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY); g_chatApi.logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX); @@ -532,15 +528,10 @@ public: } // stream in the event(s) - streamData.bRedraw = bRedraw; - - EDITSTREAM stream = {}; - stream.pfnCallback = Srmm_LogStreamCallback; - stream.dwCookie = (DWORD_PTR)&streamData; - m_rtf.SendMsg(EM_STREAMIN, wp, (LPARAM)&stream); + StreamChatRtfEvents(&streamData, bAppend); // do smileys - if (g_plugin.bSmileyInstalled && (bRedraw || (lin.ptszText && lin.iType != GC_EVENT_JOIN && lin.iType != GC_EVENT_NICK && lin.iType != GC_EVENT_ADDSTATUS && lin.iType != GC_EVENT_REMOVESTATUS))) { + if (g_plugin.bSmileyInstalled && (bAppend || (lin.ptszText && lin.iType != GC_EVENT_JOIN && lin.iType != GC_EVENT_NICK && lin.iType != GC_EVENT_ADDSTATUS && lin.iType != GC_EVENT_REMOVESTATUS))) { CHARRANGE newsel; newsel.cpMax = -1; newsel.cpMin = sel.cpMin; @@ -551,14 +542,14 @@ public: sm.cbSize = sizeof(sm); sm.hwndRichEditControl = m_rtf.GetHwnd(); sm.Protocolname = si->pszModule; - sm.rangeToReplace = bRedraw ? nullptr : &newsel; + sm.rangeToReplace = bAppend ? nullptr : &newsel; sm.disableRedraw = TRUE; sm.hContact = si->hContact; CallService(MS_SMILEYADD_REPLACESMILEYS, 0, (LPARAM)&sm); } // scroll log to bottom if the log was previously scrolled to bottom, else restore old position - if (bRedraw || (UINT)scroll.nPos >= (UINT)scroll.nMax - scroll.nPage - 5 || scroll.nMax - scroll.nMin - scroll.nPage < 50) + if (bAppend || (UINT)scroll.nPos >= (UINT)scroll.nMax - scroll.nPage - 5 || scroll.nMax - scroll.nMin - scroll.nPage < 50) ScrollToBottom(); else m_rtf.SendMsg(EM_SETSCROLLPOS, 0, (LPARAM)&point); diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index 8e2b93764c..dc6fdc6c5d 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -127,7 +127,6 @@ CTabbedWindow *GetContainer(); ///////////////////////////////////////////////////////////////////////////////////////// struct MODULEINFO : public GCModuleInfoBase {}; -struct LOGSTREAMDATA : public GCLogStreamDataBase {}; #include "cmdlist.h" #include "msgs.h" -- cgit v1.2.3