summaryrefslogtreecommitdiff
path: root/plugins/Scriver/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-07-25 14:58:05 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-07-25 14:58:05 +0300
commitbae70808afbe0ca866d008090a8e3580342d16f3 (patch)
treefb13b149d93e002e9c61894bfdd08726acb8cf04 /plugins/Scriver/src
parent8ea3ecaf3c4d554a2feb57ab551df73a701887d0 (diff)
fixes #1920 (Scriver always scrolls its log to bottom when new message arrives)
Diffstat (limited to 'plugins/Scriver/src')
-rw-r--r--plugins/Scriver/src/msgdialog.cpp4
-rw-r--r--plugins/Scriver/src/msglog.cpp47
-rw-r--r--plugins/Scriver/src/msgs.h1
-rw-r--r--plugins/Scriver/src/version.h2
4 files changed, 33 insertions, 21 deletions
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp
index 25147078a3..a233adc74b 100644
--- a/plugins/Scriver/src/msgdialog.cpp
+++ b/plugins/Scriver/src/msgdialog.cpp
@@ -1361,10 +1361,6 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
}
return TRUE;
- case DM_SCROLLLOGTOBOTTOM:
- ScrollToBottom();
- return 0;
-
case DM_REMAKELOG:
m_lastEventType = -1;
if (wParam == 0 || wParam == m_hContact)
diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp
index 67de067e91..85862fe33a 100644
--- a/plugins/Scriver/src/msglog.cpp
+++ b/plugins/Scriver/src/msglog.cpp
@@ -660,7 +660,7 @@ void StreamInTestEvents(HWND hEditWnd, GlobalMessageData *gdat)
delete dat;
}
-void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend)
+void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, int bAppend)
{
// IEVIew MOD Begin
if (m_hwndIeview != nullptr) {
@@ -672,7 +672,7 @@ void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend)
evt.hwnd = m_hwndIeview;
evt.hContact = m_hContact;
evt.pszProto = m_szProto;
- if (!fAppend) {
+ if (!bAppend) {
evt.iType = IEE_CLEAR_LOG;
CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&evt);
}
@@ -692,7 +692,7 @@ void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend)
// IEVIew MOD End
CHARRANGE oldSel, sel;
- m_log.SendMsg(EM_HIDESELECTION, TRUE, 0);
+ m_log.SendMsg(WM_SETREDRAW, FALSE, 0);
m_log.SendMsg(EM_EXGETSEL, 0, (LPARAM)&oldSel);
LogStreamData streamData = {};
@@ -701,7 +701,7 @@ void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend)
streamData.hDbEventLast = m_hDbEventLast;
streamData.dlgDat = this;
streamData.eventsToInsert = count;
- streamData.isFirst = fAppend ? m_log.GetRichTextLength() == 0 : 1;
+ streamData.isFirst = bAppend ? m_log.GetRichTextLength() == 0 : 1;
streamData.gdat = &g_dat;
EDITSTREAM stream = {};
@@ -709,8 +709,20 @@ void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend)
stream.dwCookie = (DWORD_PTR)& streamData;
sel.cpMin = 0;
+ POINT scrollPos;
+ bool bottomScroll = (GetFocus() != m_log.GetHwnd());
+ if (bottomScroll && (GetWindowLongPtr(m_log.GetHwnd(), GWL_STYLE) & WS_VSCROLL)) {
+ SCROLLINFO si = {};
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
+ GetScrollInfo(m_log.GetHwnd(), SB_VERT, &si);
+ bottomScroll = (si.nPos + (int)si.nPage) >= si.nMax;
+ }
+ if (!bottomScroll)
+ m_log.SendMsg(EM_GETSCROLLPOS, 0, (LPARAM)&scrollPos);
+
FINDTEXTEXA fi;
- if (fAppend) {
+ if (bAppend) {
GETTEXTLENGTHEX gtxl = { 0 };
gtxl.flags = GTL_DEFAULT | GTL_PRECISE | GTL_NUMCHARS;
gtxl.codepage = 1200;
@@ -728,10 +740,16 @@ void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend)
m_isMixed = 0;
}
- m_log.SendMsg(EM_STREAMIN, fAppend ? SFF_SELECTION | SF_RTF : SFF_SELECTION | SF_RTF, (LPARAM)&stream);
- m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&oldSel);
- m_log.SendMsg(EM_HIDESELECTION, FALSE, 0);
-
+ m_log.SendMsg(EM_STREAMIN, bAppend ? SFF_SELECTION | SF_RTF : SFF_SELECTION | SF_RTF, (LPARAM)&stream);
+ if (bottomScroll) {
+ sel.cpMin = sel.cpMax = -1;
+ m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel);
+ }
+ else {
+ m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&oldSel);
+ m_log.SendMsg(EM_SETSCROLLPOS, 0, (LPARAM)&scrollPos);
+ }
+
if (g_dat.smileyAddInstalled) {
SMADD_RICHEDIT3 smre;
smre.cbSize = sizeof(SMADD_RICHEDIT3);
@@ -753,14 +771,13 @@ void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend)
CallService(MS_SMILEYADD_REPLACESMILEYS, 0, (LPARAM)&smre);
}
- int len = m_log.GetRichTextLength();
- m_log.SendMsg(EM_SETSEL, len - 1, len - 1);
-
- if (!fAppend)
- m_log.SendMsg(WM_SETREDRAW, TRUE, 0);
+ m_log.SendMsg(WM_SETREDRAW, TRUE, 0);
+ if (bottomScroll) {
+ ScrollToBottom();
+ RedrawWindow(m_log.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
+ }
m_hDbEventLast = streamData.hDbEventLast;
- PostMessage(m_hwnd, DM_SCROLLLOGTOBOTTOM, 0, 0);
}
#define RTFPICTHEADERMAXSIZE 78
diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h
index 88189fb316..4139351b64 100644
--- a/plugins/Scriver/src/msgs.h
+++ b/plugins/Scriver/src/msgs.h
@@ -238,7 +238,6 @@ public:
#define DM_OPTIONSAPPLIED (WM_USER+14)
#define DM_APPENDTOLOG (WM_USER+17)
#define DM_ERRORDECIDED (WM_USER+18)
-#define DM_SCROLLLOGTOBOTTOM (WM_USER+19)
#define DM_TYPING (WM_USER+20)
#define DM_UPDATELASTMESSAGE (WM_USER+22)
#define DM_USERNAMETOCLIP (WM_USER+23)
diff --git a/plugins/Scriver/src/version.h b/plugins/Scriver/src/version.h
index cd15f34cae..7d819ff22b 100644
--- a/plugins/Scriver/src/version.h
+++ b/plugins/Scriver/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 3
#define __MINOR_VERSION 0
#define __RELEASE_NUM 1
-#define __BUILD_NUM 10
+#define __BUILD_NUM 11
#include <stdver.h>