bool CMainFrame::ShowAutoMergeDoc(CDirDoc * pDirDoc,
int nFiles, const FileLocation ifileloc[],
const DWORD dwFlags[], const String strDesc[], const String& sReportFile /*= _T("")*/,
- const PackingInfo * infoUnpacker /*= nullptr*/, OpenTextFileParams* pOpenParams /*= nullptr*/)
+ const PackingInfo * infoUnpacker /*= nullptr*/, const OpenTextFileParams* pOpenParams /*= nullptr*/)
{
ASSERT(pDirDoc != nullptr);
bool CMainFrame::ShowMergeDoc(UINT nID, CDirDoc* pDirDoc,
int nFiles, const FileLocation ifileloc[],
const DWORD dwFlags[], const String strDesc[], const String& sReportFile /*= _T("")*/,
- const PackingInfo* infoUnpacker /*= nullptr*/, OpenTextFileParams* pOpenParams /*= nullptr*/)
+ const PackingInfo* infoUnpacker /*= nullptr*/, const OpenTextFileParams* pOpenParams /*= nullptr*/)
{
switch (nID)
{
bool CMainFrame::ShowTextOrTableMergeDoc(std::optional<bool> table, CDirDoc * pDirDoc,
int nFiles, const FileLocation ifileloc[],
const DWORD dwFlags[], const String strDesc[], const String& sReportFile /*= _T("")*/,
- const PackingInfo * infoUnpacker /*= nullptr*/, OpenTextFileParams* pOpenParams /*= nullptr*/)
+ const PackingInfo * infoUnpacker /*= nullptr*/, const OpenTextFileParams* pOpenParams /*= nullptr*/)
{
if (m_pMenus[MENU_MERGEVIEW] == nullptr)
theApp.m_pDiffTemplate->m_hMenuShared = NewMergeViewMenu();
pMergeDoc->SetEnableTableEditing(table);
if (pOpenParams && table.value_or(false))
{
- CMergeDoc::TableProps props = CMergeDoc::GetTablePropertiesByFileName(fileloc[0].filepath, true, false);
+ CMergeDoc::TableProps props = CMergeDoc::GetTablePropertiesByFileName(
+ pOpenParams->m_fileExt.empty() ? fileloc[0].filepath : pOpenParams->m_fileExt, true, false);
props.delimiter = pOpenParams->m_tableDelimiter.value_or(props.delimiter);
props.quote = pOpenParams->m_tableQuote.value_or(props.quote);
props.allowNewlinesInQuotes = pOpenParams->m_tableAllowNewlinesInQuotes.value_or(props.allowNewlinesInQuotes);
return false;
}
+ if (pOpenParams && !pOpenParams->m_fileExt.empty())
+ pMergeDoc->SetTextType(pOpenParams->m_fileExt);
+
for (int pane = 0; pane < nFiles; pane++)
{
if (dwFlags)
bool CMainFrame::ShowTextMergeDoc(CDirDoc* pDirDoc,
int nFiles, const FileLocation ifileloc[],
const DWORD dwFlags[], const String strDesc[], const String& sReportFile /*= _T("")*/,
- const PackingInfo* infoUnpacker /*= nullptr*/, OpenTextFileParams* pOpenParams /*= nullptr*/)
+ const PackingInfo* infoUnpacker /*= nullptr*/, const OpenTextFileParams* pOpenParams /*= nullptr*/)
{
return ShowTextOrTableMergeDoc(false, pDirDoc, nFiles, ifileloc, dwFlags, strDesc, sReportFile, infoUnpacker, pOpenParams);
}
bool CMainFrame::ShowTableMergeDoc(CDirDoc* pDirDoc,
int nFiles, const FileLocation ifileloc[],
const DWORD dwFlags[], const String strDesc[], const String& sReportFile /*= _T("")*/,
- const PackingInfo* infoUnpacker /*= nullptr*/, OpenTextFileParams* pOpenParams /*= nullptr*/)
+ const PackingInfo* infoUnpacker /*= nullptr*/, const OpenTextFileParams* pOpenParams /*= nullptr*/)
{
return ShowTextOrTableMergeDoc(true, pDirDoc, nFiles, ifileloc, dwFlags, strDesc, sReportFile, infoUnpacker, pOpenParams);
}
}
bool CMainFrame::ShowTextMergeDoc(CDirDoc* pDirDoc, int nBuffers, const String text[],
- const String strDesc[], const String& strFileExt, OpenTextFileParams* pOpenParams /*= nullptr*/)
+ const String strDesc[], const String& strFileExt, const OpenTextFileParams* pOpenParams /*= nullptr*/)
{
FileLocation fileloc[3];
DWORD dwFlags[3] = {};
}
}
-static bool AddToRecentDocs(const PathContext& paths, const unsigned flags[], bool recurse, const String& filter)
+static bool AddToRecentDocs(const PathContext& paths,
+ const unsigned flags[], const String desc[],
+ bool recurse, const String& filter,
+ const PackingInfo *infoUnpacker, const PrediffingInfo *infoPrediffer,
+ UINT nID, const CMainFrame::OpenTextFileParams *pOpenParams)
{
+ ASSERT(paths.GetSize() <= 3);
+ const TCHAR *lmr= (paths.GetSize() == 2) ? _T("lr") : _T("lmr");
String params, title;
for (int nIndex = 0; nIndex < paths.GetSize(); ++nIndex)
{
- if (flags && (flags[nIndex] & FFILEOPEN_READONLY))
+ if (flags)
{
- switch (nIndex)
- {
- case 0: params += _T("/wl "); break;
- case 1: params += paths.GetSize() == 2 ? _T("/wr ") : _T("/wm "); break;
- case 2: params += _T("/wr "); break;
- }
+ if (flags[nIndex] & FFILEOPEN_READONLY)
+ params += strutils::format(_T("/w%c "), lmr[nIndex]);
+ if (flags[nIndex] & FFILEOPEN_SETFOCUS)
+ params += strutils::format(_T("/f%c "), lmr[nIndex]);
+ if (flags[nIndex] & FFILEOPEN_AUTOMERGE)
+ params += strutils::format(_T("/a%c "), lmr[nIndex]);
}
+ if (desc && !desc[nIndex].empty())
+ params += strutils::format(_T("/d%c \"%s\" "), lmr[nIndex], desc[nIndex]);
params += _T("\"") + paths[nIndex] + _T("\" ");
String path = paths[nIndex];
params += _T("/r ");
if (!filter.empty())
params += _T("/f \"") + filter + _T("\" ");
+ switch (nID)
+ {
+ case ID_MERGE_COMPARE_TEXT: params += _T("/t text "); break;
+ case ID_MERGE_COMPARE_TABLE: params += _T("/t table "); break;
+ case ID_MERGE_COMPARE_HEX: params += _T("/t binary "); break;
+ case ID_MERGE_COMPARE_IMAGE: params += _T("/t image "); break;
+ }
+ if (pOpenParams)
+ {
+ if (pOpenParams->m_line >= 0)
+ params += strutils::format(_T("/l %d "), pOpenParams->m_line + 1);
+ if (!pOpenParams->m_fileExt.empty())
+ params += _T("/fileext ") + pOpenParams->m_fileExt + _T(" ");
+ if (pOpenParams->m_tableDelimiter.has_value())
+ {
+ String delim(1, *pOpenParams->m_tableDelimiter);
+ if (*pOpenParams->m_tableDelimiter == '\t')
+ delim = _T("tab");
+ params += strutils::format(_T("/table-delimiter %s "), delim);
+ }
+ if (pOpenParams->m_tableQuote.has_value())
+ {
+ String quote(1, *pOpenParams->m_tableQuote);
+ if (*pOpenParams->m_tableQuote == '"')
+ quote = _T("double-quote");
+ params += strutils::format(_T("/table-quote %s "), quote);
+ }
+ if (pOpenParams->m_tableAllowNewlinesInQuotes.has_value())
+ params += strutils::format(_T("/table-allownewlinesinquotes %d "), *pOpenParams->m_tableAllowNewlinesInQuotes);
+ }
+ if (infoUnpacker && !infoUnpacker->GetPluginPipeline().empty())
+ {
+ String pipeline = infoUnpacker->GetPluginPipeline();
+ strutils::replace(pipeline, _T("\""), _T("\"\""));
+ params += _T("/unpacker \"") + pipeline + _T("\" ");
+ }
+ if (infoPrediffer && !infoPrediffer->GetPluginPipeline().empty())
+ {
+ String pipeline = infoPrediffer->GetPluginPipeline();
+ strutils::replace(pipeline, _T("\""), _T("\"\""));
+ params += _T("/prediffer \"") + pipeline + _T("\" ");
+ }
Concurrent::CreateTask([params, title](){
CoInitialize(nullptr);
const DWORD dwFlags[] /*= nullptr*/, const String strDesc[] /*= nullptr*/, const String& sReportFile /*= T("")*/,
bool bRecurse /*= false*/, CDirDoc* pDirDoc/*= nullptr*/,
const PackingInfo *infoUnpacker /*= nullptr*/, const PrediffingInfo *infoPrediffer /*= nullptr*/,
- UINT nID /*= 0*/, OpenTextFileParams *pOpenParams /*= nullptr*/)
+ UINT nID /*= 0*/, const OpenTextFileParams *pOpenParams /*= nullptr*/)
{
if (pDirDoc != nullptr && !pDirDoc->CloseMergeDocs())
return false;
if (pFiles != nullptr && (!dwFlags || !(dwFlags[0] & FFILEOPEN_NOMRU)))
{
String filter = GetOptionsMgr()->GetString(OPT_FILEFILTER_CURRENT);
- AddToRecentDocs(*pFiles, (unsigned *)dwFlags, bRecurse, filter);
+ AddToRecentDocs(*pFiles, (unsigned *)dwFlags, strDesc, bRecurse, filter, infoUnpacker, infoPrediffer, nID, pOpenParams);
}
return true;
}
-bool CMainFrame::DoFileOpen(UINT nID, const PathContext* pFiles /*= nullptr*/,
+bool CMainFrame::DoFileOpen(UINT nID, const PathContext* pFiles,
const DWORD dwFlags[] /*= nullptr*/, const String strDesc[] /*= nullptr*/,
const String& sReportFile /*= _T("")*/,
const PackingInfo *infoUnpacker /*= nullptr*/, const PrediffingInfo *infoPrediffer /*= nullptr*/,
- OpenTextFileParams *pOpenParams /*= nullptr*/)
+ const OpenTextFileParams *pOpenParams /*= nullptr*/)
{
+ ASSERT(pFiles != nullptr);
CDirDoc* pDirDoc = static_cast<CDirDoc*>(theApp.m_pDirTemplate->CreateNewDocument());
FileLocation fileloc[3];
for (int pane = 0; pane < pFiles->GetSize(); pane++)
fileloc[pane].setPath((*pFiles)[pane]);
if (infoPrediffer && !infoPrediffer->GetPluginPipeline().empty())
- pDirDoc->GetPluginManager().SetPrediffer(_T("|"), infoPrediffer->GetPluginPipeline());
- return ShowMergeDoc(nID, pDirDoc, pFiles->GetSize(), fileloc,
+ {
+ String strBothFilenames = strutils::join(pFiles->begin(), pFiles->end(), _T("|"));
+ pDirDoc->GetPluginManager().SetPrediffer(strBothFilenames, infoPrediffer->GetPluginPipeline());
+ }
+ bool result = ShowMergeDoc(nID, pDirDoc, pFiles->GetSize(), fileloc,
dwFlags, strDesc, sReportFile, infoUnpacker, pOpenParams);
+ if (!dwFlags || !(dwFlags[0] & FFILEOPEN_NOMRU))
+ AddToRecentDocs(*pFiles, (unsigned *)dwFlags, strDesc, false, _T(""), infoUnpacker, infoPrediffer, nID, pOpenParams);
+ return result;
}
void CMainFrame::UpdateFont(FRAMETYPE frame)
*/
bool CMainFrame::DoFileNew(UINT nID, int nPanes, const String strDesc[],
const PrediffingInfo *infoPrediffer /*= nullptr*/,
- OpenTextFileParams *pOpenParams)
+ const OpenTextFileParams *pOpenParams)
{
CDirDoc *pDirDoc = static_cast<CDirDoc*>(theApp.m_pDirTemplate->CreateNewDocument());
bool CMainFrame::DoSelfCompare(UINT nID, const String& file, const String strDesc[] /*= nullptr*/,
const PackingInfo *infoUnpacker /*= nullptr*/, const PrediffingInfo *infoPrediffer /*= nullptr*/,
- OpenTextFileParams *pOpenParams /*= nullptr*/)
+ const OpenTextFileParams *pOpenParams /*= nullptr*/)
{
String ext = paths::FindExtension(file);
TempFilePtr wTemp(new TempFile());