#include "PreferencesDlg.h"
#include "FileOrFolderSelect.h"
#include "PluginsListDlg.h"
+#include "SelectPluginDlg.h"
#include "stringdiffs.h"
#include "MergeCmdLineInfo.h"
#include "OptionsFont.h"
ON_UPDATE_COMMAND_UI_RANGE(ID_UNPACK_MANUAL, ID_UNPACK_AUTO, OnUpdatePluginUnpackMode)
ON_COMMAND_RANGE(ID_PREDIFFER_MANUAL, ID_PREDIFFER_AUTO, OnPluginPrediffMode)
ON_UPDATE_COMMAND_UI_RANGE(ID_PREDIFFER_MANUAL, ID_PREDIFFER_AUTO, OnUpdatePluginPrediffMode)
- ON_UPDATE_COMMAND_UI(ID_RELOAD_PLUGINS, OnUpdateReloadPlugins)
+ ON_UPDATE_COMMAND_UI(ID_OPEN_WITH_UNPACKER, OnUpdatePluginRelatedMenu)
+ ON_UPDATE_COMMAND_UI(ID_APPLY_PREDIFFER, OnUpdatePluginRelatedMenu)
+ ON_UPDATE_COMMAND_UI(ID_TRANSFORM_WITH_SCRIPT, OnUpdatePluginRelatedMenu)
+ ON_UPDATE_COMMAND_UI(ID_RELOAD_PLUGINS, OnUpdatePluginRelatedMenu)
ON_COMMAND(ID_RELOAD_PLUGINS, OnReloadPlugins)
ON_COMMAND(ID_HELP_GETCONFIG, OnSaveConfigData)
- ON_COMMAND(ID_FILE_NEW, (OnFileNew<2, FRAME_FILE>))
- ON_COMMAND(ID_FILE_NEW_TABLE, (OnFileNew<2, FRAME_FILE, true>))
- ON_COMMAND(ID_FILE_NEW_HEX, (OnFileNew<2, FRAME_HEXFILE>))
- ON_COMMAND(ID_FILE_NEW_IMAGE, (OnFileNew<2, FRAME_IMGFILE>))
- ON_COMMAND(ID_FILE_NEW3, (OnFileNew<3, FRAME_FILE>))
- ON_COMMAND(ID_FILE_NEW3_TABLE, (OnFileNew<2, FRAME_FILE, true>))
- ON_COMMAND(ID_FILE_NEW3_HEX, (OnFileNew<3, FRAME_HEXFILE>))
- ON_COMMAND(ID_FILE_NEW3_IMAGE, (OnFileNew<3, FRAME_IMGFILE>))
+ ON_COMMAND(ID_FILE_NEW, (OnFileNew<2, ID_MERGE_COMPARE_TEXT>))
+ ON_COMMAND(ID_FILE_NEW_TABLE, (OnFileNew<2, ID_MERGE_COMPARE_TABLE>))
+ ON_COMMAND(ID_FILE_NEW_HEX, (OnFileNew<2, ID_MERGE_COMPARE_HEX>))
+ ON_COMMAND(ID_FILE_NEW_IMAGE, (OnFileNew<2, ID_MERGE_COMPARE_IMAGE>))
+ ON_COMMAND(ID_FILE_NEW3, (OnFileNew<3, ID_MERGE_COMPARE_TEXT>))
+ ON_COMMAND(ID_FILE_NEW3_TABLE, (OnFileNew<2, ID_MERGE_COMPARE_TABLE>))
+ ON_COMMAND(ID_FILE_NEW3_HEX, (OnFileNew<3, ID_MERGE_COMPARE_HEX>))
+ ON_COMMAND(ID_FILE_NEW3_IMAGE, (OnFileNew<3, ID_MERGE_COMPARE_IMAGE>))
ON_COMMAND(ID_TOOLS_FILTERS, OnToolsFilters)
ON_COMMAND(ID_VIEW_STATUS_BAR, OnViewStatusBar)
ON_UPDATE_COMMAND_UI(ID_VIEW_TAB_BAR, OnUpdateViewTabBar)
ON_COMMAND(ID_PLUGINS_LIST, OnPluginsList)
ON_UPDATE_COMMAND_UI(ID_STATUS_PLUGIN, OnUpdatePluginName)
ON_NOTIFY(TBN_DROPDOWN, AFX_IDW_TOOLBAR, OnToolbarButtonDropDown)
- ON_COMMAND_RANGE(IDC_DIFF_WHITESPACE_COMPARE, IDC_DIFF_WHITESPACE_IGNOREALL, OnDiffWhitespace)
- ON_UPDATE_COMMAND_UI_RANGE(IDC_DIFF_WHITESPACE_COMPARE, IDC_DIFF_WHITESPACE_IGNOREALL, OnUpdateDiffWhitespace)
- ON_COMMAND(IDC_DIFF_IGNORECASE, OnDiffIgnoreCase)
- ON_UPDATE_COMMAND_UI(IDC_DIFF_IGNORECASE, OnUpdateDiffIgnoreCase)
- ON_COMMAND(IDC_DIFF_IGNOREEOL, OnDiffIgnoreEOL)
- ON_UPDATE_COMMAND_UI(IDC_DIFF_IGNOREEOL, OnUpdateDiffIgnoreEOL)
- ON_COMMAND(IDC_DIFF_IGNORECP, OnDiffIgnoreCP)
- ON_UPDATE_COMMAND_UI(IDC_DIFF_IGNORECP, OnUpdateDiffIgnoreCP)
- ON_COMMAND(IDC_RECURS_CHECK, OnIncludeSubfolders)
- ON_UPDATE_COMMAND_UI(IDC_RECURS_CHECK, OnUpdateIncludeSubfolders)
- ON_COMMAND_RANGE(ID_COMPMETHOD_FULL_CONTENTS, ID_COMPMETHOD_SIZE, OnCompareMethod)
- ON_UPDATE_COMMAND_UI_RANGE(ID_COMPMETHOD_FULL_CONTENTS, ID_COMPMETHOD_SIZE, OnUpdateCompareMethod)
+ ON_COMMAND_RANGE(ID_DIFF_OPTIONS_WHITESPACE_COMPARE, ID_DIFF_OPTIONS_WHITESPACE_IGNOREALL, OnDiffWhitespace)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_DIFF_OPTIONS_WHITESPACE_COMPARE, ID_DIFF_OPTIONS_WHITESPACE_IGNOREALL, OnUpdateDiffWhitespace)
+ ON_COMMAND(ID_DIFF_OPTIONS_IGNORE_BLANKLINES, OnDiffIgnoreBlankLines)
+ ON_UPDATE_COMMAND_UI(ID_DIFF_OPTIONS_IGNORE_BLANKLINES, OnUpdateDiffIgnoreBlankLines)
+ ON_COMMAND(ID_DIFF_OPTIONS_IGNORE_CASE, OnDiffIgnoreCase)
+ ON_UPDATE_COMMAND_UI(ID_DIFF_OPTIONS_IGNORE_CASE, OnUpdateDiffIgnoreCase)
+ ON_COMMAND(ID_DIFF_OPTIONS_IGNORE_EOL, OnDiffIgnoreEOL)
+ ON_UPDATE_COMMAND_UI(ID_DIFF_OPTIONS_IGNORE_EOL, OnUpdateDiffIgnoreEOL)
+ ON_COMMAND(ID_DIFF_OPTIONS_IGNORE_CODEPAGE, OnDiffIgnoreCP)
+ ON_UPDATE_COMMAND_UI(ID_DIFF_OPTIONS_IGNORE_CODEPAGE, OnUpdateDiffIgnoreCP)
+ ON_COMMAND(ID_DIFF_OPTIONS_IGNORE_COMMENTS, OnDiffIgnoreComments)
+ ON_UPDATE_COMMAND_UI(ID_DIFF_OPTIONS_IGNORE_COMMENTS, OnUpdateDiffIgnoreComments)
+ ON_COMMAND(ID_DIFF_OPTIONS_INCLUDE_SUBFOLDERS, OnIncludeSubfolders)
+ ON_UPDATE_COMMAND_UI(ID_DIFF_OPTIONS_INCLUDE_SUBFOLDERS, OnUpdateIncludeSubfolders)
+ ON_COMMAND_RANGE(ID_DIFF_OPTIONS_COMPMETHOD_FULL_CONTENTS, ID_DIFF_OPTIONS_COMPMETHOD_SIZE, OnCompareMethod)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_DIFF_OPTIONS_COMPMETHOD_FULL_CONTENTS, ID_DIFF_OPTIONS_COMPMETHOD_SIZE, OnUpdateCompareMethod)
ON_COMMAND_RANGE(ID_MRU_FIRST, ID_MRU_LAST, OnMRUs)
ON_UPDATE_COMMAND_UI(ID_MRU_FIRST, OnUpdateNoMRUs)
ON_UPDATE_COMMAND_UI(ID_NO_MRU, OnUpdateNoMRUs)
RevokeDragDrop(m_hWnd);
}
-static HMENU GetSubmenu(HMENU menu, bool bFirstSubmenu)
+static HMENU GetSubmenu(HMENU menu, int nthSubmenu)
{
- if (!bFirstSubmenu)
+ for (int nth = 0, i = 0; i < ::GetMenuItemCount(menu); i++)
{
- // look for last submenu
- for (int i = ::GetMenuItemCount(menu) ; i >= 0 ; i--)
- if (::GetSubMenu(menu, i) != nullptr)
- return ::GetSubMenu(menu, i);
- }
- else
- {
- // look for first submenu
- for (int i = 0 ; i < ::GetMenuItemCount(menu) ; i++)
- if (::GetSubMenu(menu, i) != nullptr)
+ if (::GetSubMenu(menu, i) != nullptr)
+ {
+ if (nth == nthSubmenu)
return ::GetSubMenu(menu, i);
+ nth++;
+ }
}
-
// error, submenu not found
return nullptr;
}
-static HMENU GetSubmenu(HMENU mainMenu, UINT nIDFirstMenuItem, bool bFirstSubmenu)
+static HMENU GetSubmenu(HMENU mainMenu, UINT nIDFirstMenuItem, int nthSubmenu)
{
int i;
for (i = 0 ; i < ::GetMenuItemCount(mainMenu) ; i++)
HMENU menu = ::GetSubMenu(mainMenu, i);
if (!menu)
return nullptr;
- return GetSubmenu(menu, bFirstSubmenu);
-}
-
-/**
- * @brief Find the scripts submenu from the main menu
- * As now this is the first submenu in "Edit" menu
- * We find the "Edit" menu by looking for a menu
- * starting with ID_EDIT_UNDO.
- */
-HMENU CMainFrame::GetScriptsSubmenu(HMENU mainMenu)
-{
- return GetSubmenu(mainMenu, ID_PLUGINS_LIST, false);
+ return GetSubmenu(menu, nthSubmenu);
}
/**
*/
HMENU CMainFrame::GetPrediffersSubmenu(HMENU mainMenu)
{
- return GetSubmenu(mainMenu, ID_PLUGINS_LIST, true);
+ return GetSubmenu(mainMenu, ID_PLUGINS_LIST, 1);
}
/**
*/
void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
{
- CMDIFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
-
if (!bSysMenu)
{
+ if (IMergeDoc* pMergeDoc = GetActiveIMergeDoc())
+ {
+ PathContext paths;
+ for (int i = 0; i < pMergeDoc->GetFileCount(); ++i)
+ paths.SetPath(i, pMergeDoc->GetPath(i));
+ String filteredFilenames = strutils::join(paths.begin(), paths.end(), _T("|"));
+ unsigned topMenuId = pPopupMenu->GetMenuItemID(0);
+ if (topMenuId == ID_NO_PREDIFFER)
+ {
+ UpdatePrediffersMenu();
+ }
+ else if (topMenuId == ID_MERGE_COMPARE_TEXT)
+ {
+ CMenu* pMenu = pPopupMenu;
+ // empty the menu
+ for (int i = pMenu->GetMenuItemCount() - 1; i > (ID_MERGE_COMPARE_IMAGE - ID_MERGE_COMPARE_TEXT); --i)
+ pMenu->DeleteMenu(i, MF_BYPOSITION);
+
+ CMainFrame::AppendPluginMenus(pMenu, filteredFilenames, FileTransform::UnpackerEventNames, true, ID_UNPACKERS_FIRST);
+ }
+ else if (topMenuId == ID_NO_EDIT_SCRIPTS)
+ {
+ CMenu* pMenu = pPopupMenu;
+ ASSERT(pMenu != nullptr);
+
+ // empty the menu
+ int i = pMenu->GetMenuItemCount();
+ while (i--)
+ pMenu->DeleteMenu(0, MF_BYPOSITION);
+
+ CMainFrame::AppendPluginMenus(pMenu, filteredFilenames, FileTransform::EditorScriptEventNames, false, ID_SCRIPT_FIRST);
+ }
+ else if (topMenuId == ID_PLUGINS_LIST)
+ {
+ for (int j = 0; j < 2; j++)
+ {
+ CMenu* pMenu = pPopupMenu->GetSubMenu((j == 0) ? 8 : (pPopupMenu->GetMenuItemCount() - 4));
+ ASSERT(pMenu != nullptr);
+
+ // empty the menu
+ int i = pMenu->GetMenuItemCount();
+ while (i--)
+ pMenu->DeleteMenu(0, MF_BYPOSITION);
+
+ if (j == 0)
+ CMainFrame::AppendPluginMenus(pMenu, filteredFilenames, FileTransform::UnpackerEventNames, false, ID_UNPACKERS_FIRST);
+ else
+ CMainFrame::AppendPluginMenus(pMenu, filteredFilenames, FileTransform::EditorScriptEventNames, false, ID_SCRIPT_FIRST);
+ }
+ }
+ }
+
+ CMDIFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
if (BCMenu::IsMenu(pPopupMenu))
{
BCMenu::UpdateMenu(pPopupMenu);
}
}
+ else
+ {
+ CMDIFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
+ }
}
/////////////////////////////////////////////////////////////////////////////
void CMainFrame::OnFileOpen()
{
- DoFileOpen();
+ DoFileOrFolderOpen();
}
/**
bool CMainFrame::ShowAutoMergeDoc(CDirDoc * pDirDoc,
int nFiles, const FileLocation ifileloc[],
const DWORD dwFlags[], const String strDesc[], const String& sReportFile /*= _T("")*/,
- const PackingInfo * infoUnpacker /*= nullptr*/)
+ const PackingInfo * infoUnpacker /*= nullptr*/, const OpenTextFileParams* pOpenParams /*= nullptr*/)
{
ASSERT(pDirDoc != nullptr);
std::transform(ifileloc, ifileloc + nFiles, filepaths.begin(),
[](auto& file) { return file.filepath; });
String filteredFilenames = strutils::join(filepaths.begin(), filepaths.end(), _T("|"));
- unpackedFileExtension = FileTransform::GetUnpackedFileExtension(filteredFilenames, infoUnpacker);
+ unpackedFileExtension = infoUnpacker->GetUnpackedFileExtension(filteredFilenames);
}
FileFilterHelper filterImg, filterBin;
filterImg.UseMask(true);
else if (filterBin.includeFile(filepath) && CHexMergeView::IsLoadable())
return ShowHexMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags, strDesc, sReportFile, infoUnpacker);
}
- return ShowTextOrTableMergeDoc({}, pDirDoc, nFiles, ifileloc, dwFlags, strDesc, sReportFile, infoUnpacker);
+ return ShowTextOrTableMergeDoc({}, pDirDoc, nFiles, ifileloc, dwFlags, strDesc, sReportFile, infoUnpacker, pOpenParams);
}
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*/)
+ const PackingInfo* infoUnpacker /*= nullptr*/, const OpenTextFileParams* pOpenParams /*= nullptr*/)
{
switch (nID)
{
case ID_MERGE_COMPARE_TEXT:
- return GetMainFrame()->ShowTextMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags,
- strDesc, sReportFile, infoUnpacker);
+ return ShowTextMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags,
+ strDesc, sReportFile, infoUnpacker, pOpenParams);
case ID_MERGE_COMPARE_TABLE:
- return GetMainFrame()->ShowTableMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags,
- strDesc, sReportFile, infoUnpacker);
+ return ShowTableMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags,
+ strDesc, sReportFile, infoUnpacker, pOpenParams);
case ID_MERGE_COMPARE_HEX:
- return GetMainFrame()->ShowHexMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags,
+ return ShowHexMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags,
strDesc, sReportFile, infoUnpacker);
case ID_MERGE_COMPARE_IMAGE:
- return GetMainFrame()->ShowImgMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags,
+ return ShowImgMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags,
strDesc, sReportFile, infoUnpacker);
default:
- return GetMainFrame()->ShowAutoMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags,
- strDesc, sReportFile, infoUnpacker);
+ return ShowAutoMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags,
+ strDesc, sReportFile, infoUnpacker, pOpenParams);
}
}
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*/)
+ 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(
+ 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);
+ pMergeDoc->SetTableProperties(props);
+ }
// Note that OpenDocs() takes care of closing compare window when needed.
bool bResult = pMergeDoc->OpenDocs(nFiles, fileloc, GetROFromFlags(nFiles, dwFlags).data(), strDesc);
return false;
}
+ if (pOpenParams && !pOpenParams->m_fileExt.empty())
+ pMergeDoc->SetTextType(pOpenParams->m_fileExt);
+
for (int pane = 0; pane < nFiles; pane++)
{
if (dwFlags)
}
}
- pMergeDoc->MoveOnLoad(GetActivePaneFromFlags(nFiles, dwFlags));
+ pMergeDoc->MoveOnLoad(GetActivePaneFromFlags(nFiles, dwFlags), pOpenParams ? pOpenParams->m_line : -1, true);
if (!sReportFile.empty())
pMergeDoc->GenerateReport(sReportFile);
bool CMainFrame::ShowTextMergeDoc(CDirDoc* pDirDoc,
int nFiles, const FileLocation ifileloc[],
const DWORD dwFlags[], const String strDesc[], const String& sReportFile /*= _T("")*/,
- const PackingInfo* infoUnpacker /*= nullptr*/)
+ const PackingInfo* infoUnpacker /*= nullptr*/, const OpenTextFileParams* pOpenParams /*= nullptr*/)
{
- return ShowTextOrTableMergeDoc(false, pDirDoc, nFiles, ifileloc, dwFlags, strDesc, sReportFile, infoUnpacker);
+ 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*/)
+ const PackingInfo* infoUnpacker /*= nullptr*/, const OpenTextFileParams* pOpenParams /*= nullptr*/)
{
- return ShowTextOrTableMergeDoc(true, pDirDoc, nFiles, ifileloc, dwFlags, strDesc, sReportFile, infoUnpacker);
+ return ShowTextOrTableMergeDoc(true, pDirDoc, nFiles, ifileloc, dwFlags, strDesc, sReportFile, infoUnpacker, pOpenParams);
}
bool CMainFrame::ShowHexMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
pDirDoc->AddMergeDoc(pImgMergeFrame);
if (!pImgMergeFrame->OpenDocs(nFiles, fileloc, GetROFromFlags(nFiles, dwFlags).data(), strDesc, this))
- return ShowTextMergeDoc(pDirDoc, nFiles, fileloc, dwFlags, strDesc, sReportFile, infoUnpacker);
+ return false;
for (int pane = 0; pane < nFiles; pane++)
{
}
bool CMainFrame::ShowTextMergeDoc(CDirDoc* pDirDoc, int nBuffers, const String text[],
- const String strDesc[], const String& strFileExt)
+ const String strDesc[], const String& strFileExt, const OpenTextFileParams* pOpenParams /*= nullptr*/)
{
FileLocation fileloc[3];
DWORD dwFlags[3] = {};
}
fileloc[nBuffer].setPath(workFile);
}
- return ShowTextMergeDoc(pDirDoc2, nBuffers, fileloc, dwFlags, strDesc);
+ return ShowTextMergeDoc(pDirDoc2, nBuffers, fileloc, dwFlags, strDesc, _T(""), nullptr, pOpenParams);
}
/**
}
}
-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);
* @param [in] dwRightFlags Right-side flags.
* @param [in] bRecurse Do we run recursive (folder) compare?
* @param [in] pDirDoc Dir compare document to use.
- * @param [in] prediffer Prediffer plugin name.
+ * @param [in] infoUnpacker Unpacker plugin name.
+ * @param [in] infoPrediffer Prediffer plugin name.
* @return `true` if opening files and compare succeeded, `false` otherwise.
*/
-bool CMainFrame::DoFileOpen(const PathContext * pFiles /*= nullptr*/,
- const DWORD dwFlags[] /*= nullptr*/, const String strDesc[] /*= nullptr*/, const String& sReportFile /*= T("")*/, bool bRecurse /*= false*/, CDirDoc *pDirDoc/*= nullptr*/,
- String prediffer /*= _T("")*/, const PackingInfo *infoUnpacker /*= nullptr*/)
+bool CMainFrame::DoFileOrFolderOpen(const PathContext * pFiles /*= 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*/, const OpenTextFileParams *pOpenParams /*= nullptr*/)
{
if (pDirDoc != nullptr && !pDirDoc->CloseMergeDocs())
return false;
- FileTransform::g_UnpackerMode = static_cast<PLUGIN_MODE>(GetOptionsMgr()->GetInt(OPT_PLUGINS_UNPACKER_MODE));
- FileTransform::g_PredifferMode = static_cast<PLUGIN_MODE>(GetOptionsMgr()->GetInt(OPT_PLUGINS_PREDIFFER_MODE));
+ FileTransform::AutoUnpacking = GetOptionsMgr()->GetBool(OPT_PLUGINS_UNPACKER_MODE);
+ FileTransform::AutoPrediffing = GetOptionsMgr()->GetBool(OPT_PLUGINS_PREDIFFER_MODE);
Merge7zFormatMergePluginScope scope(infoUnpacker);
pOpenDoc->m_files = tFiles;
pOpenDoc->m_bRecurse = bRecurse;
if (infoUnpacker)
- pOpenDoc->m_infoHandler = *infoUnpacker;
+ pOpenDoc->m_strUnpackerPipeline = infoUnpacker->GetPluginPipeline();
CFrameWnd *pFrame = theApp.m_pOpenTemplate->CreateNewFrame(pOpenDoc, nullptr);
theApp.m_pOpenTemplate->InitialUpdateFrame(pFrame, pOpenDoc);
return true;
}
CTempPathContext *pTempPathContext = nullptr;
- if (pathsType == paths::IS_EXISTING_DIR)
+ if (nID == 0 && pathsType == paths::IS_EXISTING_DIR)
{
DecompressResult res= DecompressArchive(m_hWnd, tFiles);
if (res.pTempPathContext)
// an archive. Don't open a new dirview if we are comparing files.
if (pDirDoc == nullptr)
{
- if (pathsType == paths::IS_EXISTING_DIR)
+ if (nID == 0 && pathsType == paths::IS_EXISTING_DIR)
{
CDirDoc::m_nDirsTemp = tFiles.GetSize();
if (m_pMenus[MENU_DIRVIEW] == nullptr)
}
// open the diff
- if (pathsType == paths::IS_EXISTING_DIR)
+ if (nID == 0 && pathsType == paths::IS_EXISTING_DIR)
{
if (pDirDoc != nullptr)
{
for (int nPane = 0; nPane < tFiles.GetSize(); nPane++)
fileloc[nPane].setPath(tFiles[nPane]);
- if (!prediffer.empty())
+ if (infoPrediffer && !infoPrediffer->GetPluginPipeline().empty())
{
String strBothFilenames = strutils::join(tFiles.begin(), tFiles.end(), _T("|"));
- pDirDoc->GetPluginManager().SetPrediffer(strBothFilenames, prediffer);
+ pDirDoc->GetPluginManager().SetPrediffer(strBothFilenames, infoPrediffer->GetPluginPipeline());
}
- ShowAutoMergeDoc(pDirDoc, tFiles.GetSize(), fileloc, dwFlags, strDesc, sReportFile,
- infoUnpacker);
+ ShowMergeDoc(nID, pDirDoc, tFiles.GetSize(), fileloc, dwFlags, strDesc, sReportFile,
+ infoUnpacker, pOpenParams);
}
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*/,
- const DWORD dwFlags[] /*= nullptr*/, const String strDesc[] /*= 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*/,
+ 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]);
- return ShowMergeDoc(nID, pDirDoc, pFiles->GetSize(), fileloc,
- dwFlags, strDesc);
+ if (infoPrediffer && !infoPrediffer->GetPluginPipeline().empty())
+ {
+ 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)
}
}
- DoFileOpen(&tFiles, dwFlags, nullptr, _T(""), recurse);
+ DoFileOrFolderOpen(&tFiles, dwFlags, nullptr, _T(""), recurse);
}
void CMainFrame::OnPluginUnpackMode(UINT nID )
switch (nID)
{
case ID_UNPACK_MANUAL:
- FileTransform::g_UnpackerMode = PLUGIN_MODE::PLUGIN_MANUAL;
+ FileTransform::AutoUnpacking = false;
break;
case ID_UNPACK_AUTO:
- FileTransform::g_UnpackerMode = PLUGIN_MODE::PLUGIN_AUTO;
+ FileTransform::AutoUnpacking = true;
break;
}
- GetOptionsMgr()->SaveOption(OPT_PLUGINS_UNPACKER_MODE, static_cast<int>(FileTransform::g_UnpackerMode));
+ for (auto pDirDoc : GetAllDirDocs())
+ {
+ pDirDoc->GetPluginManager().SetUnpackerSettingAll(FileTransform::AutoUnpacking);
+ pDirDoc->UpdateAllViews(nullptr);
+ }
+ GetOptionsMgr()->SaveOption(OPT_PLUGINS_UNPACKER_MODE, static_cast<int>(FileTransform::AutoUnpacking));
}
void CMainFrame::OnUpdatePluginUnpackMode(CCmdUI* pCmdUI)
pCmdUI->Enable(GetOptionsMgr()->GetBool(OPT_PLUGINS_ENABLED));
if (pCmdUI->m_nID == ID_UNPACK_MANUAL)
- pCmdUI->SetRadio(PLUGIN_MODE::PLUGIN_MANUAL == FileTransform::g_UnpackerMode);
+ pCmdUI->SetRadio(!FileTransform::AutoUnpacking);
if (pCmdUI->m_nID == ID_UNPACK_AUTO)
- pCmdUI->SetRadio(PLUGIN_MODE::PLUGIN_AUTO == FileTransform::g_UnpackerMode);
+ pCmdUI->SetRadio(FileTransform::AutoUnpacking);
}
+
void CMainFrame::OnPluginPrediffMode(UINT nID )
{
switch (nID)
{
case ID_PREDIFFER_MANUAL:
- FileTransform::g_PredifferMode = PLUGIN_MODE::PLUGIN_MANUAL;
+ FileTransform::AutoPrediffing = false;
break;
case ID_PREDIFFER_AUTO:
- FileTransform::g_PredifferMode = PLUGIN_MODE::PLUGIN_AUTO;
+ FileTransform::AutoPrediffing = true;
break;
}
PrediffingInfo infoPrediffer;
for (auto pMergeDoc : GetAllMergeDocs())
pMergeDoc->SetPrediffer(&infoPrediffer);
for (auto pDirDoc : GetAllDirDocs())
- pDirDoc->GetPluginManager().SetPrediffSettingAll(FileTransform::g_PredifferMode);
- GetOptionsMgr()->SaveOption(OPT_PLUGINS_PREDIFFER_MODE, static_cast<int>(FileTransform::g_PredifferMode));
+ {
+ pDirDoc->GetPluginManager().SetPrediffSettingAll(FileTransform::AutoPrediffing);
+ pDirDoc->UpdateAllViews(nullptr);
+ }
+ GetOptionsMgr()->SaveOption(OPT_PLUGINS_PREDIFFER_MODE, FileTransform::AutoPrediffing);
}
void CMainFrame::OnUpdatePluginPrediffMode(CCmdUI* pCmdUI)
pCmdUI->Enable(GetOptionsMgr()->GetBool(OPT_PLUGINS_ENABLED));
if (pCmdUI->m_nID == ID_PREDIFFER_MANUAL)
- pCmdUI->SetRadio(PLUGIN_MODE::PLUGIN_MANUAL == FileTransform::g_PredifferMode);
+ pCmdUI->SetRadio(!FileTransform::AutoPrediffing);
if (pCmdUI->m_nID == ID_PREDIFFER_AUTO)
- pCmdUI->SetRadio(PLUGIN_MODE::PLUGIN_AUTO == FileTransform::g_PredifferMode);
+ pCmdUI->SetRadio(FileTransform::AutoPrediffing);
}
/**
* @brief Called when "Reload Plugins" item is updated
*/
-void CMainFrame::OnUpdateReloadPlugins(CCmdUI* pCmdUI)
+void CMainFrame::OnUpdatePluginRelatedMenu(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(GetOptionsMgr()->GetBool(OPT_PLUGINS_ENABLED));
+ bool enabled = GetOptionsMgr()->GetBool(OPT_PLUGINS_ENABLED);
+ if (enabled && (pCmdUI->m_nID == ID_APPLY_PREDIFFER || pCmdUI->m_nID == ID_TRANSFORM_WITH_SCRIPT))
+ enabled = GetFrameType(GetActiveFrame()) == FRAME_FILE;
+ pCmdUI->Enable(enabled);
}
void CMainFrame::OnReloadPlugins()
{
- // delete all script interfaces
- // (interfaces will be created again automatically when WinMerge needs them)
- CAllThreadsScripts::GetActiveSet()->FreeAllScripts();
-
- // update the editor scripts submenu
- HMENU scriptsSubmenu = GetScriptsSubmenu(m_hMenuDefault);
- if (scriptsSubmenu != nullptr)
- CMergeEditView::createScriptsSubmenu(scriptsSubmenu);
UpdatePrediffersMenu();
}
{
CMergeEditView * pEditView = GetActiveMergeEditView();
if (pEditView != nullptr)
- pEditView->createPrediffersSubmenu(prediffersSubmenu);
+ pEditView->GetDocument()->createPrediffersSubmenu(prediffersSubmenu);
else
{
// no view or dir view : display an empty submenu
* @sa CMergeDoc::OpenDocs()
* @sa CMergeDoc::TrySaveAs()
*/
-void CMainFrame::FileNew(int nPanes, FRAMETYPE frameType, bool table)
+bool CMainFrame::DoFileNew(UINT nID, int nPanes, const String strDesc[],
+ const PrediffingInfo *infoPrediffer /*= nullptr*/,
+ const OpenTextFileParams *pOpenParams)
{
CDirDoc *pDirDoc = static_cast<CDirDoc*>(theApp.m_pDirTemplate->CreateNewDocument());
// Load emptyfile descriptors and open empty docs
// Use default codepage
DWORD dwFlags[3] = {0, 0, 0};
- String strDesc[3];
FileLocation fileloc[3];
+ String strDesc2[3];
if (nPanes == 2)
{
- strDesc[0] = _("Untitled left");
- strDesc[1] = _("Untitled right");
- fileloc[0].encoding.SetCodepage(ucr::getDefaultCodepage());
- fileloc[1].encoding.SetCodepage(ucr::getDefaultCodepage());
+ strDesc2[0] = _("Untitled left");
+ strDesc2[1] = _("Untitled right");
}
else
{
- strDesc[0] = _("Untitled left");
- strDesc[1] = _("Untitled middle");
- strDesc[2] = _("Untitled right");
- fileloc[0].encoding.SetCodepage(ucr::getDefaultCodepage());
- fileloc[1].encoding.SetCodepage(ucr::getDefaultCodepage());
- fileloc[2].encoding.SetCodepage(ucr::getDefaultCodepage());
+ strDesc2[0] = _("Untitled left");
+ strDesc2[1] = _("Untitled middle");
+ strDesc2[2] = _("Untitled right");
}
- UINT nID = ID_MERGE_COMPARE_TEXT;
- switch (frameType)
+ for (int i = 0; i < nPanes; ++i)
{
- case FRAME_FILE: nID = !table ? ID_MERGE_COMPARE_TEXT : ID_MERGE_COMPARE_TABLE; break;
- case FRAME_HEXFILE: nID = ID_MERGE_COMPARE_HEX; break;
- case FRAME_IMGFILE: nID = ID_MERGE_COMPARE_IMAGE; break;
+ if (strDesc && !strDesc[i].empty())
+ strDesc2[i] = strDesc[i];
+ fileloc[i].encoding.SetCodepage(ucr::getDefaultCodepage());
}
- ShowMergeDoc(nID, pDirDoc, nPanes, fileloc, dwFlags, strDesc);
+ if (infoPrediffer && !infoPrediffer->GetPluginPipeline().empty())
+ pDirDoc->GetPluginManager().SetPrediffer(_T("|"), infoPrediffer->GetPluginPipeline());
+ return ShowMergeDoc(nID, pDirDoc, nPanes, fileloc, dwFlags, strDesc2, _T(""), nullptr, pOpenParams);
}
/**
* @sa CMergeDoc::OpenDocs()
* @sa CMergeDoc::TrySaveAs()
*/
-template <int nFiles, CMainFrame::FRAMETYPE frameType, bool table>
+template <int nFiles, unsigned nID>
void CMainFrame::OnFileNew()
{
- FileNew(nFiles, frameType, table);
+ DoFileNew(nID, nFiles);
}
/**
theApp.m_pOpenTemplate->m_hMenuShared = NewOpenViewMenu();
COpenDoc *pOpenDoc = static_cast<COpenDoc *>(theApp.m_pOpenTemplate->CreateNewDocument());
- PathContext paths;
CFrameWnd * pFrame = GetActiveFrame();
- FRAMETYPE frame = GetFrameType(pFrame);
+ FRAMETYPE frame = pFrame ? GetFrameType(pFrame) : FRAME_OTHER;
- if (frame == FRAME_FILE)
+ if (frame == FRAME_FILE || frame == FRAME_HEXFILE || frame == FRAME_IMGFILE)
{
- CMergeDoc * pMergeDoc = static_cast<CMergeDoc *>(pFrame->GetActiveDocument());
- pOpenDoc->m_files = pMergeDoc->m_filePaths;
- for (int pane = 0; pane < pOpenDoc->m_files.GetSize(); ++pane)
- pOpenDoc->m_dwFlags[pane] = FFILEOPEN_PROJECT | (pMergeDoc->m_ptBuf[pane]->GetReadOnly() ? FFILEOPEN_PROJECT : 0);
- pOpenDoc->m_bRecurse = GetOptionsMgr()->GetBool(OPT_CMP_INCLUDE_SUBDIRS);
- pOpenDoc->m_strExt = theApp.m_pGlobalFileFilter->GetFilterNameOrMask();
+ if (IMergeDoc* pMergeDoc = GetActiveIMergeDoc())
+ {
+ PathContext paths;
+ for (int pane = 0; pane < pMergeDoc->GetFileCount(); ++pane)
+ {
+ pOpenDoc->m_dwFlags[pane] = FFILEOPEN_PROJECT | (pMergeDoc->GetReadOnly(pane) ? FFILEOPEN_READONLY : 0);
+ paths.SetPath(pane, pMergeDoc->GetPath(pane));
+ }
+ pOpenDoc->m_files = paths;
+ pOpenDoc->m_bRecurse = GetOptionsMgr()->GetBool(OPT_CMP_INCLUDE_SUBDIRS);
+ pOpenDoc->m_strExt = theApp.m_pGlobalFileFilter->GetFilterNameOrMask();
+ pOpenDoc->m_strUnpackerPipeline = pMergeDoc->GetUnpacker()->GetPluginPipeline();
+ }
}
else if (frame == FRAME_FOLDER)
{
// Get paths currently in compare
- const CDirDoc * pDoc = static_cast<const CDirDoc*>(pFrame->GetActiveDocument());
- const CDiffContext& ctxt = pDoc->GetDiffContext();
-
- // Set-up the dialog
- for (int pane = 0; pane < ctxt.GetCompareDirs(); ++pane)
+ if (const CDirDoc* pDoc = static_cast<const CDirDoc*>(pFrame->GetActiveDocument()))
{
- pOpenDoc->m_dwFlags[pane] = FFILEOPEN_PROJECT | (pDoc->GetReadOnly(pane) ? FFILEOPEN_READONLY : 0);
- pOpenDoc->m_files.SetPath(pane, paths::AddTrailingSlash(ctxt.GetNormalizedPath(pane)));
+ const CDiffContext& ctxt = pDoc->GetDiffContext();
+
+ // Set-up the dialog
+ for (int pane = 0; pane < ctxt.GetCompareDirs(); ++pane)
+ {
+ pOpenDoc->m_dwFlags[pane] = FFILEOPEN_PROJECT | (pDoc->GetReadOnly(pane) ? FFILEOPEN_READONLY : 0);
+ pOpenDoc->m_files.SetPath(pane, paths::AddTrailingSlash(ctxt.GetNormalizedPath(pane)));
+ }
+ pOpenDoc->m_bRecurse = ctxt.m_bRecursive;
+ pOpenDoc->m_strExt = static_cast<FileFilterHelper*>(ctxt.m_piFilterGlobal)->GetFilterNameOrMask();
}
- pOpenDoc->m_bRecurse = ctxt.m_bRecursive;
- pOpenDoc->m_strExt = static_cast<FileFilterHelper *>(ctxt.m_piFilterGlobal)->GetFilterNameOrMask();
}
CFrameWnd *pOpenFrame = theApp.m_pOpenTemplate->CreateNewFrame(pOpenDoc, nullptr);
(strDesc && !strDesc[2].empty()) ? strDesc[2] : _("Mine File") };
DWORD dwFlags[2] = {FFILEOPEN_READONLY | FFILEOPEN_NOMRU, FFILEOPEN_NOMRU | FFILEOPEN_MODIFIED};
PathContext tmpPathContext(revFile, workFile);
- conflictCompared = DoFileOpen(&tmpPathContext, dwFlags, strDesc2);
+ conflictCompared = DoFileOrFolderOpen(&tmpPathContext, dwFlags, strDesc2);
}
else
{
(strDesc && !strDesc[2].empty()) ? strDesc[2] : _("Mine File") };
PathContext tmpPathContext(baseFile, revFile, workFile);
DWORD dwFlags[3] = {FFILEOPEN_READONLY | FFILEOPEN_NOMRU, FFILEOPEN_READONLY | FFILEOPEN_NOMRU, FFILEOPEN_NOMRU | FFILEOPEN_MODIFIED};
- conflictCompared = DoFileOpen(&tmpPathContext, dwFlags, strDesc3);
+ conflictCompared = DoFileOrFolderOpen(&tmpPathContext, dwFlags, strDesc3);
}
}
else
return conflictCompared;
}
-bool CMainFrame::DoSelfCompare(UINT nID, const String& file, const String strDesc[] /*= nullptr*/)
+bool CMainFrame::DoSelfCompare(UINT nID, const String& file, const String strDesc[] /*= nullptr*/,
+ const PackingInfo *infoUnpacker /*= nullptr*/, const PrediffingInfo *infoPrediffer /*= nullptr*/,
+ const OpenTextFileParams *pOpenParams /*= nullptr*/)
{
String ext = paths::FindExtension(file);
TempFilePtr wTemp(new TempFile());
(strDesc && !strDesc[1].empty()) ? strDesc[1] : _("") };
DWORD dwFlags[2] = {FFILEOPEN_READONLY | FFILEOPEN_NOMRU, FFILEOPEN_NOMRU};
PathContext tmpPathContext(copiedFile, file);
- return DoFileOpen(nID, &tmpPathContext, dwFlags, strDesc2);
+ return DoFileOpen(nID, &tmpPathContext, dwFlags, strDesc2, _T(""), infoUnpacker, infoPrediffer, pOpenParams);
}
/**
}
void CMainFrame::OnDiffWhitespace(UINT nID)
{
- GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_WHITESPACE, nID - IDC_DIFF_WHITESPACE_COMPARE);
+ GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_WHITESPACE, nID - ID_DIFF_OPTIONS_WHITESPACE_COMPARE);
ApplyDiffOptions();
}
void CMainFrame::OnUpdateDiffWhitespace(CCmdUI* pCmdUI)
{
- pCmdUI->SetRadio((pCmdUI->m_nID - IDC_DIFF_WHITESPACE_COMPARE) == static_cast<UINT>(GetOptionsMgr()->GetInt(OPT_CMP_IGNORE_WHITESPACE)));
+ pCmdUI->SetRadio((pCmdUI->m_nID - ID_DIFF_OPTIONS_WHITESPACE_COMPARE) == static_cast<UINT>(GetOptionsMgr()->GetInt(OPT_CMP_IGNORE_WHITESPACE)));
+ pCmdUI->Enable();
+}
+
+void CMainFrame::OnDiffIgnoreBlankLines()
+{
+ GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_BLANKLINES, !GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_BLANKLINES));
+ ApplyDiffOptions();
+}
+
+void CMainFrame::OnUpdateDiffIgnoreBlankLines(CCmdUI* pCmdUI)
+{
+ pCmdUI->SetCheck(GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_BLANKLINES));
pCmdUI->Enable();
}
pCmdUI->Enable();
}
+void CMainFrame::OnDiffIgnoreComments()
+{
+ GetOptionsMgr()->SaveOption(OPT_CMP_FILTER_COMMENTLINES, !GetOptionsMgr()->GetBool(OPT_CMP_FILTER_COMMENTLINES));
+ ApplyDiffOptions();
+}
+
+void CMainFrame::OnUpdateDiffIgnoreComments(CCmdUI* pCmdUI)
+{
+ pCmdUI->SetCheck(GetOptionsMgr()->GetBool(OPT_CMP_FILTER_COMMENTLINES));
+ pCmdUI->Enable();
+}
+
void CMainFrame::OnIncludeSubfolders()
{
GetOptionsMgr()->SaveOption(OPT_CMP_INCLUDE_SUBDIRS, !GetOptionsMgr()->GetBool(OPT_CMP_INCLUDE_SUBDIRS));
void CMainFrame::OnCompareMethod(UINT nID)
{
- GetOptionsMgr()->SaveOption(OPT_CMP_METHOD, nID - ID_COMPMETHOD_FULL_CONTENTS);
+ GetOptionsMgr()->SaveOption(OPT_CMP_METHOD, nID - ID_DIFF_OPTIONS_COMPMETHOD_FULL_CONTENTS);
}
void CMainFrame::OnUpdateCompareMethod(CCmdUI* pCmdUI)
{
- pCmdUI->SetRadio((pCmdUI->m_nID - ID_COMPMETHOD_FULL_CONTENTS) == static_cast<UINT>(GetOptionsMgr()->GetInt(OPT_CMP_METHOD)));
+ pCmdUI->SetRadio((pCmdUI->m_nID - ID_DIFF_OPTIONS_COMPMETHOD_FULL_CONTENTS) == static_cast<UINT>(GetOptionsMgr()->GetInt(OPT_CMP_METHOD)));
pCmdUI->Enable();
}
*/
void CMainFrame::OnUpdatePluginName(CCmdUI* pCmdUI)
{
- pCmdUI->SetText(_T(""));
+ if (auto pMergeDoc = GetActiveIMergeDoc())
+ {
+ String pluginNames;
+ const PackingInfo* infoUnpacker = pMergeDoc->GetUnpacker();
+ if (infoUnpacker && !infoUnpacker->GetPluginPipeline().empty())
+ pluginNames += infoUnpacker->GetPluginPipeline() + _T("&");
+ const PrediffingInfo* infoPrediffer = pMergeDoc->GetPrediffer();
+ if (infoPrediffer && !infoPrediffer->GetPluginPipeline().empty())
+ pluginNames += infoPrediffer->GetPluginPipeline() + _T("&");
+ pCmdUI->SetText(pluginNames.substr(0, pluginNames.length() - 1).c_str());
+ }
+ else
+ pCmdUI->SetText(_T(""));
}
/**
}
}
+void CMainFrame::AppendPluginMenus(CMenu *pMenu, const String& filteredFilenames,
+ const std::vector<std::wstring>& events, bool addAllMenu, unsigned baseId)
+{
+ if (!GetOptionsMgr()->GetBool(OPT_PLUGINS_ENABLED))
+ return;
+
+ auto [suggestedPlugins, allPlugins] = FileTransform::CreatePluginMenuInfos(filteredFilenames, events, baseId);
+
+ if (!addAllMenu)
+ {
+ pMenu->AppendMenu(MF_STRING, ID_SUGGESTED_PLUGINS, _("Suggested plugins").c_str());
+ }
+
+ for (const auto& [caption, name, id, plugin] : suggestedPlugins)
+ pMenu->AppendMenu(MF_STRING, id, caption.c_str());
+
+ CMenu* pMenu2 = pMenu;
+ CMenu popupAll;
+ if (addAllMenu)
+ {
+ popupAll.CreatePopupMenu();
+ pMenu->AppendMenu(MF_POPUP, reinterpret_cast<UINT_PTR>(popupAll.m_hMenu), _("Al&l").c_str());
+ pMenu2 = &popupAll;
+ }
+ else
+ {
+ pMenu->AppendMenu(MF_SEPARATOR, 0);
+ pMenu->AppendMenu(MF_STRING, ID_NOT_SUGGESTED_PLUGINS, _("Other plugins").c_str());
+ }
+
+ std::vector<String> processTypes;
+ for (const auto& [processType, pluginList] : allPlugins)
+ processTypes.push_back(processType);
+ auto it = std::find(processTypes.begin(), processTypes.end(), _("&Others"));
+ if (it != processTypes.end())
+ {
+ processTypes.erase(it);
+ processTypes.push_back(_("&Others"));
+ }
+
+ for (const auto& processType: processTypes)
+ {
+ CMenu popup;
+ popup.CreatePopupMenu();
+ if (processType.empty())
+ {
+ for (const auto& [caption, name, id, plugin] : allPlugins[processType])
+ pMenu2->AppendMenu(MF_STRING, id, caption.c_str());
+ }
+ else
+ {
+ for (const auto& [caption, name, id, plugin] : allPlugins[processType])
+ popup.AppendMenu(MF_STRING, id, caption.c_str());
+ pMenu2->AppendMenu(MF_POPUP, reinterpret_cast<UINT_PTR>(popup.m_hMenu), processType.c_str());
+ }
+ popup.Detach();
+ }
+
+ if (addAllMenu)
+ {
+ if (baseId == ID_UNPACKERS_FIRST)
+ pMenu2->AppendMenu(MF_STRING, ID_OPEN_WITH_UNPACKER, _("&Select...").c_str());
+ else if (baseId == ID_PREDIFFERS_FIRST)
+ pMenu2->AppendMenu(MF_STRING, ID_APPLY_PREDIFFER, _("&Select...").c_str());
+ }
+ popupAll.Detach();
+}
+
+String CMainFrame::GetPluginPipelineByMenuId(unsigned idSearch, const std::vector<std::wstring>& events, unsigned baseId)
+{
+ PluginInfo* pluginFound = nullptr;
+ String pluginName;
+ auto [suggestedPlugins, allPlugins] = FileTransform::CreatePluginMenuInfos(_T(""), events, baseId);
+ for (const auto& [processType, pluginList] : allPlugins)
+ {
+ for (const auto& [caption, name, id, plugin] : pluginList)
+ {
+ if (id == idSearch)
+ {
+ pluginName = name;
+ pluginFound = plugin;
+ break;
+ }
+ }
+ }
+ if (pluginFound)
+ {
+ if (!pluginFound->GetExtendedPropertyValue(_T("ArgumentsRequired")).has_value() &&
+ !pluginFound->GetExtendedPropertyValue(pluginName + _T(".ArgumentsRequired")).has_value())
+ return pluginName;
+ CSelectPluginDlg dlg(pluginName, _T(""),
+ (baseId == ID_UNPACKERS_FIRST) ? CSelectPluginDlg::PluginType::Unpacker : (
+ (baseId == ID_PREDIFFERS_FIRST) ? CSelectPluginDlg::PluginType::Prediffer :
+ CSelectPluginDlg::PluginType::EditorScript), true);
+ if (dlg.DoModal() != IDOK)
+ return {};
+ return dlg.GetPluginPipeline();
+ }
+ return {};
+}
+
IMergeDoc* CMainFrame::GetActiveIMergeDoc()
{
CFrameWnd* pFrame = GetActiveFrame();