OSDN Git Service

'Automatically scroll to first difference' option did not work since 0db5699a19e7
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 17 Feb 2019 11:57:06 +0000 (20:57 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 17 Feb 2019 11:57:06 +0000 (20:57 +0900)
Src/HexMergeDoc.cpp
Src/HexMergeDoc.h
Src/HexMergeFrm.cpp
Src/HexMergeFrm.h
Src/ImgMergeFrm.cpp
Src/ImgMergeFrm.h
Src/MainFrm.cpp
Src/MergeDoc.cpp
Src/MergeDoc.h
Src/MergeEditView.cpp
Translations/WinMerge/English.pot

index b0268cc..eaf96d5 100644 (file)
@@ -501,7 +501,7 @@ HRESULT CHexMergeDoc::LoadOneFile(int index, LPCTSTR filename, bool readOnly, co
 /**
  * @brief Load files and initialize frame's compare result icon
  */
-bool CHexMergeDoc::OpenDocs(int nFiles, const FileLocation fileloc[], const bool bRO[], const String strDesc[], int nPane)
+bool CHexMergeDoc::OpenDocs(int nFiles, const FileLocation fileloc[], const bool bRO[], const String strDesc[])
 {
        CHexMergeFrame *pf = GetParentFrame();
        ASSERT(pf != nullptr);
@@ -522,9 +522,6 @@ bool CHexMergeDoc::OpenDocs(int nFiles, const FileLocation fileloc[], const bool
                m_pView[0]->ResizeWindow();
 
                OnRefresh();
-
-               if (GetOptionsMgr()->GetBool(OPT_SCROLL_TO_FIRST))
-                       m_pView[0]->SendMessage(WM_COMMAND, ID_FIRSTDIFF);
        }
        else
        {
@@ -534,6 +531,21 @@ bool CHexMergeDoc::OpenDocs(int nFiles, const FileLocation fileloc[], const bool
        return bSucceeded;
 }
 
+void CHexMergeDoc::MoveOnLoad(int nPane, int)
+{
+       if (nPane < 0)
+       {
+               nPane = theApp.GetProfileInt(_T("Settings"), _T("ActivePane"), 0);
+               if (nPane < 0 || nPane >= m_nBuffers)
+                       nPane = 0;
+       }
+
+       GetParentFrame()->SetActivePane(nPane);
+
+       if (GetOptionsMgr()->GetBool(OPT_SCROLL_TO_FIRST))
+               m_pView[0]->SendMessage(WM_COMMAND, ID_FIRSTDIFF);
+}
+
 void CHexMergeDoc::CheckFileChanged(void)
 {
        for (int pane = 0; pane < m_nBuffers; ++pane)
@@ -720,8 +732,8 @@ void CHexMergeDoc::OnFileReload()
                fileloc[pane].setPath(m_filePaths[pane]);
                bRO[pane] = m_pView[pane]->GetReadOnly();
        }
-       int nActivePane = GetActiveMergeView()->m_nThisPane;
-       OpenDocs(m_nBuffers, fileloc, bRO, m_strDesc, nActivePane);
+       OpenDocs(m_nBuffers, fileloc, bRO, m_strDesc);
+       MoveOnLoad(GetActiveMergeView()->m_nThisPane);
 }
 
 /**
index 4ed7c07..b54f411 100644 (file)
@@ -85,7 +85,8 @@ public:
        CHexMergeFrame * GetParentFrame() const;
        void UpdateHeaderPath(int pane);
        void RefreshOptions();
-       bool OpenDocs(int nFiles, const FileLocation fileloc[], const bool bRO[], const String strDesc[], int nPane);
+       bool OpenDocs(int nFiles, const FileLocation fileloc[], const bool bRO[], const String strDesc[]);
+       void MoveOnLoad(int nPane = -1, int nLineIndex = -1);
        void CheckFileChanged(void);
        String GetDescription(int pane) const { return m_strDesc[pane]; };
 private:
index e485cb5..1f89e54 100644 (file)
@@ -139,10 +139,7 @@ BOOL CHexMergeFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
 
        m_wndFilePathBar.SetPaneCount(m_pMergeDoc->m_nBuffers);
        m_wndFilePathBar.SetOnSetFocusCallback([&](int pane) {
-               if (m_wndSplitter.GetColumnCount() > 1)
-                       m_wndSplitter.SetActivePane(0, pane);
-               else
-                       m_wndSplitter.SetActivePane(pane, 0);
+               SetActivePane(pane);
        });
 
        // Set filename bars inactive so colors get initialized
@@ -238,6 +235,7 @@ void CHexMergeFrame::SavePosition()
                CRect rc;
                pLeft->GetWindowRect(&rc);
                theApp.WriteProfileInt(_T("Settings"), _T("WLeft"), rc.Width());
+               theApp.WriteProfileInt(_T("Settings"), _T("ActivePane"), GetActivePane());
        }
 }
 
@@ -348,6 +346,24 @@ void CHexMergeFrame::UpdateSplitter()
        m_wndSplitter.RecalcLayout();
 }
 
+int CHexMergeFrame::GetActivePane()
+{
+       int nPane;
+       if (m_wndSplitter.GetColumnCount() > 1)
+               m_wndSplitter.GetActivePane(nullptr, &nPane);
+       else
+               m_wndSplitter.GetActivePane(&nPane, nullptr);
+       return nPane;
+}
+
+void CHexMergeFrame::SetActivePane(int nPane)
+{
+       if (m_wndSplitter.GetColumnCount() > 1)
+               m_wndSplitter.SetActivePane(0, nPane);
+       else
+               m_wndSplitter.SetActivePane(nPane, 0);
+}
+
 /**
  * @brief Synchronize control and status bar placements with splitter position,
  * update mod indicators, synchronize scrollbars
index d599762..d59460a 100644 (file)
@@ -53,7 +53,8 @@ public:
 
        void UpdateAutoPaneResize();
        void UpdateSplitter();
-
+       int GetActivePane();
+       void SetActivePane(int nPane);
 
 // Attributes
 protected:
index a9bd729..2d60249 100644 (file)
@@ -199,7 +199,7 @@ CImgMergeFrame::~CImgMergeFrame()
        }
 }
 
-bool CImgMergeFrame::OpenDocs(int nFiles, const FileLocation fileloc[], const bool bRO[], const String strDesc[], int nPane, CMDIFrameWnd *pParent)
+bool CImgMergeFrame::OpenDocs(int nFiles, const FileLocation fileloc[], const bool bRO[], const String strDesc[], CMDIFrameWnd *pParent)
 {
 
        for (int pane = 0; pane < nFiles; ++pane)
@@ -228,6 +228,11 @@ bool CImgMergeFrame::OpenDocs(int nFiles, const FileLocation fileloc[], const bo
        if (GetOptionsMgr()->GetBool(OPT_SCROLL_TO_FIRST))
                m_pImgMergeWindow->FirstDiff();
 
+       return true;
+}
+
+void CImgMergeFrame::MoveOnLoad(int nPane, int)
+{
        if (nPane < 0)
        {
                nPane = theApp.GetProfileInt(_T("Settings"), _T("ActivePane"), 0);
@@ -236,8 +241,6 @@ bool CImgMergeFrame::OpenDocs(int nFiles, const FileLocation fileloc[], const bo
        }
 
        m_pImgMergeWindow->SetActivePane(nPane);
-
-       return true;
 }
 
 void CImgMergeFrame::ChangeFile(int nBuffer, const String& path)
index 32d193e..583db42 100644 (file)
@@ -58,7 +58,8 @@ public:
 
 // Operations
 public:
-       bool OpenDocs(int nFiles, const FileLocation fileloc[], const bool bRO[], const String strDesc[], int nPane, CMDIFrameWnd *pParent);
+       bool OpenDocs(int nFiles, const FileLocation fileloc[], const bool bRO[], const String strDesc[], CMDIFrameWnd *pParent);
+       void MoveOnLoad(int nPane = -1, int nLineIndex = -1);
        void ChangeFile(int pane, const String& path);
        void SetDirDoc(CDirDoc * pDirDoc);
        void UpdateResources();
index 498ba7d..86ec140 100644 (file)
@@ -711,7 +711,7 @@ bool CMainFrame::ShowMergeDoc(CDirDoc * pDirDoc,
        }
 
        // Note that OpenDocs() takes care of closing compare window when needed.
-       bool bResult = pMergeDoc->OpenDocs(nFiles, fileloc, GetROFromFlags(nFiles, dwFlags).data(), strDesc, GetActivePaneFromFlags(nFiles, dwFlags));
+       bool bResult = pMergeDoc->OpenDocs(nFiles, fileloc, GetROFromFlags(nFiles, dwFlags).data(), strDesc);
 
        if (CChildFrame *pFrame = pMergeDoc->GetParentFrame())
        {
@@ -739,6 +739,8 @@ bool CMainFrame::ShowMergeDoc(CDirDoc * pDirDoc,
                }
        }
 
+       pMergeDoc->MoveOnLoad(GetActivePaneFromFlags(nFiles, dwFlags));
+
        if (!sReportFile.empty())
                pMergeDoc->GenerateReport(sReportFile);
 
@@ -755,8 +757,10 @@ bool CMainFrame::ShowHexMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocati
        if (pHexMergeDoc == nullptr)
                return false;
 
-       if (!pHexMergeDoc->OpenDocs(nFiles, fileloc, GetROFromFlags(nFiles, dwFlags).data(), strDesc, GetActivePaneFromFlags(nFiles, dwFlags)))
+       if (!pHexMergeDoc->OpenDocs(nFiles, fileloc, GetROFromFlags(nFiles, dwFlags).data(), strDesc))
                return false;
+
+       pHexMergeDoc->MoveOnLoad(GetActivePaneFromFlags(nFiles, dwFlags));
        
        if (!sReportFile.empty())
                pHexMergeDoc->GenerateReport(sReportFile);
@@ -776,7 +780,7 @@ bool CMainFrame::ShowImgMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocati
        pImgMergeFrame->SetDirDoc(pDirDoc);
        pDirDoc->AddMergeDoc(pImgMergeFrame);
                
-       if (!pImgMergeFrame->OpenDocs(nFiles, fileloc, GetROFromFlags(nFiles, dwFlags).data(), strDesc, GetActivePaneFromFlags(nFiles, dwFlags), this))
+       if (!pImgMergeFrame->OpenDocs(nFiles, fileloc, GetROFromFlags(nFiles, dwFlags).data(), strDesc, this))
                return ShowMergeDoc(pDirDoc, nFiles, fileloc, dwFlags, strDesc, sReportFile, infoUnpacker);
 
        for (int pane = 0; pane < nFiles; pane++)
@@ -785,6 +789,8 @@ bool CMainFrame::ShowImgMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocati
                        pImgMergeFrame->DoAutoMerge(pane);
        }
 
+       pImgMergeFrame->MoveOnLoad(GetActivePaneFromFlags(nFiles, dwFlags));
+
        if (!sReportFile.empty())
                pImgMergeFrame->GenerateReport(sReportFile);
 
index 25ba81b..42cb916 100644 (file)
@@ -2599,14 +2599,12 @@ DWORD CMergeDoc::LoadOneFile(int index, String filename, bool readOnly, const St
  * @brief Loads files and does initial rescan.
  * @param fileloc [in] File to open to left/middle/right side (path & encoding info)
  * @param bRO [in] Is left/middle/right file read-only
- * @param nPane [in] Pane to activate
- * @param nLineIndex [in] Index of line in view to move the cursor to
  * @return Success/Failure/Binary (failure) per typedef enum OpenDocsResult_TYPE
  * @todo Options are still read from CMainFrame, this will change
  * @sa CMainFrame::ShowMergeDoc()
  */
 bool CMergeDoc::OpenDocs(int nFiles, const FileLocation ifileloc[],
-               const bool bRO[], const String strDesc[], int nPane/* = -1 */, int nLineIndex/* = -1 */)
+               const bool bRO[], const String strDesc[])
 {
        IDENTLEVEL identical = IDENTLEVEL_NONE;
        int nRescanResult = RESCAN_OK;
@@ -2829,29 +2827,6 @@ bool CMergeDoc::OpenDocs(int nFiles, const FileLocation ifileloc[],
                        ShowRescanError(nRescanResult, identical);
                }
 
-               if (nPane < 0)
-               {
-                       nPane = theApp.GetProfileInt(_T("Settings"), _T("ActivePane"), 0);
-                       if (nPane < 0 || nPane >= m_nBuffers)
-                               nPane = 0;
-               }
-               if (nLineIndex == -1)
-               {
-                       // scroll to first diff
-                       if (GetOptionsMgr()->GetBool(OPT_SCROLL_TO_FIRST) &&
-                               m_diffList.HasSignificantDiffs())
-                       {
-                               int nDiff = m_diffList.FirstSignificantDiff();
-                               m_pView[0][nPane]->SelectDiff(nDiff, true, false);
-                               nLineIndex = m_pView[0][nPane]->GetCursorPos().y;
-                       }
-                       else
-                       {
-                               nLineIndex = 0;
-                       }
-               }
-               m_pView[0][nPane]->GotoLine(nLineIndex, false, nPane);
-
                // Exit if files are identical should only work for the first
                // comparison and must be disabled afterward.
                theApp.m_bExitIfNoDiff = MergeCmdLineInfo::Disabled;
@@ -2875,6 +2850,32 @@ bool CMergeDoc::OpenDocs(int nFiles, const FileLocation ifileloc[],
        return true;
 }
 
+void CMergeDoc::MoveOnLoad(int nPane, int nLineIndex)
+{
+       if (nPane < 0)
+       {
+               nPane = theApp.GetProfileInt(_T("Settings"), _T("ActivePane"), 0);
+               if (nPane < 0 || nPane >= m_nBuffers)
+                       nPane = 0;
+       }
+       if (nLineIndex == -1)
+       {
+               // scroll to first diff
+               if (GetOptionsMgr()->GetBool(OPT_SCROLL_TO_FIRST) &&
+                       m_diffList.HasSignificantDiffs())
+               {
+                       int nDiff = m_diffList.FirstSignificantDiff();
+                       m_pView[0][nPane]->SelectDiff(nDiff, true, false);
+                       nLineIndex = m_pView[0][nPane]->GetCursorPos().y;
+               }
+               else
+               {
+                       nLineIndex = 0;
+               }
+       }
+       m_pView[0][nPane]->GotoLine(nLineIndex, false, nPane);
+}
+
 void CMergeDoc::ChangeFile(int nBuffer, const String& path)
 {
        if (!PromptAndSaveIfNeeded(true))
@@ -2896,7 +2897,8 @@ void CMergeDoc::ChangeFile(int nBuffer, const String& path)
        fileloc[nBuffer].setPath(path);
        fileloc[nBuffer].encoding = GuessCodepageEncoding(path, GetOptionsMgr()->GetInt(OPT_CP_DETECT));
        
-       OpenDocs(m_nBuffers, fileloc, bRO, strDesc, nBuffer, 0);
+       OpenDocs(m_nBuffers, fileloc, bRO, strDesc);
+       MoveOnLoad(nBuffer, 0);
 }
 
 /**
@@ -3146,7 +3148,8 @@ void CMergeDoc::OnFileReload()
                fileloc[pane].setPath(m_filePaths[pane]);
        }
        CPoint pt = GetActiveMergeView()->GetCursorPos();
-       OpenDocs(m_nBuffers, fileloc, bRO, m_strDesc, GetActiveMergeView()->m_nThisPane, pt.y);
+       OpenDocs(m_nBuffers, fileloc, bRO, m_strDesc);
+       MoveOnLoad(GetActiveMergeView()->m_nThisPane, pt.y);
 }
 
 /**
index e16614a..09427a8 100644 (file)
@@ -179,8 +179,9 @@ public:
        void RefreshOptions();
        void UpdateResources();
        bool OpenDocs(int nFiles, const FileLocation fileloc[],
-               const bool bRO[], const String strDesc[], int nPane = -1, int nLineIndex = -1);
+               const bool bRO[], const String strDesc[]);
        int LoadFile(CString sFileName, int nBuffer, bool & readOnly, const FileTextEncoding & encoding);
+       void MoveOnLoad(int nPane = -1, int nLinIndex = -1);
        void ChangeFile(int nBuffer, const String& path);
        void RescanIfNeeded(float timeOutInSecond);
        int Rescan(bool &bBinary, IDENTLEVEL &identical, bool bForced = false);
index fbff415..c653705 100644 (file)
@@ -453,7 +453,9 @@ std::map<int, std::vector<int>> CMergeEditView::GetColumnSelectedWordDiffIndice(
 
 void CMergeEditView::OnInitialUpdate()
 {
+       PushCursors();
        CCrystalEditViewEx::OnInitialUpdate();
+       PopCursors();
        SetFont(dynamic_cast<CMainFrame*>(AfxGetMainWnd())->m_lfDiff);
        SetAlternateDropTarget(new DropHandler(std::bind(&CMergeEditView::OnDropFiles, this, std::placeholders::_1)));
 
index e00c9a6..b56f178 100644 (file)
@@ -5,7 +5,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: WinMerge\n"
 "Report-Msgid-Bugs-To: http://bugs.winmerge.org/\n"
-"POT-Creation-Date: 2019-01-14 01:56+0000\n"
+"POT-Creation-Date: 2019-02-02 01:28+0000\n"
 "PO-Revision-Date: \n"
 "Last-Translator: \n"
 "Language-Team: English <winmerge-translate@lists.sourceforge.net>\n"