-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:
// 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;
}
#include "stdafx.h"
#include "DiffList.h"
#include "DiffWrapper.h"
+#include "coretools.h"
/**
* @brief Default constructor, initialises difflist to 64 items.
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
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 */
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);
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);
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;
};
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);
}
}
}
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)
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();
}
/////////////////////////////////////////////////////////////////////////////
if (m_hWnd == NULL)
return;
- if (pane == PANE_LEFT)
- m_EditLeft.SetWholeText(lpszString);
- else
- m_EditRight.SetWholeText(lpszString);
+ m_Edit[pane].SetWholeText(lpszString);
}
/**
if (m_hWnd == NULL)
return;
- if (pane == PANE_LEFT)
- m_EditLeft.SetActive(bActive);
- else
- m_EditRight.SetActive(bActive);
+ m_Edit[pane].SetActive(bActive);
}
private:
// this dialog uses custom edit boxes
- CFilepathEdit m_EditLeft, m_EditRight;
+ CFilepathEdit m_Edit[2];
CFont * m_pFont; /**< Font for editcontrols */
};
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
*/
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 */
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)
// 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)
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();
}
*/
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();
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
// 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);
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)
{
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;
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;
}
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);
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;
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;
}
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);
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;
*/
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;
}
/**
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 */
{
// 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);
}
}
}
{
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);
{
// 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);
}
}
}
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
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
IMPLEMENT_DYNCREATE(CMergeDiffDetailView, CCrystalTextView)
CMergeDiffDetailView::CMergeDiffDetailView()
-: m_bIsLeft(FALSE)
+: m_nThisPane(0)
, m_lineBegin(0)
, m_lineEnd(-1)
, m_diffLength(0)
// 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))
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;
{
// 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;
}
// Attributes
public:
- BOOL m_bIsLeft;
+ int m_nThisPane;
protected:
/// first line of diff (first displayable line)
int m_lineBegin;
* @brief Constructor.
*/
CMergeDoc::CMergeDoc()
-: m_ltBuf(this,TRUE)
-, m_rtBuf(this,FALSE)
-, m_pTempFiles(NULL)
+: m_pTempFiles(NULL)
{
DIFFOPTIONS options = {0};
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);
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];
}
/**
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;
}
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;
}
}
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
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
{
// ..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);
}
// 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)
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)
{
}
}
-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;
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();
}
}
/**
* @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)
// 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
{
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
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))
{
/**
* @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
{
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)
// 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)
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)
// 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);
}
// 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);
* 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()
* @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
// 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);
}
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);
// 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;
* 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!
* @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);
BOOL bApplyToAll = FALSE;
int nRetVal = -1;
- bFileChanged = IsFileChangedOnDisk(szPath, fileInfo, TRUE, bLeft);
+ bFileChanged = IsFileChangedOnDisk(szPath, fileInfo, TRUE, nBuffer);
if (bFileChanged)
{
CString msg;
// 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
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)
{
// 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;
}
* 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!
* @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;
// 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;
}
*/
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;
}
*/
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;
}
{
// 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
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();
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);
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;
}
// 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
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,
// 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
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,
// 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
void CMergeDoc::OnFileSaveAsLeft()
{
BOOL bSaveResult = FALSE;
- DoSaveAs(m_filePaths.GetLeft(), bSaveResult, TRUE);
+ DoSaveAs(m_filePaths.GetLeft(), bSaveResult, 0);
}
/**
void CMergeDoc::OnFileSaveAsRight()
{
BOOL bSaveResult = FALSE;
- DoSaveAs(m_filePaths.GetRight(), bSaveResult, FALSE);
+ DoSaveAs(m_filePaths.GetRight(), bSaveResult, 1);
}
/**
}
// 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
// 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;
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;
}
// 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;
// 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;
{
// 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
{
// 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);
}
}
}
// but now we keep all diffs, including trivial diffs
- m_ltBuf.FinishLoading();
- m_rtBuf.FinishLoading();
+ m_ptBuf[0]->FinishLoading();
+ m_ptBuf[1]->FinishLoading();
}
/**
* @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;
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);
*/
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;
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;
}
}
// 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
*/
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;
}
/**
*/
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;
}
/**
*/
CChildFrame * CMergeDoc::GetParentFrame()
{
- return dynamic_cast<CChildFrame *>(m_pLeftView->GetParentFrame());
+ return dynamic_cast<CChildFrame *>(m_pView[0]->GetParentFrame());
}
/**
/**
* @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;
// 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;
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;
}
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
}
// 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 :
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);
// 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);
}
// 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;
}
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);
}
/**
* @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);
}
/**
FlushAndRescan();
}
-void CMergeDoc::SetEditedAfterRescan(BOOL bLeft)
+void CMergeDoc::SetEditedAfterRescan(int nBuffer)
{
- if (bLeft)
- m_bLeftEditAfterRescan = TRUE;
- else
- m_bRightEditAfterRescan = TRUE;
+ m_bEditAfterRescan[nBuffer] = TRUE;
}
/**
sTitle = lpszTitle;
else
{
- if (!m_strLeftDesc.IsEmpty())
- sTitle += m_strLeftDesc;
+ if (!m_strDesc[0].IsEmpty())
+ sTitle += m_strDesc[0];
else
{
CString file;
sTitle += pszSeparator;
- if (!m_strRightDesc.IsEmpty())
- sTitle += m_strRightDesc;
+ if (!m_strDesc[1].IsEmpty())
+ sTitle += m_strDesc[1];
else
{
CString file;
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)
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);
+}
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;
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);
// 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();
// 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);
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
// 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;
// implementation methods
private:
- BOOL GetOptionInt(LPCTSTR name) const;
BOOL GetOptionBool(LPCTSTR name) const;
bool GetBreakType() const;
bool GetByteColoringOption() const;
// 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
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)
{
}
// 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);
}
/**
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)
{
}
// 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);
}
/**
*/
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)
{
}
// 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;
CMergeEditView::CMergeEditView()
{
m_pLocationView = NULL;
- m_bIsLeft = FALSE;
+ m_nThisPane = 0;
m_nModifications = 0;
m_piMergeEditStatus = 0;
SetParser(&m_xParser);
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()
*/
CCrystalTextBuffer *CMergeEditView::LocateTextBuffer()
{
- if (m_bIsLeft)
- return &GetDocument()->m_ltBuf;
- return &GetDocument()->m_rtBuf;
+ return GetDocument()->m_ptBuf[m_nThisPane];
}
/**
*/
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);
CCrystalEditViewEx::OnActivateView(bActivate, pActivateView, pDeactiveView);
CMergeDoc* pDoc = GetDocument();
- pDoc->UpdateHeaderActivity(m_bIsLeft, bActivate);
+ pDoc->UpdateHeaderActivity(m_nThisPane, bActivate);
mf->UpdatePrediffersMenu();
}
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;
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);
*/
void CMergeEditView::OnEditCut()
{
- if (IsReadOnly(m_bIsLeft))
+ if (IsReadOnly(m_nThisPane))
return;
CPoint ptSelStart, ptSelEnd;
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);
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);
}
*/
void CMergeEditView::OnUpdateEditCut(CCmdUI* pCmdUI)
{
- if (!IsReadOnly(m_bIsLeft))
+ if (!IsReadOnly(m_nThisPane))
CCrystalEditViewEx::OnUpdateEditCut(pCmdUI);
else
pCmdUI->Enable(FALSE);
*/
void CMergeEditView::OnEditPaste()
{
- if (IsReadOnly(m_bIsLeft))
+ if (IsReadOnly(m_nThisPane))
return;
CCrystalEditViewEx::Paste();
*/
void CMergeEditView::OnUpdateEditPaste(CCmdUI* pCmdUI)
{
- if (!IsReadOnly(m_bIsLeft))
+ if (!IsReadOnly(m_nThisPane))
CCrystalEditViewEx::OnUpdateEditPaste(pCmdUI);
else
pCmdUI->Enable(FALSE);
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;
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);
void CMergeEditView::OnNextdiff()
{
CMergeDoc *pd = GetDocument();
- int cnt = pd->m_ltBuf.GetLineCount();
+ int cnt = pd->m_ptBuf[0]->GetLineCount();
if (cnt <= 0)
return;
void CMergeEditView::OnPrevdiff()
{
CMergeDoc *pd = GetDocument();
- int cnt = pd->m_ltBuf.GetLineCount();
+ int cnt = pd->m_ptBuf[0]->GetLineCount();
if (cnt <= 0)
return;
void CMergeEditView::OnL2r()
{
// Check that right side is not readonly
- if (IsReadOnly(FALSE))
+ if (IsReadOnly(1))
return;
CMergeDoc *pDoc = GetDocument();
{
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);
}
}
void CMergeEditView::OnUpdateL2r(CCmdUI* pCmdUI)
{
// Check that right side is not readonly
- if (!IsReadOnly(FALSE))
+ if (!IsReadOnly(1))
{
int firstDiff, lastDiff;
GetFullySelectedDiffs(firstDiff, lastDiff);
void CMergeEditView::OnR2l()
{
// Check that left side is not readonly
- if (IsReadOnly(TRUE))
+ if (IsReadOnly(0))
return;
CMergeDoc *pDoc = GetDocument();
{
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);
}
}
void CMergeEditView::OnUpdateR2l(CCmdUI* pCmdUI)
{
// Check that left side is not readonly
- if (!IsReadOnly(TRUE))
+ if (!IsReadOnly(0))
{
int firstDiff, lastDiff;
GetFullySelectedDiffs(firstDiff, lastDiff);
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);
}
/**
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);
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);
}
/**
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);
*/
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);
}
CMergeDoc* pDoc = GetDocument();
- pDoc->SetEditedAfterRescan(m_bIsLeft);
+ pDoc->SetEditedAfterRescan(m_nThisPane);
// simple hook for multiplex undo operations
// deleted by jtuc 2003-06-28
// 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)
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();
}
}
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);
_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())
{
* @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();
}
/**
{
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);
{
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);
{
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);
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);
}
/**
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);
}
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);
}
/**
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);
}
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);
}
*/
void CMergeEditView::OnUpdateStatusLeftRO(CCmdUI* pCmdUI)
{
- BOOL bROLeft = GetDocument()->m_ltBuf.GetReadOnly();
+ BOOL bROLeft = GetDocument()->m_ptBuf[0]->GetReadOnly();
pCmdUI->Enable(bROLeft);
}
*/
void CMergeEditView::OnUpdateStatusRightRO(CCmdUI* pCmdUI)
{
- BOOL bRORight = GetDocument()->m_rtBuf.GetReadOnly();
+ BOOL bRORight = GetDocument()->m_ptBuf[1]->GetReadOnly();
pCmdUI->Enable(bRORight);
}
{
CMergeDoc *pd = GetDocument();
ASSERT(pd);
- pd->UpdateHeaderPath(m_bIsLeft);
+ pd->UpdateHeaderPath(m_nThisPane);
pd->FlushAndRescan(TRUE);
}
}
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);
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);
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)
{
if (nRealLine > nLastLine)
nRealLine = nLastLine;
- GotoLine(nRealLine, TRUE, dlg.m_nFile == 0);
+ GotoLine(nRealLine, TRUE, dlg.m_nFile);
}
else
{
* 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();
// 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;
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;
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);
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,
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;
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;
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);
+}
+
// Attributes
public:
- BOOL m_bIsLeft;
+ int m_nThisPane;
LONG m_nModifications;
IMergeEditStatus * m_piMergeEditStatus; /**< interface to status bar */
CLocationView * m_pLocationView; /**< Pointer to locationview */
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();
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();
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()
};
}
/**
+ * @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.
*/
}
/**
+ * @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()
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) */
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;
#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