/**
* @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);
m_pView[0]->ResizeWindow();
OnRefresh();
-
- if (GetOptionsMgr()->GetBool(OPT_SCROLL_TO_FIRST))
- m_pView[0]->SendMessage(WM_COMMAND, ID_FIRSTDIFF);
}
else
{
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)
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);
}
/**
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:
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
CRect rc;
pLeft->GetWindowRect(&rc);
theApp.WriteProfileInt(_T("Settings"), _T("WLeft"), rc.Width());
+ theApp.WriteProfileInt(_T("Settings"), _T("ActivePane"), GetActivePane());
}
}
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
void UpdateAutoPaneResize();
void UpdateSplitter();
-
+ int GetActivePane();
+ void SetActivePane(int nPane);
// Attributes
protected:
}
}
-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)
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);
}
m_pImgMergeWindow->SetActivePane(nPane);
-
- return true;
}
void CImgMergeFrame::ChangeFile(int nBuffer, const String& path)
// 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();
}
// 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())
{
}
}
+ pMergeDoc->MoveOnLoad(GetActivePaneFromFlags(nFiles, dwFlags));
+
if (!sReportFile.empty())
pMergeDoc->GenerateReport(sReportFile);
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);
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++)
pImgMergeFrame->DoAutoMerge(pane);
}
+ pImgMergeFrame->MoveOnLoad(GetActivePaneFromFlags(nFiles, dwFlags));
+
if (!sReportFile.empty())
pImgMergeFrame->GenerateReport(sReportFile);
* @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;
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;
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))
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);
}
/**
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);
}
/**
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);
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)));
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"