OSDN Git Service

Fix 'Automatic Rescan' not working after splitting panes
[winmerge-jp/winmerge-jp.git] / Src / MergeEditView.h
index 40381a2..d7efe29 100644 (file)
@@ -1,21 +1,7 @@
 /////////////////////////////////////////////////////////////////////////////
 //    WinMerge:  an interactive diff/merge utility
 //    Copyright (C) 1997  Dean P. Grimm
-//
-//    This program is free software; you can redistribute it and/or modify
-//    it under the terms of the GNU General Public License as published by
-//    the Free Software Foundation; either version 2 of the License, or
-//    (at your option) any later version.
-//
-//    This program is distributed in the hope that it will be useful,
-//    but WITHOUT ANY WARRANTY; without even the implied warranty of
-//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//    GNU General Public License for more details.
-//
-//    You should have received a copy of the GNU General Public License
-//    along with this program; if not, write to the Free Software
-//    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
+//    SPDX-License-Identifier: GPL-2.0-or-later
 /////////////////////////////////////////////////////////////////////////////
 /** 
  * @file  MergeEditView.h
@@ -44,6 +30,8 @@ const UINT CONTEXT_LINES_BELOW = 3;
 #include "edtlib.h"
 #include "GhostTextView.h"
 #include "OptionsDiffColors.h"
+#include <map>
+#include <vector>
 
 class IMergeEditStatus;
 class CLocationView;
@@ -79,16 +67,11 @@ public:
         * then these indexes are changed.
         */
        int m_nThisPane;
+       int m_nThisGroup;
+       bool m_bDetailView;
        IMergeEditStatus * m_piMergeEditStatus; /**< interface to status bar */
 
 protected:
-       /**
-        * Are automatic rescans enabled?
-        * If automatic rescans are enabled then we rescan files after edit
-        * events, unless timer suppresses rescan. We suppress rescans within
-        * certain time from previous rescan.
-        */
-       bool m_bAutomaticRescan;
        /// first line of diff (first displayable line)
        int m_lineBegin;
        /// last line of diff (last displayable line)
@@ -99,73 +82,74 @@ private:
        This flag is set when we receive an OnTimer command, and we want 
        to wait for theApp::OnIdle before processing it 
        */
-       bool fTimerWaitingForIdle;
+       unsigned fTimerWaitingForIdle;
        COLORSETTINGS m_cachedColors; /**< Cached color settings */
 
        /// active prediffer ID : helper to check the radio button
        int m_CurrentPredifferID;
 
-       bool m_bCurrentLineIsDiff; /**< TRUE if cursor is in diff line */
-       CLocationView * m_pLocationView; /**< Pointer to locationview */
+       bool m_bCurrentLineIsDiff; /**< `true` if cursor is in diff line */
+
+       bool m_bChangedSchemeManually;  /**< `true` if the syntax highlighting scheme is changed manually */
 
 // Operations
 public:
        void RefreshOptions();
-       bool EnableRescan(bool bEnable);
        bool IsReadOnly(int pane) const;
        void ShowDiff(bool bScroll, bool bSelectText);
-       virtual void OnEditOperation(int nAction, LPCTSTR pszText, int cchText);
-       void UpdateLineLengths();
+       virtual void OnEditOperation(int nAction, LPCTSTR pszText, size_t cchText) override;
        bool IsLineInCurrentDiff(int nLine) const;
        void SelectNone();
        void SelectDiff(int nDiff, bool bScroll = true, bool bSelectText = true);
+       void DeselectDiffIfCursorNotInCurrentDiff();
        virtual CCrystalTextBuffer *LocateTextBuffer ();
        const CCrystalTextBuffer *LocateTextBuffer () const { return const_cast<CMergeEditView *>(this)->LocateTextBuffer(); };
        void GetFullySelectedDiffs(int & firstDiff, int & lastDiff);
+       void GetFullySelectedDiffs(int & firstDiff, int & lastDiff, int & firstWordDiff,  int & lastWordDiff, const CPoint *pptStart = nullptr, const CPoint *ppEnd = nullptr);
+       void GetSelectedDiffs(int & firstDiff, int & lastDiff);
+       std::map<int, std::vector<int>> GetColumnSelectedWordDiffIndice();
        CString GetSelectedText();
+       std::pair<int, int> GetSelectedLineAndCharacterCount();
        CString GetLineText(int idx);
        CMergeDoc* GetDocument();
        const CMergeDoc *GetDocument() const { return const_cast<CMergeEditView *>(this)->GetDocument(); }
        void UpdateResources();
-       BOOL IsModified() { return (LocateTextBuffer()->IsModified()); }
+       bool IsModified() { return (LocateTextBuffer()->IsModified()); }
        void PrimeListWithFile();
        void SetStatusInterface(IMergeEditStatus * piMergeEditStatus);
        void SelectArea(const CPoint & ptStart, const CPoint & ptEnd) { SetSelection(ptStart, ptEnd); } // make public
-       void GetSelection(CPoint &ptStart, CPoint &ptEnd) { CCrystalTextView::GetSelection(ptStart, ptEnd); }
-       virtual void UpdateSiblingScrollPos (bool bHorz);
-       virtual int GetAdditionalTextBlocks (int nLineIndex, TEXTBLOCK *&pBuf);
-       virtual COLORREF GetColor(int nColorIndex);
+       using CGhostTextView::GetSelection;
+       virtual void UpdateSiblingScrollPos (bool bHorz) override;
+    virtual std::vector<CrystalLineParser::TEXTBLOCK> GetMarkerTextBlocks(int nLineIndex) const;
+       virtual std::vector<CrystalLineParser::TEXTBLOCK> GetAdditionalTextBlocks (int nLineIndex) override;
+       virtual COLORREF GetColor(int nColorIndex) const override;
        virtual void GetLineColors (int nLineIndex, COLORREF & crBkgnd,
-                       COLORREF & crText, bool & bDrawWhitespace);
+                       COLORREF & crText, bool & bDrawWhitespace) override;
        virtual void GetLineColors2 (int nLineIndex, DWORD ignoreFlags
                , COLORREF & crBkgnd, COLORREF & crText, bool & bDrawWhitespace);
        void WMGoto() { OnWMGoto(); };
-       void GotoLine(UINT nLine, bool bRealLine, int pane);
+       void GotoLine(UINT nLine, bool bRealLine, int pane, bool bMoveAnchor = true);
        int GetTopLine() const { return m_nTopLine; }
-       int GetScreenLines() { return CCrystalTextView::GetScreenLines(); }
+       using CCrystalTextView::GetScreenLines;
        int GetTopSubLine() const { return m_nTopSubLine; }
-       int GetSubLines(int nLineIndex) { return CCrystalTextView::GetSubLines(nLineIndex); }
-       virtual int GetSubLineCount() { return CCrystalTextView::GetSubLineCount(); }
-       virtual int GetSubLineIndex(int nLineIndex) { return CCrystalTextView::GetSubLineIndex(nLineIndex); }
-       virtual void GetLineBySubLine(int nSubLineIndex, int &nLine, int &nSubLine) {
-               CCrystalTextView::GetLineBySubLine(nSubLineIndex, nLine, nSubLine);
-       }
-       virtual int GetEmptySubLines( int nLineIndex );
-       virtual void InvalidateSubLineIndexCache( int nLineIndex );
+       using CCrystalTextView::GetSubLines;
+       using CCrystalTextView::GetSubLineCount;
+       using CCrystalTextView::GetSubLineIndex;
+       using CCrystalTextView::GetLineBySubLine;
+       virtual int GetEmptySubLines( int nLineIndex ) override;
+       virtual void InvalidateSubLineIndexCache( int nLineIndex ) override;
        void RepaintLocationPane();
        bool SetPredifferByName(const CString & prediffer);
        void SetPredifferByMenu(UINT nID);
        void DocumentsLoaded();
-       void SetLocationView(const CLocationView * pView = NULL);
        void UpdateLocationViewPosition(int nTopLine = -1, int nBottomLine = -1);
-       virtual void RecalcPageLayouts(CDC * pdc, CPrintInfo * pInfo);
-       virtual void GetPrintHeaderText(int nPageNum, CString & text);
-       virtual void PrintHeader(CDC * pdc, int nPageNum);
-       virtual void PrintFooter(CDC * pdc, int nPageNum);
-       virtual void SetWordWrapping( bool bWordWrap );
+       virtual void RecalcPageLayouts(CDC * pdc, CPrintInfo * pInfo) override;
+       virtual void GetPrintHeaderText(int nPageNum, CString & text) override;
+       virtual void PrintHeader(CDC * pdc, int nPageNum) override;
+       virtual void PrintFooter(CDC * pdc, int nPageNum) override;
+       virtual void SetWordWrapping( bool bWordWrap ) override;
        void UpdateStatusbar();
        CMergeEditView *GetGroupView(int nPane) const;
-       bool IsDetailViewPane() const;
 
        virtual void OnDisplayDiff(int nDiff=0);
 
@@ -177,6 +161,13 @@ public:
        bool IsCursorInDiff() const;
        bool IsDiffVisible(int nDiff);
        void ZoomText(short amount);
+       virtual bool QueryEditable() override;
+       virtual void EnsureVisible(CPoint pt) override;
+       virtual void EnsureVisible(CPoint ptStart, CPoint ptEnd) override;
+       bool EnsureInDiff(CPoint& pt);
+       void SetSelection(const CPoint& ptStart, const CPoint& ptEnd, bool bUpdateView = true) override;
+       void ScrollToSubLine(int nNewTopLine, bool bNoSmoothScroll = false, bool bTrackScrollBar = true) override;
+       void SetActivePane();
 
        // Overrides
        // ClassWizard generated virtual function overrides
@@ -195,8 +186,8 @@ public:
 // Implementation
 protected:
        virtual ~CMergeEditView();
-       virtual void OnUpdateSibling (CCrystalTextView * pUpdateSource, BOOL bHorz);
-       virtual void OnUpdateCaret();
+       virtual void OnUpdateSibling (CCrystalTextView * pUpdateSource, bool bHorz) override;
+       virtual void OnUpdateCaret() override;
        bool MergeModeKeyDown(MSG* pMsg);
        int FindPrediffer(LPCTSTR prediffer) const;
        bool IsDiffVisible(const DIFFRANGE& diff, int nLinesBelow = 0);
@@ -204,6 +195,7 @@ protected:
        void OnUpdateNext3wayDiff(CCmdUI* pCmdUI, int type);
        void OnPrev3wayDiff(int type);
        void OnUpdatePrev3wayDiff(CCmdUI* pCmdUI, int type);
+       void OnDropFiles(const std::vector<String>& files);
 
        // Generated message map functions
 protected:
@@ -255,24 +247,32 @@ protected:
        afx_msg void OnUpdatePrevdiffRO(CCmdUI* pCmdUI);
        afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
        afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
+       afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
        afx_msg void OnAllLeft();
        afx_msg void OnUpdateAllLeft(CCmdUI* pCmdUI);
        afx_msg void OnAllRight();
        afx_msg void OnUpdateAllRight(CCmdUI* pCmdUI);
        afx_msg void OnAutoMerge();
        afx_msg void OnUpdateAutoMerge(CCmdUI* pCmdUI);
-       afx_msg void OnX2Y(int srcPane, int dstPane);
+       afx_msg void OnX2Y(int srcPane, int dstPane, bool selectedLineOnly = false);
        afx_msg void OnUpdateX2Y(int dstPane, CCmdUI* pCmdUI);
        afx_msg void OnL2r();
        afx_msg void OnUpdateL2r(CCmdUI* pCmdUI);
+       afx_msg void OnLinesL2r();
+       afx_msg void OnUpdateLinesL2r(CCmdUI* pCmdUI);
        afx_msg void OnR2l();
        afx_msg void OnUpdateR2l(CCmdUI* pCmdUI);
+       afx_msg void OnLinesR2l();
+       afx_msg void OnUpdateLinesR2l(CCmdUI* pCmdUI);
        afx_msg void OnCopyFromLeft();
        afx_msg void OnUpdateCopyFromLeft(CCmdUI* pCmdUI);
+       afx_msg void OnCopyLinesFromLeft();
+       afx_msg void OnUpdateCopyLinesFromLeft(CCmdUI* pCmdUI);
        afx_msg void OnCopyFromRight();
        afx_msg void OnUpdateCopyFromRight(CCmdUI* pCmdUI);
+       afx_msg void OnCopyLinesFromRight();
+       afx_msg void OnUpdateCopyLinesFromRight(CCmdUI* pCmdUI);
        afx_msg void OnAddSyncPoint();
-       afx_msg void OnUpdateAddSyncPoint(CCmdUI* pCmdUI);
        afx_msg void OnClearSyncPoints();
        afx_msg void OnUpdateClearSyncPoints(CCmdUI* pCmdUI);
        afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI);
@@ -287,6 +287,8 @@ protected:
        template<bool reversed>
        afx_msg void OnSelectLineDiff();
        afx_msg void OnUpdateSelectLineDiff(CCmdUI* pCmdUI);
+       afx_msg void OnAddToSubstitutionFilters();
+       afx_msg void OnUpdateAddToSubstitutionFilters(CCmdUI* pCmdUI);
        afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
        afx_msg void OnUpdateEditReplace(CCmdUI* pCmdUI);
        afx_msg void OnLeftReadOnly();
@@ -304,10 +306,13 @@ protected:
        afx_msg void OnR2LNext();
        afx_msg void OnUpdateR2LNext(CCmdUI* pCmdUI);
        afx_msg void OnChangePane();
-       afx_msg void OnUpdateChangePane(CCmdUI* pCmdUI);
        afx_msg void OnWMGoto();
-       afx_msg void OnUpdateWMGoto(CCmdUI* pCmdUI);
-       afx_msg void OnUpdateScripts(CCmdUI* pCmdUI);
+       afx_msg void OnGotoMovedLineLM();
+       afx_msg void OnUpdateGotoMovedLineLM(CCmdUI* pCmdUI);
+       afx_msg void OnGotoMovedLineMR();
+       afx_msg void OnUpdateGotoMovedLineMR(CCmdUI* pCmdUI);
+       afx_msg void OnShellMenu();
+       afx_msg void OnUpdateShellMenu(CCmdUI* pCmdUI);
        afx_msg void OnScripts(UINT nID );
        afx_msg void OnUpdateNoPrediffer(CCmdUI* pCmdUI);
        afx_msg void OnUpdatePrediffer(CCmdUI* pCmdUI);
@@ -323,11 +328,17 @@ protected:
        afx_msg void OnUpdateViewLineNumbers(CCmdUI* pCmdUI);
        afx_msg void OnViewWordWrap();
        afx_msg void OnUpdateViewWordWrap(CCmdUI* pCmdUI);
+       afx_msg void OnViewWhitespace();
+       afx_msg void OnUpdateViewWhitespace(CCmdUI* pCmdUI);
+       afx_msg void OnViewEOL();
+       afx_msg void OnUpdateViewEOL(CCmdUI* pCmdUI);
        afx_msg void OnOpenFile();
        afx_msg void OnOpenFileWith();
        afx_msg void OnOpenFileWithEditor();
-       afx_msg void OnViewSwapPanes();
-       afx_msg void OnUpdateViewSwapPanes(CCmdUI* pCmdUI);
+       afx_msg void OnOpenParentFolder();
+       afx_msg void OnViewSwapPanes12();
+       afx_msg void OnViewSwapPanes23();
+       afx_msg void OnViewSwapPanes13();
        afx_msg void OnUpdateNoEditScripts(CCmdUI* pCmdUI);
        afx_msg void OnSize(UINT nType, int cx, int cy);
        afx_msg void OnHelp();
@@ -337,19 +348,29 @@ protected:
        afx_msg void OnChangeScheme(UINT nID);
        afx_msg void OnUpdateChangeScheme(CCmdUI* pCmdUI);
        afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
+       afx_msg void OnMouseHWheel(UINT nFlags, short zDelta, CPoint pt);
        afx_msg void OnViewZoomIn();
        afx_msg void OnViewZoomOut();
        afx_msg void OnViewZoomNormal();
+       afx_msg void OnWindowSplit();
+       afx_msg void OnUpdateWindowSplit(CCmdUI* pCmdUI);
+       afx_msg void OnStatusBarDblClick(NMHDR* pNMHDR, LRESULT* pResult);
+
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
 };
 
 #ifndef _DEBUG  // debug version in DiffView.cpp
 inline CMergeDoc* CMergeEditView::GetDocument()
-   { return (CMergeDoc*)m_pDocument; }
+   { return reinterpret_cast<CMergeDoc*>(m_pDocument); }
 #endif
 
-/////////////////////////////////////////////////////////////////////////////
+/**
+ * @brief Check if cursor is inside difference.
+ * @return true if cursor is inside difference.
+ */
+inline bool CMergeEditView::IsCursorInDiff() const
+{
+       return m_bCurrentLineIsDiff;
+}
 
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Visual C++ will insert additional declarations immediately before the previous line.