OSDN Git Service

PATCH: [ 1265295 ] Swap file compare panes (use pointers for buffers)
authorKimmo Varis <kimmov@gmail.com>
Mon, 28 Nov 2005 18:12:54 +0000 (18:12 +0000)
committerKimmo Varis <kimmov@gmail.com>
Mon, 28 Nov 2005 18:12:54 +0000 (18:12 +0000)
 - submitted by Takashi Sawanaka

42 files changed:
Src/Changes.txt
Src/ChildFrm.cpp
Src/DiffList.cpp
Src/DiffList.h
Src/DirDoc.cpp
Src/EditorFilepathBar.cpp
Src/EditorFilepathBar.h
Src/Languages/Brazilian/MergeBrazilian.rc
Src/Languages/Bulgarian/MergeBulgarian.rc
Src/Languages/Catalan/MergeCatalan.rc
Src/Languages/ChineseSimplified/MergeChineseSimplified.rc
Src/Languages/ChineseTraditional/MergeChineseTraditional.rc
Src/Languages/Czech/MergeCzech.rc
Src/Languages/Danish/MergeDanish.rc
Src/Languages/Dutch/MergeDutch.rc
Src/Languages/French/MergeFrench.rc
Src/Languages/German/MergeGerman.rc
Src/Languages/Hungarian/MergeHungarian.rc
Src/Languages/Italian/MergeItalian.rc
Src/Languages/Japanese/MergeJapanese.rc
Src/Languages/Korean/MergeKorean.rc
Src/Languages/Norwegian/MergeNorwegian.rc
Src/Languages/Polish/MergePolish.rc
Src/Languages/Russian/MergeRussian.rc
Src/Languages/Slovak/MergeSlovak.rc
Src/Languages/Spanish/MergeSpanish.rc
Src/Languages/Swedish/MergeSwedish.rc
Src/Languages/Turkish/MergeTurkish.rc
Src/LocationView.cpp
Src/LocationView.h
Src/MainFrm.cpp
Src/Merge.rc
Src/MergeDiffDetailView.cpp
Src/MergeDiffDetailView.h
Src/MergeDoc.cpp
Src/MergeDoc.h
Src/MergeDocLineDiffs.cpp
Src/MergeEditView.cpp
Src/MergeEditView.h
Src/PathContext.cpp
Src/PathContext.h
Src/resource.h

index 96d0ba2..6399987 100644 (file)
@@ -1,4 +1,14 @@
-2005-12-28 Perry
+2005-11-28 Kimmo
+ PATCH: [ 1265295 ] Swap file compare panes (use pointers for buffers)
+  Submitted by Takashi Sawanaka
+  Src: ChildFrm.cpp DiffList.cpp DiffList.h DirDoc.cpp EditorFilepathBar.cpp
+   EditorFilepathBar.h LocationView.cpp LocationView.h MainFrm.cpp Merge.rc
+   MergeDiffDetailView.cpp MergeDiffDetailView.h MergeDoc.cpp MergeDoc.h
+   MergeDocLineDiffs.cpp MergeEditView.cpp MergeEditView.h PathContext.cpp
+   PathContext.h resource.h
+  Src/Languages: *.rc resource.h
+
+2005-11-28 Perry
  PATCH: [ 1336598 ] Add extensions DisplayXMLFiles plugin
  Add several new extensions, bump version (1.0.2.0 -> 1.0.3.0)
   Plugins\src_VCPP\DisplayXMLFiles:
index 0aea5db..495b7f2 100644 (file)
@@ -200,16 +200,16 @@ BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
        // tell merge doc about these views
        CMergeDoc * pDoc = dynamic_cast<CMergeDoc *>(pContext->m_pCurrentDoc);
        pDoc->SetMergeViews(pLeft, pRight);
-       pLeft->m_bIsLeft = TRUE;
-       pRight->m_bIsLeft = FALSE;
+       pLeft->m_nThisPane = 0;
+       pRight->m_nThisPane = 1;
 
        // stash left & right detail pointers into the mergedoc
        CMergeDiffDetailView * pLeftDetail = (CMergeDiffDetailView *)m_wndDetailSplitter.GetPane(0,0);
        CMergeDiffDetailView * pRightDetail = (CMergeDiffDetailView *)m_wndDetailSplitter.GetPane(1,0);
        // tell merge doc about these views
        pDoc->SetMergeDetailViews(pLeftDetail, pRightDetail);
-       pLeftDetail->m_bIsLeft = TRUE;
-       pRightDetail->m_bIsLeft = FALSE;
+       pLeftDetail->m_nThisPane = 0;
+       pRightDetail->m_nThisPane = 1;
        
        return TRUE;
 }
index b155daf..7b6e3b5 100644 (file)
@@ -25,6 +25,7 @@
 #include "stdafx.h"
 #include "DiffList.h"
 #include "DiffWrapper.h"
+#include "coretools.h"
 
 /**
  * @brief Default constructor, initialises difflist to 64 items.
@@ -431,3 +432,18 @@ const DIFFRANGE * DiffList::LastSignificantDiffRange() const
        if (m_lastSignificant == -1) return NULL;
        return DiffRangeAt(m_lastSignificant);
 }
+
+/**
+ * @brief Swap members of diffrange
+ */
+void DiffList::Swap()
+{
+       for (int i = 0; i < m_diffs.GetSize(); ++i)
+       {
+               swap<UINT>(&m_diffs[i].diffrange.begin0, &m_diffs[i].diffrange.begin1);
+               swap<UINT>(&m_diffs[i].diffrange.end0, &m_diffs[i].diffrange.end1);
+               swap<UINT>(&m_diffs[i].diffrange.dbegin0, &m_diffs[i].diffrange.dbegin1);
+               swap<UINT>(&m_diffs[i].diffrange.dend0, &m_diffs[i].diffrange.dend1);
+               swap<int>(&m_diffs[i].diffrange.blank0, &m_diffs[i].diffrange.blank1);
+       }
+}
\ No newline at end of file
index 6250d31..424ff70 100644 (file)
@@ -121,6 +121,7 @@ public:
        const DIFFRANGE * DiffRangeAt(int nDiff) const;
 
        void ConstructSignificantChain(); // must be called after diff list is entirely populated
+       void Swap();
 
 private:
        CArray<DiffRangeInfo,DiffRangeInfo> m_diffs; /**< Difference list */
index 1752fcd..5c17747 100644 (file)
@@ -306,8 +306,8 @@ void CDirDoc::Rescan()
        if (m_bMarkedRescan)
                m_pCompareStats->IncreaseTotalItems(m_pDirView->GetSelectedCount());
 
-       UpdateHeaderPath(TRUE);
-       UpdateHeaderPath(FALSE);
+       UpdateHeaderPath(0);
+       UpdateHeaderPath(1);
        // draw the headers as active ones
        pf->GetHeaderInterface()->SetActive(0, TRUE);
        pf->GetHeaderInterface()->SetActive(1, TRUE);
@@ -626,6 +626,10 @@ void CDirDoc::UpdateChangedItem(PathContext &paths,
        UINT nDiffs, UINT nTrivialDiffs, BOOL bIdentical)
 {
        POSITION pos = FindItemFromPaths(paths.GetLeft(), paths.GetRight());
+       // TODO: when this happens?
+       if (!pos)
+               // Two files were swapped.
+               pos = FindItemFromPaths(paths.GetRight(), paths.GetLeft());
        ASSERT(pos);
        int ind = m_pDirView->GetItemIndex((DWORD)pos);
 
index 4497f0d..6fd1942 100644 (file)
@@ -54,8 +54,8 @@ BOOL CEditorFilePathBar::Create(CWnd* pParentWnd)
                return FALSE;
 
        // subclass the two custom edit boxes
-       m_EditLeft.SubClassEdit(IDC_STATIC_TITLE_LEFT, this);
-       m_EditRight.SubClassEdit(IDC_STATIC_TITLE_RIGHT, this);
+       m_Edit[0].SubClassEdit(IDC_STATIC_TITLE_LEFT, this);
+       m_Edit[1].SubClassEdit(IDC_STATIC_TITLE_RIGHT, this);
 
        return TRUE;
 };
@@ -88,8 +88,8 @@ BOOL CEditorFilePathBar::LookLikeThisWnd(const CWnd * pWnd)
                        if (pFont->GetLogFont(&lfFont))
                        {
                                m_pFont->CreateFontIndirect(&lfFont);
-                               m_EditLeft.SetFont(m_pFont);
-                               m_EditRight.SetFont(m_pFont);
+                               m_Edit[0].SetFont(m_pFont);
+                               m_Edit[1].SetFont(m_pFont);
                        }
                }
        }
@@ -120,19 +120,19 @@ void CEditorFilePathBar::Resize()
        GetWindowPlacement(&infoBar);
 
        WINDOWPLACEMENT info1;
-       m_EditLeft.GetWindowPlacement(&info1);
+       m_Edit[0].GetWindowPlacement(&info1);
        info1.rcNormalPosition.right = infoBar.rcNormalPosition.right /
                PaneCount - 2;
-       m_EditLeft.SetWindowPlacement(&info1);
-       m_EditLeft.RefreshDisplayText();
+       m_Edit[0].SetWindowPlacement(&info1);
+       m_Edit[0].RefreshDisplayText();
 
        WINDOWPLACEMENT info2;
-       m_EditRight.GetWindowPlacement(&info2);
+       m_Edit[1].GetWindowPlacement(&info2);
        info2.rcNormalPosition.left = infoBar.rcNormalPosition.right /
                PaneCount + 2;
        info2.rcNormalPosition.right = infoBar.rcNormalPosition.right;
-       m_EditRight.SetWindowPlacement(&info2);
-       m_EditRight.RefreshDisplayText();
+       m_Edit[1].SetWindowPlacement(&info2);
+       m_Edit[1].RefreshDisplayText();
 }
 /** 
  * @brief resize both controls to given sizes (the ones of the splitter views)
@@ -145,16 +145,16 @@ void CEditorFilePathBar::Resize(int leftWidth, int rightWidth)
        WINDOWPLACEMENT info1;
 
        // resize left filename
-       m_EditLeft.GetWindowPlacement(&info1);
+       m_Edit[0].GetWindowPlacement(&info1);
        info1.rcNormalPosition.right = info1.rcNormalPosition.left + leftWidth + 4;
-       m_EditLeft.SetWindowPlacement(&info1);
-       m_EditLeft.RefreshDisplayText();
+       m_Edit[0].SetWindowPlacement(&info1);
+       m_Edit[0].RefreshDisplayText();
 
        // resize right filename
        info1.rcNormalPosition.left = info1.rcNormalPosition.right + 3;
        info1.rcNormalPosition.right = info1.rcNormalPosition.left + rightWidth + 4;
-       m_EditRight.SetWindowPlacement(&info1);
-       m_EditRight.RefreshDisplayText();
+       m_Edit[1].SetWindowPlacement(&info1);
+       m_Edit[1].RefreshDisplayText();
 }
 
 /////////////////////////////////////////////////////////////////////////////
@@ -226,10 +226,7 @@ void CEditorFilePathBar::SetText(int pane, LPCTSTR lpszString)
        if (m_hWnd == NULL)
                return;
 
-       if (pane == PANE_LEFT)
-               m_EditLeft.SetWholeText(lpszString);
-       else
-               m_EditRight.SetWholeText(lpszString);
+       m_Edit[pane].SetWholeText(lpszString);
 }
 
 /** 
@@ -246,8 +243,5 @@ void CEditorFilePathBar::SetActive(int pane, BOOL bActive)
        if (m_hWnd == NULL)
                return;
 
-       if (pane == PANE_LEFT)
-               m_EditLeft.SetActive(bActive);
-       else
-               m_EditRight.SetActive(bActive);
+       m_Edit[pane].SetActive(bActive);
 }
index 833c4eb..52a085c 100644 (file)
@@ -78,7 +78,7 @@ protected:
 
 private:
        // this dialog uses custom edit boxes
-       CFilepathEdit m_EditLeft, m_EditRight;
+       CFilepathEdit m_Edit[2];
        CFont * m_pFont; /**< Font for editcontrols */
 };
 
index 78f7f7d..3fedc0c 100644 (file)
@@ -342,6 +342,8 @@ BEGIN
         MENUITEM "E&xibir Espaços",             ID_VIEW_WHITESPACE
         MENUITEM "Vie&w Line Differences",      ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "Barra de &Ferramentas",       ID_VIEW_TOOLBAR
         MENUITEM "Barra de &Status",            ID_VIEW_STATUS_BAR
         MENUITEM "Diff &Pane",                  ID_VIEW_DETAIL_BAR
@@ -2632,6 +2634,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Seleciona o Idioma usado na interface\nLíngua"
     ID_VIEW_LINEDIFFS       "Shows differences inside lines with different color\nShow Line Diff"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index 730adfb..c954bf3 100644 (file)
@@ -342,6 +342,8 @@ BEGIN
         MENUITEM "&Âèæäàé ïðàçíèòå ìåñòà",            ID_VIEW_WHITESPACE
         MENUITEM "Vie&w Line Differences",      ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "&Èíñòðóìåíòè",                    ID_VIEW_TOOLBAR
         MENUITEM "&Status Bar",                 ID_VIEW_STATUS_BAR
         MENUITEM "Ëèñò ñ &ðàçëè÷èÿòà",                  ID_VIEW_DETAIL_BAR
@@ -2532,6 +2534,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Èçáåðåòå åçèêà íà êîèòî äà å ïðîãðàìàòà\nÅçèê"
     ID_VIEW_LINEDIFFS       "Shows differences inside lines with different color\nShow Line Diff"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index 5175a6d..93d7bc7 100644 (file)
@@ -342,6 +342,8 @@ BEGIN
         MENUITEM "Mostra els es&pais",          ID_VIEW_WHITESPACE
         MENUITEM "&Veure les diferències de la línia", ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "Barra d'ei&nes",              ID_VIEW_TOOLBAR
         MENUITEM "Barra d'est&at",              ID_VIEW_STATUS_BAR
         MENUITEM "Subfinest&ra de diferències", ID_VIEW_DETAIL_BAR
@@ -2531,6 +2533,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Selecciona l'idioma de la interfície d'usuari\nIdioma"
     ID_VIEW_LINEDIFFS       "Mostra les diferències dins les línies en un color diferent\nMostra les diferències de línia"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index 1c2ed96..f5f4945 100644 (file)
@@ -342,6 +342,8 @@ BEGIN
         MENUITEM "ÏÔʾ¿Õ°×ºÍÖƱí·û(&V)",        ID_VIEW_WHITESPACE
         MENUITEM "ÏÔʾÐÐÖв»Í¬(&W)",            ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "¹¤¾ßÀ¸(&T)",                  ID_VIEW_TOOLBAR
         MENUITEM "״̬À¸(&S)",                  ID_VIEW_STATUS_BAR
         MENUITEM "¶Ô±È´°¸ñ(&P)",                ID_VIEW_DETAIL_BAR
@@ -2498,6 +2500,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Ñ¡Ôñµ±Ç°Óû§½Ó¿ÚÓïÑÔ\nÓïÑÔ"
     ID_VIEW_LINEDIFFS       "ÒÔ²»Í¬µÄÑÕÉ«ÏÔʾÐÐÖеIJ»Í¬\nÏÔʾÐÐÖв»Í¬"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index c2961a1..cb74875 100644 (file)
@@ -341,6 +341,8 @@ BEGIN
         MENUITEM "À˵øªÅ¥Õ©M¸õ®æ(&V)",          ID_VIEW_WHITESPACE
         MENUITEM "À˵ø¦C¤£¦P(&W)",              ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "¤u¨ã¦C(&T)",                  ID_VIEW_TOOLBAR
         MENUITEM "ª¬ºA¦C(&S)",                  ID_VIEW_STATUS_BAR
         MENUITEM "¤£¦Pµ¡®Ø(&P)",                ID_VIEW_DETAIL_BAR
@@ -2610,6 +2612,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "¿ï¨ú¥Ø«e¥Î¤á¤¶­±»y¨¥\n»y¨¥"
     ID_VIEW_LINEDIFFS       "¥H¤£¦P¦â±mÅã¥Ü¦C¤ºªº¤£¦P\nÅã¥Ü¦C¤£¦P"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index 861c426..a7c16bd 100644 (file)
@@ -342,6 +342,8 @@ BEGIN
         MENUITEM "&View Whitespace",            ID_VIEW_WHITESPACE
         MENUITEM "Vie&w Line Differences",      ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "&Panel nástroju",             ID_VIEW_TOOLBAR
         MENUITEM "&Stavový rádek",              ID_VIEW_STATUS_BAR
         MENUITEM "Diff &Pane",                  ID_VIEW_DETAIL_BAR
@@ -2630,6 +2632,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Zvolit jazyk pro u\9eivatelské rozhraní\nLanguage"
     ID_VIEW_LINEDIFFS       "Shows differences inside lines with different color\nShow Line Diff"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index 8c84e24..c05ac46 100644 (file)
@@ -342,6 +342,8 @@ BEGIN
         MENUITEM "Vis &mellemrum",              ID_VIEW_WHITESPACE
         MENUITEM "Vie&w Line Differences",      ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "V&ærktøjslinje",              ID_VIEW_TOOLBAR
         MENUITEM "S&tatuslinje",                ID_VIEW_STATUS_BAR
         MENUITEM "H&orisontalt panel",                  ID_VIEW_DETAIL_BAR
@@ -2513,6 +2515,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Vælg sprog til brugerfladen\nSprog"
     ID_VIEW_LINEDIFFS       "Shows differences inside lines with different color\nShow Line Diff"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index 7607c3e..677ee21 100644 (file)
@@ -343,6 +343,8 @@ BEGIN
         MENUITEM "Wit&ruimte tonen",            ID_VIEW_WHITESPACE
         MENUITEM "Vie&w Line Differences",      ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "&Werkbalk",                   ID_VIEW_TOOLBAR
         MENUITEM "&Statusbalk",                 ID_VIEW_STATUS_BAR
         MENUITEM "Diff &Pane",                  ID_VIEW_DETAIL_BAR
@@ -2632,6 +2634,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "De gewenste taal selecteren.\nTaal"
     ID_VIEW_LINEDIFFS       "Shows differences inside lines with different color\nShow Line Diff"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index 90e9012..2aa1af4 100644 (file)
@@ -342,6 +342,8 @@ BEGIN
         MENUITEM "&Afficher les espaces",             ID_VIEW_WHITESPACE
         MENUITEM "Afficher la granularité des lignes", ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "Barre d'&outils",                   ID_VIEW_TOOLBAR
         MENUITEM "Barre d'&état",                     ID_VIEW_STATUS_BAR
         MENUITEM "Dé&tail des différences",           ID_VIEW_DETAIL_BAR
@@ -2515,6 +2517,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Sélectionner le langage de l'interface\nLangage"
     ID_VIEW_LINEDIFFS       "Afficher les différences des lignes avec différentes couleurs\nAfficher différences des lignes"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index 460d85c..530d9b0 100644 (file)
@@ -346,6 +346,8 @@ BEGIN
         MENUITEM "Leer&zeichen anzeigen",       ID_VIEW_WHITESPACE
         MENUITEM "Zeilenuntersc&hied anzeigen", ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "&Symbolleiste",               ID_VIEW_TOOLBAR
         MENUITEM "S&tatusleiste",               ID_VIEW_STATUS_BAR
         MENUITEM "U&nterschiedsleiste",         ID_VIEW_DETAIL_BAR
@@ -2630,6 +2632,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Wählt die Sprache der Benutzeroberfläche.\nSprache"
     ID_VIEW_LINEDIFFS       "Zeigt Unterschiede innerhalb der Zeilen mit unterschiedlicher Farbe.\nZeilenunterschied anzeigen"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index 05dfe43..1f2a60b 100644 (file)
@@ -342,6 +342,8 @@ BEGIN
         MENUITEM "&Szóközök mutatása",            ID_VIEW_WHITESPACE
         MENUITEM "Sorok &eltérésének mutatása",      ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "&Eszköztár",                    ID_VIEW_TOOLBAR
         MENUITEM "&Álapotsor",                 ID_VIEW_STATUS_BAR
         MENUITEM "Eltérés &panel",                  ID_VIEW_DETAIL_BAR
@@ -2514,6 +2516,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Add meg a használni kívánt nyelvet\nNyelv"
     ID_VIEW_LINEDIFFS       "A sorok közötti különbségek kijelzés más-más színnel\nSorok eltérésének mutatása"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index 8039f9c..6aca2c4 100644 (file)
@@ -342,6 +342,8 @@ BEGIN
         MENUITEM "&Visualizza spazi bianchi",   ID_VIEW_WHITESPACE
         MENUITEM "Visualizza &differenze nelle linee",      ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "Barra degli &strumenti",      ID_VIEW_TOOLBAR
         MENUITEM "&Barra di stato",             ID_VIEW_STATUS_BAR
         MENUITEM "&Pannello delle differenze",  ID_VIEW_DETAIL_BAR
@@ -2630,6 +2632,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Seleziona la lingua dell'interfaccia utente\nLingua"
     ID_VIEW_LINEDIFFS       "Mostra le differenze all'interno delle linee con colori diversi\nMostra differenze nelle linee"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index 6a683e2..0ed85cf 100644 (file)
@@ -342,6 +342,8 @@ BEGIN
         MENUITEM "\8bó\94\92\82ð\95\\8e¦(&V)",              ID_VIEW_WHITESPACE
         MENUITEM "\8ds\93à\82Ì\8d·\88Ù\82ð\95\\8e¦(&W)",        ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "\83y\83C\83\93\82Ì\8cð\8a·(&A)",            ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "\83c\81[\83\8b\83o\81[(&T)",              ID_VIEW_TOOLBAR
         MENUITEM "\83X\83e\81[\83^\83X\83o\81[(&S)",          ID_VIEW_STATUS_BAR
         MENUITEM "Diff\83y\83C\83\93(&P)",              ID_VIEW_DETAIL_BAR
@@ -2518,6 +2520,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "\8c»\8dÝ\82Ì\83\86\81[\83U\81[\83C\83\93\83^\81[\83t\83F\81[\83X\8c¾\8cê\82ð\91I\91ð\82µ\82Ü\82·\n\8c¾\8cê"
     ID_VIEW_LINEDIFFS       "\8ds\93à\82Ì\8d·\88Ù\82ð\90F\82ð\95Ï\82¦\82Ä\95\\8e¦\82µ\82Ü\82·\n\8ds\93à\82Ì\8d·\88Ù\82ð\95\\8e¦"
+    ID_VIEW_SWAPPANES       "2\82Â\82Ì\83y\83C\83\93\82Ì\88Ê\92u\82ð\8cð\8a·\82µ\82Ü\82·"
 END
 
 // MERGE MENU
index 464e100..d96239d 100644 (file)
@@ -342,6 +342,8 @@ BEGIN
         MENUITEM "°ø¹é º¸±â(&V)",               ID_VIEW_WHITESPACE
         MENUITEM "Vie&w Line Differences",      ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "Åø¹Ù(&T)",                    ID_VIEW_TOOLBAR
         MENUITEM "»óÅ ǥ½ÃÁÙ(&S)",             ID_VIEW_STATUS_BAR
         MENUITEM "¼±Åàºñ±³Ã¢ º¸±â(&P)",        ID_VIEW_DETAIL_BAR
@@ -2511,6 +2513,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "¾ð¾î¸¦ ¼±ÅÃÇÕ´Ï´Ù.\n¾ð¾î"
     ID_VIEW_LINEDIFFS       "Shows differences inside lines with different color\nShow Line Diff"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index f783862..c98f73e 100644 (file)
@@ -342,6 +342,8 @@ BEGIN
         MENUITEM "&Vis mellomrom",              ID_VIEW_WHITESPACE
         MENUITEM "V&is linjeforksjell",         ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "&Verktøylinje",               ID_VIEW_TOOLBAR
         MENUITEM "S&tatuslinje",                ID_VIEW_STATUS_BAR
         MENUITEM "&Forskjellsvindu",            ID_VIEW_DETAIL_BAR
@@ -2629,6 +2631,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Velg språk til brukergrensesnittet\nSpråk"
     ID_VIEW_LINEDIFFS       "Vis forskjeller på en linje med forskjellig farge\nVis linjeforskjell"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index 8fbf01f..e3428ee 100644 (file)
@@ -342,6 +342,8 @@ BEGIN
         MENUITEM "&Poka¿ bia³e znaki",          ID_VIEW_WHITESPACE
         MENUITEM "Poka¿ ró¿nice &linii",      ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "Pasek &narzêdzi",             ID_VIEW_TOOLBAR
         MENUITEM "Pasek s&tanu",                ID_VIEW_STATUS_BAR
         MENUITEM "Panel &ró¿nic",                  ID_VIEW_DETAIL_BAR
@@ -2630,6 +2632,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Wybierz jêzyk interfejsu u¿ytkownika\nJêzyk"
     ID_VIEW_LINEDIFFS       "Poka¿ ró¿nice w liniach o ró¿nym kolorze\nPoka¿ ró¿ne linie"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index 257c020..62e9101 100644 (file)
@@ -348,6 +348,8 @@ BEGIN
         MENUITEM "Ïîêàçû&âàòü íåâèäèìûå",       ID_VIEW_WHITESPACE
         MENUITEM "Ïîêàçûâàòü îòëè÷èÿ â ñòðîêàõ", ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "Ïà&íåëü èíñòðóìåíòîâ",        ID_VIEW_TOOLBAR
         MENUITEM "&Ñòðîêà ñîñòîÿíèÿ",           ID_VIEW_STATUS_BAR
         MENUITEM "Ïàíå&ëü ñðàâíåíèÿ",           ID_VIEW_DETAIL_BAR
@@ -2524,6 +2526,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Âûáîð ÿçûêà ïîëüçîâàòåëÿ\nLanguage"
     ID_VIEW_LINEDIFFS       "Âûäåëèòü îòëè÷èÿ â ñòðîêàõ ðàçíûìè öâåòàìè\nShow Line Diff"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index 2440314..65d7433 100644 (file)
@@ -342,6 +342,8 @@ BEGIN
         MENUITEM "&Zobraz prázdne miesto",      ID_VIEW_WHITESPACE
         MENUITEM "Vie&w Line Differences",      ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "&Panel nástrojov",            ID_VIEW_TOOLBAR
         MENUITEM "&Stavový riadok",             ID_VIEW_STATUS_BAR
         MENUITEM "Diff &Pane",                  ID_VIEW_DETAIL_BAR
@@ -2630,6 +2632,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Zvoli\9d jazyk u\9eivate¾ského rozhrania\nJazyk"
     ID_VIEW_LINEDIFFS       "Shows differences inside lines with different color\nShow Line Diff"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index e11ccb9..41a7c3f 100644 (file)
@@ -342,6 +342,8 @@ BEGIN
         MENUITEM "Mostrar &espacios",            ID_VIEW_WHITESPACE
         MENUITEM "Mostrar diferencias de &línea",      ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "Barra de &herramientas",      ID_VIEW_TOOLBAR
         MENUITEM "Barra de &estado",            ID_VIEW_STATUS_BAR
         MENUITEM "Panel de di&ferencias",                  ID_VIEW_DETAIL_BAR
@@ -2630,6 +2632,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Permite seleccionar el idioma del interface de usuario\nIdioma"
     ID_VIEW_LINEDIFFS       "Muestra las diferencias en las líneas en un color diferente\nMostrar diferencias de línea"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index 27ac9d8..1fd1699 100644 (file)
@@ -341,6 +341,8 @@ BEGIN
         MENUITEM "Visa &mellanslag",            ID_VIEW_WHITESPACE
         MENUITEM "Visa &radskillnader",         ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "V&erktygsfält",               ID_VIEW_TOOLBAR
         MENUITEM "S&tatusfält",                 ID_VIEW_STATUS_BAR
         MENUITEM "Skillnadsfält",               ID_VIEW_DETAIL_BAR
@@ -2629,6 +2631,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Väljer språk för användargränssnittet\nSpråk"
     ID_VIEW_LINEDIFFS       "Visar skillnader inom rader med olika färg\nVisa radskillnad"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index 1ffa5cc..c0906c7 100644 (file)
@@ -341,6 +341,8 @@ BEGIN
         MENUITEM "&Boþluklarý Göster",          ID_VIEW_WHITESPACE
         MENUITEM "Vie&w Line Differences",      ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "Araç Çubuðu",                 ID_VIEW_TOOLBAR
         MENUITEM "Durum Çubuðu",                ID_VIEW_STATUS_BAR
         MENUITEM "Fark Penceresi",              ID_VIEW_DETAIL_BAR
@@ -2516,6 +2518,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Select the current user interfacce language\nLanguage"
     ID_VIEW_LINEDIFFS       "Shows differences inside lines with different color\nShow Line Diff"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index f3d7623..bc26d40 100644 (file)
@@ -43,7 +43,7 @@ static const double MAX_LINEPIX = 4.0;
  */
 enum LOCBAR_TYPE
 {
-       BAR_NONE = 0,   /**< No bar in given coords */
+       BAR_NONE = -1,  /**< No bar in given coords */
        BAR_LEFT,               /**< Left side bar in given coords */
        BAR_RIGHT,              /**< Right side bar in given coords */
        BAR_YAREA,              /**< Y-Coord in bar area */
@@ -56,9 +56,7 @@ IMPLEMENT_DYNCREATE(CLocationView, CView)
 
 
 CLocationView::CLocationView()
-       : m_view0(0)
-       , m_view1(0)
-       , m_visibleTop(-1)
+       : m_visibleTop(-1)
        , m_visibleBottom(-1)
 //     MOVEDLINE_LIST m_movedLines; //*< List of moved block connecting lines */
        , m_bIgnoreTrivials(true)
@@ -67,6 +65,9 @@ CLocationView::CLocationView()
        // There is no GUI to do this
 
        SetConnectMovedBlocks(mf->m_options.GetInt(OPT_CONNECT_MOVED_BLOCKS));
+
+       m_view[0] = NULL;
+       m_view[1] = NULL;
 }
 
 BEGIN_MESSAGE_MAP(CLocationView, CView)
@@ -112,12 +113,12 @@ CMergeDoc* CLocationView::GetDocument() // non-debug version is inline
 void CLocationView::OnUpdate( CView* pSender, LPARAM lHint, CObject* pHint )
 {
        CMergeDoc* pDoc = GetDocument();
-       m_view0 = pDoc->GetLeftView();
-       m_view1 = pDoc->GetRightView();
+       m_view[0] = pDoc->GetLeftView();
+       m_view[1] = pDoc->GetRightView();
 
        // Give pointer to MergeEditView
-       m_view0->m_pLocationView = this;
-       m_view1->m_pLocationView = this;
+       m_view[0]->m_pLocationView = this;
+       m_view[1]->m_pLocationView = this;
 
        Invalidate();
 }
@@ -136,12 +137,12 @@ void CLocationView::OnUpdate( CView* pSender, LPARAM lHint, CObject* pHint )
  */
 void CLocationView::OnDraw(CDC* pDC)
 {
-       if (!m_view0->IsInitialized()) return;
+       if (!m_view[0]->IsInitialized()) return;
 
        CRect rc;
        GetClientRect(rc);
 
-       if (m_view0 == NULL || m_view1 == NULL)
+       if (m_view[0] == NULL || m_view[1] == NULL)
                return;
 
        CMergeDoc *pDoc = GetDocument();
@@ -151,7 +152,7 @@ void CLocationView::OnDraw(CDC* pDC)
        m_nRightBarLeft = 2 * m_nLeftBarLeft + w;
        m_nRightBarRight = m_nRightBarLeft + w;
        const double hTotal = rc.Height() - (2 * Y_OFFSET); // Height of draw area
-       const int nbLines = min(m_view0->GetLineCount(), m_view1->GetLineCount());
+       const int nbLines = min(m_view[0]->GetLineCount(), m_view[1]->GetLineCount());
        double LineInPix = hTotal / nbLines;
        COLORREF cr0 = CLR_NONE; // Left side color
        COLORREF cr1 = CLR_NONE; // Right side color
@@ -191,15 +192,15 @@ void CLocationView::OnDraw(CDC* pDC)
                // here nstart0 = first line of block
                int nBeginY = (int) (nstart0 * LineInPix + Y_OFFSET);
                int nEndY = (int) ((blockHeight + nstart0) * LineInPix + Y_OFFSET);
-               BOOL bInsideDiff = m_view0->IsLineInCurrentDiff(nstart0);
+               BOOL bInsideDiff = m_view[0]->IsLineInCurrentDiff(nstart0);
 
                // Draw left side block
-               m_view0->GetLineColors2(nstart0, ignoreFlags, cr0, crt, bwh);
+               m_view[0]->GetLineColors2(nstart0, ignoreFlags, cr0, crt, bwh);
                CRect r0(m_nLeftBarLeft, nBeginY, m_nLeftBarRight, nEndY);
                DrawRect(pDC, r0, cr0, bInsideDiff);
                
                // Draw right side block
-               m_view1->GetLineColors2(nstart0, ignoreFlags, cr1, crt, bwh);
+               m_view[1]->GetLineColors2(nstart0, ignoreFlags, cr1, crt, bwh);
                CRect r1(m_nRightBarLeft, nBeginY, m_nRightBarRight, nEndY);
                DrawRect(pDC, r1, cr1, bInsideDiff);
 
@@ -296,7 +297,7 @@ void CLocationView::OnDraw(CDC* pDC)
 BOOL CLocationView::GetNextRect(int &nLineIndex)
 {
        CMergeDoc *pDoc = GetDocument();
-       const int nbLines = min(m_view0->GetLineCount(), m_view1->GetLineCount());
+       const int nbLines = min(m_view[0]->GetLineCount(), m_view[1]->GetLineCount());
 
        while(1)
        {
@@ -438,7 +439,7 @@ BOOL CLocationView::GotoLocation(CPoint point, BOOL bRealLine)
        CRect rc;
        GetClientRect(rc);
 
-       if (m_view0 == NULL || m_view1 == NULL)
+       if (m_view[0] == NULL || m_view[1] == NULL)
                return FALSE;
 
        int line = -1;
@@ -455,11 +456,9 @@ BOOL CLocationView::GotoLocation(CPoint point, BOOL bRealLine)
        else
                return FALSE;
 
-       m_view0->GotoLine(line, bRealLine, bar == BAR_LEFT);
-       if (bar == BAR_LEFT)
-               m_view0->SetFocus();
-       else if (bar == BAR_RIGHT)
-               m_view1->SetFocus();
+       m_view[0]->GotoLine(line, bRealLine, bar);
+       if (bar == BAR_LEFT || bar == BAR_RIGHT)
+               m_view[bar]->SetFocus();
 
        return TRUE;
 }
@@ -535,14 +534,12 @@ void CLocationView::OnContextMenu(CWnd* pWnd, CPoint point)
        switch (command)
        {
        case ID_LOCBAR_GOTODIFF:
-               m_view0->GotoLine(nLine, TRUE, bar == BAR_LEFT);
-               if (bar == BAR_LEFT)
-                       m_view0->SetFocus();
-               else
-                       m_view1->SetFocus();
+               m_view[0]->GotoLine(nLine, TRUE, bar);
+       if (bar == BAR_LEFT || bar == BAR_RIGHT)
+               m_view[bar]->SetFocus();
                break;
        case ID_EDIT_WMGOTO:
-               m_view0->WMGoto();
+               m_view[0]->WMGoto();
                break;
        case ID_DISPLAY_MOVED_NONE:
                SetConnectMovedBlocks(DISPLAY_MOVED_NONE);
@@ -571,7 +568,7 @@ int CLocationView::GetLineFromYPos(int nYCoord, CRect rc, int bar,
        BOOL bRealLine)
 {
        CMergeDoc* pDoc = GetDocument();
-       const int nbLines = min(m_view0->GetLineCount(), m_view1->GetLineCount());
+       const int nbLines = min(m_view[0]->GetLineCount(), m_view[1]->GetLineCount());
        int line = (int) (m_pixInLines * (nYCoord - Y_OFFSET));
        int nRealLine = -1;
 
@@ -586,14 +583,7 @@ int CLocationView::GetLineFromYPos(int nYCoord, CRect rc, int bar,
                return line;
 
        // Get real line (exclude ghost lines)
-       if (bar == BAR_LEFT)
-       {
-               nRealLine = pDoc->m_ltBuf.ComputeRealLine(line);
-       }
-       else if (bar == BAR_RIGHT)
-       {
-               nRealLine = pDoc->m_rtBuf.ComputeRealLine(line);
-       }
+       nRealLine = pDoc->m_ptBuf[bar]->ComputeRealLine(line);
        return nRealLine;
 }
 
@@ -611,7 +601,7 @@ int CLocationView::IsInsideBar(CRect rc, POINT pt)
        BOOL bYarea = FALSE;
        const int w = rc.Width() / 4;
        const int x = (rc.Width() - 2 * w) / 3;
-       const int nbLines = min(m_view0->GetLineCount(), m_view1->GetLineCount());
+       const int nbLines = min(m_view[0]->GetLineCount(), m_view[1]->GetLineCount());
        // We need '1 / m_pixInLines' to get line in pixels and
        // that multiplied by linecount gives us bottom coord for bars.
        double xbarBottom = min(nbLines / m_pixInLines + Y_OFFSET, rc.Height() - Y_OFFSET);
@@ -655,7 +645,7 @@ void CLocationView::DrawVisibleAreaRect(int nTopLine, int nBottomLine)
        CRect rc;
        GetClientRect(rc);
        const double hTotal = rc.Height() - (2 * Y_OFFSET); // Height of draw area
-       const int nbLines = min(m_view0->GetLineCount(), m_view1->GetLineCount());
+       const int nbLines = min(m_view[0]->GetLineCount(), m_view[1]->GetLineCount());
        double LineInPix = hTotal / nbLines;
        if (LineInPix > MAX_LINEPIX)
                LineInPix = MAX_LINEPIX;
@@ -723,8 +713,8 @@ void CLocationView::UpdateVisiblePos(int nTopLine, int nBottomLine)
  */
 void CLocationView::OnClose()
 {
-       m_view0->m_pLocationView = NULL;
-       m_view1->m_pLocationView = NULL;
+       m_view[0]->m_pLocationView = NULL;
+       m_view[1]->m_pLocationView = NULL;
 }
 
 /** 
index 524a68c..d96e252 100644 (file)
@@ -66,8 +66,7 @@ protected:
        void DrawConnectLines();
 
 private:
-       CMergeEditView* m_view0;
-       CMergeEditView* m_view1;
+       CMergeEditView* m_view[2];
        int m_displayMovedBlocks;
        double m_pixInLines; //*< How many pixels is one line in bars */
        UINT m_nLeftBarLeft; //*< Left edge of left-side bar */
index 30e0832..5cc20c7 100644 (file)
@@ -1805,8 +1805,8 @@ void CMainFrame::OnClose()
                        {
                                // Set modified status to false so that we are not asking
                                // about saving again. 
-                               pMergeDoc->m_ltBuf.SetModified(FALSE);
-                               pMergeDoc->m_rtBuf.SetModified(FALSE);
+                               pMergeDoc->m_ptBuf[0]->SetModified(FALSE);
+                               pMergeDoc->m_ptBuf[1]->SetModified(FALSE);
                        }
                }
        }
@@ -2178,7 +2178,7 @@ void CMainFrame::OnToolsGeneratePatch()
        {
                CMergeDoc * pMergeDoc = (CMergeDoc *) pFrame->GetActiveDocument();
                // If there are changes in files, tell user to save them first
-               if (pMergeDoc->m_ltBuf.IsModified() || pMergeDoc->m_ltBuf.IsModified())
+               if (pMergeDoc->m_ptBuf[0]->IsModified() || pMergeDoc->m_ptBuf[0]->IsModified())
                {
                        bOpenDialog = FALSE;
                        AfxMessageBox(IDS_SAVEFILES_FORPATCH, MB_ICONSTOP);
@@ -2950,8 +2950,8 @@ void CMainFrame::OnWindowCloseAll()
                        {
                                // Set modified status to false so that we are not asking
                                // about saving again. 
-                               pMergeDoc->m_ltBuf.SetModified(FALSE);
-                               pMergeDoc->m_rtBuf.SetModified(FALSE);
+                               pMergeDoc->m_ptBuf[0]->SetModified(FALSE);
+                               pMergeDoc->m_ptBuf[1]->SetModified(FALSE);
                        }
                }
        }
index 06f54f8..a9df109 100644 (file)
@@ -350,6 +350,8 @@ BEGIN
         MENUITEM "&View Whitespace",            ID_VIEW_WHITESPACE
         MENUITEM "Vie&w Line Differences",      ID_VIEW_LINEDIFFS
         MENUITEM SEPARATOR
+        MENUITEM "Sw&ap Panes",                 ID_VIEW_SWAPPANES
+        MENUITEM SEPARATOR
         MENUITEM "&Toolbar",                    ID_VIEW_TOOLBAR
         MENUITEM "&Status Bar",                 ID_VIEW_STATUS_BAR
         MENUITEM "Diff &Pane",                  ID_VIEW_DETAIL_BAR
@@ -2525,6 +2527,7 @@ BEGIN
     ID_VIEW_DIR_STATISTICS  "Show folder compare statistics dialog"
     ID_VIEW_LANGUAGE        "Select the current user interfacce language\nLanguage"
     ID_VIEW_LINEDIFFS       "Shows differences inside lines with different color\nShow Line Diff"
+    ID_VIEW_SWAPPANES       "Swap the positions of the two panes"
 END
 
 // MERGE MENU
index 22430d2..42575c5 100644 (file)
@@ -36,7 +36,7 @@ static char THIS_FILE[] = __FILE__;
 IMPLEMENT_DYNCREATE(CMergeDiffDetailView, CCrystalTextView)
 
 CMergeDiffDetailView::CMergeDiffDetailView()
-: m_bIsLeft(FALSE)
+: m_nThisPane(0)
 , m_lineBegin(0)
 , m_lineEnd(-1)
 , m_diffLength(0)
@@ -78,14 +78,12 @@ CMergeDoc* CMergeDiffDetailView::GetDocument() // non-debug version is inline
 // CMergeDiffDetailView message handlers
 CCrystalTextBuffer *CMergeDiffDetailView::LocateTextBuffer ()
 {
-       if (m_bIsLeft)
-               return &GetDocument()->m_ltBuf;
-       return &GetDocument()->m_rtBuf;
+       return GetDocument()->m_ptBuf[m_nThisPane];
 }
 
 void CMergeDiffDetailView::DoScroll(UINT code, UINT pos, BOOL bDoScroll)
 {
-       TRACE(_T("Scroll %s: pos=%d\n"), m_bIsLeft? _T("left"):_T("right"), pos);
+       TRACE(_T("Scroll %s: pos=%d\n"), m_nThisPane == 0 ? _T("left"):_T("right"), pos);
        if (bDoScroll
                && (code == SB_THUMBPOSITION
                        || code == SB_THUMBTRACK))
@@ -186,16 +184,8 @@ int CMergeDiffDetailView::GetAdditionalTextBlocks (int nLineIndex, TEXTBLOCK *pB
        pBuf[0].m_nBgColorIndex = COLORINDEX_NONE;
        for (int i = 0; i < nWordDiffs; i++)
        {
-               if (m_bIsLeft)
-               {
-                       pBuf[1 + i * 2].m_nCharPos = worddiffs[i].start[0];
-                       pBuf[2 + i * 2].m_nCharPos = worddiffs[i].end[0] + 1;
-               }
-               else
-               {
-                       pBuf[1 + i * 2].m_nCharPos = worddiffs[i].start[1];
-                       pBuf[2 + i * 2].m_nCharPos = worddiffs[i].end[1] + 1;
-               }
+               pBuf[1 + i * 2].m_nCharPos = worddiffs[i].start[m_nThisPane];
+               pBuf[2 + i * 2].m_nCharPos = worddiffs[i].end[m_nThisPane] + 1;
                pBuf[1 + i * 2].m_nColorIndex = COLORINDEX_HIGHLIGHTTEXT1 | COLORINDEX_APPLYFORCE;
                pBuf[1 + i * 2].m_nBgColorIndex = COLORINDEX_HIGHLIGHTBKGND1 | COLORINDEX_APPLYFORCE;
                pBuf[2 + i * 2].m_nColorIndex = COLORINDEX_NONE;
@@ -559,8 +549,8 @@ BOOL CMergeDiffDetailView::PreTranslateMessage(MSG* pMsg)
                {
                        // Set modified status to false so that we are not asking
                        // about saving again
-                       pd->m_ltBuf.SetModified(FALSE);
-                       pd->m_rtBuf.SetModified(FALSE);
+                       pd->m_ptBuf[0]->SetModified(FALSE);
+                       pd->m_ptBuf[1]->SetModified(FALSE);
                        AfxGetMainWnd()->PostMessage(WM_COMMAND, ID_FILE_CLOSE);
                        return FALSE;
                }
index 137c5cc..abfa98c 100644 (file)
@@ -38,7 +38,7 @@ protected:
 
 // Attributes
 public:
-       BOOL m_bIsLeft;
+       int m_nThisPane;
 protected:
        /// first line of diff (first displayable line)
        int m_lineBegin;
index b121a30..c75e6d1 100644 (file)
@@ -103,9 +103,7 @@ END_MESSAGE_MAP()
  * @brief Constructor.
  */
 CMergeDoc::CMergeDoc()
-: m_ltBuf(this,TRUE)
-, m_rtBuf(this,FALSE)
-, m_pTempFiles(NULL)
+: m_pTempFiles(NULL)
 {
        DIFFOPTIONS options = {0};
 
@@ -113,17 +111,23 @@ CMergeDoc::CMergeDoc()
        m_bEnableRescan = TRUE;
        // COleDateTime m_LastRescan
        curUndo = undoTgt.begin();
-       m_pLeftView=NULL;
-       m_pRightView=NULL;
-       m_pLeftDetailView=NULL;
-       m_pRightDetailView=NULL;
+       m_pView[0]=NULL;
+       m_pView[1]=NULL;
+       m_pDetailView[0]=NULL;
+       m_pDetailView[1]=NULL;
        m_pDirDoc=NULL;
        m_pInfoUnpacker = new PackingInfo;
-       m_nLeftBufferType = BUFFER_NORMAL;
-       m_nRightBufferType = BUFFER_NORMAL;
+       m_nBufferType[0] = BUFFER_NORMAL;
+       m_nBufferType[1] = BUFFER_NORMAL;
        m_bMergingMode = mf->m_options.GetBool(OPT_MERGE_MODE);
-       m_bLeftEditAfterRescan = FALSE;
-       m_bRightEditAfterRescan = FALSE;
+       m_bEditAfterRescan[0] = FALSE;
+       m_bEditAfterRescan[1] = FALSE;
+       m_ptBuf[0] = new CDiffTextBuffer(this, 0);
+       m_ptBuf[1] = new CDiffTextBuffer(this, 1);
+       m_pSaveFileInfo[0] = new DiffFileInfo();
+       m_pSaveFileInfo[1] = new DiffFileInfo();
+       m_pRescanFileInfo[0] = new DiffFileInfo();
+       m_pRescanFileInfo[1] = new DiffFileInfo();
 
        m_diffWrapper.SetDetectMovedBlocks(mf->m_options.GetBool(OPT_CMP_MOVED_BLOCKS));
        options.nIgnoreWhitespace = mf->m_options.GetInt(OPT_CMP_IGNORE_WHITESPACE);
@@ -152,6 +156,12 @@ CMergeDoc::~CMergeDoc()
 
        delete m_pInfoUnpacker;
        delete m_pTempFiles;
+       delete m_pSaveFileInfo[0];
+       delete m_pSaveFileInfo[1];
+       delete m_pRescanFileInfo[0];
+       delete m_pRescanFileInfo[1];
+       delete m_ptBuf[0];
+       delete m_ptBuf[1];
 }
 
 /**
@@ -160,8 +170,8 @@ CMergeDoc::~CMergeDoc()
 void CMergeDoc::DeleteContents ()
 {
        CDocument::DeleteContents ();
-       m_ltBuf.FreeAll ();
-       m_rtBuf.FreeAll ();
+       m_ptBuf[0]->FreeAll ();
+       m_ptBuf[1]->FreeAll ();
        delete m_pTempFiles;
        m_pTempFiles = NULL;
 }
@@ -234,8 +244,8 @@ BOOL CMergeDoc::OnNewDocument()
        VERIFY(s.LoadString(IDS_FILE_COMPARISON_TITLE));
        SetTitle(s);
        
-       m_ltBuf.InitNew ();
-       m_rtBuf.InitNew ();
+       m_ptBuf[0]->InitNew ();
+       m_ptBuf[1]->InitNew ();
        return TRUE;
 }
 
@@ -339,9 +349,9 @@ int CMergeDoc::Rescan(BOOL &bBinary, BOOL &bIdentical,
        }
 
        bLeftFileChanged = IsFileChangedOnDisk(m_filePaths.GetLeft(), fileInfo,
-               FALSE, TRUE);
+               FALSE, 0);
        bRightFileChanged = IsFileChangedOnDisk(m_filePaths.GetRight(), fileInfo,
-               FALSE, FALSE);
+               FALSE, 1);
        m_LastRescan = COleDateTime::GetCurrentTime();
 
        // get the desired files to temp locations so we can edit them dynamically
@@ -354,15 +364,15 @@ int CMergeDoc::Rescan(BOOL &bBinary, BOOL &bIdentical,
                if (!m_pTempFiles->CreateFiles(m_filePaths))
                        return RESCAN_TEMP_ERR;
 
-               m_ltBuf.SetTempPath(m_pTempFiles->GetPath());
-               m_rtBuf.SetTempPath(m_pTempFiles->GetPath());
+               m_ptBuf[0]->SetTempPath(m_pTempFiles->GetTempPath());
+               m_ptBuf[1]->SetTempPath(m_pTempFiles->GetTempPath());
        }
 
        // output buffers to temp files (in UTF-8 if TCHAR=wchar_t or buffer was Unicode)
        if (bBinary == FALSE)
        {
-               SaveBuffForDiff(m_ltBuf, m_pTempFiles->GetLeft());
-               SaveBuffForDiff(m_rtBuf, m_pTempFiles->GetRight());
+               SaveBuffForDiff(*m_ptBuf[0], m_pTempFiles->GetLeft());
+               SaveBuffForDiff(*m_ptBuf[1], m_pTempFiles->GetRight());
        }
 
        // Set up DiffWrapper
@@ -394,7 +404,7 @@ int CMergeDoc::Rescan(BOOL &bBinary, BOOL &bIdentical,
        {
                // ..lasf DIFFRANGE of file which has EOL must be
                // fixed to contain last line too
-               m_diffWrapper.FixLastDiffRange(m_ltBuf.GetLineCount(), m_rtBuf.GetLineCount(),
+               m_diffWrapper.FixLastDiffRange(m_ptBuf[0]->GetLineCount(), m_ptBuf[1]->GetLineCount(),
                                status.bRightMissingNL);
        }
 
@@ -416,23 +426,23 @@ int CMergeDoc::Rescan(BOOL &bBinary, BOOL &bIdentical,
                // BTW, this solves the problem of double asserts
                // (during the display of an assert message box, a second assert in one of the 
                //  display functions happens, and hides the first assert)
-               m_pLeftView->DetachFromBuffer();
-               m_pRightView->DetachFromBuffer();
-               m_pLeftDetailView->DetachFromBuffer();
-               m_pRightDetailView->DetachFromBuffer();
+               m_pView[0]->DetachFromBuffer();
+               m_pView[1]->DetachFromBuffer();
+               m_pDetailView[0]->DetachFromBuffer();
+               m_pDetailView[1]->DetachFromBuffer();
 
                // Remove blank lines and clear winmerge flags
                // this operation does not change the modified flag
-               m_ltBuf.prepareForRescan();
-               m_rtBuf.prepareForRescan();
+               m_ptBuf[0]->prepareForRescan();
+               m_ptBuf[1]->prepareForRescan();
 
                // Analyse diff-list (updating real line-numbers)
                // this operation does not change the modified flag
                PrimeTextBuffers();
 
                // Apply flags to lines that moved, to differentiate from appeared/disappeared lines
-               FlagMovedLines(m_diffWrapper.GetMoved0(), &m_ltBuf);
-               FlagMovedLines(m_diffWrapper.GetMoved1(), &m_rtBuf);
+               FlagMovedLines(m_diffWrapper.GetMoved0(), m_ptBuf[0]);
+               FlagMovedLines(m_diffWrapper.GetMoved1(), m_ptBuf[1]);
                
                // After PrimeTextBuffers() we know amount of real diffs
                // (m_nDiffs) and trivial diffs (m_nTrivialDiffs)
@@ -442,25 +452,25 @@ int CMergeDoc::Rescan(BOOL &bBinary, BOOL &bIdentical,
                        bIdentical = TRUE;
 
                // just apply some options to the views
-               m_pLeftView->PrimeListWithFile();
-               m_pRightView->PrimeListWithFile();
-               m_pLeftDetailView->PrimeListWithFile();
-               m_pRightDetailView->PrimeListWithFile();
+               m_pView[0]->PrimeListWithFile();
+               m_pView[1]->PrimeListWithFile();
+               m_pDetailView[0]->PrimeListWithFile();
+               m_pDetailView[1]->PrimeListWithFile();
 
                // Now buffers data are valid
-               m_pLeftView->ReAttachToBuffer();
-               m_pRightView->ReAttachToBuffer();
-               m_pLeftDetailView->ReAttachToBuffer();
-               m_pRightDetailView->ReAttachToBuffer();
+               m_pView[0]->ReAttachToBuffer();
+               m_pView[1]->ReAttachToBuffer();
+               m_pDetailView[0]->ReAttachToBuffer();
+               m_pDetailView[1]->ReAttachToBuffer();
 
-               m_bLeftEditAfterRescan = FALSE;
-               m_bRightEditAfterRescan = FALSE;
+               m_bEditAfterRescan[0] = FALSE;
+               m_bEditAfterRescan[1] = FALSE;
        }
 
        theApp.SetLastCompareResult(bIdentical ? 0 : 1);
 
-       m_leftRescanFileInfo.Update(m_filePaths.GetLeft());
-       m_rightRescanFileInfo.Update(m_filePaths.GetRight());
+       m_pRescanFileInfo[0]->Update(m_filePaths.GetLeft());
+       m_pRescanFileInfo[1]->Update(m_filePaths.GetRight());
 
        if (bLeftFileChanged)
        {
@@ -559,10 +569,10 @@ void CMergeDoc::ShowRescanError(int nRescanResult,
        }
 }
 
-CMergeDoc::CDiffTextBuffer::CDiffTextBuffer(CMergeDoc * pDoc, BOOL bLeft)
+CMergeDoc::CDiffTextBuffer::CDiffTextBuffer(CMergeDoc * pDoc, int pane)
 {
        m_pOwnerDoc = pDoc;
-       m_bIsLeft=bLeft;
+       m_nThisPane = pane;
        unpackerSubcode = 0;
        m_unicoding = 0;
        m_codepage = 0;
@@ -607,7 +617,7 @@ void CMergeDoc::CDiffTextBuffer::AddUndoRecord(BOOL bInsert, const CPoint & ptSt
        if (m_aUndoBuf[m_nUndoPosition - 1].m_dwFlags & UNDO_BEGINGROUP)
        {
                m_pOwnerDoc->undoTgt.erase(m_pOwnerDoc->curUndo, m_pOwnerDoc->undoTgt.end());
-               m_pOwnerDoc->undoTgt.push_back(m_bIsLeft ? m_pOwnerDoc->m_pLeftView : m_pOwnerDoc->m_pRightView);
+               m_pOwnerDoc->undoTgt.push_back(m_pOwnerDoc->m_pView[m_nThisPane]);
                m_pOwnerDoc->curUndo = m_pOwnerDoc->undoTgt.end();
        }
 }
@@ -650,22 +660,22 @@ private:
 
 /**
  * @brief Copy all diffs from one side to side.
- * @param [in] bSrcLeft Source side from which diff is copied
- * @param [in] bCurrentLeft Currently active view (where cursor is)
+ * @param [in] srcPane Source side from which diff is copied
+ * @param [in] dstPane Destination side
  */
-void CMergeDoc::CopyAllList(bool bSrcLeft, bool bCurrentLeft)
+void CMergeDoc::CopyAllList(int srcPane, int dstPane)
 {
-       CopyMultipleList(bSrcLeft, bCurrentLeft, 0, m_diffList.GetSize() - 1);
+       CopyMultipleList(srcPane, dstPane, 0, m_diffList.GetSize() - 1);
 }
 
 /**
  * @brief Copy range of diffs from one side to side.
- * @param [in] bSrcLeft Source side from which diff is copied
- * @param [in] bCurrentLeft Currently active view (where cursor is)
+ * @param [in] srcPane Source side from which diff is copied
+ * @param [in] dstPane Destination side
  * @param [in] firstDiff First diff copied (0-based index)
  * @param [in] lastDiff Last diff copied (0-based index)
  */
-void CMergeDoc::CopyMultipleList(bool bSrcLeft, bool bCurrentLeft, int firstDiff, int lastDiff)
+void CMergeDoc::CopyMultipleList(int srcPane, int dstPane, int firstDiff, int lastDiff)
 {
 #ifdef _DEBUG
        if (firstDiff > lastDiff)
@@ -687,14 +697,14 @@ void CMergeDoc::CopyMultipleList(bool bSrcLeft, bool bCurrentLeft, int firstDiff
        // because we don't rescan() so it does not change
 
        SetCurrentDiff(lastDiff);
-       ListCopy(bSrcLeft, bCurrentLeft);
+       ListCopy(srcPane, dstPane);
 
        // copy from bottom up is more efficient
        for(int i = lastDiff - 1; i >= firstDiff; --i)
        {
                SetCurrentDiff(i);
                // Group merge with previous (merge undo data to one action)
-               ListCopy(bSrcLeft, bCurrentLeft, true);
+               ListCopy(srcPane, dstPane, true);
        }
 
        suppressRescan.Clear(); // done suppress Rescan
@@ -715,8 +725,8 @@ BOOL CMergeDoc::SanityCheckDiff(DIFFRANGE dr)
 {
        int cd_dbegin = dr.dbegin0;
        int cd_dend = dr.dend0;
-       DWORD dwLeftFlags = m_ltBuf.GetLineFlags(cd_dend);
-       DWORD dwRightFlags = m_rtBuf.GetLineFlags(cd_dend);
+       DWORD dwLeftFlags = m_ptBuf[0]->GetLineFlags(cd_dend);
+       DWORD dwRightFlags = m_ptBuf[1]->GetLineFlags(cd_dend);
 
        // Optimization - check last line first so we don't need to
        // check whole diff for obvious cases
@@ -728,8 +738,8 @@ BOOL CMergeDoc::SanityCheckDiff(DIFFRANGE dr)
 
        for (int line = cd_dbegin; line < cd_dend; line++)
        {
-               dwLeftFlags = m_ltBuf.GetLineFlags(cd_dend);
-               dwRightFlags = m_rtBuf.GetLineFlags(cd_dend);
+               dwLeftFlags = m_ptBuf[0]->GetLineFlags(cd_dend);
+               dwRightFlags = m_ptBuf[1]->GetLineFlags(cd_dend);
                if (!(dwLeftFlags & LF_WINMERGE_FLAGS) ||
                        !(dwRightFlags & LF_WINMERGE_FLAGS))
                {
@@ -741,12 +751,12 @@ BOOL CMergeDoc::SanityCheckDiff(DIFFRANGE dr)
 
 /**
  * @brief Copy selected (=current) difference from from side to side.
- * @param [in] bSrcLeft Source side from which diff is copied
- * @param [in] bCurrentLeft Currently active view (where cursor is)
+ * @param [in] srcPane Source side from which diff is copied
+ * @param [in] dstPane Destination side
  * @param [in] bGroupWithPrevious Adds diff to same undo group with
  * previous action (allows one undo for copy all)
  */
-void CMergeDoc::ListCopy(bool bSrcLeft, bool bCurrentLeft,
+void CMergeDoc::ListCopy(int srcPane, int dstPane,
                bool bGroupWithPrevious /*= false*/)
 {
        // suppress Rescan during this method
@@ -760,12 +770,12 @@ void CMergeDoc::ListCopy(bool bSrcLeft, bool bCurrentLeft,
        {
                DIFFRANGE cd;
                VERIFY(m_diffList.GetDiff(curDiff, cd));
-               CDiffTextBuffer& sbuf = bSrcLeft? m_ltBuf:m_rtBuf;
-               CDiffTextBuffer& dbuf = bSrcLeft? m_rtBuf:m_ltBuf;
+               CDiffTextBuffer& sbuf = *m_ptBuf[srcPane];
+               CDiffTextBuffer& dbuf = *m_ptBuf[dstPane];
                BOOL bSrcWasMod = sbuf.IsModified();
-               int cd_dbegin = bSrcLeft? cd.dbegin0:cd.dbegin1;
-               int cd_dend = bSrcLeft? cd.dend0:cd.dend1;
-               int cd_blank = bSrcLeft? cd.blank0:cd.blank1;
+               int cd_dbegin = srcPane == 0 ? cd.dbegin0 : cd.dbegin1;
+               int cd_dend = srcPane == 0 ? cd.dend0 : cd.dend1;
+               int cd_blank = srcPane == 0 ? cd.blank0 : cd.blank1;
                BOOL bInSync = SanityCheckDiff(cd);
 
                if (bInSync == FALSE)
@@ -777,11 +787,10 @@ void CMergeDoc::ListCopy(bool bSrcLeft, bool bCurrentLeft,
                // If we remove whole diff from current view, we must fix cursor
                // position first. Normally we would move to end of previous line,
                // but we want to move to begin of that line for usability.
-               if ((cd.op == OP_LEFTONLY && bCurrentLeft == true) ||
-                       (cd.op == OP_RIGHTONLY && bCurrentLeft == false))
+               if ((cd.op == OP_LEFTONLY && dstPane == 0) ||
+                       (cd.op == OP_RIGHTONLY && dstPane == 1))
                {
-                       CCrystalTextView * pCurView = bCurrentLeft ?
-                               m_pLeftView : m_pRightView;
+                       CCrystalTextView * pCurView = m_pView[dstPane];
                        CPoint currentPos = pCurView->GetCursorPos();
                        currentPos.x = 0;
                        if (currentPos.y > 0)
@@ -794,12 +803,7 @@ void CMergeDoc::ListCopy(bool bSrcLeft, bool bCurrentLeft,
                int limit = cd_dend;
 
                // curView is the view which is changed, so the opposite of the source view
-               CCrystalTextView* curView;
-
-               if(bSrcLeft)
-                       curView = m_pRightView;
-               else
-                       curView = m_pLeftView;
+               CCrystalTextView* dstView = m_pView[dstPane];
 
                dbuf.BeginUndoGroup(bGroupWithPrevious);
                if (cd_blank>=0)
@@ -808,16 +812,16 @@ void CMergeDoc::ListCopy(bool bSrcLeft, bool bCurrentLeft,
                        // delete only on destination side since rescan will clear the other side
                        if(cd_blank==0)
                        {
-                               dbuf.DeleteText(curView, cd_blank, 0, cd_dend+1, 0, CE_ACTION_MERGE);
+                               dbuf.DeleteText(dstView, cd_blank, 0, cd_dend+1, 0, CE_ACTION_MERGE);
                        }
                        else
                        {
-                               dbuf.DeleteText(curView, cd_blank-1, dbuf.GetLineLength(cd_blank-1), cd_dend, dbuf.GetLineLength(cd_dend), CE_ACTION_MERGE);
+                               dbuf.DeleteText(dstView, cd_blank-1, dbuf.GetLineLength(cd_blank-1), cd_dend, dbuf.GetLineLength(cd_dend), CE_ACTION_MERGE);
                        }
                        deleted_lines=cd_dend-cd_blank+1;
 
                        limit=cd_blank-1;
-                       dbuf.FlushUndoGroup(curView);
+                       dbuf.FlushUndoGroup(dstView);
                        dbuf.BeginUndoGroup(TRUE);
                }
 
@@ -829,11 +833,11 @@ void CMergeDoc::ListCopy(bool bSrcLeft, bool bCurrentLeft,
                        // text exists on left side, so just replace
                        strLine = _T("");
                        sbuf.GetFullLine(i, strLine);
-                       dbuf.ReplaceFullLine(curView, i, strLine, CE_ACTION_MERGE);
-                       dbuf.FlushUndoGroup(curView);
+                       dbuf.ReplaceFullLine(dstView, i, strLine, CE_ACTION_MERGE);
+                       dbuf.FlushUndoGroup(dstView);
                        dbuf.BeginUndoGroup(TRUE);
                }
-               dbuf.FlushUndoGroup(curView);
+               dbuf.FlushUndoGroup(dstView);
 
                // remove the diff
                SetCurrentDiff(-1);
@@ -863,6 +867,7 @@ void CMergeDoc::ListCopy(bool bSrcLeft, bool bCurrentLeft,
  * previous save.
  * - [out] : Statuscode of this saving try
  * @param [in, out] sError Error string from lower level saving code
+ * @param [in] nBuffer Buffer we are saving
  * @return FALSE as long as the user is not satisfied. Calling function
  * should not continue until TRUE is returned.
  * @sa CMergeDoc::DoSave()
@@ -870,7 +875,7 @@ void CMergeDoc::ListCopy(bool bSrcLeft, bool bCurrentLeft,
  * @sa CMergeDoc::CDiffTextBuffer::SaveToFile()
  */
 BOOL CMergeDoc::TrySaveAs(CString &strPath, int &nSaveResult, CString & sError,
-       BOOL bLeft, PackingInfo * pInfoTempUnpacker)
+       int nBuffer, PackingInfo * pInfoTempUnpacker)
 {
        CString s;
        CString strSavePath; // New path for next saving try
@@ -884,8 +889,8 @@ BOOL CMergeDoc::TrySaveAs(CString &strPath, int &nSaveResult, CString & sError,
        // Select message based on reason function called
        if (nSaveResult == SAVE_PACK_FAILED)
        {
-               AfxFormatString2(s, bLeft ? IDS_FILEPACK_FAILED_LEFT :
-                       IDS_FILEPACK_FAILED_RIGHT, strPath, pInfoTempUnpacker->pluginName);
+               AfxFormatString2(s, IDS_FILEPACK_FAILED_LEFT + nBuffer,
+                       strPath, pInfoTempUnpacker->pluginName);
                // replace the unpacker with a "do nothing" unpacker
                pInfoTempUnpacker->Initialize(PLUGIN_MANUAL);
        }
@@ -902,14 +907,14 @@ BOOL CMergeDoc::TrySaveAs(CString &strPath, int &nSaveResult, CString & sError,
        switch (answer)
        {
        case IDOK:
-               if (bLeft)
+               if (nBuffer == 0)
                        VERIFY(title.LoadString(IDS_SAVE_LEFT_AS));
                else
                        VERIFY(title.LoadString(IDS_SAVE_RIGHT_AS));
 
                if (SelectFile(s, strPath, title, NULL, FALSE))
                {
-                       CDiffTextBuffer *pBuffer = bLeft ? &m_ltBuf : &m_rtBuf;
+                       CDiffTextBuffer *pBuffer = m_ptBuf[nBuffer];
                        strSavePath = s;
                        nSaveResult = pBuffer->SaveToFile(strSavePath, FALSE, sError,
                                pInfoTempUnpacker);
@@ -919,20 +924,12 @@ BOOL CMergeDoc::TrySaveAs(CString &strPath, int &nSaveResult, CString & sError,
                                // We are saving scratchpad (unnamed file)
                                if (strPath.IsEmpty())
                                {
-                                       if (bLeft)
-                                       {
-                                               m_nLeftBufferType = BUFFER_UNNAMED_SAVED;
-                                               m_strLeftDesc.Empty();
-                                       }
-                                       else
-                                       {
-                                               m_nRightBufferType = BUFFER_UNNAMED_SAVED;
-                                               m_strRightDesc.Empty();
-                                       }
+                                       m_nBufferType[nBuffer] = BUFFER_UNNAMED_SAVED;
+                                       m_strDesc[nBuffer].Empty();
                                }
                                        
                                strPath = strSavePath;
-                               UpdateHeaderPath(bLeft);
+                               UpdateHeaderPath(nBuffer);
                        }
                        else
                                result = FALSE;
@@ -958,7 +955,7 @@ BOOL CMergeDoc::TrySaveAs(CString &strPath, int &nSaveResult, CString & sError,
  * empty/NULL if new file is created (scratchpad) without filename.
  * @param [out] bSaveSuccess Will contain information about save success with
  * the original name (to determine if file statuses should be changed)
- * @param [in] bLeft If TRUE we are saving left(side) file, else right file
+ * @param [in] nBuffer Index (0-based) of buffer to save
  * @return Tells if caller can continue (no errors happened)
  * @note Return value does not tell if SAVING succeeded. Caller must
  * Check value of bSaveSuccess parameter after calling this function!
@@ -969,7 +966,7 @@ BOOL CMergeDoc::TrySaveAs(CString &strPath, int &nSaveResult, CString & sError,
  * @sa CMainFrame::CheckSavePath()
  * @sa CMergeDoc::CDiffTextBuffer::SaveToFile()
  */
-BOOL CMergeDoc::DoSave(LPCTSTR szPath, BOOL &bSaveSuccess, BOOL bLeft)
+BOOL CMergeDoc::DoSave(LPCTSTR szPath, BOOL &bSaveSuccess, int nBuffer)
 {
        DiffFileInfo fileInfo;
        CString strSavePath(szPath);
@@ -978,7 +975,7 @@ BOOL CMergeDoc::DoSave(LPCTSTR szPath, BOOL &bSaveSuccess, BOOL bLeft)
        BOOL bApplyToAll = FALSE;       
        int nRetVal = -1;
 
-       bFileChanged = IsFileChangedOnDisk(szPath, fileInfo, TRUE, bLeft);
+       bFileChanged = IsFileChangedOnDisk(szPath, fileInfo, TRUE, nBuffer);
        if (bFileChanged)
        {
                CString msg;
@@ -1030,7 +1027,7 @@ BOOL CMergeDoc::DoSave(LPCTSTR szPath, BOOL &bSaveSuccess, BOOL bLeft)
        // or SAVE_DONE when the save succeeds
        // TODO: Shall we return this code in addition to bSaveSuccess ?
        int nSaveErrorCode = SAVE_DONE;
-       CDiffTextBuffer *pBuffer = bLeft ? &m_ltBuf : &m_rtBuf;
+       CDiffTextBuffer *pBuffer = m_ptBuf[nBuffer];
 
        // Assume empty filename means Scratchpad (unnamed file)
        // Todo: This is not needed? - buffer type check should be enough
@@ -1038,8 +1035,8 @@ BOOL CMergeDoc::DoSave(LPCTSTR szPath, BOOL &bSaveSuccess, BOOL bLeft)
                nSaveErrorCode = SAVE_NO_FILENAME;
 
        // Handle unnamed buffers
-       if (( bLeft && m_nLeftBufferType == BUFFER_UNNAMED) ||
-               (!bLeft && m_nRightBufferType == BUFFER_UNNAMED))
+       if ((m_nBufferType[nBuffer] == BUFFER_UNNAMED) ||
+               (m_nBufferType[nBuffer] == BUFFER_UNNAMED))
                        nSaveErrorCode = SAVE_NO_FILENAME;
 
        if (nSaveErrorCode == SAVE_DONE)
@@ -1050,26 +1047,17 @@ BOOL CMergeDoc::DoSave(LPCTSTR szPath, BOOL &bSaveSuccess, BOOL bLeft)
        {
                // Saving failed, user may save to another location if wants to
                do
-                       result = TrySaveAs(strSavePath, nSaveErrorCode, sError, bLeft, &infoTempUnpacker);
+                       result = TrySaveAs(strSavePath, nSaveErrorCode, sError, nBuffer, &infoTempUnpacker);
                while (!result);
        }
 
        // Saving succeeded with given/selected filename
        if (nSaveErrorCode == SAVE_DONE)
        {
-               if (bLeft)
-               {
-                       m_leftSaveFileInfo.Update(strSavePath);
-                       m_leftRescanFileInfo.Update(m_filePaths.GetLeft());
-                       m_filePaths.SetLeft(strSavePath);
-               }
-               else
-               {
-                       m_rightSaveFileInfo.Update(strSavePath);
-                       m_rightRescanFileInfo.Update(m_filePaths.GetRight());
-                       m_filePaths.SetRight(strSavePath);
-               }
-               UpdateHeaderPath(bLeft);
+               m_pSaveFileInfo[nBuffer]->Update(strSavePath);
+               m_pRescanFileInfo[nBuffer]->Update(m_filePaths.GetPath(nBuffer));
+               m_filePaths.SetPath(nBuffer, strSavePath);
+               UpdateHeaderPath(nBuffer);
                bSaveSuccess = TRUE;
                result = TRUE;
        }
@@ -1090,7 +1078,7 @@ BOOL CMergeDoc::DoSave(LPCTSTR szPath, BOOL &bSaveSuccess, BOOL bLeft)
  * empty/NULL if new file is created (scratchpad) without filename.
  * @param [out] bSaveSuccess Will contain information about save success with
  * the original name (to determine if file statuses should be changed)
- * @param [in] bLeft If TRUE we are saving left(side) file, else right file
+ * @param [in] nBuffer Index (0-based) of buffer to save
  * @return Tells if caller can continue (no errors happened)
  * @note Return value does not tell if SAVING succeeded. Caller must
  * Check value of bSaveSuccess parameter after calling this function!
@@ -1098,7 +1086,7 @@ BOOL CMergeDoc::DoSave(LPCTSTR szPath, BOOL &bSaveSuccess, BOOL bLeft)
  * @sa CMainFrame::CheckSavePath()
  * @sa CMergeDoc::CDiffTextBuffer::SaveToFile()
  */
-BOOL CMergeDoc::DoSaveAs(LPCTSTR szPath, BOOL &bSaveSuccess, BOOL bLeft)
+BOOL CMergeDoc::DoSaveAs(LPCTSTR szPath, BOOL &bSaveSuccess, int nBuffer)
 {
        CString strSavePath(szPath);
        CString sError;
@@ -1122,25 +1110,16 @@ BOOL CMergeDoc::DoSaveAs(LPCTSTR szPath, BOOL &bSaveSuccess, BOOL bLeft)
 
        // Loop until user succeeds saving or cancels
        do
-               result = TrySaveAs(strSavePath, nSaveErrorCode, sError, bLeft, &infoTempUnpacker);
+               result = TrySaveAs(strSavePath, nSaveErrorCode, sError, nBuffer, &infoTempUnpacker);
        while (!result);
 
        // Saving succeeded with given/selected filename
        if (nSaveErrorCode == SAVE_DONE)
        {
-               if (bLeft)
-               {
-                       m_leftSaveFileInfo.Update(strSavePath);
-                       m_leftRescanFileInfo.Update(m_filePaths.GetLeft());
-                       m_filePaths.SetLeft(strSavePath);
-               }
-               else
-               {
-                       m_rightSaveFileInfo.Update(strSavePath);
-                       m_rightRescanFileInfo.Update(m_filePaths.GetRight());
-                       m_filePaths.SetRight(strSavePath);
-               }
-               UpdateHeaderPath(bLeft);
+               m_pSaveFileInfo[nBuffer]->Update(strSavePath);
+               m_pRescanFileInfo[nBuffer]->Update(m_filePaths.GetPath(nBuffer));
+               m_filePaths.SetPath(nBuffer, strSavePath);
+               UpdateHeaderPath(nBuffer);
                bSaveSuccess = TRUE;
                result = TRUE;
        }
@@ -1152,13 +1131,13 @@ BOOL CMergeDoc::DoSaveAs(LPCTSTR szPath, BOOL &bSaveSuccess, BOOL bLeft)
  */
 int CMergeDoc::RightLineInMovedBlock(int apparentLeftLine)
 {
-       if (!(m_ltBuf.GetLineFlags(apparentLeftLine) & LF_MOVED))
+       if (!(m_ptBuf[0]->GetLineFlags(apparentLeftLine) & LF_MOVED))
                return -1;
 
-       int realLeftLine = m_ltBuf.ComputeRealLine(apparentLeftLine);
+       int realLeftLine = m_ptBuf[0]->ComputeRealLine(apparentLeftLine);
        int realRightLine = m_diffWrapper.RightLineInMovedBlock(realLeftLine);
        if (realRightLine != -1)
-               return m_rtBuf.ComputeApparentLine(realRightLine);
+               return m_ptBuf[1]->ComputeApparentLine(realRightLine);
        else
                return -1;
 }
@@ -1168,13 +1147,13 @@ int CMergeDoc::RightLineInMovedBlock(int apparentLeftLine)
  */
 int CMergeDoc::LeftLineInMovedBlock(int apparentRightLine)
 {
-       if (!(m_rtBuf.GetLineFlags(apparentRightLine) & LF_MOVED))
+       if (!(m_ptBuf[1]->GetLineFlags(apparentRightLine) & LF_MOVED))
                return -1;
 
-       int realRightLine = m_rtBuf.ComputeRealLine(apparentRightLine);
+       int realRightLine = m_ptBuf[1]->ComputeRealLine(apparentRightLine);
        int realLeftLine = m_diffWrapper.LeftLineInMovedBlock(realRightLine);
        if (realLeftLine != -1)
-               return m_ltBuf.ComputeApparentLine(realLeftLine);
+               return m_ptBuf[0]->ComputeApparentLine(realLeftLine);
        else
                return -1;
 }
@@ -1196,8 +1175,8 @@ BOOL CMergeDoc::CanCloseFrame(CFrameWnd* /*pFrame*/)
        {
                // Set modified status to false so that we are not asking
                // about saving again in OnCloseDocument()
-               m_ltBuf.SetModified(FALSE);
-               m_rtBuf.SetModified(FALSE);
+               m_ptBuf[0]->SetModified(FALSE);
+               m_ptBuf[1]->SetModified(FALSE);
                return TRUE;
        }
        else
@@ -1837,10 +1816,10 @@ void CMergeDoc::FlushAndRescan(BOOL bForced /* =FALSE */)
        CCrystalTextView* curView = dynamic_cast<CCrystalTextView*> (GetParentFrame()->GetActiveView());
 
        // store cursors and hide caret
-       m_pLeftView->PushCursors();
-       m_pRightView->PushCursors();
-       m_pLeftDetailView->PushCursors();
-       m_pRightDetailView->PushCursors();
+       m_pView[0]->PushCursors();
+       m_pView[1]->PushCursors();
+       m_pDetailView[0]->PushCursors();
+       m_pDetailView[1]->PushCursors();
        if (curView)
                curView->HideCursor();
 
@@ -1849,28 +1828,28 @@ void CMergeDoc::FlushAndRescan(BOOL bForced /* =FALSE */)
        int nRescanResult = Rescan(bBinary, bIdentical, bForced);
 
        // restore cursors and caret
-       m_pLeftView->PopCursors();
-       m_pRightView->PopCursors();
-       m_pLeftDetailView->PopCursors();
-       m_pRightDetailView->PopCursors();
+       m_pView[0]->PopCursors();
+       m_pView[1]->PopCursors();
+       m_pDetailView[0]->PopCursors();
+       m_pDetailView[1]->PopCursors();
        if (curView)
                curView->ShowCursor();
 
        // because of ghostlines, m_nTopLine may differ just after Rescan
        // scroll both views to the same top line
-       CMergeEditView * fixedView = m_pLeftView;
-       if (curView == m_pLeftView || curView == m_pRightView)
+       CMergeEditView * fixedView = m_pView[0];
+       if (curView == m_pView[0] || curView == m_pView[1])
                // only one view needs to scroll so do not scroll the active view
                fixedView = (CMergeEditView*) curView;
        fixedView->UpdateSiblingScrollPos(FALSE);
 
        // make sure we see the cursor from the curent view
-       if (curView == m_pRightView || curView == m_pLeftView)
+       if (curView == m_pView[1] || curView == m_pView[0])
                curView->EnsureVisible(curView->GetCursorPos());
 
        // scroll both diff views to the same top line
-       CMergeDiffDetailView * fixedDetailView = m_pLeftDetailView;
-       if (curView == m_pLeftDetailView || curView == m_pRightDetailView)
+       CMergeDiffDetailView * fixedDetailView = m_pDetailView[0];
+       if (curView == m_pDetailView[0] || curView == m_pDetailView[1])
                // only one view needs to scroll so do not scroll the active view
                fixedDetailView = (CMergeDiffDetailView*) curView;
        fixedDetailView->UpdateSiblingScrollPos(FALSE);
@@ -1893,22 +1872,22 @@ void CMergeDoc::OnFileSave()
        BOOL bLChangedOriginal = FALSE;
        BOOL bRChangedOriginal = FALSE;
 
-       if (m_ltBuf.IsModified() && !m_ltBuf.GetReadOnly())
+       if (m_ptBuf[0]->IsModified() && !m_ptBuf[0]->GetReadOnly())
        {
                // (why we don't use return value of DoSave)
                // DoSave will return TRUE if it wrote to something successfully
                // but we have to know if it overwrote the original file
                BOOL bSaveOriginal = FALSE;
-               DoSave(m_filePaths.GetLeft(), bSaveOriginal, TRUE );
+               DoSave(m_filePaths.GetLeft(), bSaveOriginal, 0);
                if (bSaveOriginal)
                        bLChangedOriginal = TRUE;
        }
 
-       if (m_rtBuf.IsModified() && !m_rtBuf.GetReadOnly())
+       if (m_ptBuf[1]->IsModified() && !m_ptBuf[1]->GetReadOnly())
        {
                // See comments above for left case
                BOOL bSaveOriginal = FALSE;
-               DoSave(m_filePaths.GetRight(), bSaveOriginal, FALSE);
+               DoSave(m_filePaths.GetRight(), bSaveOriginal, 1);
                if (bSaveOriginal)
                        bRChangedOriginal = TRUE;
        }
@@ -1920,7 +1899,7 @@ void CMergeDoc::OnFileSave()
                // If DirDoc contains diffs
                if (m_pDirDoc->HasDiffs())
                {
-                       if (m_bLeftEditAfterRescan || m_bRightEditAfterRescan)
+                       if (m_bEditAfterRescan[0] || m_bEditAfterRescan[1])
                                FlushAndRescan(FALSE);
 
                        BOOL bIdentical = !m_diffList.HasSignificantDiffs(); // True if status should be set to identical
@@ -1938,10 +1917,10 @@ void CMergeDoc::OnFileSaveLeft()
        BOOL bLSaveSuccess = FALSE;
        BOOL bLModified = FALSE;
 
-       if (m_ltBuf.IsModified() && !m_ltBuf.GetReadOnly())
+       if (m_ptBuf[0]->IsModified() && !m_ptBuf[0]->GetReadOnly())
        {
                bLModified = TRUE;
-               DoSave(m_filePaths.GetLeft(), bLSaveSuccess, TRUE );
+               DoSave(m_filePaths.GetLeft(), bLSaveSuccess, 0);
        }
 
        // If file were modified and saving succeeded,
@@ -1951,7 +1930,7 @@ void CMergeDoc::OnFileSaveLeft()
                // If DirDoc contains compare results
                if (m_pDirDoc->HasDiffs())
                {
-                       if (m_bLeftEditAfterRescan || m_bRightEditAfterRescan)
+                       if (m_bEditAfterRescan[0] || m_bEditAfterRescan[1])
                                FlushAndRescan(FALSE);
 
                        BOOL bIdentical = !m_diffList.HasSignificantDiffs(); // True if status should be set to identical
@@ -1969,10 +1948,10 @@ void CMergeDoc::OnFileSaveRight()
        BOOL bRSaveSuccess = FALSE;
        BOOL bRModified = FALSE;
 
-       if (m_rtBuf.IsModified() && !m_rtBuf.GetReadOnly())
+       if (m_ptBuf[1]->IsModified() && !m_ptBuf[1]->GetReadOnly())
        {
                bRModified = TRUE;
-               DoSave(m_filePaths.GetRight(), bRSaveSuccess, FALSE);
+               DoSave(m_filePaths.GetRight(), bRSaveSuccess, 1);
        }
 
        // If file were modified and saving succeeded,
@@ -1982,7 +1961,7 @@ void CMergeDoc::OnFileSaveRight()
                // If DirDoc contains compare results
                if (m_pDirDoc->HasDiffs())
                {
-                       if (m_bLeftEditAfterRescan || m_bRightEditAfterRescan)
+                       if (m_bEditAfterRescan[0] || m_bEditAfterRescan[1])
                                FlushAndRescan(FALSE);
 
                        BOOL bIdentical = !m_diffList.HasSignificantDiffs(); // True if status should be set to identical
@@ -1998,7 +1977,7 @@ void CMergeDoc::OnFileSaveRight()
 void CMergeDoc::OnFileSaveAsLeft()
 {
        BOOL bSaveResult = FALSE;
-       DoSaveAs(m_filePaths.GetLeft(), bSaveResult, TRUE);
+       DoSaveAs(m_filePaths.GetLeft(), bSaveResult, 0);
 }
 
 /**
@@ -2007,7 +1986,7 @@ void CMergeDoc::OnFileSaveAsLeft()
 void CMergeDoc::OnFileSaveAsRight()
 {
        BOOL bSaveResult = FALSE;
-       DoSaveAs(m_filePaths.GetRight(), bSaveResult, FALSE);
+       DoSaveAs(m_filePaths.GetRight(), bSaveResult, 1);
 }
 
 /**
@@ -2090,14 +2069,14 @@ void CMergeDoc::PrimeTextBuffers()
        }
 
        // resize m_aLines once for each view
-       UINT lcount0 = m_ltBuf.GetLineCount();
-       UINT lcount1 = m_rtBuf.GetLineCount();
+       UINT lcount0 = m_ptBuf[0]->GetLineCount();
+       UINT lcount1 = m_ptBuf[1]->GetLineCount();
        UINT lcount0new = lcount0 + LeftExtras;
        UINT lcount1new = lcount1 + RightExtras;
 // this ASSERT may be false because of empty last line (see function's note)
 //     ASSERT(lcount0new == lcount1new);
-       m_ltBuf.m_aLines.SetSize(lcount0new);
-       m_rtBuf.m_aLines.SetSize(lcount1new);
+       m_ptBuf[0]->m_aLines.SetSize(lcount0new);
+       m_ptBuf[1]->m_aLines.SetSize(lcount1new);
 
        // walk the diff list backward, move existing lines to proper place,
        // add ghost lines, and set flags
@@ -2113,8 +2092,8 @@ void CMergeDoc::PrimeTextBuffers()
                // But matched lines after last diff may differ because of empty last line (see function's note)
                if (nDiff < nDiffCount - 1)
                        ASSERT(nline0 == nline1);
-               m_ltBuf.MoveLine(curDiff.end0+1, lcount0-1, lcount0new-nline0);
-               m_rtBuf.MoveLine(curDiff.end1+1, lcount1-1, lcount1new-nline1);
+               m_ptBuf[0]->MoveLine(curDiff.end0+1, lcount0-1, lcount0new-nline0);
+               m_ptBuf[1]->MoveLine(curDiff.end1+1, lcount1-1, lcount1new-nline1);
                lcount0new -= nline0;
                lcount1new -= nline1;
                lcount0 -= nline0;
@@ -2129,30 +2108,30 @@ void CMergeDoc::PrimeTextBuffers()
                if (nextra > 0) 
                {
                        // more lines on the left
-                       m_ltBuf.MoveLine(curDiff.begin0, curDiff.end0, lcount0new-nline0);
-                       m_rtBuf.MoveLine(curDiff.begin1, curDiff.end1, lcount1new-nline0);
-                       m_rtBuf.SetEmptyLine(lcount1new - nextraAbs, nextraAbs);
+                       m_ptBuf[0]->MoveLine(curDiff.begin0, curDiff.end0, lcount0new-nline0);
+                       m_ptBuf[1]->MoveLine(curDiff.begin1, curDiff.end1, lcount1new-nline0);
+                       m_ptBuf[1]->SetEmptyLine(lcount1new - nextraAbs, nextraAbs);
                        for (int i = 1; i <= nextraAbs; i++)
-                               m_rtBuf.SetLineFlag(lcount1new-i, LF_GHOST, TRUE, FALSE, FALSE);
+                               m_ptBuf[1]->SetLineFlag(lcount1new-i, LF_GHOST, TRUE, FALSE, FALSE);
                        lcount0new -= nline0;
                        lcount1new -= nline0;
                }
                else if (nextra < 0) 
                {
                        // more lines on the right
-                       m_ltBuf.MoveLine(curDiff.begin0, curDiff.end0, lcount0new-nline1);
-                       m_rtBuf.MoveLine(curDiff.begin1, curDiff.end1, lcount1new-nline1);
-                       m_ltBuf.SetEmptyLine(lcount0new - nextraAbs, nextraAbs);
+                       m_ptBuf[0]->MoveLine(curDiff.begin0, curDiff.end0, lcount0new-nline1);
+                       m_ptBuf[1]->MoveLine(curDiff.begin1, curDiff.end1, lcount1new-nline1);
+                       m_ptBuf[0]->SetEmptyLine(lcount0new - nextraAbs, nextraAbs);
                        for (int i = 1; i <= nextraAbs; i++)
-                               m_ltBuf.SetLineFlag(lcount0new-i, LF_GHOST, TRUE, FALSE, FALSE);
+                               m_ptBuf[0]->SetLineFlag(lcount0new-i, LF_GHOST, TRUE, FALSE, FALSE);
                        lcount0new -= nline1;
                        lcount1new -= nline1;
                }
                else 
                {
                        // same number of lines
-                       m_ltBuf.MoveLine(curDiff.begin0, curDiff.end0, lcount0new-nline0);
-                       m_rtBuf.MoveLine(curDiff.begin1, curDiff.end1, lcount1new-nline1);
+                       m_ptBuf[0]->MoveLine(curDiff.begin0, curDiff.end0, lcount0new-nline0);
+                       m_ptBuf[1]->MoveLine(curDiff.begin1, curDiff.end1, lcount1new-nline1);
                        lcount0new -= nline0;
                        lcount1new -= nline1;
                }
@@ -2178,7 +2157,7 @@ void CMergeDoc::PrimeTextBuffers()
                        // flag lines
                        {
                                for (UINT i = curDiff.dbegin0 ; i <= curDiff.dend0; i++)
-                                       m_ltBuf.SetLineFlag(i, LF_DIFF, TRUE, FALSE, FALSE);
+                                       m_ptBuf[0]->SetLineFlag(i, LF_DIFF, TRUE, FALSE, FALSE);
                                // blanks are already inserted (and flagged) to compensate for diff on other side
                        }
                        break;
@@ -2195,7 +2174,7 @@ void CMergeDoc::PrimeTextBuffers()
                        // flag lines
                        {
                                for (UINT i = curDiff.dbegin1 ; i <= curDiff.dend1 ; i++)
-                                       m_rtBuf.SetLineFlag(i, LF_DIFF, TRUE, FALSE, FALSE);
+                                       m_ptBuf[1]->SetLineFlag(i, LF_DIFF, TRUE, FALSE, FALSE);
                                // blanks are already inserted (and flagged) to compensate for diff on other side
                        }
                        break;
@@ -2228,14 +2207,14 @@ void CMergeDoc::PrimeTextBuffers()
                                        {
                                                // set diff or trivial flag
                                                DWORD dflag = (curDiff.op == OP_DIFF) ? LF_DIFF : LF_TRIVIAL;
-                                               m_ltBuf.SetLineFlag(i, dflag, TRUE, FALSE, FALSE);
+                                               m_ptBuf[0]->SetLineFlag(i, dflag, TRUE, FALSE, FALSE);
                                        }
                                        else
                                        {
                                                // ghost lines are already inserted (and flagged)
                                                // ghost lines opposite to trivial lines are ghost and trivial
                                                if (curDiff.op == OP_TRIVIAL)
-                                                       m_ltBuf.SetLineFlag(i, LF_TRIVIAL, TRUE, FALSE, FALSE);
+                                                       m_ptBuf[0]->SetLineFlag(i, LF_TRIVIAL, TRUE, FALSE, FALSE);
                                        }
                                }
                                // right side
@@ -2245,14 +2224,14 @@ void CMergeDoc::PrimeTextBuffers()
                                        {
                                                // set diff or trivial flag
                                                DWORD dflag = (curDiff.op == OP_DIFF) ? LF_DIFF : LF_TRIVIAL;
-                                               m_rtBuf.SetLineFlag(i, dflag, TRUE, FALSE, FALSE);
+                                               m_ptBuf[1]->SetLineFlag(i, dflag, TRUE, FALSE, FALSE);
                                        }
                                        else
                                        {
                                                // ghost lines are already inserted (and flagged)
                                                // ghost lines opposite to trivial lines are ghost and trivial
                                                if (curDiff.op == OP_TRIVIAL)
-                                                       m_rtBuf.SetLineFlag(i, LF_TRIVIAL, TRUE, FALSE, FALSE);
+                                                       m_ptBuf[1]->SetLineFlag(i, LF_TRIVIAL, TRUE, FALSE, FALSE);
                                        }
                                }
                        }
@@ -2269,8 +2248,8 @@ void CMergeDoc::PrimeTextBuffers()
        // but now we keep all diffs, including trivial diffs
 
 
-       m_ltBuf.FinishLoading();
-       m_rtBuf.FinishLoading();
+       m_ptBuf[0]->FinishLoading();
+       m_ptBuf[1]->FinishLoading();
 }
 
 /**
@@ -2278,11 +2257,11 @@ void CMergeDoc::PrimeTextBuffers()
  * @param [in] szPath File to check
  * @param [in] dfi Previous fileinfo of file
  * @param [in] bSave If TRUE Compare to last save-info, else to rescan-info
- * @param [in] bLeft If TRUE, compare left file, else right file
+ * @param [in] nBuffer Index (0-based) of buffer
  * @return TRUE if file is changed.
  */
 BOOL CMergeDoc::IsFileChangedOnDisk(LPCTSTR szPath, DiffFileInfo &dfi,
-       BOOL bSave, BOOL bLeft)
+       BOOL bSave, int nBuffer)
 {
        DiffFileInfo *fileInfo = NULL;
        BOOL bFileChanged = FALSE;
@@ -2291,20 +2270,10 @@ BOOL CMergeDoc::IsFileChangedOnDisk(LPCTSTR szPath, DiffFileInfo &dfi,
        if (bIgnoreSmallDiff)
                tolerance = SmallTimeDiff; // From MainFrm.h
 
-       if (bLeft)
-       {
-               if (bSave)
-                       fileInfo = &m_leftSaveFileInfo;
-               else
-                       fileInfo = &m_leftRescanFileInfo;
-       }
+       if (bSave)
+               fileInfo = m_pSaveFileInfo[nBuffer];
        else
-       {
-               if (bSave)
-                       fileInfo = &m_rightSaveFileInfo;
-               else
-                       fileInfo = &m_rightRescanFileInfo;
-       }
+               fileInfo = m_pRescanFileInfo[nBuffer];
 
        dfi.Update(szPath);
 
@@ -2335,8 +2304,8 @@ BOOL CMergeDoc::IsFileChangedOnDisk(LPCTSTR szPath, DiffFileInfo &dfi,
  */
 BOOL CMergeDoc::SaveHelper(BOOL bAllowCancel)
 {
-       const BOOL bLModified = m_ltBuf.IsModified();
-       const BOOL bRModified = m_rtBuf.IsModified();
+       const BOOL bLModified = m_ptBuf[0]->IsModified();
+       const BOOL bRModified = m_ptBuf[1]->IsModified();
        BOOL result = TRUE;
        BOOL bLSaveSuccess = FALSE;
        BOOL bRSaveSuccess = FALSE;
@@ -2351,23 +2320,23 @@ BOOL CMergeDoc::SaveHelper(BOOL bAllowCancel)
        if (!m_filePaths.GetLeft().IsEmpty())
                dlg.m_sLeftFile = m_filePaths.GetLeft();
        else
-               dlg.m_sLeftFile = m_strLeftDesc;
+               dlg.m_sLeftFile = m_strDesc[0];
        if (!m_filePaths.GetRight().IsEmpty())
                dlg.m_sRightFile = m_filePaths.GetRight();
        else
-               dlg.m_sRightFile = m_strRightDesc;
+               dlg.m_sRightFile = m_strDesc[1];
 
        if (dlg.DoModal() == IDOK)
        {
                if (bLModified && dlg.m_leftSave == SAVECLOSING_SAVE)
                {
-                       if (!DoSave(m_filePaths.GetLeft(), bLSaveSuccess, TRUE))
+                       if (!DoSave(m_filePaths.GetLeft(), bLSaveSuccess, 0))
                                result = FALSE;
                }
 
                if (bRModified && dlg.m_rightSave == SAVECLOSING_SAVE)
                {
-                       if (!DoSave(m_filePaths.GetRight(), bRSaveSuccess, FALSE))
+                       if (!DoSave(m_filePaths.GetRight(), bRSaveSuccess, 1))
                                result = FALSE;
                }
        }
@@ -2382,7 +2351,7 @@ BOOL CMergeDoc::SaveHelper(BOOL bAllowCancel)
                // If directory compare has results
                if (m_pDirDoc->HasDiffs())
                {
-                       if (m_bLeftEditAfterRescan || m_bRightEditAfterRescan)
+                       if (m_bEditAfterRescan[0] || m_bEditAfterRescan[1])
                                FlushAndRescan(FALSE);
 
                        BOOL bIdentical = !m_diffList.HasSignificantDiffs(); // True if status should be set to identical
@@ -2410,10 +2379,10 @@ void CMergeDoc::RescanIfNeeded(float timeOutInSecond)
  */
 void CMergeDoc::SetMergeViews(CMergeEditView * pLeft, CMergeEditView * pRight)
 {
-       ASSERT(pLeft && !m_pLeftView);
-       m_pLeftView = pLeft;
-       ASSERT(pRight && !m_pRightView);
-       m_pRightView = pRight;
+       ASSERT(pLeft && !m_pView[0]);
+       m_pView[0] = pLeft;
+       ASSERT(pRight && !m_pView[1]);
+       m_pView[1] = pRight;
 }
 
 /**
@@ -2421,10 +2390,10 @@ void CMergeDoc::SetMergeViews(CMergeEditView * pLeft, CMergeEditView * pRight)
  */
 void CMergeDoc::SetMergeDetailViews(CMergeDiffDetailView * pLeft, CMergeDiffDetailView * pRight)
 {
-       ASSERT(pLeft && !m_pLeftDetailView);
-       m_pLeftDetailView = pLeft;
-       ASSERT(pRight && !m_pRightDetailView);
-       m_pRightDetailView = pRight;
+       ASSERT(pLeft && !m_pDetailView[0]);
+       m_pDetailView[0] = pLeft;
+       ASSERT(pRight && !m_pDetailView[1]);
+       m_pDetailView[1] = pRight;
 }
 
 /**
@@ -2441,7 +2410,7 @@ void CMergeDoc::SetDirDoc(CDirDoc * pDirDoc)
  */
 CChildFrame * CMergeDoc::GetParentFrame() 
 {
-       return dynamic_cast<CChildFrame *>(m_pLeftView->GetParentFrame()); 
+       return dynamic_cast<CChildFrame *>(m_pView[0]->GetParentFrame()); 
 }
 
 /**
@@ -2470,28 +2439,20 @@ BOOL CMergeDoc::CloseNow()
 /**
  * @brief Loads file to buffer and shows load-errors
  * @param [in] sFileName File to open
- * @param [in] bLeft Left/right-side file
+ * @param [in] nBuffer Index (0-based) of buffer to load
  * @param [out] readOnly whether file is read-only
  * @param [in] codepage relevant 8-bit codepage if any (0 if none or unknown)
  * @return Tells if files were loaded succesfully
  * @sa CMergeDoc::OpenDocs()
  **/
-int CMergeDoc::LoadFile(CString sFileName, BOOL bLeft, BOOL & readOnly, int codepage)
+int CMergeDoc::LoadFile(CString sFileName, int nBuffer, BOOL & readOnly, int codepage)
 {
        CDiffTextBuffer *pBuf;
        CString sError;
        int retVal = FRESULT_ERROR;
 
-       if (bLeft)
-       {
-               pBuf = &m_ltBuf;
-               m_filePaths.SetLeft(sFileName);
-       }
-       else
-       {
-               pBuf = &m_rtBuf;
-               m_filePaths.SetRight(sFileName);
-       }
+       pBuf = m_ptBuf[nBuffer];
+       nBuffer == 0 ? m_filePaths.SetLeft(sFileName) : m_filePaths.SetRight(sFileName);
 
        int nCrlfStyle = CRLF_STYLE_AUTOMATIC;
        CString sOpenError;
@@ -2564,14 +2525,14 @@ CMergeDoc::OpenDocs(CString sLeftFile, CString sRightFile,
 
        // Prevent displaying views during LoadFile
        // Note : attach buffer again only if both loads succeed
-       m_pLeftView->DetachFromBuffer();
-       m_pRightView->DetachFromBuffer();
-       m_pLeftDetailView->DetachFromBuffer();
-       m_pRightDetailView->DetachFromBuffer();
+       m_pView[0]->DetachFromBuffer();
+       m_pView[1]->DetachFromBuffer();
+       m_pDetailView[0]->DetachFromBuffer();
+       m_pDetailView[1]->DetachFromBuffer();
 
        // free the buffers
-       m_ltBuf.FreeAll ();
-       m_rtBuf.FreeAll ();
+       m_ptBuf[0]->FreeAll ();
+       m_ptBuf[1]->FreeAll ();
 
        // build the text being filtered, "|" separates files as it is forbidden in filenames
        m_strBothFilenames = sLeftFile + _T("|") + sRightFile;
@@ -2581,26 +2542,26 @@ CMergeDoc::OpenDocs(CString sLeftFile, CString sRightFile,
        if (!sLeftFile.IsEmpty())
        {
                if (mf->m_strLeftDesc.IsEmpty())
-                       m_nLeftBufferType = BUFFER_NORMAL;
+                       m_nBufferType[0] = BUFFER_NORMAL;
                else
                {
-                       m_nLeftBufferType = BUFFER_NORMAL_NAMED;
-                       m_strLeftDesc = mf->m_strLeftDesc;
+                       m_nBufferType[0] = BUFFER_NORMAL_NAMED;
+                       m_strDesc[0] = mf->m_strLeftDesc;
                        mf->m_strLeftDesc.Empty();
                }
 
-               m_leftSaveFileInfo.Update(sLeftFile);
-               m_leftRescanFileInfo.Update(sLeftFile);
+               m_pSaveFileInfo[0]->Update(sLeftFile);
+               m_pRescanFileInfo[0]->Update(sLeftFile);
 
                // Load left side file
-               nLeftSuccess = LoadFile(sLeftFile, TRUE, bROLeft, cpleft);
+               nLeftSuccess = LoadFile(sLeftFile, 0, bROLeft, cpleft);
        }
        else
        {
-               m_nLeftBufferType = BUFFER_UNNAMED;
+               m_nBufferType[0] = BUFFER_UNNAMED;
 
-               m_ltBuf.InitNew();
-               m_strLeftDesc = mf->m_strLeftDesc;
+               m_ptBuf[0]->InitNew();
+               m_strDesc[0] = mf->m_strLeftDesc;
                nLeftSuccess = FRESULT_OK;
        }
        
@@ -2609,31 +2570,31 @@ CMergeDoc::OpenDocs(CString sLeftFile, CString sRightFile,
        if (!sRightFile.IsEmpty())
        {
                if (mf->m_strRightDesc.IsEmpty())
-                       m_nRightBufferType = BUFFER_NORMAL;
+                       m_nBufferType[1] = BUFFER_NORMAL;
                else
                {
-                       m_nRightBufferType = BUFFER_NORMAL_NAMED;
-                       m_strRightDesc = mf->m_strRightDesc;
+                       m_nBufferType[1] = BUFFER_NORMAL_NAMED;
+                       m_strDesc[1] = mf->m_strRightDesc;
                        mf->m_strRightDesc.Empty();
                }
 
-               m_rightSaveFileInfo.Update(sRightFile);
-               m_rightRescanFileInfo.Update(sRightFile);
+               m_pSaveFileInfo[1]->Update(sRightFile);
+               m_pRescanFileInfo[1]->Update(sRightFile);
                if (nLeftSuccess == FRESULT_OK || nLeftSuccess == FRESULT_BINARY)
-                       nRightSuccess = LoadFile(sRightFile, FALSE, bRORight, cpright);
+                       nRightSuccess = LoadFile(sRightFile, 1, bRORight, cpright);
        }
        else
        {
-               m_nRightBufferType = BUFFER_UNNAMED;
+               m_nBufferType[1] = BUFFER_UNNAMED;
 
-               m_rtBuf.InitNew();
-               m_strRightDesc = mf->m_strRightDesc;
+               m_ptBuf[1]->InitNew();
+               m_strDesc[1] = mf->m_strRightDesc;
                nRightSuccess = FRESULT_OK;
        }
 
        // scratchpad : we don't call LoadFile, so
        // we need to initialize the unpacker as a "do nothing" one
-       if (m_nLeftBufferType == BUFFER_UNNAMED && m_nRightBufferType == BUFFER_UNNAMED)
+       if (m_nBufferType[0] == BUFFER_UNNAMED && m_nBufferType[1] == BUFFER_UNNAMED)
                m_pInfoUnpacker->Initialize(PLUGIN_MANUAL);
 
        // Bail out if either side failed
@@ -2648,24 +2609,24 @@ CMergeDoc::OpenDocs(CString sLeftFile, CString sRightFile,
        }
 
        // Now buffers data are valid
-       m_pLeftView->AttachToBuffer();
-       m_pRightView->AttachToBuffer();
-       m_pLeftDetailView->AttachToBuffer();
-       m_pRightDetailView->AttachToBuffer();
+       m_pView[0]->AttachToBuffer();
+       m_pView[1]->AttachToBuffer();
+       m_pDetailView[0]->AttachToBuffer();
+       m_pDetailView[1]->AttachToBuffer();
 
-       m_pLeftView->SetColorContext(mf->m_pSyntaxColors);
-       m_pRightView->SetColorContext(mf->m_pSyntaxColors);
-       m_pLeftDetailView->SetColorContext(mf->m_pSyntaxColors);
-       m_pRightDetailView->SetColorContext(mf->m_pSyntaxColors);
+       m_pView[0]->SetColorContext(mf->m_pSyntaxColors);
+       m_pView[1]->SetColorContext(mf->m_pSyntaxColors);
+       m_pDetailView[0]->SetColorContext(mf->m_pSyntaxColors);
+       m_pDetailView[1]->SetColorContext(mf->m_pSyntaxColors);
 
        // Set read-only statuses
-       m_ltBuf.SetReadOnly(bROLeft);
-       m_rtBuf.SetReadOnly(bRORight);
+       m_ptBuf[0]->SetReadOnly(bROLeft);
+       m_ptBuf[1]->SetReadOnly(bRORight);
 
        // Check the EOL sensitivity option (do it before Rescan)
        DIFFOPTIONS diffOptions = {0};
        m_diffWrapper.GetOptions(&diffOptions);
-       if (m_ltBuf.GetCRLFMode() != m_rtBuf.GetCRLFMode() &&
+       if (m_ptBuf[0]->GetCRLFMode() != m_ptBuf[1]->GetCRLFMode() &&
                !mf->m_options.GetBool(OPT_ALLOW_MIXED_EOL) && diffOptions.bEolSensitive)
        {
                // Options and files not are not compatible :
@@ -2775,8 +2736,8 @@ CMergeDoc::OpenDocs(CString sLeftFile, CString sRightFile,
                pRight->SetDisableBSAtSOL(FALSE);
                
                // set the frame window header
-               UpdateHeaderPath(TRUE);
-               UpdateHeaderPath(FALSE);
+               UpdateHeaderPath(0);
+               UpdateHeaderPath(1);
 
                // Set tab type (tabs/spaces)
                BOOL bInsertTabs = (mf->m_options.GetInt(OPT_TAB_TYPE) == 0);
@@ -2785,8 +2746,8 @@ CMergeDoc::OpenDocs(CString sLeftFile, CString sRightFile,
 
                // Inform user that files are identical
                // Don't show message if new buffers created
-               if (bIdentical && (m_nLeftBufferType == BUFFER_NORMAL ||
-                       m_nRightBufferType == BUFFER_NORMAL))
+               if (bIdentical && (m_nBufferType[0] == BUFFER_NORMAL ||
+                       m_nBufferType[1] == BUFFER_NORMAL))
                {
                        ShowRescanError(nRescanResult, bBinary, bIdentical);
                }
@@ -2804,8 +2765,8 @@ CMergeDoc::OpenDocs(CString sLeftFile, CString sRightFile,
 
        // Force repaint of location pane to update it in case we had some warning
        // dialog visible and it got painted before files were loaded
-       if (m_pLeftView)
-               m_pLeftView->RepaintLocationPane();
+       if (m_pView[0])
+               m_pView[0]->RepaintLocationPane();
 
        return OPENRESULTS_SUCCESS;
 }
@@ -2886,57 +2847,43 @@ void CMergeDoc::RefreshOptions()
        m_diffWrapper.SetOptions(&options);
 
        // Refresh view options
-       m_pLeftView->RefreshOptions();
-       m_pRightView->RefreshOptions();
+       m_pView[0]->RefreshOptions();
+       m_pView[1]->RefreshOptions();
 }
 
 /**
  * @brief Write path and filename to headerbar
  * @note SetText() does not repaint unchanged text
  */
-void CMergeDoc::UpdateHeaderPath(BOOL bLeft)
+void CMergeDoc::UpdateHeaderPath(int pane)
 {
        CChildFrame *pf = GetParentFrame();
        ASSERT(pf);
-       int nPane = 0;
        CString sText;
        BOOL bChanges = FALSE;
 
-       if (bLeft)
+       if (m_nBufferType[pane] == BUFFER_UNNAMED ||
+               m_nBufferType[pane] == BUFFER_NORMAL_NAMED)
        {
-               if (m_nLeftBufferType == BUFFER_UNNAMED ||
-                       m_nLeftBufferType == BUFFER_NORMAL_NAMED)
-               {
-                       sText = m_strLeftDesc;
-               }
-               else
-               {
-                       sText = m_filePaths.GetLeft();
-                       m_pDirDoc->ApplyLeftDisplayRoot(sText);
-               }
-               bChanges = m_ltBuf.IsModified();
-               nPane = 0;
+               sText = m_strDesc[pane];
        }
        else
        {
-               if (m_nRightBufferType == BUFFER_UNNAMED ||
-                       m_nRightBufferType == BUFFER_NORMAL_NAMED)
+               sText = m_filePaths.GetPath(pane);
+               if (m_pDirDoc)
                {
-                       sText = m_strRightDesc;
-               }
-               else
-               {
-                       sText = m_filePaths.GetRight();
-                       m_pDirDoc->ApplyRightDisplayRoot(sText);
+                       if (pane == 0)
+                               m_pDirDoc->ApplyLeftDisplayRoot(sText);
+                       else
+                               m_pDirDoc->ApplyRightDisplayRoot(sText);
                }
-               bChanges = m_rtBuf.IsModified();
-               nPane = 1;
        }
+       bChanges = m_ptBuf[pane]->IsModified();
 
        if (bChanges)
                sText.Insert(0, _T("* "));
 
-       pf->GetHeaderInterface()->SetText(nPane, sText);
+       pf->GetHeaderInterface()->SetText(pane, sText);
 
        SetTitle(NULL);
 }
@@ -2944,12 +2891,11 @@ void CMergeDoc::UpdateHeaderPath(BOOL bLeft)
 /**
  * @brief Paint differently the headerbar of the active view
  */
-void CMergeDoc::UpdateHeaderActivity(BOOL bLeft, BOOL bActivate)
+void CMergeDoc::UpdateHeaderActivity(int pane, BOOL bActivate)
 {
        CChildFrame *pf = GetParentFrame();
        ASSERT(pf);
-       int nPane = (bLeft) ? 0 : 1;
-       pf->GetHeaderInterface()->SetActive(nPane, bActivate);
+       pf->GetHeaderInterface()->SetActive(pane, bActivate);
 }
 
 /**
@@ -2982,12 +2928,9 @@ void CMergeDoc::SetDetectMovedBlocks(BOOL bDetectMovedBlocks)
        FlushAndRescan();
 }
 
-void CMergeDoc::SetEditedAfterRescan(BOOL bLeft)
+void CMergeDoc::SetEditedAfterRescan(int nBuffer)
 {
-       if (bLeft)
-               m_bLeftEditAfterRescan = TRUE;
-       else
-               m_bRightEditAfterRescan = TRUE;
+       m_bEditAfterRescan[nBuffer] = TRUE;
 }
 
 /**
@@ -3002,8 +2945,8 @@ void CMergeDoc::SetTitle(LPCTSTR lpszTitle)
                sTitle = lpszTitle;
        else
        {
-               if (!m_strLeftDesc.IsEmpty())
-                       sTitle += m_strLeftDesc;
+               if (!m_strDesc[0].IsEmpty())
+                       sTitle += m_strDesc[0];
                else
                {
                        CString file;
@@ -3019,8 +2962,8 @@ void CMergeDoc::SetTitle(LPCTSTR lpszTitle)
 
                sTitle += pszSeparator;
 
-               if (!m_strRightDesc.IsEmpty())
-                       sTitle += m_strRightDesc;
+               if (!m_strDesc[1].IsEmpty())
+                       sTitle += m_strDesc[1];
                else
                {
                        CString file;
@@ -3045,35 +2988,29 @@ void CMergeDoc::UpdateResources()
        CString str;
 
        VERIFY(str.LoadString(IDS_EMPTY_LEFT_FILE));
-       m_strLeftDesc = str;
+       m_strDesc[0] = str;
        VERIFY(str.LoadString(IDS_EMPTY_RIGHT_FILE));
-       m_strRightDesc = str;
-       UpdateHeaderPath(TRUE);
-       UpdateHeaderPath(FALSE);
+       m_strDesc[1] = str;
+       UpdateHeaderPath(0);
+       UpdateHeaderPath(1);
 
        GetParentFrame()->UpdateResources();
        GetLeftView()->UpdateResources();
        GetRightView()->UpdateResources();
 }
 
-// Lookup named property and return as int
-BOOL CMergeDoc::GetOptionInt(LPCTSTR name) const
-{
-       // Currently options are held by the main frame, in a subobject called m_options
-       return mf->m_options.GetInt(name);
-}
 
 // Lookup named property and return as BOOL
 BOOL CMergeDoc::GetOptionBool(LPCTSTR name) const
 {
        // Currently options are held by the main frame, in a subobject called m_options
-       return mf->m_options.GetBool(name);
+       return mf->m_options.GetInt(name);
 }
 
 // Return current word breaking break type setting (whitespace only or include punctuation)
 bool CMergeDoc::GetBreakType() const
 {
-       return !!GetOptionInt(OPT_BREAK_TYPE);
+       return !!GetOptionBool(OPT_BREAK_TYPE);
 }
 
 // Return true to do line diff colors at the byte level (false to do them at word level)
@@ -3083,3 +3020,32 @@ bool CMergeDoc::GetByteColoringOption() const
        return !GetOptionBool(OPT_BREAK_ON_WORDS);
 }
 
+/// Swap files and update views
+void CMergeDoc::SwapFiles()
+{
+       // Swap buffers and so on
+       swap<CDiffTextBuffer *>(&m_ptBuf[0], &m_ptBuf[1]);
+       swap<DiffFileInfo *>(&m_pSaveFileInfo[0], &m_pSaveFileInfo[1]);
+       swap<DiffFileInfo *>(&m_pRescanFileInfo[0], &m_pRescanFileInfo[1]);
+       swap<BUFFERTYPE>(&m_nBufferType[0], &m_nBufferType[1]);
+       swap<BOOL>(&m_bEditAfterRescan[0], &m_bEditAfterRescan[1]);
+       swap<CString>(&m_strDesc[0], &m_strDesc[1]);
+
+       CString tmpString = m_filePaths.GetLeft();
+       m_filePaths.SetLeft(m_filePaths.GetRight());
+       m_filePaths.SetRight(tmpString);
+       
+       m_diffList.Swap();
+
+       // Reattach text buffers
+       m_pView[0]->ReAttachToBuffer(m_ptBuf[0]);
+       m_pView[1]->ReAttachToBuffer(m_ptBuf[1]);
+       m_pDetailView[0]->ReAttachToBuffer(m_ptBuf[0]);
+       m_pDetailView[1]->ReAttachToBuffer(m_ptBuf[1]);
+
+       // Update views
+       UpdateHeaderPath(0);
+       UpdateHeaderPath(1);
+
+       UpdateAllViews(NULL);
+}
index ec60884..5a67416 100644 (file)
@@ -127,7 +127,7 @@ class CDiffTextBuffer : public CGhostTextBuffer
                friend class CMergeDoc;
 private :
                CMergeDoc * m_pOwnerDoc;
-               BOOL m_bIsLeft; /**< Left/Right side */
+               int m_nThisPane; /**< Left/Right side */
                BOOL FlagIsSet(UINT line, DWORD flag);
                CString m_strTempPath;
                int unpackerSubcode;
@@ -165,7 +165,7 @@ public :
                int getCodepage() const { return m_codepage; }
                void setCodepage(int value) { m_codepage = value; }
 
-               CDiffTextBuffer(CMergeDoc * pDoc, BOOL bLeft);
+               CDiffTextBuffer(CMergeDoc * pDoc, int pane);
 
                // If line has text (excluding eol), set strLine to text (excluding eol)
                BOOL GetLine(int nLineIndex, CString &strLine);
@@ -192,8 +192,7 @@ public :
 
 // Begin declaration of CMergeDoc
 
-       CDiffTextBuffer m_ltBuf; /**< Left side text buffer */
-       CDiffTextBuffer m_rtBuf; /**< Right side text buffer */
+       CDiffTextBuffer *m_ptBuf[2]; /**< Left/Right side text buffer */
 
 protected: // create from serialization only
        CMergeDoc();
@@ -202,41 +201,39 @@ protected: // create from serialization only
        
        // Operations
 public:        
-       DiffFileInfo m_leftSaveFileInfo;
-       DiffFileInfo m_rightSaveFileInfo;
-       DiffFileInfo m_leftRescanFileInfo;
-       DiffFileInfo m_rightRescanFileInfo;
+       DiffFileInfo *m_pSaveFileInfo[2];
+       DiffFileInfo *m_pRescanFileInfo[2];
        DiffList m_diffList;
        UINT m_nTrivialDiffs; /**< Amount of trivial (ignored) diffs */
        PathContext m_filePaths; /**< Filepaths for this document */
        /// String of concatenated filenames as text to apply plugins filter to
        CString m_strBothFilenames;
 
-       void UpdateHeaderPath(BOOL bLeft);
-       void UpdateHeaderActivity(BOOL bLeft, BOOL bActivate);
+       void UpdateHeaderPath(int pane);
+       void UpdateHeaderActivity(int pane, BOOL bActivate);
        void RefreshOptions();
        void UpdateResources();
        OPENRESULTS_TYPE OpenDocs(CString sLeftFile, CString sRightFile,
                BOOL bROLeft, BOOL bRORight, int cpleft, int cpright);
        void CompareBinaries(CString sLeftFile, CString sRightFile, int nLeftSuccess, int nRightSuccess);
-       int LoadFile(CString sFileName, BOOL bLeft, BOOL & readOnly, int codepage);
+       int LoadFile(CString sFileName, int nBuffer, BOOL & readOnly, int codepage);
        void RescanIfNeeded(float timeOutInSecond);
        int Rescan(BOOL &bBinary, BOOL &bIdentical, BOOL bForced = FALSE);
        void ShowRescanError(int nRescanResult, BOOL bBinary, BOOL bIdentical);
        void AddUndoAction(UINT nBegin, UINT nEnd, UINT nDiff, int nBlanks, BOOL bInsert, CMergeEditView *pList);
        BOOL Undo();
-       void CopyAllList(bool bSrcLeft, bool bCurrentLeft);
-       void CopyMultipleList(bool bSrcLeft, bool bCurrentLeft, int firstDiff, int lastDiff);
+       void CopyAllList(int srcPane, int dstPane);
+       void CopyMultipleList(int srcPane, int dstPane, int firstDiff, int lastDiff);
        BOOL SanityCheckDiff(DIFFRANGE dr);
-       void ListCopy(bool bSrcLeft, bool bCurrentLeft, bool bGroupWithPrevious = false);
+       void ListCopy(int srcPane, int dstPane, bool bGroupWithPrevious = false);
        BOOL TrySaveAs(CString &strPath, int &nLastErrorCode, CString & sError,
-               BOOL bLeft, PackingInfo * pInfoTempUnpacker);
-       BOOL DoSave(LPCTSTR szPath, BOOL &bSaveSuccess, BOOL bLeft);
-       BOOL DoSaveAs(LPCTSTR szPath, BOOL &bSaveSuccess, BOOL bLeft);
+               int nBuffer, PackingInfo * pInfoTempUnpacker);
+       BOOL DoSave(LPCTSTR szPath, BOOL &bSaveSuccess, int nBuffer);
+       BOOL DoSaveAs(LPCTSTR szPath, BOOL &bSaveSuccess, int nBuffer);
        int RightLineInMovedBlock(int leftLine);
        int LeftLineInMovedBlock(int rightLine);
        void SetDiffViewMode(BOOL bEnable);
-       void SetEditedAfterRescan(BOOL bLeft);
+       void SetEditedAfterRescan(int nBuffer);
 
        void SetUnpacker(PackingInfo * infoUnpacker);
        void SetPrediffer(PrediffingInfo * infoPrediffer);
@@ -246,11 +243,14 @@ public:
        void SetDirDoc(CDirDoc * pDirDoc);
        void DirDocClosing(CDirDoc * pDirDoc);
        BOOL CloseNow();
-
-       CMergeEditView * GetLeftView() const { return m_pLeftView; }
-       CMergeEditView * GetRightView() const { return m_pRightView; }
-       CMergeDiffDetailView * GetLeftDetailView() const { return m_pLeftDetailView; }
-       CMergeDiffDetailView * GetRightDetailView() const { return m_pRightDetailView; }
+       void SwapFiles();
+
+       CMergeEditView * GetLeftView() const { return m_pView[0]; }
+       CMergeEditView * GetRightView() const { return m_pView[1]; }
+       CMergeEditView * GetView(int pane) const { return m_pView[pane]; }
+       CMergeDiffDetailView * GetLeftDetailView() const { return m_pDetailView[0]; }
+       CMergeDiffDetailView * GetRightDetailView() const { return m_pDetailView[1]; }
+       CMergeDiffDetailView * GetDetailView(int pane) const { return m_pDetailView[pane]; }
        CChildFrame * GetParentFrame();
 
        // Overrides
@@ -278,7 +278,7 @@ private:
 // Implementation
 public:
        BOOL IsFileChangedOnDisk(LPCTSTR szPath, DiffFileInfo &dfi,
-               BOOL bSave, BOOL bLeft);
+               BOOL bSave, int nBuffer);
        BOOL SaveHelper(BOOL bAllowCancel);
        std::vector<CMergeEditView*> undoTgt;
        std::vector<CMergeEditView*>::iterator curUndo;
@@ -293,7 +293,6 @@ public:
 
 // implementation methods
 private:
-       BOOL GetOptionInt(LPCTSTR name) const;
        BOOL GetOptionBool(LPCTSTR name) const;
        bool GetBreakType() const;
        bool GetByteColoringOption() const;
@@ -301,23 +300,18 @@ private:
 // Implementation data
 protected:
        int m_nCurDiff; /**< Selected diff, 0-based index, -1 if no diff selected */
-       CMergeEditView * m_pLeftView; /**< Pointer to left view */
-       CMergeEditView * m_pRightView; /**< Pointer to right view */
-       CMergeDiffDetailView * m_pLeftDetailView;
-       CMergeDiffDetailView * m_pRightDetailView;
+       CMergeEditView * m_pView[2]; /**< Pointer to left/right view */
+       CMergeDiffDetailView * m_pDetailView[2];
        CDirDoc * m_pDirDoc;
        BOOL m_bEnableRescan; /**< Automatic rescan enabled/disabled */
        COleDateTime m_LastRescan; /**< Time of last rescan (for delaying) */ 
        CDiffWrapper m_diffWrapper;
        /// information about the file packer/unpacker
        PackingInfo * m_pInfoUnpacker;
-       CString m_strLeftDesc; /**< Left side description text */
-       CString m_strRightDesc; /**< Right side description text */
-       BUFFERTYPE m_nLeftBufferType;
-       BUFFERTYPE m_nRightBufferType;
+       CString m_strDesc[2]; /**< Left/right side description text */
+       BUFFERTYPE m_nBufferType[2];
        BOOL m_bMergingMode; /**< Merging or Edit mode */
-       BOOL m_bLeftEditAfterRescan; /**< Left doc edited after rescanning */
-       BOOL m_bRightEditAfterRescan; /**< Right doc edited after rescanning */
+       BOOL m_bEditAfterRescan[2]; /**< Left/right doc edited after rescanning */
        TempFileContext * m_pTempFiles; /**< Temp files for compared files */
 
 // friend access
index bea6a8f..e3dacd5 100644 (file)
@@ -78,7 +78,7 @@ HighlightDiffRect(CMergeDiffDetailView * pView, const CRect & rc)
 void CMergeDoc::Showlinediff(CMergeEditView * pView, DIFFLEVEL difflvl)
 {
        CRect rc1, rc2;
-       Computelinediff(m_pLeftView, m_pRightView, pView->GetCursorPos().y, &rc1, &rc2, difflvl);
+       Computelinediff(m_pView[0], m_pView[1], pView->GetCursorPos().y, &rc1, &rc2, difflvl);
 
        if (rc1.top == -1 && rc2.top == -1)
        {
@@ -91,8 +91,8 @@ void CMergeDoc::Showlinediff(CMergeEditView * pView, DIFFLEVEL difflvl)
        }
 
        // Actually display selection areas on screen in both edit panels
-       HighlightDiffRect(m_pLeftView, rc1);
-       HighlightDiffRect(m_pRightView, rc2);
+       HighlightDiffRect(m_pView[0], rc1);
+       HighlightDiffRect(m_pView[1], rc2);
 }
 
 /**
@@ -101,7 +101,7 @@ void CMergeDoc::Showlinediff(CMergeEditView * pView, DIFFLEVEL difflvl)
 void CMergeDoc::Showlinediff(CMergeDiffDetailView * pView, DIFFLEVEL difflvl)
 {
        CRect rc1, rc2;
-       Computelinediff(m_pLeftDetailView, m_pRightDetailView, pView->GetCursorPos().y, &rc1, &rc2, difflvl);
+       Computelinediff(m_pDetailView[0], m_pDetailView[1], pView->GetCursorPos().y, &rc1, &rc2, difflvl);
 
        if (rc1.top == -1 && rc2.top == -1)
        {
@@ -114,8 +114,8 @@ void CMergeDoc::Showlinediff(CMergeDiffDetailView * pView, DIFFLEVEL difflvl)
        }
 
        // Actually display selection areas on screen in both detail panels
-       HighlightDiffRect(m_pLeftDetailView, rc1);
-       HighlightDiffRect(m_pRightDetailView, rc2);
+       HighlightDiffRect(m_pDetailView[0], rc1);
+       HighlightDiffRect(m_pDetailView[1], rc2);
 }
 
 /**
@@ -322,14 +322,14 @@ void CMergeDoc::Computelinediff(CCrystalTextView * pView1, CCrystalTextView * pV
  */
 void CMergeDoc::GetWordDiffArray(int nLineIndex, wdiffarray *pworddiffs)
 {
-       if (nLineIndex >= m_pLeftView->GetLineCount()) return;
-       if (nLineIndex >= m_pRightView->GetLineCount()) return;
+       if (nLineIndex >= m_pView[0]->GetLineCount()) return;
+       if (nLineIndex >= m_pView[1]->GetLineCount()) return;
 
        DIFFOPTIONS diffOptions = {0};
        m_diffWrapper.GetOptions(&diffOptions);
 
-       CString str1 = m_pLeftView->GetLineChars(nLineIndex);
-       CString str2 = m_pRightView->GetLineChars(nLineIndex);
+       CString str1 = m_pView[0]->GetLineChars(nLineIndex);
+       CString str2 = m_pView[1]->GetLineChars(nLineIndex);
 
        if (!diffOptions.bEolSensitive)
        {
@@ -353,8 +353,8 @@ void CMergeDoc::GetWordDiffArray(int nLineIndex, wdiffarray *pworddiffs)
        }
 
        // We truncate diffs to remain inside line (ie, to not flag eol characters)
-       int width1 = m_pLeftView->GetLineLength(nLineIndex);
-       int width2 = m_pRightView->GetLineLength(nLineIndex);
+       int width1 = m_pView[0]->GetLineLength(nLineIndex);
+       int width2 = m_pView[1]->GetLineLength(nLineIndex);
 
        // Options that affect comparison
        bool casitive = !diffOptions.bIgnoreCase;
index 28fd46c..bbf5196 100644 (file)
@@ -64,7 +64,7 @@ IMPLEMENT_DYNCREATE(CMergeEditView, CCrystalEditViewEx)
 CMergeEditView::CMergeEditView()
 {
        m_pLocationView = NULL;
-       m_bIsLeft = FALSE;
+       m_nThisPane = 0;
        m_nModifications = 0;
        m_piMergeEditStatus = 0;
        SetParser(&m_xParser);
@@ -180,6 +180,8 @@ BEGIN_MESSAGE_MAP(CMergeEditView, CCrystalEditViewEx)
        ON_COMMAND(ID_FILE_OPEN_REGISTERED, OnOpenFile)
        ON_COMMAND(ID_FILE_OPEN_WITHEDITOR, OnOpenFileWithEditor)
        ON_COMMAND(ID_FILE_OPEN_WITH, OnOpenFileWith)
+       ON_COMMAND(ID_VIEW_SWAPPANES, OnViewSwapPanes)
+       ON_UPDATE_COMMAND_UI(ID_VIEW_LINEDIFFS, OnUpdateViewSwapPanes)
        //}}AFX_MSG_MAP
 END_MESSAGE_MAP()
 
@@ -203,9 +205,7 @@ CMergeDoc* CMergeEditView::GetDocument() // non-debug version is inline
  */
 CCrystalTextBuffer *CMergeEditView::LocateTextBuffer()
 {
-       if (m_bIsLeft)
-               return &GetDocument()->m_ltBuf;
-       return &GetDocument()->m_rtBuf;
+       return GetDocument()->m_ptBuf[m_nThisPane];
 }
 
 /**
@@ -214,7 +214,7 @@ CCrystalTextBuffer *CMergeEditView::LocateTextBuffer()
  */
 void CMergeEditView::DoScroll(UINT code, UINT pos, BOOL bDoScroll)
 {
-       TRACE(_T("Scroll %s: pos=%d\n"), m_bIsLeft? _T("left"):_T("right"), pos);
+       TRACE(_T("Scroll %s: pos=%d\n"), m_nThisPane == 0 ? _T("left"):_T("right"), pos);
        if (bDoScroll && (code == SB_THUMBPOSITION || code == SB_THUMBTRACK))
        {
                ScrollToLine(pos);
@@ -334,7 +334,7 @@ void CMergeEditView::OnActivateView(BOOL bActivate, CView* pActivateView, CView*
        CCrystalEditViewEx::OnActivateView(bActivate, pActivateView, pDeactiveView);
 
        CMergeDoc* pDoc = GetDocument();
-       pDoc->UpdateHeaderActivity(m_bIsLeft, bActivate);
+       pDoc->UpdateHeaderActivity(m_nThisPane, bActivate);
        mf->UpdatePrediffersMenu();
 }
 
@@ -361,16 +361,8 @@ int CMergeEditView::GetAdditionalTextBlocks (int nLineIndex, TEXTBLOCK *pBuf)
        pBuf[0].m_nBgColorIndex = COLORINDEX_NONE;
        for (int i = 0; i < nWordDiffs; i++)
        {
-               if (m_bIsLeft)
-               {
-                       pBuf[1 + i * 2].m_nCharPos = worddiffs[i].start[0];
-                       pBuf[2 + i * 2].m_nCharPos = worddiffs[i].end[0] + 1;
-               }
-               else
-               {
-                       pBuf[1 + i * 2].m_nCharPos = worddiffs[i].start[1];
-                       pBuf[2 + i * 2].m_nCharPos = worddiffs[i].end[1] + 1;
-               }
+               pBuf[1 + i * 2].m_nCharPos = worddiffs[i].start[m_nThisPane];
+               pBuf[2 + i * 2].m_nCharPos = worddiffs[i].end[m_nThisPane] + 1;
                if (lineInCurrentDiff)
                {
                        pBuf[1 + i * 2].m_nColorIndex = COLORINDEX_HIGHLIGHTTEXT1 | COLORINDEX_APPLYFORCE;
@@ -698,8 +690,7 @@ void CMergeEditView::OnEditCopy()
 
        CString text;
 
-       CMergeDoc::CDiffTextBuffer * buffer
-               = m_bIsLeft ? &pDoc->m_ltBuf : &pDoc->m_rtBuf;
+       CMergeDoc::CDiffTextBuffer * buffer = pDoc->m_ptBuf[m_nThisPane];
 
        buffer->GetTextWithoutEmptys(ptSelStart.y, ptSelStart.x,
                ptSelEnd.y, ptSelEnd.x, text);
@@ -720,7 +711,7 @@ void CMergeEditView::OnUpdateEditCopy(CCmdUI* pCmdUI)
  */
 void CMergeEditView::OnEditCut()
 {
-       if (IsReadOnly(m_bIsLeft))
+       if (IsReadOnly(m_nThisPane))
                return;
 
        CPoint ptSelStart, ptSelEnd;
@@ -732,12 +723,8 @@ void CMergeEditView::OnEditCut()
                return;
 
        CString text;
-       if (m_bIsLeft)
-               pDoc->m_ltBuf.GetTextWithoutEmptys(ptSelStart.y, ptSelStart.x,
-                       ptSelEnd.y, ptSelEnd.x, text);
-       else
-               pDoc->m_rtBuf.GetTextWithoutEmptys(ptSelStart.y, ptSelStart.x,
-                       ptSelEnd.y, ptSelEnd.x, text);
+       pDoc->m_ptBuf[m_nThisPane]->GetTextWithoutEmptys(ptSelStart.y, ptSelStart.x,
+               ptSelEnd.y, ptSelEnd.x, text);
 
        PutToClipboard(text);
 
@@ -748,12 +735,8 @@ void CMergeEditView::OnEditCut()
        SetCursorPos(ptCursorPos);
        EnsureVisible(ptCursorPos);
 
-       if (m_bIsLeft)
-               pDoc->m_ltBuf.DeleteText(this, ptSelStart.y, ptSelStart.x, ptSelEnd.y,
-                       ptSelEnd.x, CE_ACTION_CUT);
-       else
-               pDoc->m_rtBuf.DeleteText(this, ptSelStart.y, ptSelStart.x, ptSelEnd.y,
-                       ptSelEnd.x, CE_ACTION_CUT);
+       pDoc->m_ptBuf[m_nThisPane]->DeleteText(this, ptSelStart.y, ptSelStart.x, ptSelEnd.y,
+               ptSelEnd.x, CE_ACTION_CUT);
 
        m_pTextBuffer->SetModified(TRUE);
 }
@@ -763,7 +746,7 @@ void CMergeEditView::OnEditCut()
  */
 void CMergeEditView::OnUpdateEditCut(CCmdUI* pCmdUI)
 {
-       if (!IsReadOnly(m_bIsLeft))
+       if (!IsReadOnly(m_nThisPane))
                CCrystalEditViewEx::OnUpdateEditCut(pCmdUI);
        else
                pCmdUI->Enable(FALSE);
@@ -774,7 +757,7 @@ void CMergeEditView::OnUpdateEditCut(CCmdUI* pCmdUI)
  */
 void CMergeEditView::OnEditPaste()
 {
-       if (IsReadOnly(m_bIsLeft))
+       if (IsReadOnly(m_nThisPane))
                return;
 
        CCrystalEditViewEx::Paste();
@@ -786,7 +769,7 @@ void CMergeEditView::OnEditPaste()
  */
 void CMergeEditView::OnUpdateEditPaste(CCmdUI* pCmdUI)
 {
-       if (!IsReadOnly(m_bIsLeft))
+       if (!IsReadOnly(m_nThisPane))
                CCrystalEditViewEx::OnUpdateEditPaste(pCmdUI);
        else
                pCmdUI->Enable(FALSE);
@@ -801,14 +784,14 @@ void CMergeEditView::OnEditUndo()
        CMergeEditView *tgt = *(pDoc->curUndo-1);
        if(tgt==this)
        {
-               if (IsReadOnly(m_bIsLeft))
+               if (IsReadOnly(m_nThisPane))
                        return;
 
                GetParentFrame()->SetActiveView(this, TRUE);
                if(CCrystalEditViewEx::DoEditUndo())
                {
                        --pDoc->curUndo;
-                       pDoc->UpdateHeaderPath(m_bIsLeft);
+                       pDoc->UpdateHeaderPath(m_nThisPane);
                        pDoc->FlushAndRescan();
 
                        int nAction;
@@ -833,7 +816,7 @@ void CMergeEditView::OnUpdateEditUndo(CCmdUI* pCmdUI)
        if (pDoc->curUndo!=pDoc->undoTgt.begin())
        {
                CMergeEditView *tgt = *(pDoc->curUndo-1);
-               pCmdUI->Enable( !IsReadOnly(tgt->m_bIsLeft));
+               pCmdUI->Enable( !IsReadOnly(tgt->m_nThisPane));
        }
        else
                pCmdUI->Enable(FALSE);
@@ -892,7 +875,7 @@ void CMergeEditView::OnUpdateLastdiff(CCmdUI* pCmdUI)
 void CMergeEditView::OnNextdiff()
 {
        CMergeDoc *pd = GetDocument();
-       int cnt = pd->m_ltBuf.GetLineCount();
+       int cnt = pd->m_ptBuf[0]->GetLineCount();
        if (cnt <= 0)
                return;
 
@@ -956,7 +939,7 @@ void CMergeEditView::OnUpdateNextdiff(CCmdUI* pCmdUI)
 void CMergeEditView::OnPrevdiff()
 {
        CMergeDoc *pd = GetDocument();
-       int cnt = pd->m_ltBuf.GetLineCount();
+       int cnt = pd->m_ptBuf[0]->GetLineCount();
        if (cnt <= 0)
                return;
 
@@ -1107,7 +1090,7 @@ void CMergeEditView::UpdateLineLengths()
 void CMergeEditView::OnL2r()
 {
        // Check that right side is not readonly
-       if (IsReadOnly(FALSE))
+       if (IsReadOnly(1))
                return;
 
        CMergeDoc *pDoc = GetDocument();
@@ -1119,14 +1102,14 @@ void CMergeEditView::OnL2r()
        {
                WaitStatusCursor waitstatus(LoadResString(IDS_STATUS_COPYL2R));
                if (currentDiff != -1 && pDoc->m_diffList.IsDiffSignificant(currentDiff))
-                       pDoc->ListCopy(true, !!m_bIsLeft);
+                       pDoc->ListCopy(0, 1);
                else
-                       pDoc->CopyMultipleList(true, !!m_bIsLeft, firstDiff, lastDiff);
+                       pDoc->CopyMultipleList(0, 1, firstDiff, lastDiff);
        }
        else if (currentDiff != -1 && pDoc->m_diffList.IsDiffSignificant(currentDiff))
        {
                WaitStatusCursor waitstatus(LoadResString(IDS_STATUS_COPYL2R));
-               pDoc->ListCopy(true, !!m_bIsLeft);
+               pDoc->ListCopy(0, 1);
        }
 }
 
@@ -1136,7 +1119,7 @@ void CMergeEditView::OnL2r()
 void CMergeEditView::OnUpdateL2r(CCmdUI* pCmdUI)
 {
        // Check that right side is not readonly
-       if (!IsReadOnly(FALSE))
+       if (!IsReadOnly(1))
        {
                int firstDiff, lastDiff;
                GetFullySelectedDiffs(firstDiff, lastDiff);
@@ -1165,7 +1148,7 @@ void CMergeEditView::OnUpdateL2r(CCmdUI* pCmdUI)
 void CMergeEditView::OnR2l()
 {
        // Check that left side is not readonly
-       if (IsReadOnly(TRUE))
+       if (IsReadOnly(0))
                return;
 
        CMergeDoc *pDoc = GetDocument();
@@ -1177,14 +1160,14 @@ void CMergeEditView::OnR2l()
        {
                WaitStatusCursor waitstatus(LoadResString(IDS_STATUS_COPYR2L));
                if (currentDiff != -1 && pDoc->m_diffList.IsDiffSignificant(currentDiff))
-                       pDoc->ListCopy(false, !!m_bIsLeft);
+                       pDoc->ListCopy(1, 0);
                else
-                       pDoc->CopyMultipleList(false, !!m_bIsLeft, firstDiff, lastDiff);
+                       pDoc->CopyMultipleList(1, 0, firstDiff, lastDiff);
        }
        else if (currentDiff != -1 && pDoc->m_diffList.IsDiffSignificant(currentDiff))
        {
                WaitStatusCursor waitstatus(LoadResString(IDS_STATUS_COPYR2L));
-               pDoc->ListCopy(false, !!m_bIsLeft);
+               pDoc->ListCopy(1, 0);
        }
 }
 
@@ -1194,7 +1177,7 @@ void CMergeEditView::OnR2l()
 void CMergeEditView::OnUpdateR2l(CCmdUI* pCmdUI)
 {
        // Check that left side is not readonly
-       if (!IsReadOnly(TRUE))
+       if (!IsReadOnly(0))
        {
                int firstDiff, lastDiff;
                GetFullySelectedDiffs(firstDiff, lastDiff);
@@ -1216,11 +1199,11 @@ void CMergeEditView::OnUpdateR2l(CCmdUI* pCmdUI)
 void CMergeEditView::OnAllLeft()
 {
        // Check that left side is not readonly
-       if (IsReadOnly(TRUE))
+       if (IsReadOnly(0))
                return;
        WaitStatusCursor waitstatus(LoadResString(IDS_STATUS_COPYALL2L));
 
-       GetDocument()->CopyAllList(false, !!m_bIsLeft);
+       GetDocument()->CopyAllList(1, 0);
 }
 
 /**
@@ -1229,7 +1212,7 @@ void CMergeEditView::OnAllLeft()
 void CMergeEditView::OnUpdateAllLeft(CCmdUI* pCmdUI)
 {
        // Check that left side is not readonly
-       if (!IsReadOnly(TRUE))
+       if (!IsReadOnly(0))
                pCmdUI->Enable(GetDocument()->m_diffList.HasSignificantDiffs());
        else
                pCmdUI->Enable(FALSE);
@@ -1241,12 +1224,12 @@ void CMergeEditView::OnUpdateAllLeft(CCmdUI* pCmdUI)
 void CMergeEditView::OnAllRight()
 {
        // Check that right side is not readonly
-       if (IsReadOnly(FALSE))
+       if (IsReadOnly(1))
                return;
 
        WaitStatusCursor waitstatus(LoadResString(IDS_STATUS_COPYALL2R));
 
-       GetDocument()->CopyAllList(true, !!m_bIsLeft);
+       GetDocument()->CopyAllList(0, 1);
 }
 
 /**
@@ -1255,7 +1238,7 @@ void CMergeEditView::OnAllRight()
 void CMergeEditView::OnUpdateAllRight(CCmdUI* pCmdUI)
 {
        // Check that right side is not readonly
-       if (!IsReadOnly(FALSE))
+       if (!IsReadOnly(1))
                pCmdUI->Enable(GetDocument()->m_diffList.HasSignificantDiffs());
        else
                pCmdUI->Enable(FALSE);
@@ -1270,7 +1253,7 @@ void CMergeEditView::OnUpdateAllRight(CCmdUI* pCmdUI)
  */
 void CMergeEditView::OnEditOperation(int nAction, LPCTSTR pszText)
 {
-       if (IsReadOnly(m_bIsLeft))
+       if (IsReadOnly(m_nThisPane))
        {
                // We must not arrive here, and assert helps detect troubles
                ASSERT(0);
@@ -1278,7 +1261,7 @@ void CMergeEditView::OnEditOperation(int nAction, LPCTSTR pszText)
        }
 
        CMergeDoc* pDoc = GetDocument();
-       pDoc->SetEditedAfterRescan(m_bIsLeft);
+       pDoc->SetEditedAfterRescan(m_nThisPane);
 
        // simple hook for multiplex undo operations
        // deleted by jtuc 2003-06-28
@@ -1296,7 +1279,7 @@ void CMergeEditView::OnEditOperation(int nAction, LPCTSTR pszText)
        // augment with additional operations
 
        // Change header to inform about changed doc
-       pDoc->UpdateHeaderPath(m_bIsLeft);
+       pDoc->UpdateHeaderPath(m_nThisPane);
 
        // If automatic rescan enabled, rescan after edit events
        if (m_bAutomaticRescan)
@@ -1330,14 +1313,14 @@ void CMergeEditView::OnEditRedo()
        CMergeEditView *tgt = *(pDoc->curUndo);
        if(tgt==this)
        {
-               if (IsReadOnly(m_bIsLeft))
+               if (IsReadOnly(m_nThisPane))
                        return;
 
                GetParentFrame()->SetActiveView(this, TRUE);
                if(CCrystalEditViewEx::DoEditRedo())
                {
                        ++pDoc->curUndo;
-                       pDoc->UpdateHeaderPath(m_bIsLeft);
+                       pDoc->UpdateHeaderPath(m_nThisPane);
                        pDoc->FlushAndRescan();
                }
        }
@@ -1356,7 +1339,7 @@ void CMergeEditView::OnUpdateEditRedo(CCmdUI* pCmdUI)
        if (pDoc->curUndo!=pDoc->undoTgt.end())
        {
                CMergeEditView *tgt = *(pDoc->curUndo);
-               pCmdUI->Enable( !IsReadOnly(tgt->m_bIsLeft));
+               pCmdUI->Enable( !IsReadOnly(tgt->m_nThisPane));
        }
        else
                pCmdUI->Enable(FALSE);
@@ -1387,16 +1370,8 @@ void CMergeEditView::ShowDiff(BOOL bScroll, BOOL bSelectText)
                _RPTF2(_CRT_ERROR, "Selected diff > diffcount (%d > %d)!",
                        nDiff, pd->m_diffList.GetSize());
 
-       if (m_bIsLeft)
-       {
-               pCurrentView = pd->GetLeftView();
-               pOtherView = pd->GetRightView();
-       }
-       else
-       {
-               pCurrentView = pd->GetRightView();
-               pOtherView = pd->GetLeftView();
-       }
+       pCurrentView = pd->GetView(m_nThisPane);
+       pOtherView = pd->GetView(1 - m_nThisPane);
 
        if (nDiff >= 0 && nDiff < pd->m_diffList.GetSize())
        {
@@ -1484,16 +1459,9 @@ void CMergeEditView::OnTimer(UINT nIDEvent)
  * @brief Returns if buffer is read-only
  * @note This has no any relation to file being read-only!
  */
-BOOL CMergeEditView::IsReadOnly(BOOL bLeft)
+BOOL CMergeEditView::IsReadOnly(int pane)
 {
-       CCrystalTextBuffer *pBuf = NULL;
-
-       if (bLeft)
-               pBuf = &GetDocument()->m_ltBuf;
-       else
-               pBuf = &GetDocument()->m_rtBuf;
-
-       return pBuf->GetReadOnly();
+       return GetDocument()->m_ptBuf[pane]->GetReadOnly();
 }
 
 /**
@@ -1503,7 +1471,7 @@ void CMergeEditView::OnUpdateFileSaveLeft(CCmdUI* pCmdUI)
 {
        CMergeDoc *pd = GetDocument();
 
-       if (!IsReadOnly(TRUE) && pd->m_ltBuf.IsModified())
+       if (!IsReadOnly(0) && pd->m_ptBuf[0]->IsModified())
                pCmdUI->Enable(TRUE);
        else
                pCmdUI->Enable(FALSE);
@@ -1516,7 +1484,7 @@ void CMergeEditView::OnUpdateFileSaveRight(CCmdUI* pCmdUI)
 {
        CMergeDoc *pd = GetDocument();
 
-       if (!IsReadOnly(FALSE) && pd->m_rtBuf.IsModified())
+       if (!IsReadOnly(1) && pd->m_ptBuf[1]->IsModified())
                pCmdUI->Enable(TRUE);
        else
                pCmdUI->Enable(FALSE);
@@ -1627,7 +1595,7 @@ void CMergeEditView::OnUpdateFileSave(CCmdUI* pCmdUI)
 {
        CMergeDoc *pd = GetDocument();
 
-       if (pd->m_ltBuf.IsModified() || pd->m_rtBuf.IsModified())
+       if (pd->m_ptBuf[0]->IsModified() || pd->m_ptBuf[1]->IsModified())
                pCmdUI->Enable(TRUE);
        else
                pCmdUI->Enable(FALSE);
@@ -1639,8 +1607,8 @@ void CMergeEditView::OnUpdateFileSave(CCmdUI* pCmdUI)
 void CMergeEditView::OnLeftReadOnly()
 {
        CMergeDoc *pd = GetDocument();
-       BOOL bReadOnly = pd->m_ltBuf.GetReadOnly();
-       pd->m_ltBuf.SetReadOnly(!bReadOnly);
+       BOOL bReadOnly = pd->m_ptBuf[0]->GetReadOnly();
+       pd->m_ptBuf[0]->SetReadOnly(!bReadOnly);
 }
 
 /**
@@ -1649,7 +1617,7 @@ void CMergeEditView::OnLeftReadOnly()
 void CMergeEditView::OnUpdateLeftReadOnly(CCmdUI* pCmdUI)
 {
        CMergeDoc *pd = GetDocument();
-       BOOL bReadOnly = pd->m_ltBuf.GetReadOnly();
+       BOOL bReadOnly = pd->m_ptBuf[0]->GetReadOnly();
        pCmdUI->Enable(TRUE);
        pCmdUI->SetCheck(bReadOnly);
 }
@@ -1660,8 +1628,8 @@ void CMergeEditView::OnUpdateLeftReadOnly(CCmdUI* pCmdUI)
 void CMergeEditView::OnRightReadOnly()
 {
        CMergeDoc *pd = GetDocument();
-       BOOL bReadOnly = pd->m_rtBuf.GetReadOnly();
-       pd->m_rtBuf.SetReadOnly(!bReadOnly);
+       BOOL bReadOnly = pd->m_ptBuf[1]->GetReadOnly();
+       pd->m_ptBuf[1]->SetReadOnly(!bReadOnly);
 }
 
 /**
@@ -1670,7 +1638,7 @@ void CMergeEditView::OnRightReadOnly()
 void CMergeEditView::OnUpdateRightReadOnly(CCmdUI* pCmdUI)
 {
        CMergeDoc *pd = GetDocument();
-       BOOL bReadOnly = pd->m_rtBuf.GetReadOnly();
+       BOOL bReadOnly = pd->m_ptBuf[1]->GetReadOnly();
        pCmdUI->Enable(TRUE);
        pCmdUI->SetCheck(bReadOnly);
 }
@@ -1769,11 +1737,7 @@ void CMergeEditView::OnUpdateShowlinechardiff(CCmdUI* pCmdUI)
 void CMergeEditView::OnUpdateEditReplace(CCmdUI* pCmdUI)
 {
        CMergeDoc *pd = GetDocument();
-       BOOL bReadOnly = FALSE;
-       if (m_bIsLeft)
-               bReadOnly = pd->m_ltBuf.GetReadOnly();
-       else
-               bReadOnly = pd->m_rtBuf.GetReadOnly();
+       BOOL bReadOnly = pd->m_ptBuf[m_nThisPane]->GetReadOnly();
 
        pCmdUI->Enable(!bReadOnly);
 }
@@ -1783,7 +1747,7 @@ void CMergeEditView::OnUpdateEditReplace(CCmdUI* pCmdUI)
  */
 void CMergeEditView::OnUpdateStatusLeftRO(CCmdUI* pCmdUI)
 {
-       BOOL bROLeft = GetDocument()->m_ltBuf.GetReadOnly();
+       BOOL bROLeft = GetDocument()->m_ptBuf[0]->GetReadOnly();
        pCmdUI->Enable(bROLeft);
 }
 
@@ -1792,7 +1756,7 @@ void CMergeEditView::OnUpdateStatusLeftRO(CCmdUI* pCmdUI)
  */
 void CMergeEditView::OnUpdateStatusRightRO(CCmdUI* pCmdUI)
 {
-       BOOL bRORight = GetDocument()->m_rtBuf.GetReadOnly();
+       BOOL bRORight = GetDocument()->m_ptBuf[1]->GetReadOnly();
        pCmdUI->Enable(bRORight);
 }
 
@@ -2035,7 +1999,7 @@ void CMergeEditView::OnConvertEolTo(UINT nID )
        {
                CMergeDoc *pd = GetDocument();
                ASSERT(pd);
-               pd->UpdateHeaderPath(m_bIsLeft);
+               pd->UpdateHeaderPath(m_nThisPane);
                pd->FlushAndRescan(TRUE);
        }
 }
@@ -2091,7 +2055,7 @@ void CMergeEditView::OnL2RNext()
 void CMergeEditView::OnUpdateL2RNext(CCmdUI* pCmdUI)
 {
        // Check that right side is not readonly
-       if (!IsReadOnly(FALSE))
+       if (!IsReadOnly(1))
                pCmdUI->Enable(GetDocument()->GetCurrentDiff()!=-1);
        else
                pCmdUI->Enable(FALSE);
@@ -2116,7 +2080,7 @@ void CMergeEditView::OnR2LNext()
 void CMergeEditView::OnUpdateR2LNext(CCmdUI* pCmdUI)
 {
        // Check that left side is not readonly
-       if (!IsReadOnly(TRUE))
+       if (!IsReadOnly(0))
                pCmdUI->Enable(GetDocument()->GetCurrentDiff()!=-1);
        else
                pCmdUI->Enable(FALSE);
@@ -2163,41 +2127,22 @@ void CMergeEditView::OnWMGoto()
        int nRealLine = 0;
        int nLastLine = 0;
 
-       if (m_bIsLeft)
-       {
-               nRealLine = pDoc->m_ltBuf.ComputeRealLine(pos.y);
-               int nLineCount = pDoc->m_ltBuf.GetLineCount();
-               nLastLine = pDoc->m_ltBuf.ComputeRealLine(nLineCount - 1);
-       }
-       else
-       {
-               nRealLine = pDoc->m_rtBuf.ComputeRealLine(pos.y);
-               int nLineCount = pDoc->m_rtBuf.GetLineCount();
-               nLastLine = pDoc->m_rtBuf.ComputeRealLine(nLineCount - 1);
-       }
+       nRealLine = pDoc->m_ptBuf[m_nThisPane]->ComputeRealLine(pos.y);
+       int nLineCount = pDoc->m_ptBuf[m_nThisPane]->GetLineCount();
+       nLastLine = pDoc->m_ptBuf[m_nThisPane]->ComputeRealLine(nLineCount - 1);
 
        // Set active file and current line selected in dialog
        dlg.m_strParam.Format(_T("%d"), nRealLine + 1);
-       dlg.m_nFile = m_bIsLeft ? 0 : 1;
+       dlg.m_nFile = m_nThisPane;
        dlg.m_nGotoWhat = 0;
 
        if (dlg.DoModal() == IDOK)
        {
                CMergeDoc * pDoc = GetDocument();
                CMergeEditView * pCurrentView = NULL;
-               CMergeEditView * pOtherView = NULL;
 
                // Get views
-               if (dlg.m_nFile == 0)
-               {
-                       pCurrentView = pDoc->GetLeftView();
-                       pOtherView = pDoc->GetRightView();
-               }
-               else
-               {
-                       pOtherView = pDoc->GetLeftView();
-                       pCurrentView = pDoc->GetRightView();
-               }
+               pCurrentView = pDoc->GetView(dlg.m_nFile);
 
                if (dlg.m_nGotoWhat == 0)
                {
@@ -2207,7 +2152,7 @@ void CMergeEditView::OnWMGoto()
                        if (nRealLine > nLastLine)
                                nRealLine = nLastLine;
 
-                       GotoLine(nRealLine, TRUE, dlg.m_nFile == 0);
+                       GotoLine(nRealLine, TRUE, dlg.m_nFile);
                }
                else
                {
@@ -2402,7 +2347,7 @@ void CMergeEditView::OnUpdateMergingStatus(CCmdUI *pCmdUI)
  * it is apparent line (including deleted lines)
  * @param [in] bLeft If TRUE linenumber is for left pane
  */
-void CMergeEditView::GotoLine(UINT nLine, BOOL bRealLine, BOOL bLeft)
+void CMergeEditView::GotoLine(UINT nLine, BOOL bRealLine, int pane)
 {
        CMergeDoc *pDoc = GetDocument();
        CMergeEditView *pLeftView = pDoc->GetLeftView();
@@ -2414,20 +2359,10 @@ void CMergeEditView::GotoLine(UINT nLine, BOOL bRealLine, BOOL bLeft)
        // Compute apparent (shown linenumber) line
        if (bRealLine)
        {
-               if (bLeft)
-               {
-                       if (nRealLine > pDoc->m_ltBuf.GetLineCount() - 1)
-                               nRealLine = pDoc->m_ltBuf.GetLineCount() - 1;
+               if (nRealLine > pDoc->m_ptBuf[pane]->GetLineCount() - 1)
+                       nRealLine = pDoc->m_ptBuf[pane]->GetLineCount() - 1;
 
-                       nApparentLine = pDoc->m_ltBuf.ComputeApparentLine(nRealLine);
-               }
-               else
-               {
-                       if (nRealLine > pDoc->m_rtBuf.GetLineCount() - 1)
-                               nRealLine = pDoc->m_rtBuf.GetLineCount() - 1;
-
-                       nApparentLine = pDoc->m_rtBuf.ComputeApparentLine(nRealLine);
-               }
+               nApparentLine = pDoc->m_ptBuf[pane]->ComputeApparentLine(nRealLine);
        }
        CPoint ptPos;
        ptPos.x = 0;
@@ -2460,8 +2395,8 @@ void CMergeEditView::OnWindowClose()
        else
        {
                // Set modified to false so we don't ask again about saving
-               pDoc->m_ltBuf.SetModified(FALSE);
-               pDoc->m_rtBuf.SetModified(FALSE);
+               pDoc->m_ptBuf[0]->SetModified(FALSE);
+               pDoc->m_ptBuf[1]->SetModified(FALSE);
                GetParentFrame()->PostMessage(WM_CLOSE, 0, 0);
        }
        m_pLocationView = NULL;
@@ -2550,17 +2485,14 @@ void CMergeEditView::OnEditCopyLineNumbers()
        GetSelection(ptStart, ptEnd);
 
        // Get last selected line (having widest linenumber)
-       line = pDoc->m_rtBuf.ComputeRealLine(ptEnd.y);
+       line = pDoc->m_ptBuf[1]->ComputeRealLine(ptEnd.y);
        strNum.Format(_T("%d"), line + 1);
        nNumWidth = strNum.GetLength();
        
        for (int i = ptStart.y; i <= ptEnd.y; i++)
        {
                // We need to convert to real linenumbers
-               if (m_bIsLeft)
-                       line = pDoc->m_ltBuf.ComputeRealLine(i);
-               else
-                       line = pDoc->m_rtBuf.ComputeRealLine(i);
+               line = pDoc->m_ptBuf[m_nThisPane]->ComputeRealLine(i);
 
                // Insert spaces to align different width linenumbers (99, 100)
                strLine = GetLineText(i);
@@ -2591,7 +2523,7 @@ void CMergeEditView::OnOpenFile()
        CMergeDoc * pDoc = GetDocument();
        ASSERT(pDoc != NULL);
 
-       CString sFileName = m_bIsLeft ? pDoc->m_filePaths.GetLeft() : pDoc->m_filePaths.GetRight();
+       CString sFileName = pDoc->m_filePaths.GetPath(m_nThisPane);
        if (sFileName.IsEmpty())
                return;
        int rtn = (int)ShellExecute(::GetDesktopWindow(), _T("edit"), sFileName,
@@ -2611,7 +2543,7 @@ void CMergeEditView::OnOpenFileWith()
        CMergeDoc * pDoc = GetDocument();
        ASSERT(pDoc != NULL);
 
-       CString sFileName = m_bIsLeft ? pDoc->m_filePaths.GetLeft() : pDoc->m_filePaths.GetRight();
+       CString sFileName = pDoc->m_filePaths.GetPath(m_nThisPane);
        if (sFileName.IsEmpty())
                return;
 
@@ -2632,7 +2564,7 @@ void CMergeEditView::OnOpenFileWithEditor()
        CMergeDoc * pDoc = GetDocument();
        ASSERT(pDoc != NULL);
 
-       CString sFileName = m_bIsLeft ? pDoc->m_filePaths.GetLeft() : pDoc->m_filePaths.GetRight();
+       CString sFileName = pDoc->m_filePaths.GetPath(m_nThisPane);
        if (sFileName.IsEmpty())
                return;
 
@@ -2684,3 +2616,17 @@ bool CMergeEditView::IsInitialized() const
        CMergeDoc::CDiffTextBuffer * pBuffer = dynamic_cast<CMergeDoc::CDiffTextBuffer *>(pThis->LocateTextBuffer());
        return pBuffer->IsInitialized();
 }
+
+/**
+ * @brief Swap the positions of the two panes
+ */
+void CMergeEditView::OnViewSwapPanes()
+{
+       GetDocument()->SwapFiles();
+}
+
+void CMergeEditView::OnUpdateViewSwapPanes(CCmdUI* pCmdUI)
+{
+       pCmdUI->Enable(TRUE);
+}
+
index 21ade2c..22bb658 100644 (file)
@@ -123,7 +123,7 @@ protected:
 
 // Attributes
 public:
-       BOOL m_bIsLeft;
+       int m_nThisPane;
        LONG m_nModifications;
        IMergeEditStatus * m_piMergeEditStatus; /**< interface to status bar */
        CLocationView * m_pLocationView; /**< Pointer to locationview */
@@ -150,7 +150,7 @@ private:
 public:
        void RefreshOptions();
        BOOL EnableRescan(BOOL bEnable);
-       BOOL IsReadOnly(BOOL bLeft);
+       BOOL IsReadOnly(int pane);
        void ShowDiff(BOOL bScroll, BOOL bSelectText);
        virtual void OnEditOperation(int nAction, LPCTSTR pszText);
        void UpdateLineLengths();
@@ -178,7 +178,7 @@ public:
        virtual void GetLineColors2 (int nLineIndex, DWORD ignoreFlags
                , COLORREF & crBkgnd, COLORREF & crText, BOOL & bDrawWhitespace);
        void WMGoto() { OnWMGoto(); };
-       void GotoLine(UINT nLine, BOOL bRealLine, BOOL bLeft);
+       void GotoLine(UINT nLine, BOOL bRealLine, int pane);
        int GetTopLine() { return m_nTopLine; };
        int GetScreenLines() { return CCrystalTextView::GetScreenLines(); };
        void RepaintLocationPane();
@@ -288,6 +288,8 @@ protected:
        afx_msg void OnOpenFile();
        afx_msg void OnOpenFileWith();
        afx_msg void OnOpenFileWithEditor();
+       afx_msg void OnViewSwapPanes();
+       afx_msg void OnUpdateViewSwapPanes(CCmdUI* pCmdUI);
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
 };
index 12562c1..e39294e 100644 (file)
@@ -83,6 +83,16 @@ CString PathContext::GetRight(BOOL bNormalized) const
 }
 
 /**
+ * @brief Return path
+ * @param [in] index index of path to return
+ * @param [in] sNormalized If TRUE normalized path is returned.
+ */
+CString PathContext::GetPath(int index, BOOL bNormalized) const
+{
+       return index == 0 ? m_pathLeft.GetPath(bNormalized) : m_pathRight.GetPath(bNormalized);
+}
+
+/**
  * @brief Set left path.
  * @param [in] path New path for item.
  */
@@ -103,6 +113,25 @@ void PathContext::SetRight(LPCTSTR path)
 }
 
 /**
+ * @brief Set path
+ * @param [in] index index of path to set
+ * @param [in] path New path for item.
+ */
+void PathContext::SetPath(int index, LPCTSTR path)
+{
+       if (index == 0)
+       {
+               m_pathLeft.SetPath(path);
+               m_pathLeft.NormalizePath();
+       }
+       else
+       {
+               m_pathRight.SetPath(path);
+               m_pathRight.NormalizePath();
+       }
+}
+
+/**
  * @brief Destructor, deletes existing temp files.
  */
 TempFileContext::~TempFileContext()
index 1a9ec0d..dcdbf95 100644 (file)
@@ -39,8 +39,10 @@ public:
        PathContext(CString sLeft, CString sRight);
        CString GetLeft(BOOL bNormalized = TRUE) const;
        CString GetRight(BOOL bNormalized = TRUE) const;
+       CString GetPath(int index, BOOL bNormalized = TRUE) const;
        void SetLeft(LPCTSTR path);
        void SetRight(LPCTSTR path);
+       void SetPath(int index, LPCTSTR path);
 
 private:
        PathInfo m_pathLeft; /**< First path (left path at start) */
@@ -57,7 +59,7 @@ public:
        BOOL CreateFiles(const PathContext &paths);
        BOOL FilesExist();
        void DeleteFiles();
-       const CString & GetPath() const { return m_sTempPath; }
+       const CString & GetTempPath() const { return m_sTempPath; }
 
 private:
        CString m_sTempPath;
index 87af4fb..4a27d6d 100644 (file)
 #define ID_HELP_MERGE7ZMISMATCH         33094
 #define ID_FILE_OPENPROJECT             33095
 #define ID_VIEW_SHOWHIDDENITEMS         33096
+#define ID_VIEW_SWAPPANES               33097
 
 // Next default values for new objects
 //
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_3D_CONTROLS                     1
 #define _APS_NEXT_RESOURCE_VALUE        228
-#define _APS_NEXT_COMMAND_VALUE         33096
+#define _APS_NEXT_COMMAND_VALUE         33098
 #define _APS_NEXT_CONTROL_VALUE         1199
 #define _APS_NEXT_SYMED_VALUE           113
 #endif