• R/O
  • HTTP
  • SSH
  • HTTPS

timidity41: Commit


Commit MetaInfo

Révisionf795b82f3bff6e3b97c5c1b454054d3860751dcb (tree)
l'heure2018-06-07 12:26:59
AuteurStarg <starg@user...>
CommiterStarg

Message de Log

Implement scroll-by-drag for new console

Change Summary

Modification

--- a/interface/w32g_new_console.cpp
+++ b/interface/w32g_new_console.cpp
@@ -440,6 +440,12 @@ StyledTextBuffer GlobalNewConsoleBuffer;
440440
441441 class NewConsoleWindow
442442 {
443+ enum TimerKind
444+ {
445+ RedrawTimer,
446+ DragScrollTimer
447+ };
448+
443449 public:
444450 explicit NewConsoleWindow(StyledTextBuffer& buffer) : m_Buffer(buffer)
445451 {
@@ -570,7 +576,7 @@ public:
570576 private:
571577 void OnCreate()
572578 {
573- ::SetTimer(m_hWnd, 1, 200, nullptr);
579+ ::SetTimer(m_hWnd, RedrawTimer, 200, nullptr);
574580
575581 ::ShowScrollBar(m_hWnd, SB_BOTH, true);
576582 InitializeGDIResource();
@@ -579,6 +585,7 @@ private:
579585
580586 void OnDestroy()
581587 {
588+ ::KillTimer(m_hWnd, RedrawTimer);
582589 UninitializeGDIResource();
583590 }
584591
@@ -778,6 +785,7 @@ private:
778785 if (m_SelStart.has_value())
779786 {
780787 SetCapture(m_hWnd);
788+ ::SetTimer(m_hWnd, DragScrollTimer, 100, nullptr);
781789 }
782790
783791 InvalidateRect(m_hWnd, nullptr, true);
@@ -787,6 +795,7 @@ private:
787795 {
788796 if (m_SelStart.has_value())
789797 {
798+ ::KillTimer(m_hWnd, DragScrollTimer);
790799 ::ReleaseCapture();
791800
792801 auto lock = m_Lock.LockShared();
@@ -861,6 +870,14 @@ private:
861870 m_CurrentLeftColumnNumber = std::min(m_CurrentLeftColumnNumber + 1, GetMaxLeftColumnNumber());
862871 break;
863872
873+ case VK_PRIOR:
874+ m_CurrentTopLineNumber = std::max(0, m_CurrentTopLineNumber - GetVisibleLinesInWindow());
875+ break;
876+
877+ case VK_NEXT:
878+ m_CurrentTopLineNumber = std::min(m_CurrentTopLineNumber + GetVisibleLinesInWindow(), GetMaxTopLineNumber());
879+ break;
880+
864881 case VK_HOME:
865882 m_CurrentTopLineNumber = 0;
866883 break;
@@ -876,9 +893,34 @@ private:
876893 InvalidateRect(m_hWnd, nullptr, true);
877894 }
878895
879- void OnTimer(WPARAM, LPARAM)
896+ void OnTimer(WPARAM wParam, LPARAM)
880897 {
881- InvalidateRect(m_hWnd, nullptr, true);
898+ switch (wParam)
899+ {
900+ case RedrawTimer:
901+ InvalidateRect(m_hWnd, nullptr, true);
902+ break;
903+
904+ case DragScrollTimer:
905+ {
906+ POINT pt;
907+ ::GetCursorPos(&pt);
908+ ::ScreenToClient(m_hWnd, &pt);
909+
910+ auto lock = m_Lock.LockUnique();
911+ DoDragScrollNoLock(pt.x, pt.y);
912+
913+ if (m_SelStart.has_value())
914+ {
915+ m_SelEnd = TextLocationFromPosition(pt.x, pt.y, false);
916+ InvalidateRect(m_hWnd, nullptr, true);
917+ }
918+ }
919+ break;
920+
921+ default:
922+ break;
923+ }
882924 }
883925
884926 void InitializeGDIResource()
@@ -987,6 +1029,30 @@ private:
9871029 return (rc.right - rc.left) / m_FontWidth;
9881030 }
9891031
1032+ void DoDragScrollNoLock(int x, int y)
1033+ {
1034+ RECT rc;
1035+ ::GetClientRect(m_hWnd, &rc);
1036+
1037+ if (x < rc.left)
1038+ {
1039+ m_CurrentLeftColumnNumber = std::max(0, m_CurrentLeftColumnNumber - 1);
1040+ }
1041+ else if (rc.right <= x)
1042+ {
1043+ m_CurrentLeftColumnNumber = std::min(m_CurrentLeftColumnNumber + 1, GetMaxLeftColumnNumber());
1044+ }
1045+
1046+ if (y < rc.top)
1047+ {
1048+ m_CurrentTopLineNumber = std::max(0, m_CurrentTopLineNumber - 1);
1049+ }
1050+ else if (rc.bottom <= y)
1051+ {
1052+ m_CurrentTopLineNumber = std::min(m_CurrentTopLineNumber + 1, GetMaxTopLineNumber());
1053+ }
1054+ }
1055+
9901056 bool ShouldAutoScroll() const
9911057 {
9921058 return !m_SelStart.has_value() && !m_SelEnd.has_value() && GetMaxTopLineNumber() <= m_CurrentTopLineNumber;
Afficher sur ancien navigateur de dépôt.