OSDN Git Service

Fix 'Automatic Rescan' not working after splitting panes
[winmerge-jp/winmerge-jp.git] / Src / MergeEditView.h
index be511f1..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
@@ -86,13 +72,6 @@ public:
        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)
@@ -111,21 +90,26 @@ private:
 
        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, 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, int & firstWordDiff, int & lastWordDiff, const CPoint *pptStart = nullptr, const CPoint *ppEnd = nullptr);
+       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(); }
@@ -136,14 +120,15 @@ public:
        void SelectArea(const CPoint & ptStart, const CPoint & ptEnd) { SetSelection(ptStart, ptEnd); } // make public
        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) override;
+       virtual COLORREF GetColor(int nColorIndex) const override;
        virtual void GetLineColors (int nLineIndex, COLORREF & crBkgnd,
                        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; }
        using CCrystalTextView::GetScreenLines;
        int GetTopSubLine() const { return m_nTopSubLine; }
@@ -176,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
@@ -194,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);
@@ -255,22 +247,31 @@ 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 OnClearSyncPoints();
        afx_msg void OnUpdateClearSyncPoints(CCmdUI* pCmdUI);
@@ -286,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,6 +307,10 @@ protected:
        afx_msg void OnUpdateR2LNext(CCmdUI* pCmdUI);
        afx_msg void OnChangePane();
        afx_msg void OnWMGoto();
+       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 );
@@ -323,10 +330,15 @@ protected:
        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 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();
@@ -336,11 +348,14 @@ 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()
 };
@@ -349,3 +364,13 @@ protected:
 inline CMergeDoc* CMergeEditView::GetDocument()
    { 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;
+}
+