OSDN Git Service

Add /t command line option to specify the type of window to display files in
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sat, 17 Jul 2021 05:02:57 +0000 (14:02 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sat, 17 Jul 2021 05:02:57 +0000 (14:02 +0900)
Docs/Manual/EN/Command_line.xml
Docs/Manual/JP/Command_line.xml
Src/MainFrm.cpp
Src/MainFrm.h
Src/Merge.cpp
Src/MergeCmdLineInfo.cpp
Src/MergeCmdLineInfo.h

index ddaaf1c..a77d2fd 100644 (file)
@@ -34,6 +34,9 @@
       <arg choice="opt" rep="norepeat"><option>/m</option>
       <replaceable>compare-method</replaceable></arg>
 
+      <arg choice="opt" rep="norepeat"><option>/t</option>
+      <replaceable>window-type</replaceable></arg>
+
       <arg><option>/x</option></arg>
 
       <arg><option>/xq</option></arg>
         <secondary>applying in command line</secondary>
       </indexterm>
 
-      <term><option>/m</option></term>
+      <term><option>/m <replaceable>compare-method</replaceable></option></term>
       <listitem>
         <para>Sets the compare method to use for the comparison.
         This can be one of the keywords <userinput>Full</userinput>,
         <userinput>Quick</userinput>, <userinput>Binary</userinput>,
-        <userinput>Date</userinput>, <userinput>SizeDate</userinput>, 
+        <userinput>Date</userinput>, <userinput>SizeDate</userinput> or 
         <userinput>Size</userinput>.</para>
       </listitem>
     </varlistentry>
 
     <varlistentry>
+      <indexterm>
+        <primary>window type</primary>
+        <secondary>applying in command line</secondary>
+      </indexterm>
+
+      <term><option>/t <replaceable>window-type</replaceable></option></term>
+      <listitem>
+        <para>Specifies the type of window in which to display files.
+        This can be one of the keywords <userinput>Text</userinput>,
+        <userinput>Table</userinput>, <userinput>Binary</userinput> or
+        <userinput>Image</userinput>.</para>
+      </listitem>
+    </varlistentry>
+
+    <varlistentry>
       <term><option>/x</option></term>
       <listitem>
         <para>Closes WinMerge (after displaying an information
index 1747b43..2d88f25 100644 (file)
@@ -34,6 +34,9 @@
       <arg choice="opt" rep="norepeat"><option>/m</option>
       <replaceable>compare-method</replaceable></arg>
 
+      <arg choice="opt" rep="norepeat"><option>/t</option>
+      <replaceable>window-type</replaceable></arg>
+
       <arg><option>/x</option></arg>
 
       <arg><option>/xq</option></arg>
         <secondary>applying in command line</secondary>
       </indexterm>
 
-      <term><option>/m</option></term>
+      <term><option>/m <replaceable>compare-method</replaceable></option></term>
       <listitem>
         <para>フォルダ比較方法を指定します。
         次のキーワードが指定できます。<userinput>Full</userinput>,
         <userinput>Quick</userinput>, <userinput>Binary</userinput>,
-        <userinput>Date</userinput>, <userinput>SizeDate</userinput>, 
-        <userinput>Size</userinput>.</para>
+        <userinput>Date</userinput>, <userinput>SizeDate</userinput> 
+        <userinput>Size</userinput></para>
+      </listitem>
+    </varlistentry>
+
+    <varlistentry>
+      <indexterm>
+        <primary>window type</primary>
+        <secondary>applying in command line</secondary>
+      </indexterm>
+
+      <term><option>/t <replaceable>window-type</replaceable></option></term>
+      <listitem>
+        <para>ファイルを表示するウインドウの種類を指定します。
+        次のキーワードが指定できます。 <userinput>Text</userinput>,
+        <userinput>Table</userinput>, <userinput>Binary</userinput>,
+        <userinput>Image</userinput></para>
       </listitem>
     </varlistentry>
 
index 2a949b3..246258d 100644 (file)
@@ -737,19 +737,19 @@ bool CMainFrame::ShowMergeDoc(UINT nID, CDirDoc* pDirDoc,
        switch (nID)
        {
        case ID_MERGE_COMPARE_TEXT:
-               return GetMainFrame()->ShowTextMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags,
+               return ShowTextMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags,
                        strDesc, sReportFile, infoUnpacker, line);
        case ID_MERGE_COMPARE_TABLE:
-               return GetMainFrame()->ShowTableMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags,
+               return ShowTableMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags,
                        strDesc, sReportFile, infoUnpacker, line);
        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,
+               return ShowAutoMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags,
                        strDesc, sReportFile, infoUnpacker, line);
        }
 }
@@ -1064,8 +1064,10 @@ static bool AddToRecentDocs(const PathContext& paths, const unsigned flags[], bo
  * @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*/,
-       const PackingInfo *infoUnpacker /*= nullptr*/, const PrediffingInfo *infoPrediffer /*= nullptr*/, int line /*= -1*/)
+       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*/, int line /*= -1*/)
 {
        if (pDirDoc != nullptr && !pDirDoc->CloseMergeDocs())
                return false;
@@ -1133,7 +1135,7 @@ bool CMainFrame::DoFileOpen(const PathContext * pFiles /*= nullptr*/,
        }
 
        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)
@@ -1148,7 +1150,7 @@ bool CMainFrame::DoFileOpen(const PathContext * pFiles /*= nullptr*/,
        // 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)
@@ -1162,7 +1164,7 @@ bool CMainFrame::DoFileOpen(const PathContext * pFiles /*= nullptr*/,
        }
 
        // open the diff
-       if (pathsType == paths::IS_EXISTING_DIR)
+       if (nID == 0 && pathsType == paths::IS_EXISTING_DIR)
        {
                if (pDirDoc != nullptr)
                {
@@ -1192,7 +1194,7 @@ bool CMainFrame::DoFileOpen(const PathContext * pFiles /*= nullptr*/,
                        pDirDoc->GetPluginManager().SetPrediffer(strBothFilenames, infoPrediffer->GetPluginPipeline());
                }
 
-               ShowAutoMergeDoc(pDirDoc, tFiles.GetSize(), fileloc, dwFlags, strDesc, sReportFile,
+               ShowMergeDoc(nID, pDirDoc, tFiles.GetSize(), fileloc, dwFlags, strDesc, sReportFile,
                                infoUnpacker, line);
        }
 
index 1527760..6d4cf00 100644 (file)
@@ -93,7 +93,7 @@ public:
        bool DoFileOpen(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, int line = -1);
+               const PackingInfo * infoUnpacker = nullptr, const PrediffingInfo * infoPrediffer = nullptr, UINT nID = 0, int line = -1);
        bool DoFileOpen(UINT nID, const PathContext* pFiles = nullptr,
                const DWORD dwFlags[] = nullptr, const String strDesc[] = nullptr,
                const String& sReportFile = _T(""), const PackingInfo* infoUnpacker = nullptr, int line = -1);
index 3cf32ca..743abab 100644 (file)
@@ -659,6 +659,8 @@ bool CMergeApp::ParseArgsAndDoOpen(MergeCmdLineInfo& cmdInfo, CMainFrame* pMainF
        String strDesc[3];
        std::unique_ptr<PackingInfo> infoUnpacker;
        std::unique_ptr<PrediffingInfo> infoPrediffer;
+       unsigned nID = cmdInfo.m_nWindowType == MergeCmdLineInfo::AUTOMATIC ?
+               0 : static_cast<unsigned>(cmdInfo.m_nWindowType) + ID_MERGE_COMPARE_TEXT - 1;
 
        m_bNonInteractive = cmdInfo.m_bNonInteractive;
 
@@ -718,14 +720,14 @@ bool CMergeApp::ParseArgsAndDoOpen(MergeCmdLineInfo& cmdInfo, CMainFrame* pMainF
                        DWORD dwFlags[3] = {cmdInfo.m_dwLeftFlags, cmdInfo.m_dwMiddleFlags, cmdInfo.m_dwRightFlags};
                        bCompared = pMainFrame->DoFileOpen(&cmdInfo.m_Files,
                                dwFlags, strDesc, cmdInfo.m_sReportFile, cmdInfo.m_bRecurse, nullptr,
-                               infoUnpacker.get(), infoPrediffer.get(), cmdInfo.m_nLineIndex);
+                               infoUnpacker.get(), infoPrediffer.get(), nID, cmdInfo.m_nLineIndex);
                }
                else if (cmdInfo.m_Files.GetSize() > 1)
                {
                        DWORD dwFlags[3] = {cmdInfo.m_dwLeftFlags, cmdInfo.m_dwRightFlags, FFILEOPEN_NONE};
                        bCompared = pMainFrame->DoFileOpen(&cmdInfo.m_Files,
                                dwFlags, strDesc, cmdInfo.m_sReportFile, cmdInfo.m_bRecurse, nullptr,
-                               infoUnpacker.get(), infoPrediffer.get(), cmdInfo.m_nLineIndex);
+                               infoUnpacker.get(), infoPrediffer.get(), nID, cmdInfo.m_nLineIndex);
                }
                else if (cmdInfo.m_Files.GetSize() == 1)
                {
@@ -734,7 +736,7 @@ bool CMergeApp::ParseArgsAndDoOpen(MergeCmdLineInfo& cmdInfo, CMainFrame* pMainF
                        {
                                strDesc[0] = cmdInfo.m_sLeftDesc;
                                strDesc[1] = cmdInfo.m_sRightDesc;
-                               bCompared = pMainFrame->DoSelfCompare(IDOK, sFilepath, strDesc, nullptr, cmdInfo.m_nLineIndex);
+                               bCompared = pMainFrame->DoSelfCompare(nID, sFilepath, strDesc, nullptr, cmdInfo.m_nLineIndex);
                        }
                        else if (IsProjectFile(sFilepath))
                        {
@@ -753,7 +755,7 @@ bool CMergeApp::ParseArgsAndDoOpen(MergeCmdLineInfo& cmdInfo, CMainFrame* pMainF
                                DWORD dwFlags[3] = {cmdInfo.m_dwLeftFlags, cmdInfo.m_dwRightFlags, FFILEOPEN_NONE};
                                bCompared = pMainFrame->DoFileOpen(&cmdInfo.m_Files,
                                        dwFlags, strDesc, cmdInfo.m_sReportFile, cmdInfo.m_bRecurse, nullptr,
-                                       infoUnpacker.get(), infoPrediffer.get(), cmdInfo.m_nLineIndex);
+                                       infoUnpacker.get(), infoPrediffer.get(), nID, cmdInfo.m_nLineIndex);
                        }
                }
                else if (cmdInfo.m_Files.GetSize() == 0) // if there are no input args, we can check the display file dialog flag
index d3fd89f..7f6ac01 100644 (file)
@@ -115,6 +115,7 @@ const TCHAR *MergeCmdLineInfo::SetConfig(const TCHAR *q)
  */
 MergeCmdLineInfo::MergeCmdLineInfo(const TCHAR *q):
        m_nCmdShow(SHOWNORMAL),
+       m_nWindowType(AUTOMATIC),
        m_bEscShutdown(false),
        m_bExitIfNoDiff(Disabled),
        m_bRecurse(false),
@@ -227,6 +228,24 @@ void MergeCmdLineInfo::ParseWinMergeCmdLine(const TCHAR *q)
                        // -f "mask" - file filter mask ("*.h *.cpp")
                        q = EatParam(q, m_sFileFilter);
                }
+               else if (param == _T("t"))
+               {
+                       // -t "type" - window type
+                       q = EatParam(q, param);
+                       param = strutils::makelower(param);
+                       if (param == _T("automatic"))
+                               m_nWindowType = WindowType::AUTOMATIC;
+                       else if (param == _T("text"))
+                               m_nWindowType = WindowType::TEXT;
+                       else if (param == _T("table"))
+                               m_nWindowType = WindowType::TABLE;
+                       else if (param == _T("binary"))
+                               m_nWindowType = WindowType::BINARY;
+                       else if (param == _T("image"))
+                               m_nWindowType = WindowType::IMAGE;
+                       else
+                               m_sErrorMessages.push_back(_T("Unknown window type '") + param + _T("' specified"));
+               }
                else if (param == _T("m"))
                {
                        // -m "method" - compare method
index 25ff4f6..836a9e7 100644 (file)
@@ -52,7 +52,17 @@ public:
                SIZE,
        };
 
+       enum WindowType
+       {
+               AUTOMATIC,
+               TEXT,
+               TABLE,
+               BINARY,
+               IMAGE,
+       };
+
        ShowWindowType m_nCmdShow; /**< Initial state of the application's window. */
+       WindowType m_nWindowType; /**< The type of window that displays the files to compare. */
 
        bool m_bEscShutdown; /**< Pressing ESC will close the application */
        ExitNoDiff m_bExitIfNoDiff; /**< Exit if files are identical. */