OSDN Git Service

2.0 initial checkin
authorgrimmd <none@none>
Wed, 7 Mar 2001 15:11:30 +0000 (15:11 +0000)
committergrimmd <none@none>
Wed, 7 Mar 2001 15:11:30 +0000 (15:11 +0000)
19 files changed:
Src/ChildFrm.cpp
Src/ChildFrm.h
Src/DirFrame.cpp
Src/DirFrame.h
Src/DirView.cpp
Src/DirView.h
Src/MainFrm.cpp
Src/MainFrm.h
Src/Merge.cpp
Src/Merge.dsp
Src/Merge.rc
Src/MergeDoc.cpp
Src/MergeDoc.h
Src/MergeEditView.cpp [new file with mode: 0644]
Src/MergeEditView.h [new file with mode: 0644]
Src/StdAfx.cpp
Src/StdAfx.h
Src/res/mg_cur.cur [new file with mode: 0644]
Src/resource.h

index 6b60348..9b75024 100644 (file)
@@ -27,6 +27,7 @@
 #include "ChildFrm.h"
 #include "DiffView.h"
 #include "MainFrm.h"
+#include "MergeEditView.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -44,11 +45,13 @@ BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
        ON_WM_CREATE()
        ON_WM_CLOSE()
        ON_WM_SIZE()
+       ON_WM_TIMER()
        //}}AFX_MSG_MAP
 END_MESSAGE_MAP()
 
 static UINT indicators[] =
 {
+       ID_SEPARATOR,
        ID_SEPARATOR
 };
 
@@ -58,6 +61,7 @@ static UINT indicators[] =
 CChildFrame::CChildFrame()
 {
        m_bActivated = FALSE;
+       m_nLastSplitPos=0;
 }
 
 CChildFrame::~CChildFrame()
@@ -83,7 +87,7 @@ BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
        //      width = rc.Width()/2;
 
        if (!m_wndSplitter.CreateView(0, 0,
-               RUNTIME_CLASS(CDiffView), CSize(-1, 200), pContext))
+               RUNTIME_CLASS(CMergeEditView), CSize(-1, 200), pContext))
        {
                TRACE0("Failed to create first pane\n");
                return FALSE;
@@ -91,16 +95,16 @@ BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
        
        // add the second splitter pane - an input view in column 1
        if (!m_wndSplitter.CreateView(0, 1,
-               RUNTIME_CLASS(CDiffView), CSize(-1, 200), pContext))
+               RUNTIME_CLASS(CMergeEditView), CSize(-1, 200), pContext))
        {
                TRACE0("Failed to create second pane\n");
                return FALSE;
        }
        
-       mf->m_pLeft = (CDiffView *)m_wndSplitter.GetPane(0,0);
+       mf->m_pLeft = (CMergeEditView *)m_wndSplitter.GetPane(0,0);
        //mf->m_pLeft->OnInitialUpdate();
        mf->m_pLeft->m_bIsLeft=TRUE;
-       mf->m_pRight = (CDiffView *)m_wndSplitter.GetPane(0,1);
+       mf->m_pRight = (CMergeEditView *)m_wndSplitter.GetPane(0,1);
        //mf->m_pRight->OnInitialUpdate();
        mf->m_pRight->m_bIsLeft=FALSE;
        mf->m_pLeft->UpdateWindow();
@@ -141,8 +145,27 @@ int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
 {
        if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
                return -1;
+
+       ModifyStyle(WS_THICKFRAME,0); // this is necessary to prevent the sizing tab on right
+
+       if (!m_wndStatusBar.Create(this) ||
+               !m_wndStatusBar.SetIndicators(indicators,
+                 sizeof(indicators)/sizeof(UINT)))
+       {
+               TRACE0("Failed to create status bar\n");
+               return -1;      // fail to create
+       }       
+
+       ModifyStyle(0,WS_THICKFRAME);
+
+       m_wndStatusBar.SetBarStyle(CBRS_ALIGN_TOP);
+       m_wndStatusBar.SetPaneStyle(0, SBPS_NORMAL);
+       m_wndStatusBar.SetPaneStyle(1, SBPS_NORMAL);
        
-       //MDIMaximize();
+       m_wndSplitter.SetScrollStyle(WS_HSCROLL|WS_VSCROLL);
+       m_wndSplitter.RecalcLayout();
+
+       SetTimer(0, 250, NULL); // used to update the title headers
        return 0;
 }
 
@@ -155,12 +178,17 @@ void CChildFrame::ActivateFrame(int nCmdShow)
                        nCmdShow = SW_SHOWMAXIMIZED;
                else
                        nCmdShow = SW_SHOWNORMAL;
-       CRect rc;
-       GetClientRect(&rc);
-       m_wndSplitter.SetColumnInfo(0, rc.Width()/2, 10);
-       m_wndSplitter.RecalcLayout();
+               CRect rc;
+               GetClientRect(&rc);
+               m_wndSplitter.SetColumnInfo(0, rc.Width()/2, 10);
+               m_wndSplitter.RecalcLayout();
     }
        CMDIChildWnd::ActivateFrame(nCmdShow);
+       UpdateHeaderSizes();
+       if (mf->m_pLeft!=NULL)
+       {
+               mf->m_pLeft->UpdateStatusMessage();
+       }
 }
 
 BOOL CChildFrame::DestroyWindow() 
@@ -194,11 +222,52 @@ void CChildFrame::OnSize(UINT nType, int cx, int cy)
 {
        CMDIChildWnd::OnSize(nType, cx, cy);
        
-       CRect rc;
-       GetClientRect(&rc);
        if(IsWindowVisible())
        {
+               CRect rc;
+               GetClientRect(&rc);             
                m_wndSplitter.SetColumnInfo(0, rc.Width()/2, 10);
                m_wndSplitter.RecalcLayout();
+
+               UpdateHeaderSizes();
        }
 }
+
+void CChildFrame::UpdateHeaderSizes()
+{
+       if(IsWindowVisible())
+       {
+               int w,wmin;
+               m_wndSplitter.GetColumnInfo(0, w, wmin);        
+               m_wndStatusBar.SetPaneInfo(0, ID_SEPARATOR, SBPS_NORMAL, w-1);
+               m_wndStatusBar.SetPaneInfo(1, ID_SEPARATOR, SBPS_STRETCH, 0);
+       }
+
+}
+
+BOOL CChildFrame::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) 
+{
+       // TODO: Add your specialized code here and/or call the base class
+       
+       return CMDIChildWnd::OnNotify(wParam, lParam, pResult);
+}
+
+void CChildFrame::OnTimer(UINT nIDEvent) 
+{
+       if (IsWindowVisible())
+       {
+               int w,wmin;
+               m_wndSplitter.GetColumnInfo(0, w, wmin);
+               if (w != m_nLastSplitPos && w > 0)
+               {
+                       UpdateHeaderSizes();
+                       m_nLastSplitPos = w;
+               }
+       }
+       CMDIChildWnd::OnTimer(nIDEvent);
+}
+
+void CChildFrame::SetHeaderText(int nPane, const CString &text)
+{
+       m_wndStatusBar.SetPaneText(nPane, text);
+}
index cafcd1d..5ce76c6 100644 (file)
@@ -33,6 +33,7 @@ class CChildFrame : public CMDIChildWnd
        DECLARE_DYNCREATE(CChildFrame)
 public:
        CChildFrame();
+       CStatusBar  m_wndStatusBar;
 
 // Attributes
 protected:
@@ -50,10 +51,13 @@ public:
        virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
        virtual void ActivateFrame(int nCmdShow = -1);
        virtual BOOL DestroyWindow();
+       protected:
+       virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
        //}}AFX_VIRTUAL
 
 // Implementation
 public:
+       void SetHeaderText(int nPane, const CString& text);
        void SavePosition();
        virtual ~CChildFrame();
 #ifdef _DEBUG
@@ -63,11 +67,14 @@ public:
 
 // Generated message map functions
 protected:
+       int m_nLastSplitPos;
+       void UpdateHeaderSizes();
        BOOL m_bActivated;
        //{{AFX_MSG(CChildFrame)
        afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
        afx_msg void OnClose();
        afx_msg void OnSize(UINT nType, int cx, int cy);
+       afx_msg void OnTimer(UINT nIDEvent);
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
 };
index 3fbed37..2bbfddd 100644 (file)
@@ -93,3 +93,11 @@ void CDirFrame::SetStatus(LPCTSTR szStatus)
        m_wndStatusBar.SetPaneText(0, szStatus);
 }
 
+
+void CDirFrame::ActivateFrame(int nCmdShow) 
+{
+       if (m_wndStatusBar.IsWindowVisible())
+               m_wndStatusBar.SetPaneText(1, _T("")); // clear the diff status
+       
+       CMDIChildWnd::ActivateFrame(nCmdShow);
+}
index 8960ba5..0d575a0 100644 (file)
@@ -46,6 +46,8 @@ public:
 // Overrides
        // ClassWizard generated virtual function overrides
        //{{AFX_VIRTUAL(CDirFrame)
+       public:
+       virtual void ActivateFrame(int nCmdShow = -1);
        //}}AFX_VIRTUAL
 
 // Implementation
index be71739..40c1f07 100644 (file)
@@ -60,6 +60,8 @@ BEGIN_MESSAGE_MAP(CDirView, CListViewEx)
        ON_UPDATE_COMMAND_UI(ID_DIR_COPY_FILE_TO_LEFT, OnUpdateDirCopyFileToLeft)
        ON_COMMAND(ID_DIR_COPY_FILE_TO_RIGHT, OnDirCopyFileToRight)
        ON_UPDATE_COMMAND_UI(ID_DIR_COPY_FILE_TO_RIGHT, OnUpdateDirCopyFileToRight)
+       ON_WM_DESTROY()
+       ON_WM_SETFOCUS()
        //}}AFX_MSG_MAP
        ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnClick)
 END_MESSAGE_MAP()
@@ -103,13 +105,35 @@ void CDirView::OnInitialUpdate()
        m_sortColumn = -1;      // start up in no sorted order.
        m_pList = &GetListCtrl();
        GetDocument()->m_pView = this;
+
+    // Replace standard header with sort header
+    if (HWND hWnd = ListView_GetHeader(m_pList->m_hWnd))
+            m_ctlSortHeader.SubclassWindow(hWnd);
+        
        
+       int w;
+       CString sKey;
+       CString sFmt(_T("WDirHdr%d")), sSect(_T("DirView"));
+
+       sKey.Format(sFmt, DV_NAME);
+       w = max(10, theApp.GetProfileInt(sSect, sKey, 150));
+       m_pList->InsertColumn(DV_NAME, _T("Filename"), LVCFMT_LEFT, w);
+
+       sKey.Format(sFmt, DV_PATH);
+       w = max(10, theApp.GetProfileInt(sSect, sKey, 200));
+       m_pList->InsertColumn(DV_PATH, _T("Directory"), LVCFMT_LEFT, w);
 
-       m_pList->InsertColumn(DV_NAME, _T("Filename"), LVCFMT_LEFT, 150);
-       m_pList->InsertColumn(DV_PATH, _T("Directory"), LVCFMT_LEFT, 200);
-       m_pList->InsertColumn(DV_STATUS, _T("Comparison result"), LVCFMT_LEFT, 250);
-       m_pList->InsertColumn(DV_LTIME, _T("Left Time"), LVCFMT_LEFT, 150);
-       m_pList->InsertColumn(DV_RTIME, _T("Right Time"), LVCFMT_LEFT, 150);
+       sKey.Format(sFmt, DV_STATUS);
+       w = max(10, theApp.GetProfileInt(sSect, sKey, 250));
+       m_pList->InsertColumn(DV_STATUS, _T("Comparison result"), LVCFMT_LEFT, w);
+
+       sKey.Format(sFmt, DV_LTIME);
+       w = max(10, theApp.GetProfileInt(sSect, sKey, 150));
+       m_pList->InsertColumn(DV_LTIME, _T("Left Time"), LVCFMT_LEFT, w);
+
+       sKey.Format(sFmt, DV_RTIME);
+       w = max(10, theApp.GetProfileInt(sSect, sKey, 150));
+       m_pList->InsertColumn(DV_RTIME, _T("Right Time"), LVCFMT_LEFT, w);
 
        CBitmap bm;
        VERIFY (m_imageList.Create (16, 16, ILC_MASK, 0, 1));
@@ -139,6 +163,8 @@ void CDirView::OnInitialUpdate()
        bm.Detach();
        m_pList->SetImageList (&m_imageList, LVSIL_SMALL);
        UpdateResources();
+
+       //m_ctlSortHeader.SetSortImage(m_sortColumn, m_bSortAscending);
 }
 
 void CDirView::OnLButtonDblClk(UINT nFlags, CPoint point) 
@@ -473,7 +499,34 @@ void CDirView::OnColumnClick(NMHDR *pNMHDR, LRESULT *pResult)
                m_bSortAscending = true;
                m_sortColumn = pNMListView->iSubItem;
        }
+       m_ctlSortHeader.SetSortImage(m_sortColumn, m_bSortAscending);
+
        //sort using static CompareFunc comparison function
        GetListCtrl ().SortItems (CompareFunc, reinterpret_cast<DWORD>(this));//pNMListView->iSubItem);
        *pResult = 0;
 }
+
+void CDirView::OnDestroy() 
+{
+       // save the column widths
+       CListCtrl& ctl = GetListCtrl();
+
+       CHeaderCtrl *phdr = ctl.GetHeaderCtrl();
+       for (int i=0; i < phdr->GetItemCount(); i++)
+       {
+               CString s;
+               s.Format(_T("WDirHdr%d"), i);
+               theApp.WriteProfileInt(_T("DirView"), s, ctl.GetColumnWidth(i));
+       }
+
+       CListViewEx::OnDestroy();
+       
+}
+
+void CDirView::OnSetFocus(CWnd* pOldWnd) 
+{
+       CListViewEx::OnSetFocus(pOldWnd);
+       
+       mf->SetDiffStatus(-1,-1);
+       
+}
index 4b25858..89241d0 100644 (file)
@@ -36,6 +36,7 @@
 // CDirView view
 #include <afxcview.h>
 #include "listvwex.h"
+#include "SortHeaderCtrl.h"
 
 class CDirDoc;
 
@@ -49,6 +50,7 @@ protected:
        CImageList m_imageList;
 public:
        CDirDoc* GetDocument(); // non-debug version is inline
+       CSortHeaderCtrl         m_ctlSortHeader;
 
 // Operations
 public:
@@ -87,6 +89,8 @@ protected:
        afx_msg void OnUpdateDirCopyFileToLeft(CCmdUI* pCmdUI);
        afx_msg void OnDirCopyFileToRight();
        afx_msg void OnUpdateDirCopyFileToRight(CCmdUI* pCmdUI);
+       afx_msg void OnDestroy();
+       afx_msg void OnSetFocus(CWnd* pOldWnd);
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
 };
index 5b4de93..a274d52 100644 (file)
@@ -31,6 +31,7 @@
 #include "DirView.h"
 #include "DirDoc.h"
 #include "OpenDlg.h"
+#include "MergeEditView.h"
 
 #include "diff.h"
 #include "getopt.h"
@@ -43,6 +44,7 @@
 #include "PropGeneral.h"
 #include "RegKey.h"
 #include "logfile.h"
+#include "PropSyntax.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -117,6 +119,7 @@ CMainFrame::CMainFrame()
        m_strVssProject = theApp.GetProfileString(_T("Settings"), _T("VssProject"), _T(""));
        m_strVssPath = theApp.GetProfileString(_T("Settings"), _T("VssPath"), _T(""));
        m_nTabSize = theApp.GetProfileInt(_T("Settings"), _T("TabSize"), 4);
+       m_bHiliteSyntax = theApp.GetProfileInt(_T("Settings"), _T("HiliteSyntax"), TRUE)!=0;
        if (m_strVssPath.IsEmpty())
        {
                CRegKeyEx reg;
@@ -224,7 +227,7 @@ void CMainFrame::ShowMergeDoc(LPCTSTR szLeft, LPCTSTR szRight)
        if (docNull)
                m_pMergeDoc = (CMergeDoc*)theApp.m_pDiffTemplate->OpenDocumentFile(NULL);
        else if (mf->m_pLeft)
-               mf->m_pLeft->SendMessage(WM_COMMAND, ID_FILE_SAVE);
+               m_pLeft->SendMessage(WM_COMMAND, ID_FILE_SAVE);
 
        if (m_pMergeDoc != NULL)
        {
@@ -233,9 +236,30 @@ void CMainFrame::ShowMergeDoc(LPCTSTR szLeft, LPCTSTR szRight)
                if (m_pMergeDoc->Rescan())
                {
                        if (docNull)
-                               MDIActivate(m_pMergeDoc->m_pView->GetParent());
+                       {
+                               CWnd* pWnd = m_pMergeDoc->m_pView->GetParent();
+                               MDIActivate(pWnd);
+                       }
                        else
                                MDINext();
+                       
+                       // set the document types
+                       TCHAR name[MAX_PATH],ext[MAX_PATH];
+                       split_filename(szLeft, NULL, name, ext);
+                       m_pLeft->SetTextType(ext);
+                       split_filename(szRight, NULL, name, ext);
+                       m_pRight->SetTextType(ext);
+                       
+                       
+                       // set the frame window header
+                       CChildFrame *pf = static_cast<CChildFrame *>(m_pMergeDoc->m_pView->GetParentFrame());
+                       if (pf != NULL)
+                       {
+                               pf->SetHeaderText(0, szLeft);
+                               pf->SetHeaderText(1, szRight);
+                       }
+
+                       mf->m_pLeft->UpdateStatusMessage();
                }
                else
                {
@@ -305,7 +329,16 @@ void CMainFrame::OnUpdateHideBackupFiles(CCmdUI* pCmdUI)
 
 void CMainFrame::OnHelpGnulicense() 
 {
-       ShellExecute(m_hWnd, _T("open"), _T("notepad.exe"),_T("Copying"), NULL, SW_SHOWNORMAL);
+       TCHAR path[MAX_PATH], temp[MAX_PATH];
+       GetModuleFileName(NULL, temp, MAX_PATH);
+       split_filename(temp, path, NULL, NULL);
+       _tcscat(path, _T("\\Copying"));
+
+       CFileStatus status;
+       if (CFile::GetStatus(path, status))
+               ShellExecute(m_hWnd, _T("open"), _T("notepad.exe"),path, NULL, SW_SHOWNORMAL);
+       else
+               ShellExecute(NULL, _T("open"), _T("http://www.gnu.org/copyleft/gpl.html"), NULL, NULL, SW_SHOWNORMAL);
 }
 
 
@@ -447,7 +480,9 @@ void CMainFrame::OnProperties()
        CPropertySheet sht(IDS_PROPERTIES_TITLE);
        CPropVss vss;
        CPropGeneral gen;
+       CPropSyntax syn;
        sht.AddPage(&gen);
+       sht.AddPage(&syn);
        sht.AddPage(&vss);
        
        vss.m_nVerSys = m_nVerSys;
@@ -459,6 +494,8 @@ void CMainFrame::OnProperties()
        gen.m_bIgnoreBlankLines = m_bIgnoreBlankLines;
        gen.m_bScroll = m_bScrollToFirst;
        gen.m_nTabSize = m_nTabSize;
+
+       syn.m_bHiliteSyntax = m_bHiliteSyntax;
        
        if (sht.DoModal()==IDOK)
        {
@@ -484,6 +521,10 @@ void CMainFrame::OnProperties()
                theApp.WriteProfileInt(_T("Settings"), _T("IgnoreBlankLines"), m_bIgnoreBlankLines);
                theApp.WriteProfileInt(_T("Settings"), _T("IgnoreCase"), m_bIgnoreCase);
 
+               m_bHiliteSyntax = syn.m_bHiliteSyntax;
+               theApp.WriteProfileInt(_T("Settings"), _T("HiliteSyntax"), m_bHiliteSyntax);
+
+
                // make an attempt at rescanning any open diff sessions
                if (m_pLeft != NULL && m_pRight != NULL)
                {
@@ -687,7 +728,7 @@ void CMainFrame::OnViewSelectfont()
        CHOOSEFONT cf;
        memset(&cf, 0, sizeof(CHOOSEFONT));
        cf.lStructSize = sizeof(CHOOSEFONT);
-       cf.Flags = CF_INITTOLOGFONTSTRUCT|CF_FORCEFONTEXIST|CF_SCREENFONTS|CF_SCRIPTSONLY;
+       cf.Flags = CF_INITTOLOGFONTSTRUCT|CF_FORCEFONTEXIST|CF_SCREENFONTS|CF_FIXEDPITCHONLY;
        cf.lpLogFont = &m_lfDiff;
        if (ChooseFont(&cf))
        {
@@ -714,6 +755,8 @@ void CMainFrame::OnViewSelectfont()
 
 void CMainFrame::GetFontProperties()
 {
+       m_bFontSpecified=FALSE;
+       /*TODO
        m_bFontSpecified = theApp.GetProfileInt(_T("Font"), _T("Specified"), FALSE)!=FALSE;
        if (m_bFontSpecified)
        {
@@ -732,7 +775,7 @@ void CMainFrame::GetFontProperties()
                m_lfDiff.lfPitchAndFamily = (BYTE)theApp.GetProfileInt(_T("Font"), _T("PitchAndFamily"), FF_SWISS | DEFAULT_PITCH);
                _tcscpy(m_lfDiff.lfFaceName, theApp.GetProfileString(_T("Font"), _T("FaceName"), _T("MS Sans Serif")));
        }
-       else
+       else*/
                memset(&m_lfDiff, 0, sizeof(LOGFONT));
 }
 
@@ -775,7 +818,7 @@ void CMainFrame::OnHelpContents()
        if (CFile::GetStatus(path, status))
                ShellExecute(NULL, _T("open"), path, NULL, NULL, SW_SHOWNORMAL);
        else
-               ShellExecute(NULL, _T("open"), _T("http://www.geocities.com/SiliconValley/Vista/8632/WinMerge/index.html"), NULL, NULL, SW_SHOWNORMAL);
+               ShellExecute(NULL, _T("open"), _T("http://winmerge.sourceforge.net/docs/index.html"), NULL, NULL, SW_SHOWNORMAL);
 
 }
 
index 0a25a57..753d528 100644 (file)
@@ -36,6 +36,7 @@
 class CDiffView;
 class CDirView;
 class CDirDoc;
+class CMergeEditView;
 
 class CMainFrame : public CMDIFrameWnd
 {
@@ -65,6 +66,7 @@ public:
 
 // Implementation
 public:
+       BOOL m_bHiliteSyntax;
        void SetDiffStatus(int nDiff, int nDiffCnt);
        BOOL m_bFirstTime;
        CString m_strSaveAsPath;
@@ -85,7 +87,7 @@ public:
        BOOL m_bIgnoreWhitespace;
        BOOL m_bScrollToFirst;
        void ShowMergeDoc(LPCTSTR szLeft, LPCTSTR szRight);
-       CDiffView *m_pLeft, *m_pRight;
+       CMergeEditView *m_pLeft, *m_pRight;
        CMergeDoc *m_pMergeDoc;
        CDirDoc *m_pDirDoc;
        virtual ~CMainFrame();
index 5ef87d0..c28244d 100644 (file)
@@ -37,6 +37,7 @@
 #include "logfile.h"
 #include "coretools.h"
 
+#include "MergeEditView.h"
 #ifdef _DEBUG
 #define new DEBUG_NEW
 #undef THIS_FILE
@@ -127,7 +128,7 @@ BOOL CMergeApp::InitInstance()
                IDR_MERGETYPE,
                RUNTIME_CLASS(CMergeDoc),
                RUNTIME_CLASS(CChildFrame), // custom MDI child frame
-               RUNTIME_CLASS(CDiffView));
+               RUNTIME_CLASS(CMergeEditView));
        AddDocTemplate(m_pDiffTemplate);
        m_pDirTemplate = new CMultiDocTemplate(
                IDR_MERGETYPE,
index 73f3b27..836c78f 100644 (file)
@@ -44,7 +44,7 @@ RSC=rc.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /MD /W4 /GX /Zi /Od /I "." /I "..\common" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "HAVE_STDLIB_H" /D "STDC_HEADERS" /D HAVE_STRING_H=1 /D PR_FILE_NAME=\"pr\" /D DIFF_PROGRAM=\"diff\" /D "REGEX_MALLOC" /D "__MSC__" /D "__NT__" /D USG=1 /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MD /W4 /GX /Zi /Od /I "." /I "..\common" /I ".\editlib" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "HAVE_STDLIB_H" /D "STDC_HEADERS" /D HAVE_STRING_H=1 /D PR_FILE_NAME=\"pr\" /D DIFF_PROGRAM=\"diff\" /D "REGEX_MALLOC" /D "__MSC__" /D "__NT__" /D USG=1 /D EDITPADC_CLASS= /Yu"stdafx.h" /FD /c
 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL"
 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL"
 # ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
@@ -57,7 +57,7 @@ LINK32=link.exe
 # ADD LINK32 version.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /out:"..\Build\MergeRelease/WinMerge.exe" /verbose:lib
 # SUBTRACT LINK32 /pdb:none
 # Begin Special Build Tool
-TargetPath=\Merge\Build\MergeRelease\WinMerge.exe
+TargetPath=\Programs\Merge\Build\MergeRelease\WinMerge.exe
 SOURCE="$(InputPath)"
 PostBuild_Cmds=StampVer -vstampver.inf -i4 -j4 -o2 $(TargetPath)
 # End Special Build Tool
@@ -76,7 +76,7 @@ PostBuild_Cmds=StampVer -vstampver.inf -i4 -j4 -o2 $(TargetPath)
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I "..\common" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "HAVE_STDLIB_H" /D "STDC_HEADERS" /D HAVE_STRING_H=1 /D PR_FILE_NAME=\"pr\" /D DIFF_PROGRAM=\"diff\" /D "REGEX_MALLOC" /D "__MSC__" /D "__NT__" /D USG=1 /FR /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I "..\common" /I ".\editlib" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "HAVE_STDLIB_H" /D "STDC_HEADERS" /D HAVE_STRING_H=1 /D PR_FILE_NAME=\"pr\" /D DIFF_PROGRAM=\"diff\" /D "REGEX_MALLOC" /D "__MSC__" /D "__NT__" /D USG=1 /D EDITPADC_CLASS= /FR /Yu"stdafx.h" /FD /c
 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL"
 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL"
 # ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
@@ -103,7 +103,7 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "ms" /I "." /I "..\releases\current\common" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "HAVE_STDLIB_H" /D "STDC_HEADERS" /D HAVE_STRING_H=1 /D PR_FILE_NAME=\"pr\" /D DIFF_PROGRAM=\"diff\" /D "REGEX_MALLOC" /D "__MSC__" /D "__NT__" /D USG=1 /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "." /I "..\common" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "HAVE_STDLIB_H" /D "STDC_HEADERS" /D HAVE_STRING_H=1 /D PR_FILE_NAME=\"pr\" /D DIFF_PROGRAM=\"diff\" /D "REGEX_MALLOC" /D "__MSC__" /D "__NT__" /D USG=1 /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "." /I "..\common" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "HAVE_STDLIB_H" /D "STDC_HEADERS" /D HAVE_STRING_H=1 /D PR_FILE_NAME=\"pr\" /D DIFF_PROGRAM=\"diff\" /D "REGEX_MALLOC" /D "__MSC__" /D "__NT__" /D USG=1 /D EDITPADC_CLASS=AFX_EXT_CLASS /Yu"stdafx.h" /FD /c
 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL"
 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL"
 # ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
@@ -236,10 +236,13 @@ SOURCE=.\DiffView.cpp
 
 !IF  "$(CFG)" == "Merge - Win32 Release"
 
+# PROP Exclude_From_Build 1
 # SUBTRACT CPP /D "HAVE_STDLIB_H" /D "STDC_HEADERS" /D HAVE_STRING_H=1 /D PR_FILE_NAME=\"pr\" /D DIFF_PROGRAM=\"diff\" /D "REGEX_MALLOC" /D "__MSC__" /D "__NT__" /D USG=1
 
 !ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
 
+# PROP Exclude_From_Build 1
+
 !ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
 
 !ENDIF 
@@ -482,6 +485,10 @@ SOURCE=.\MergeDoc.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\MergeEditView.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\NORMAL.C
 
 !IF  "$(CFG)" == "Merge - Win32 Release"
@@ -533,6 +540,10 @@ SOURCE=.\PropGeneral.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\PropSyntax.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\PropVss.cpp
 
 !IF  "$(CFG)" == "Merge - Win32 Release"
@@ -598,6 +609,10 @@ SOURCE=.\SIDE.C
 # End Source File
 # Begin Source File
 
+SOURCE=..\common\SortHeaderCtrl.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\Splash.cpp
 
 !IF  "$(CFG)" == "Merge - Win32 Release"
@@ -731,6 +746,17 @@ SOURCE=.\DiffContext.h
 # Begin Source File
 
 SOURCE=.\DiffView.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
 # End Source File
 # Begin Source File
 
@@ -782,6 +808,10 @@ SOURCE=.\MergeDoc.h
 # End Source File
 # Begin Source File
 
+SOURCE=.\MergeEditView.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\OpenDlg.h
 # End Source File
 # Begin Source File
@@ -790,6 +820,10 @@ SOURCE=.\PropGeneral.h
 # End Source File
 # Begin Source File
 
+SOURCE=.\PropSyntax.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\PropVss.h
 # End Source File
 # Begin Source File
@@ -810,6 +844,10 @@ SOURCE=.\Resource.h
 # End Source File
 # Begin Source File
 
+SOURCE=..\common\SortHeaderCtrl.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\Splash.h
 # End Source File
 # Begin Source File
@@ -866,6 +904,10 @@ SOURCE=.\res\folder1.bmp
 # End Source File
 # Begin Source File
 
+SOURCE=.\res\lfile.bmp
+# End Source File
+# Begin Source File
+
 SOURCE=.\res\Merge.ico
 # End Source File
 # Begin Source File
@@ -878,6 +920,10 @@ SOURCE=.\res\MergeDoc.ico
 # End Source File
 # Begin Source File
 
+SOURCE=.\res\mg_cur.cur
+# End Source File
+# Begin Source File
+
 SOURCE=.\res\notequal.bmp
 # End Source File
 # Begin Source File
@@ -909,6 +955,997 @@ SOURCE=.\res\unknown.bmp
 SOURCE=.\res\winmerge.bmp
 # End Source File
 # End Group
+# Begin Group "EditLib"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\editlib\asp.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\basic.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\batch.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\ccrystaleditview.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\ccrystaleditview.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\ccrystaleditview.inl
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\ccrystaltextbuffer.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\ccrystaltextbuffer.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\ccrystaltextbuffer.inl
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\ccrystaltextview.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\ccrystaltextview.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\ccrystaltextview.inl
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\ccrystaltextview2.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\ceditreplacedlg.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\ceditreplacedlg.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\cfindtextdlg.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\cfindtextdlg.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\chcondlg.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\chcondlg.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\cplusplus.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\cregexp.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\cregexp.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\crystaleditviewex.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\crystaleditviewex.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\crystalparser.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\crystalparser.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\crystaltextblock.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\crystaltextblock.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\cs2cs.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\cs2cs.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\dcl.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\editcmd.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\editreg.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\edtlib.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\edtlib.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\filesup.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\filesup.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\filesup.inl
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\fortran.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\fpattern.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\fpattern.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\gotodlg.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\gotodlg.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\html.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\is.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\java.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\lisp.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\memcombo.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\memcombo.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\memcombo.inl
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\pascal.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\perl.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\php.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\python.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\registry.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\registry.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\resource.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\rexx.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\rsrc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\sgml.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\sh.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\siod.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\sql.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\statbar.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\statbar.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\tcl.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\tex.cpp
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\editlib\wispelld.h
+
+!IF  "$(CFG)" == "Merge - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Debug"
+
+# PROP Intermediate_Dir "..\Build\MergeDebug"
+
+!ELSEIF  "$(CFG)" == "Merge - Win32 Bound Check"
+
+!ENDIF 
+
+# End Source File
+# End Group
 # Begin Source File
 
 SOURCE=.\ReadMe.txt
index f373698..7ba6599 100644 (file)
@@ -90,7 +90,6 @@ BEGIN
         MENUITEM "Undo",                        ID_UNDO
         MENUITEM SEPARATOR
         MENUITEM "Save Changes...",             ID_POPUP_SAVE
-        MENUITEM "Edit file",                   ID_POPUP_EDITFILE
     END
 END
 
@@ -191,7 +190,6 @@ BEGIN
     VK_TAB,         ID_PREVDIFF,            VIRTKEY, SHIFT, NOINVERT
     VK_UP,          ID_PREVDIFF,            VIRTKEY, NOINVERT
     "X",            ID_EDIT_CUT,            VIRTKEY, CONTROL, NOINVERT
-    "Z",            ID_EDIT_UNDO,           VIRTKEY, CONTROL, NOINVERT
 END
 
 
@@ -200,19 +198,23 @@ END
 // Dialog
 //
 
-IDD_ABOUTBOX DIALOG DISCARDABLE  0, 0, 198, 90
+IDD_ABOUTBOX DIALOG DISCARDABLE  0, 0, 223, 122
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "About WinMerge"
 FONT 8, "MS Sans Serif"
 BEGIN
     ICON            IDR_MAINFRAME,IDC_STATIC,24,14,21,20
     LTEXT           "WinMerge",IDC_STATIC,63,13,63,8,SS_NOPREFIX
-    DEFPUSHBUTTON   "OK",IDOK,159,7,32,14,WS_GROUP
+    DEFPUSHBUTTON   "OK",IDOK,184,7,32,14,WS_GROUP
     LTEXT           "Version 1.0",IDC_VERSION,64,23,84,8,SS_NOPREFIX
     LTEXT           "All rights reserved.",IDC_STATIC,7,60,170,8
-    LTEXT           "Visit the WinMerge HomePage!",IDC_WWW,7,76,184,8
-    CONTROL         "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,72,184,1
-    LTEXT           "© 2000 Thingamahoochie Software",IDC_COMPANY,7,49,184,8
+    LTEXT           "Visit the WinMerge HomePage!",IDC_WWW,7,107,209,8
+    CONTROL         "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,103,209,1
+    LTEXT           "© 2000 Thingamahoochie Software",IDC_COMPANY,7,49,209,8
+    LTEXT           "Syntax Highlighting Edit View by Andrei Stcherbatchenko ",
+                    IDC_STATIC,7,71,209,8
+    LTEXT           "Various Syntaxes by Ferdinand Prantl",IDC_STATIC,7,81,
+                    209,8
 END
 
 IDD_OPEN DIALOGEX 0, 0, 352, 98
@@ -331,6 +333,15 @@ BEGIN
     LTEXT           "Comments",IDC_STATIC,18,7,34,10
 END
 
+IDD_PROPSYNTAX DIALOG DISCARDABLE  0, 0, 235, 156
+STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
+CAPTION "Hilighting"
+FONT 8, "MS Sans Serif"
+BEGIN
+    CONTROL         "Hilight syntax",IDC_HILITE_CHECK,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,7,7,57,10
+END
+
 
 #ifndef _MAC
 /////////////////////////////////////////////////////////////////////////////
@@ -360,7 +371,7 @@ BEGIN
             VALUE "FileDescription", "WinMerge Application\0"
             VALUE "FileVersion", "999.999.999.999\0"
             VALUE "InternalName", "WinMerge\0"
-            VALUE "LegalCopyright", "© 2000 Dean P. Grimm / Thingamahoochie Software\0"
+            VALUE "LegalCopyright", "© 1996-2001 Dean P. Grimm / Thingamahoochie Software\0"
             VALUE "LegalTrademarks", "\0"
             VALUE "OriginalFilename", "WinMerge.EXE\0"
             VALUE "PrivateBuild", "\0"
@@ -389,9 +400,9 @@ BEGIN
     IDD_ABOUTBOX, DIALOG
     BEGIN
         LEFTMARGIN, 7
-        RIGHTMARGIN, 191
+        RIGHTMARGIN, 216
         TOPMARGIN, 7
-        BOTTOMMARGIN, 83
+        BOTTOMMARGIN, 115
     END
 
     IDD_OPEN, DIALOG
@@ -446,6 +457,14 @@ BEGIN
         TOPMARGIN, 7
         BOTTOMMARGIN, 104
     END
+
+    IDD_PROPSYNTAX, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 228
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 149
+    END
 END
 #endif    // APSTUDIO_INVOKED
 
@@ -515,6 +534,13 @@ END
 
 /////////////////////////////////////////////////////////////////////////////
 //
+// Cursor
+//
+
+IDR_MARGIN_CURSOR       CURSOR  DISCARDABLE     "res\\mg_cur.cur"
+
+/////////////////////////////////////////////////////////////////////////////
+//
 // String Table
 //
 
index 08fee7b..27bf80e 100644 (file)
@@ -33,6 +33,8 @@
 #include "fnmatch.h"
 #include "coretools.h"
 #include "VssPrompt.h"
+#include "MergeEditView.h"
+#include "cs2cs.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -53,12 +55,18 @@ END_MESSAGE_MAP()
 /////////////////////////////////////////////////////////////////////////////
 // CMergeDoc construction/destruction
 
-CMergeDoc::CMergeDoc()
+
+#pragma warning(disable:4355)
+CMergeDoc::CMergeDoc() : m_ltBuf(this,TRUE), m_rtBuf(this,FALSE)
 {
        m_diffs.SetSize(64);
        m_nDiffs=0;
        m_pView=NULL;
+       m_nCurDiff=-1;
+       m_strTempLeftFile=_T("");
+       m_strTempRightFile=_T("");
 }
+#pragma warning(default:4355)
 
 CMergeDoc::~CMergeDoc()
 {      
@@ -69,6 +77,71 @@ CMergeDoc::~CMergeDoc()
                delete pitem;
        }
        mf->m_pMergeDoc = NULL;
+  CleanupTempFiles();
+  mf->SetDiffStatus(-1,-1); // clear diff status
+}
+
+
+void CMergeDoc::DeleteContents ()
+{
+  CDocument::DeleteContents ();
+  m_ltBuf.FreeAll ();
+  m_rtBuf.FreeAll ();
+  CleanupTempFiles();
+}
+
+void CMergeDoc::OnFileEvent (WPARAM wEvent, LPCTSTR pszPathName)
+{
+  /*if (!(theApp.m_dwFlags & EP_NOTIFY_CHANGES))
+    return;
+       MessageBeep (MB_ICONEXCLAMATION);
+       CFrameWnd *pwndMain= (CFrameWnd*) theApp.GetMainWnd ();
+       ASSERT (pwndMain);
+       if (!pwndMain->IsWindowVisible ())
+          ((CMainFrame*) pwndMain)->FlashUntilFocus ();
+       if (wEvent & FE_MODIFIED)
+       {
+         bool bReload = (theApp.m_dwFlags & EP_AUTO_RELOAD) != 0;
+         if (!bReload)
+           {
+          CString sMsg;
+          sMsg.Format (IDS_FILE_CHANGED, pszPathName);
+             bReload = AfxMessageBox (sMsg, MB_YESNO|MB_ICONQUESTION) == IDYES;
+           }
+         if (bReload)
+        {
+               POSITION pos = GetFirstViewPosition ();
+          ASSERT (pos);
+               CEditPadView *pView;
+          do
+            {
+                   pView = (CEditPadView*) GetNextView (pos);
+              pView->PushCursor ();
+            }
+          while (pos);
+          m_xTextBuffer.FreeAll ();
+          m_xTextBuffer.LoadFromFile (pszPathName);
+               pos = GetFirstViewPosition ();
+          ASSERT (pos);
+          do
+            {
+                   pView = (CEditPadView*) GetNextView (pos);
+              pView->PopCursor ();
+              HWND hWnd = pView->GetSafeHwnd ();
+              ::RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE|RDW_INTERNALPAINT|RDW_ERASE|RDW_ERASENOW|RDW_UPDATENOW|RDW_NOFRAME);
+            }
+          while (pos);
+        }
+    }
+  else if (wEvent & FE_DELETED)
+    {
+      if (!(theApp.m_dwFlags & EP_AUTO_RELOAD))
+        {
+          CString sMsg;
+          sMsg.Format (IDS_FILE_DELETED, pszPathName);
+               AfxMessageBox (sMsg, MB_OK|MB_ICONINFORMATION);
+        }
+    }*/
 }
 
 BOOL CMergeDoc::OnNewDocument()
@@ -80,6 +153,9 @@ BOOL CMergeDoc::OnNewDocument()
        VERIFY(s.LoadString(IDS_FILE_COMPARISON_TITLE));
        SetTitle(s);
 
+       
+    m_ltBuf.InitNew ();
+    m_rtBuf.InitNew ();
        return TRUE;
 }
 
@@ -128,14 +204,30 @@ BOOL CMergeDoc::Rescan()
        struct change *e, *p;
        struct change *script=NULL;
        BOOL bResult=FALSE;
+       int nResumeTopLine=0;
 
        BeginWaitCursor();
 
+       // get the desired files to temp locations so we can edit them dynamically
+       if (!TempFilesExist())
+       {
+               if (!InitTempFiles(m_strLeftFile, m_strRightFile))
+               {
+                       return FALSE;
+               }
+       }
+       else
+       {
+               // find the top line to scroll back to
+               nResumeTopLine = mf->m_pLeft->GetScrollPos(SB_VERT)+1;
+       }
+
        m_diffs.RemoveAll();
        m_nDiffs=0;
+       m_nCurDiff=-1;
        
-       split_filename(m_strLeftFile, dir0, name0, NULL);
-       split_filename(m_strRightFile, dir1, name1, NULL); 
+       split_filename(m_strTempLeftFile, dir0, name0, NULL);
+       split_filename(m_strTempRightFile, dir1, name1, NULL); 
        memset(&inf[0], 0,sizeof(inf[0]));
        memset(&inf[1], 0,sizeof(inf[1]));
        
@@ -253,12 +345,12 @@ BOOL CMergeDoc::Rescan()
                        // display the files
                        if (m_nDiffs>0)
                        {
-                               mf->m_pLeft->PrimeListWithFile(m_strLeftFile);
-                               mf->m_pRight->PrimeListWithFile(m_strRightFile);
+                               mf->m_pLeft->PrimeListWithFile(m_strTempLeftFile);
+                               mf->m_pRight->PrimeListWithFile(m_strTempRightFile);
 
-                               int lcnt = mf->m_pLeft->m_pList->GetItemCount();
-                               int rcnt = mf->m_pRight->m_pList->GetItemCount();
-                               if (lcnt < rcnt)
+                               int lcnt = mf->m_pLeft->GetLineCount();
+                               int rcnt = mf->m_pRight->GetLineCount();
+                               /*TODO: if (lcnt < rcnt)
                                {
                                        m_diffs[m_nDiffs-1].dbegin0 = lcnt;
                                        m_diffs[m_nDiffs-1].dend0 = rcnt;
@@ -282,7 +374,7 @@ BOOL CMergeDoc::Rescan()
                                        mf->m_pRight->AddItem(rcnt, 0, "");
                                        mf->m_pRight->m_pList->SetItemData(rcnt, 1);
                                        rcnt++;
-                               }
+                               }*/
                                bResult=TRUE;
                        }
                        else if (diff_flag)
@@ -306,6 +398,12 @@ BOOL CMergeDoc::Rescan()
                free (free1);
 
        EndWaitCursor();
+
+       if (nResumeTopLine>0)
+       {
+               mf->m_pLeft->GoToLine(nResumeTopLine, FALSE);
+               mf->m_pRight->GoToLine(nResumeTopLine, FALSE);
+       }
        return bResult;
 }
 
@@ -334,7 +432,7 @@ void CMergeDoc::AddDiffRange(UINT begin0, UINT end0, UINT begin1, UINT end1, BYT
 }
 
 
-void CMergeDoc::AddUndoAction(UINT nBegin, UINT nEnd, UINT nDiff, int nBlanks, BOOL bInsert, CDiffView *pList)
+void CMergeDoc::AddUndoAction(UINT nBegin, UINT nEnd, UINT nDiff, int nBlanks, BOOL bInsert, CMergeEditView *pList)
 {
        CUndoItem *pitem = new CUndoItem;
        if (pitem != NULL)
@@ -348,7 +446,7 @@ void CMergeDoc::AddUndoAction(UINT nBegin, UINT nEnd, UINT nDiff, int nBlanks, B
                if (bInsert)
                        for (UINT i=nBegin; i <= nEnd; i++)
                        {
-                               CString s = pitem->m_pList->m_pList->GetItemText(i, 0);
+                               CString s = pitem->m_pList->GetLineText(i);
                                pitem->list.AddTail(s);
                        }
 
@@ -358,7 +456,7 @@ void CMergeDoc::AddUndoAction(UINT nBegin, UINT nEnd, UINT nDiff, int nBlanks, B
 
 BOOL CMergeDoc::Undo()
 {
-       if (!m_undoList.IsEmpty())
+/*TODO if (!m_undoList.IsEmpty())
        {
                CUndoItem *pitem = (CUndoItem *)m_undoList.RemoveHead();
                if (pitem != NULL)
@@ -398,42 +496,97 @@ BOOL CMergeDoc::Undo()
 
                        return TRUE;
                }
-       }
+       }*/
        return FALSE;
 }
 
 
-void CMergeDoc::ListCopy(CDiffView * pSrcList, CDiffView * pDestList)
+void CMergeDoc::ListCopy(CMergeEditView * pSrcList, CMergeEditView * pDestList)
 {
-       CString s;
-       int sel;
-       int begin,end=-1;
-       begin = sel = pSrcList->m_pList->GetNextItem(-1,LVNI_SELECTED);
-       if (sel==-1)
-               return;
-       while ((sel=pSrcList->m_pList->GetNextItem(sel,LVNI_SELECTED)) != -1)
-       {
-               end=sel;
-       }
-       if (end==-1)
-               end=begin;
-               
-       int diff = LineToDiff(begin);
-       if (pDestList->m_bIsLeft)
-       {
-               AddUndoAction(begin, end, diff, m_diffs[diff].blank0, TRUE, pDestList);
-               m_diffs[diff].blank0 = m_diffs[diff].blank1;
-       }
-       else 
+       if (pSrcList!=NULL && pDestList!=NULL)
        {
-               AddUndoAction(begin, end, diff, m_diffs[diff].blank1, TRUE, pDestList);
-               m_diffs[diff].blank1 = m_diffs[diff].blank0;
-       }
-       sel=-1;
-       while ((sel=pSrcList->m_pList->GetNextItem(sel,LVNI_SELECTED)) != -1)
-       {
-               s = pSrcList->m_pList->GetItemText(sel,0);
-               pDestList->m_pList->SetItemText(sel,0,s);
+               // make sure we're on a diff
+               int curDiff = GetCurrentDiff();
+               if (curDiff!=-1)
+               {
+                       BOOL bSrcLeft = pSrcList->m_bIsLeft;
+                       DIFFRANGE &cd = m_diffs[curDiff];
+                       CDiffTextBuffer& sbuf = bSrcLeft? m_ltBuf:m_rtBuf;
+                       CDiffTextBuffer& dbuf = bSrcLeft? m_rtBuf:m_ltBuf;
+                       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;
+
+                       // TODO: add the undo action
+
+                       // clear the line flags
+                       for (int i=cd_dbegin; i <= cd_dend; i++)
+                       {
+                               sbuf.SetLineFlag(i, LF_WINMERGE_FLAGS, FALSE, FALSE, FALSE);
+                               dbuf.SetLineFlag(i, LF_WINMERGE_FLAGS, FALSE, FALSE, FALSE);
+                       }
+
+                       // if the current diff contains missing lines, remove them from both sides
+                       int deleted_lines=0;
+                       if (cd_blank>=0)
+                       {
+                               // text was missing, so delete rest of lines on both sides
+                               sbuf.DeleteText(pSrcList, cd_blank, 0, cd_dend+1, 0);
+                               dbuf.DeleteText(pDestList, cd_blank, 0, cd_dend+1, 0);
+                           deleted_lines=cd_dend-cd_blank+1;
+                       }
+                       
+
+                       // copy the selected text over
+                       CString strLine;
+                       int limit;
+                       if (cd_blank>=0)
+                               limit=cd_blank-1;
+                       else
+                               limit=cd_dend;
+                       for (i=cd_dbegin; i <= limit; i++)
+                       {
+                               // text exists on left side, so just replace
+                               sbuf.GetLine(i, strLine);
+                               dbuf.ReplaceLine(i, strLine);
+                       }
+
+                       //mf->m_pRight->ReplaceSelection(strText, 0);
+                       pSrcList->SelectNone();
+                       pDestList->SelectNone();
+
+                       //pSrcList->InvalidateLines(cd_dbegin, cd_dend);
+                       //pDestList->InvalidateLines(cd_dbegin, cd_dend);
+
+                       // remove the diff                      
+                       SetCurrentDiff(-1);
+                       m_diffs.RemoveAt(curDiff);
+                       m_nDiffs--;
+
+                       // adjust remaining diffs
+                       if (deleted_lines>0)
+                       {
+                               for (int i=curDiff; i < (int)m_nDiffs; i++)
+                               {
+                                       DIFFRANGE &cd = m_diffs[i];
+                                       cd.dbegin0 -= deleted_lines;
+                                       cd.dbegin1 -= deleted_lines;
+                                       cd.dend0 -= deleted_lines;
+                                       cd.dend1 -= deleted_lines;
+                                       cd.blank0 -= deleted_lines;
+                                       cd.blank1 -= deleted_lines;
+                               }
+                       }
+
+                       pSrcList->UpdateStatusMessage();
+                       pSrcList->Invalidate();
+                       pDestList->Invalidate();
+
+                       // reset the mod status of the source view because we do make some
+                       // changes, but none that concern the source text
+                       sbuf.SetModified(bSrcWasMod);
+               }
        }
        pDestList->AddMod();
        pDestList->UpdateWindow();
@@ -441,9 +594,8 @@ void CMergeDoc::ListCopy(CDiffView * pSrcList, CDiffView * pDestList)
 
 
 
-BOOL CMergeDoc::DoSave(LPCTSTR szPath, CListCtrl * pList, BOOL bLeft)
+BOOL CMergeDoc::DoSave(LPCTSTR szPath, CMergeEditView * /*pList*/, BOOL bLeft)
 {
-       HANDLE hf;
        CString strSavePath(szPath);
 
        if (!mf->m_strSaveAsPath.IsEmpty())
@@ -470,34 +622,9 @@ BOOL CMergeDoc::DoSave(LPCTSTR szPath, CListCtrl * pList, BOOL bLeft)
        if (!mf->CreateBackup(strSavePath))
                return FALSE;
 
-       if ((hf=FOPEN(strSavePath, GENERIC_WRITE, CREATE_ALWAYS)) != INVALID_HANDLE_VALUE)
-       {
-               CString s;
-               int idx,cnt = pList->GetItemCount();
-               int blank0,blank1;
-               for (int i=0; i < cnt; i++)
-               {
-                       idx=LineToDiff(i);
-                       s = pList->GetItemText(i,0);
-                       if (idx!=-1)
-                       {
-                               blank0 = m_diffs[idx].blank0;
-                               blank1 = m_diffs[idx].blank1;
-                               if ((bLeft && (blank0 < 0 || i < blank0))
-                               || (!bLeft && (blank1 < 0 || i < blank1)))
-                               {
-                                       FPRINTF(hf, "%s\r\n", s);
-                                       //FPRINTF(hf, "%s\r\n", Tabify(s));
-                               }
-                       }
-                       else
-                               FPRINTF(hf, "%s\r\n", s);
-                       //FPRINTF(hf, "%s\r\n", Tabify(s));
-               }
-               CloseHandle(hf);
-               return TRUE;
-       }
-       return FALSE;
+       if(bLeft)
+               return m_ltBuf.SaveToFile(strSavePath);
+       return m_rtBuf.SaveToFile(strSavePath);
 }
 
 
@@ -594,15 +721,257 @@ UINT CMergeDoc::CountPrevBlanks(UINT nCurLine, BOOL bLeft)
        return nBlanks;
 }
 
-BOOL CMergeDoc::CanCloseFrame(CFrameWnd* pFrame
+BOOL CMergeDoc::CanCloseFrame(CFrameWnd* /*pFrame*/
 {
        if (mf->m_pLeft)
                if (!mf->m_pLeft->SaveHelper())
                        return FALSE;
-
        
-       BOOL result = CDocument::CanCloseFrame(pFrame);
-       if (result)
-               mf->m_pLeft = mf->m_pRight = NULL;
-       return result;
+       mf->m_pLeft = mf->m_pRight = NULL;
+       return TRUE;
+}
+
+void CMergeDoc::SetCurrentDiff(int nDiff)
+{
+       if (nDiff >= 0 && nDiff < (int)m_nDiffs)
+               m_nCurDiff = nDiff;
+       else
+               m_nCurDiff = -1;
+}
+
+#define FLAGSET(f)   ((m_aLines[nLine].m_dwFlags&(f))==(f))
+
+BOOL CMergeDoc::CDiffTextBuffer::SaveToFile (LPCTSTR pszFileName, 
+                                                                                        int nCrlfStyle /*= CRLF_STYLE_AUTOMATIC*/ , 
+                                                                                        BOOL bClearModifiedFlag /*= TRUE*/ )
+{
+  ASSERT (nCrlfStyle == CRLF_STYLE_AUTOMATIC || nCrlfStyle == CRLF_STYLE_DOS ||
+          nCrlfStyle == CRLF_STYLE_UNIX || nCrlfStyle == CRLF_STYLE_MAC);
+  ASSERT (m_bInit);
+  HANDLE hTempFile = INVALID_HANDLE_VALUE;
+  HANDLE hSearch = INVALID_HANDLE_VALUE;
+  TCHAR szTempFileDir[_MAX_PATH + 1];
+  TCHAR szTempFileName[_MAX_PATH + 1];
+  TCHAR szBackupFileName[_MAX_PATH + 1];
+  BOOL bSuccess = FALSE;
+  __try
+  {
+    TCHAR drive[_MAX_PATH], dir[_MAX_PATH], name[_MAX_PATH], ext[_MAX_PATH];
+#ifdef _UNICODE
+    _wsplitpath (pszFileName, drive, dir, name, ext);
+#else
+    _splitpath (pszFileName, drive, dir, name, ext);
+#endif
+    _tcscpy (szTempFileDir, drive);
+    _tcscat (szTempFileDir, dir);
+    _tcscpy (szBackupFileName, pszFileName);
+    _tcscat (szBackupFileName, _T (".bak"));
+
+    if (::GetTempFileName (szTempFileDir, _T ("MRG"), 0, szTempFileName) == 0)
+      __leave;
+
+      hTempFile =::CreateFile (szTempFileName, GENERIC_WRITE, 0, NULL,
+                               CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+      if (hTempFile == INVALID_HANDLE_VALUE)
+        __leave;
+
+        if (nCrlfStyle == CRLF_STYLE_AUTOMATIC)
+          nCrlfStyle = m_nCRLFMode;
+
+          ASSERT (nCrlfStyle >= 0 && nCrlfStyle <= 2);
+          LPCTSTR pszCRLF = crlfs[nCrlfStyle];
+          int nCRLFLength = _tcslen (pszCRLF);
+
+          int nLineCount = m_aLines.GetSize ();
+          for (int nLine = 0; nLine < nLineCount; nLine++)
+            {
+                         // skip blank diff lines
+                         if ((!m_bIsLeft && FLAGSET(LF_LEFT_ONLY))
+                                 || (m_bIsLeft && FLAGSET(LF_RIGHT_ONLY)))
+                               continue;
+
+              int nLength = m_aLines[nLine].m_nLength;
+              DWORD dwWrittenBytes;
+              if (nLength > 0)
+                {
+                  LPCTSTR pszLine = m_aLines[nLine].m_pcLine;
+                  if (m_nSourceEncoding >= 0)
+                    {
+                      LPTSTR pszBuf;
+                      iconvert_new (m_aLines[nLine].m_pcLine, &pszBuf, 1, m_nSourceEncoding, m_nSourceEncoding == 15);
+                      if (!::WriteFile (hTempFile, pszBuf, nLength, &dwWrittenBytes, NULL))
+                        {
+                          free (pszBuf);
+                          __leave;
+                        }
+                      free (pszBuf);
+                    }
+                  else
+                    if (!::WriteFile (hTempFile, pszLine, nLength, &dwWrittenBytes, NULL))
+                      __leave;
+                  if (nLength != (int) dwWrittenBytes)
+                    __leave;
+                }
+              if (nLine < nLineCount - 1)     //  Last line must not end with CRLF
+
+                {
+                  if (!::WriteFile (hTempFile, pszCRLF, nCRLFLength, &dwWrittenBytes, NULL))
+                    __leave;
+                  if (nCRLFLength != (int) dwWrittenBytes)
+                    __leave;
+                }
+            }
+    ::CloseHandle (hTempFile);
+    hTempFile = INVALID_HANDLE_VALUE;
+
+    if (m_bCreateBackupFile)
+      {
+        WIN32_FIND_DATA wfd;
+        hSearch =::FindFirstFile (pszFileName, &wfd);
+        if (hSearch != INVALID_HANDLE_VALUE)
+          {
+            //  File exist - create backup file
+            ::DeleteFile (szBackupFileName);
+            if (!::MoveFile (pszFileName, szBackupFileName))
+              __leave;
+            ::FindClose (hSearch);
+            hSearch = INVALID_HANDLE_VALUE;
+          }
+      }
+    else
+      {
+        ::DeleteFile (pszFileName);
+      }
+
+    //  Move temporary file to target name
+    if (!::MoveFile (szTempFileName, pszFileName))
+      __leave;
+
+      if (bClearModifiedFlag)
+        {
+          SetModified (FALSE);
+          m_nSyncPosition = m_nUndoPosition;
+        }
+    bSuccess = TRUE;
+  }
+  __finally
+  {
+    if (hSearch != INVALID_HANDLE_VALUE)
+      ::FindClose (hSearch);
+      if (hTempFile != INVALID_HANDLE_VALUE)
+        ::CloseHandle (hTempFile);
+        ::DeleteFile (szTempFileName);
+      }
+      return bSuccess;
+}
+
+void CMergeDoc::CDiffTextBuffer::ReplaceLine(int nLine, const CString &strText)
+{
+  DeleteLine(nLine);
+
+  int endl,endc;
+  InternalInsertText(NULL, nLine, 0, strText, endl,endc);
+}
+
+void CMergeDoc::CDiffTextBuffer::DeleteLine(int nLine)
+{
+       if (GetLineLength(nLine)>0)
+               DeleteText(m_bIsLeft? mf->m_pLeft:mf->m_pRight, nLine, 0, nLine, GetLineLength(nLine));
+}
+
+BOOL CMergeDoc::InitTempFiles(const CString& srcPathL, const CString& strPathR)
+{
+       CleanupTempFiles();
+
+       CString strPath = GetModulePath(NULL);
+       if (m_strTempLeftFile.IsEmpty())
+       {
+               TCHAR name[MAX_PATH];
+               ::GetTempFileName (strPath, _T ("_LT"), 0, name);
+               m_strTempLeftFile = name;
+
+               if (!::CopyFile(srcPathL, m_strTempLeftFile, FALSE))
+                       return FALSE;
+               ::SetFileAttributes(m_strTempLeftFile, FILE_ATTRIBUTE_NORMAL);
+       }
+       if (m_strTempRightFile.IsEmpty())
+       {
+               TCHAR name[MAX_PATH];
+               ::GetTempFileName (strPath, _T ("_RT"), 0, name);
+               m_strTempRightFile = name;
+
+               if (!::CopyFile(strPathR, m_strTempRightFile, FALSE))
+                       return FALSE;
+               ::SetFileAttributes(m_strTempRightFile, FILE_ATTRIBUTE_NORMAL);
+       }
+       return TRUE;
+}
+
+void TraceLastErrorMessage()
+{
+       LPVOID lpMsgBuf;
+       FormatMessage( 
+               FORMAT_MESSAGE_ALLOCATE_BUFFER | 
+               FORMAT_MESSAGE_FROM_SYSTEM | 
+               FORMAT_MESSAGE_IGNORE_INSERTS,
+               NULL,
+               GetLastError(),
+               MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+               (LPTSTR) &lpMsgBuf,
+               0,
+               NULL 
+               );
+       // Process any inserts in lpMsgBuf.
+       // ...
+       // Display the string.
+       //MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
+       TRACE((LPCTSTR)lpMsgBuf);
+       // Free the buffer.
+       LocalFree( lpMsgBuf );
+}
+
+void CMergeDoc::CleanupTempFiles()
+{
+       if (!m_strTempLeftFile.IsEmpty())
+       {
+               if (::DeleteFile(m_strTempLeftFile))
+                       m_strTempLeftFile = _T("");
+               else
+                       TraceLastErrorMessage();
+       }
+       if (!m_strTempRightFile.IsEmpty())
+       {
+               if (::DeleteFile(m_strTempRightFile))
+                       m_strTempRightFile = _T("");
+               else
+                       TraceLastErrorMessage();
+       }
+}
+
+BOOL CMergeDoc::TempFilesExist()
+{
+       CFileStatus s1,s2;
+       return (!m_strTempLeftFile.IsEmpty() 
+               && CFile::GetStatus(m_strTempLeftFile, s1)
+               && !m_strTempRightFile.IsEmpty() 
+               && CFile::GetStatus(m_strTempRightFile, s2));
+}
+
+void CMergeDoc::FlushAndRescan()
+{
+       if (m_ltBuf.IsModified())
+               m_ltBuf.SaveToFile(m_strTempLeftFile, CRLF_STYLE_AUTOMATIC, FALSE);
+       if (m_rtBuf.IsModified())
+               m_rtBuf.SaveToFile(m_strTempRightFile, CRLF_STYLE_AUTOMATIC, FALSE);
+       CWnd *pFocus =  mf->m_pLeft->GetFocus();
+       mf->m_pLeft->PushCursor();
+       mf->m_pRight->PushCursor();
+       Rescan();
+       mf->m_pLeft->PopCursor();
+       mf->m_pRight->PopCursor();
+       if (pFocus!=NULL)
+               pFocus->SetFocus();
+
+       mf->m_pLeft->UpdateStatusMessage();
 }
index 02b8657..790402b 100644 (file)
@@ -29,6 +29,7 @@
 #endif // _MSC_VER >= 1000
 
 #include "afxtempl.h"
+#include "CCrystalTextBuffer.h"
 
 #define OP_NONE                        0
 #define OP_LEFTONLY            1
@@ -42,7 +43,7 @@ typedef struct tagDIFFRANGE {
        BYTE op;
 }DIFFRANGE;
 
-class CDiffView;
+class CMergeEditView;
 
 class CUndoItem
 {
@@ -50,34 +51,80 @@ public:
        UINT begin,end,diffidx;
        int blank;
        BOOL bInsert;
-       CDiffView *m_pList;
+       CMergeEditView *m_pList;
        CStringList list;
 };
 
 
 class CMergeDoc : public CDocument
 {
+// Attributes
+public:
+       public :
+class CDiffTextBuffer : public CCrystalTextBuffer
+      {
+private :
+        CMergeDoc * m_pOwnerDoc;
+               BOOL m_bIsLeft;
+public :
+             void DeleteLine(int nLine);
+             void ReplaceLine(int nLine, const CString& strText);
+               BOOL SaveToFile (LPCTSTR pszFileName, 
+                                                                                        int nCrlfStyle = CRLF_STYLE_AUTOMATIC , 
+                                                                                        BOOL bClearModifiedFlag = TRUE );
+
+        CDiffTextBuffer (CMergeDoc * pDoc, BOOL bLeft)
+        {
+          m_pOwnerDoc = pDoc;
+                 m_bIsLeft=bLeft;
+        }
+        BOOL GetLine( int nLineIndex, CString &strLine )
+        {
+               int             nLineLength = CCrystalTextBuffer::GetLineLength( nLineIndex );
+
+               if( nLineLength <= 0 )
+                       return FALSE;
+
+               _tcsncpy ( strLine.GetBuffer( nLineLength ), CCrystalTextBuffer::GetLineChars( nLineIndex ), nLineLength );
+               strLine.ReleaseBuffer( nLineLength );
+
+               return TRUE;
+        }
+        virtual void SetModified (BOOL bModified = TRUE)
+        {
+          CCrystalTextBuffer::SetModified (bModified);
+          m_pOwnerDoc->SetModifiedFlag (bModified);
+        }
+               void InsertLine (LPCTSTR pszLine, int nLength = -1, int nPosition = -1)
+               {
+                       CCrystalTextBuffer::InsertLine(pszLine, nLength, nPosition);
+               }
+
+      };
+
+    CDiffTextBuffer m_ltBuf;
+    CDiffTextBuffer m_rtBuf;
+
 protected: // create from serialization only
        CMergeDoc();
        DECLARE_DYNCREATE(CMergeDoc)
 
-// Attributes
-public:
        
        // Operations
 public:        
-       CDiffView * m_pView;
+       CMergeEditView * m_pView;
        CPtrList m_undoList;
        CArray<DIFFRANGE,DIFFRANGE> m_diffs;
        UINT m_nDiffs;
+       int m_nCurDiff;
        CString m_strLeftFile, m_strRightFile;
 
        BOOL Rescan();
        void AddDiffRange(UINT begin0, UINT end0, UINT begin1, UINT end1, BYTE op);
-       void AddUndoAction(UINT nBegin, UINT nEnd, UINT nDiff, int nBlanks, BOOL bInsert, CDiffView *pList);
+       void AddUndoAction(UINT nBegin, UINT nEnd, UINT nDiff, int nBlanks, BOOL bInsert, CMergeEditView *pList);
        BOOL Undo();
-       void ListCopy(CDiffView * pSrcList, CDiffView * pDestList);
-       BOOL DoSave(LPCTSTR szPath, CListCtrl * pList, BOOL bLeft);
+       void ListCopy(CMergeEditView * pSrcList, CMergeEditView * pDestList);
+       BOOL DoSave(LPCTSTR szPath, CMergeEditView * pList, BOOL bLeft);
        //CString ExpandTabs(LPCTSTR szText);
        //CString Tabify(LPCTSTR szText);
        int LineToDiff(UINT nLine);
@@ -90,12 +137,20 @@ public:
        virtual BOOL OnNewDocument();
        virtual void Serialize(CArchive& ar);
        virtual BOOL CanCloseFrame(CFrameWnd* pFrame);
+       virtual void DeleteContents ();
        //}}AFX_VIRTUAL
 
 // Implementation
 public:
+       void FlushAndRescan();
+       BOOL TempFilesExist();
+       void CleanupTempFiles();
+       BOOL InitTempFiles(const CString& srcPathL, const CString& strPathR);
+       void SetCurrentDiff(int nDiff);
+       int GetCurrentDiff() { return m_nCurDiff; }
        UINT CountPrevBlanks(UINT nCurLine, BOOL bLeft);
        virtual ~CMergeDoc();
+       virtual void OnFileEvent (WPARAM wEvent, LPCTSTR pszPathName);
 #ifdef _DEBUG
        virtual void AssertValid() const;
        virtual void Dump(CDumpContext& dc) const;
@@ -105,6 +160,8 @@ protected:
 
 // Generated message map functions
 protected:
+       CString m_strTempRightFile;
+       CString m_strTempLeftFile;
        //{{AFX_MSG(CMergeDoc)
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
diff --git a/Src/MergeEditView.cpp b/Src/MergeEditView.cpp
new file mode 100644 (file)
index 0000000..a36e084
--- /dev/null
@@ -0,0 +1,920 @@
+// MergeEditView.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "merge.h"
+#include "MergeEditView.h"
+#include "MergeDoc.h"
+#include "MainFrm.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CMergeEditView
+
+IMPLEMENT_DYNCREATE(CMergeEditView, CCrystalEditViewEx)
+
+CMergeEditView::CMergeEditView()
+{
+       m_bIsLeft=FALSE;
+       m_nModifications=0;
+  SetParser (&m_xParser);
+}
+
+CMergeEditView::~CMergeEditView()
+{
+}
+
+
+BEGIN_MESSAGE_MAP(CMergeEditView, CCrystalEditViewEx)
+       //{{AFX_MSG_MAP(CMergeEditView)
+       ON_WM_HSCROLL()
+       ON_WM_VSCROLL()
+       ON_COMMAND(ID_ALL_LEFT, OnAllLeft)
+       ON_UPDATE_COMMAND_UI(ID_ALL_LEFT, OnUpdateAllLeft)
+       ON_COMMAND(ID_ALL_RIGHT, OnAllRight)
+       ON_UPDATE_COMMAND_UI(ID_ALL_RIGHT, OnUpdateAllRight)
+       ON_COMMAND(ID_CURDIFF, OnCurdiff)
+       ON_UPDATE_COMMAND_UI(ID_CURDIFF, OnUpdateCurdiff)
+       ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
+       ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateEditCopy)
+       ON_COMMAND(ID_EDIT_CUT, OnEditCut)
+       ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, OnUpdateEditCut)
+       ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
+       ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdateEditPaste)
+       ON_COMMAND(ID_EDIT_UNDO, OnEditUndo)
+       ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo)
+       ON_COMMAND(ID_FIRSTDIFF, OnFirstdiff)
+       ON_UPDATE_COMMAND_UI(ID_FIRSTDIFF, OnUpdateFirstdiff)
+       ON_COMMAND(ID_L2R, OnL2r)
+       ON_UPDATE_COMMAND_UI(ID_L2R, OnUpdateL2r)
+       ON_COMMAND(ID_LASTDIFF, OnLastdiff)
+       ON_UPDATE_COMMAND_UI(ID_LASTDIFF, OnUpdateLastdiff)
+       ON_COMMAND(ID_NEXTDIFF, OnNextdiff)
+       ON_UPDATE_COMMAND_UI(ID_NEXTDIFF, OnUpdateNextdiff)
+       ON_COMMAND(ID_PREVDIFF, OnPrevdiff)
+       ON_UPDATE_COMMAND_UI(ID_PREVDIFF, OnUpdatePrevdiff)
+       ON_COMMAND(ID_R2L, OnR2l)
+       ON_UPDATE_COMMAND_UI(ID_R2L, OnUpdateR2l)
+       ON_WM_LBUTTONDBLCLK()
+       ON_WM_LBUTTONUP()
+       ON_WM_KEYUP()
+       ON_WM_CHAR()
+       ON_WM_SETFOCUS()
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CMergeEditView diagnostics
+
+#ifdef _DEBUG
+void CMergeEditView::AssertValid() const
+{
+       CCrystalEditViewEx::AssertValid();
+}
+
+void CMergeEditView::Dump(CDumpContext& dc) const
+{
+       CCrystalEditViewEx::Dump(dc);
+}
+CMergeDoc* CMergeEditView::GetDocument() // non-debug version is inline
+{
+       ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMergeDoc)));
+       return (CMergeDoc*)m_pDocument;
+}
+#endif //_DEBUG
+
+/////////////////////////////////////////////////////////////////////////////
+// CMergeEditView message handlers
+CCrystalTextBuffer *CMergeEditView::LocateTextBuffer ()
+{
+       if (m_bIsLeft)
+               return &GetDocument()->m_ltBuf;
+       return &GetDocument()->m_rtBuf;
+}
+
+
+void CMergeEditView::DoScroll(UINT code, UINT pos, BOOL bDoScroll)
+{
+       TRACE(_T("Scroll %s: pos=%d\n"), m_bIsLeft? _T("left"):_T("right"), pos);
+       if (bDoScroll
+               && (code == SB_THUMBPOSITION
+                       || code == SB_THUMBTRACK))
+       {
+               ScrollToLine(pos);
+       }
+       CCrystalEditViewEx::OnVScroll(code, pos, NULL);
+}
+
+
+
+BOOL CMergeEditView::SaveHelper()
+{
+       BOOL result = TRUE;
+       CMergeDoc *pd = GetDocument();
+       CString s;
+
+       AfxFormatString1(s, IDS_SAVE_FMT, pd->m_strLeftFile); 
+       if (mf->m_pLeft
+               && mf->m_pLeft->IsModified())
+       {
+               switch(AfxMessageBox(s, MB_YESNOCANCEL|MB_ICONQUESTION))
+               {
+               case IDYES:
+                       if (pd->DoSave(pd->m_strLeftFile, mf->m_pLeft, TRUE))
+                               mf->m_pLeft->ResetMod();
+                       else
+                               result=FALSE;
+                       break;
+               case IDNO:
+                       break;
+               default:  // IDCANCEL
+                       result=FALSE;
+                       break;
+               }
+       }
+
+       AfxFormatString1(s, IDS_SAVE_FMT, pd->m_strRightFile); 
+       if (mf->m_pRight
+               && mf->m_pRight->IsModified())
+       {
+               switch(AfxMessageBox(s, MB_YESNOCANCEL|MB_ICONQUESTION))
+               {
+               case IDYES:
+                       if (pd->DoSave(pd->m_strRightFile, mf->m_pRight, FALSE))
+                               mf->m_pRight->ResetMod();
+                       else
+                               result=FALSE;
+                       break;
+               case IDNO:
+                       break;
+               default:  // IDCANCEL
+                       result=FALSE;
+                       break;
+               }
+       }
+       return result;
+}
+
+void CMergeEditView::UpdateResources()
+{
+
+}
+
+BOOL CMergeEditView::PrimeListWithFile(LPCTSTR szFilename)
+{
+       CMergeDoc *pd = GetDocument();
+       CStdioFile file;
+       UINT extras=0;   // extra lines added to view
+
+       // get the text buffer for the current view and initialize it
+       CMergeDoc::CDiffTextBuffer *pBuf = static_cast<CMergeDoc::CDiffTextBuffer*>(LocateTextBuffer());
+       pBuf->FreeAll();
+
+       // load the raw file data into the buffer
+       if (!pBuf->LoadFromFile(szFilename))
+       {
+               return FALSE;
+       }
+       CString blankline(_T(""));
+       int blanklen=blankline.GetLength();
+
+       // walk the diff stack and flag the line codes
+       pd->SetCurrentDiff(-1);
+       for (int nDiff=0; nDiff < static_cast<int>(pd->m_nDiffs); ++nDiff)
+       {
+               DIFFRANGE &curDiff = pd->m_diffs[nDiff];
+
+               // handle left-only for the left view
+               switch (curDiff.op)
+               {
+               case OP_LEFTONLY:
+                       if (m_bIsLeft)
+                       {
+                               // just flag the lines
+                               curDiff.dbegin0 = curDiff.begin0+extras;
+                               curDiff.dend0 = curDiff.end0+extras;
+                               curDiff.blank0 = -1;
+                               for (UINT i=curDiff.dbegin0; i <= curDiff.dend0; i++)
+                               {
+                                       pBuf->SetLineFlag(i, LF_LEFT_ONLY, TRUE, FALSE, FALSE);
+                               }
+                       }
+                       else
+                       {
+                               // need to insert blanks to compensate for diff on other side
+                               curDiff.dbegin1 = curDiff.begin1+extras;
+                               curDiff.dend1 = curDiff.dbegin1+(curDiff.end0-curDiff.begin0);
+                               curDiff.blank1 = curDiff.dbegin1;
+                               for (UINT i=curDiff.dbegin1; i <= curDiff.dend1; i++)
+                               {
+                                       pBuf->InsertLine(blankline, blanklen, i);
+                                       pBuf->SetLineFlag(i, LF_LEFT_ONLY, TRUE, FALSE, FALSE);
+                                       extras++;
+                               }
+                       }
+                       break;
+               case OP_RIGHTONLY:
+                       if (!m_bIsLeft)
+                       {
+                               // just flag the lines
+                               curDiff.dbegin1 = curDiff.begin1+extras;
+                               curDiff.dend1 = curDiff.end1+extras;
+                               curDiff.blank1 = -1;
+                               for (UINT i=curDiff.dbegin1; i <= curDiff.dend1; i++)
+                               {
+                                       pBuf->SetLineFlag(i, LF_RIGHT_ONLY, TRUE, FALSE, FALSE);
+                               }
+                       }
+                       else
+                       {
+                               // need to insert blanks to compensate for diff on other side
+                               curDiff.dbegin0 = curDiff.begin0+extras;
+                               curDiff.dend0 = curDiff.dbegin0+(curDiff.end1-curDiff.begin1);
+                               curDiff.blank0 = curDiff.dbegin0;
+                               for (UINT i=curDiff.dbegin0; i <= curDiff.dend0; i++)
+                               {
+                                       pBuf->InsertLine(blankline, blanklen, i);
+                                       pBuf->SetLineFlag(i, LF_RIGHT_ONLY, TRUE, FALSE, FALSE);
+                                       extras++;
+                               }
+                       }
+                       break;
+               case OP_DIFF:
+                       {
+                               if (m_bIsLeft)
+                               {
+                                       // just flag the lines
+                                       curDiff.dbegin0 = curDiff.begin0+extras;
+                                       curDiff.dend0 = curDiff.end0+extras;
+                                       for (UINT i=curDiff.dbegin0; i <= curDiff.dend0; i++)
+                                       {
+                                               pBuf->SetLineFlag(i, LF_DIFF, TRUE, FALSE, FALSE);
+                                       }
+
+                                       // insert blanks if needed
+                                       int blanks = (curDiff.end1-curDiff.begin1)-(curDiff.end0-curDiff.begin0);
+                                       if (blanks>0)
+                                       {
+                                               curDiff.blank0 = curDiff.dend0+1;
+                                               curDiff.blank1 = -1;
+                                               for (int b=0; b < blanks; b++)
+                                               {
+                                                       int idx = curDiff.blank0+b;
+                                                       pBuf->InsertLine(blankline, blanklen, idx);
+                                                       pBuf->SetLineFlag(idx, LF_RIGHT_ONLY, TRUE, FALSE, FALSE);
+                                                       curDiff.dend0++;
+                                                       extras++;
+                                               }
+                                       }
+                               }
+                               else
+                               {
+                                       // just flag the lines
+                                       curDiff.dbegin1 = curDiff.begin1+extras;
+                                       curDiff.dend1 = curDiff.end1+extras;
+                                       for (UINT i=curDiff.dbegin1; i <= curDiff.dend1; i++)
+                                       {
+                                               pBuf->SetLineFlag(i, LF_DIFF, TRUE, FALSE, FALSE);
+                                       }
+
+                                       // insert blanks if needed
+                                       int blanks = (curDiff.end0-curDiff.begin0)-(curDiff.end1-curDiff.begin1);
+                                       if (blanks>0)
+                                       {
+                                               curDiff.blank1 = curDiff.dend1+1;
+                                               curDiff.blank0 = -1;
+                                               for (int b=0; b < blanks; b++)
+                                               {
+                                                       int idx = curDiff.blank1+b;
+                                                       pBuf->InsertLine(blankline, blanklen, idx);
+                                                       pBuf->SetLineFlag(idx, LF_LEFT_ONLY, TRUE, FALSE, FALSE);
+                                                       curDiff.dend1++;
+                                                       extras++;
+                                               }
+                                       }
+                               }
+
+                       }
+                       break;
+               }
+       }
+
+
+       pBuf->SetReadOnly(FALSE);
+       SetWordWrapping(FALSE);
+       ResetView();
+
+       return TRUE;
+}
+
+CString CMergeEditView::GetLineText(int idx)
+{
+       return CString(GetLineChars(idx));
+}
+
+CString CMergeEditView::GetSelectedText()
+{
+       CPoint ptStart, ptEnd;
+       CString strText;
+       GetSelection(ptStart, ptEnd);
+       GetText(ptStart, ptEnd, strText);
+       return strText;
+}
+
+void CMergeEditView::AddMod()
+{
+
+}
+
+void CMergeEditView::ResetMod()
+{
+
+}
+
+void CMergeEditView::OnInitialUpdate() 
+{
+       m_LogFont.lfPitchAndFamily = FIXED_PITCH|FF_DONTCARE;
+       CCrystalEditViewEx::OnInitialUpdate();
+       GetDocument()->m_pView = this;
+}
+
+void CMergeEditView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) 
+{
+       // TODO: Add your specialized code here and/or call the base class
+       
+       CCrystalEditViewEx::OnActivateView(bActivate, pActivateView, pDeactiveView);
+}
+
+void CMergeEditView::GetLineColors (int nLineIndex, COLORREF & crBkgnd,
+                                COLORREF & crText, BOOL & bDrawWhitespace)
+{
+  if (mf->m_bHiliteSyntax)
+       CCrystalEditViewEx::GetLineColors(nLineIndex, crBkgnd, crText, bDrawWhitespace);
+  DWORD dwLineFlags = GetLineFlags (nLineIndex);
+  if (dwLineFlags & LF_DIFF)
+  {
+         if (IsLineInCurrentDiff(nLineIndex))
+               crBkgnd = RGB(255,0,0);
+         else
+               crBkgnd = RGB(255,255,92);
+      crText = RGB(0,0,0);
+         bDrawWhitespace = TRUE;
+      return;
+  }
+  else if (dwLineFlags & LF_DELETED)
+  {
+      if (IsLineInCurrentDiff(nLineIndex))
+               crBkgnd = RGB(255,0,0);
+         else
+               crBkgnd = RGB(192,192,192);
+      crText = RGB(0,0,0);
+         bDrawWhitespace = TRUE;
+      return;
+  }
+  else if (dwLineFlags & LF_LEFT_ONLY)
+  {
+         if (IsLineInCurrentDiff(nLineIndex))
+               crBkgnd = RGB(255,0,0);
+         else if (m_bIsLeft)
+               crBkgnd = RGB(255,255,92);
+         else
+               crBkgnd = RGB(192,192,192);
+      crText = RGB(0,0,0);
+         bDrawWhitespace = TRUE;
+      return;
+  }
+  else if (dwLineFlags & LF_RIGHT_ONLY)
+  {
+         if (IsLineInCurrentDiff(nLineIndex))
+               crBkgnd = RGB(255,0,0);
+         else if (m_bIsLeft)
+               crBkgnd = RGB(192,192,192);
+         else
+               crBkgnd = RGB(255,255,92);
+      crText = RGB(0,0,0);
+         bDrawWhitespace = TRUE;
+      return;
+  }  
+  else if (!mf->m_bHiliteSyntax)
+  {
+         crBkgnd = RGB(255,255,255);
+         crText = RGB(0,0,0);
+         bDrawWhitespace = FALSE;
+         return;
+  }
+
+
+  
+}
+
+void CMergeEditView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
+{
+       CCrystalEditViewEx::OnHScroll(nSBCode, nPos, pScrollBar);
+
+       UpdateSiblingScrollPos(TRUE);
+}
+
+void CMergeEditView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
+{
+       // TODO: Add your message handler code here and/or call default
+       
+       CCrystalEditViewEx::OnVScroll(nSBCode, nPos, pScrollBar);
+       UpdateSiblingScrollPos(FALSE);
+}
+
+void CMergeEditView::UpdateSiblingScrollPos (BOOL bHorz)
+{
+  CSplitterWnd *pSplitterWnd = GetParentSplitter (this, FALSE);
+  if (pSplitterWnd != NULL)
+  {
+      //  See CSplitterWnd::IdFromRowCol() implementation for details
+      int nCurrentRow = (GetDlgCtrlID () - AFX_IDW_PANE_FIRST) / 16;
+      int nCurrentCol = (GetDlgCtrlID () - AFX_IDW_PANE_FIRST) % 16;
+      ASSERT (nCurrentRow >= 0 && nCurrentRow < pSplitterWnd->GetRowCount ());
+      ASSERT (nCurrentCol >= 0 && nCurrentCol < pSplitterWnd->GetColumnCount ());
+         
+         int nRows = pSplitterWnd->GetRowCount ();
+         int nCols = pSplitterWnd->GetColumnCount ();
+         for (int nRow = 0; nRow < nRows; nRow++)
+         {
+          for (int nCol = 0; nCol < nCols; nCol++)
+                 {
+              if (!(nRow == nCurrentRow && nCol == nCurrentCol))  //  We don't need to update ourselves
+                         {
+                                 CMergeEditView *pSiblingView = static_cast<CMergeEditView*>(GetSiblingView (nRow, nCol));
+                                 if (pSiblingView != NULL)
+                                         pSiblingView->OnUpdateSibling (this, bHorz);
+                         }
+                 }
+         }
+  }
+}
+
+void CMergeEditView::OnUpdateSibling (CCrystalTextView * pUpdateSource, BOOL bHorz)
+{
+  if (pUpdateSource != this)
+    {
+      ASSERT (pUpdateSource != NULL);
+      ASSERT_KINDOF (CCrystalTextView, pUpdateSource);
+         CMergeEditView *pSrcView = static_cast<CMergeEditView*>(pUpdateSource);
+      if (!bHorz)  // changed this so bHorz works right
+        {
+          ASSERT (pSrcView->m_nTopLine >= 0);
+          ASSERT (pSrcView->m_nTopLine < GetLineCount ());
+          if (pSrcView->m_nTopLine != m_nTopLine)
+            {
+              ScrollToLine (pSrcView->m_nTopLine, TRUE, FALSE);
+              UpdateCaret ();
+                         RecalcVertScrollBar(TRUE);
+            }
+        }
+      else
+        {
+          ASSERT (pSrcView->m_nOffsetChar >= 0);
+          ASSERT (pSrcView->m_nOffsetChar < GetMaxLineLength ());
+          if (pSrcView->m_nOffsetChar != m_nOffsetChar)
+            {
+              ScrollToChar (pSrcView->m_nOffsetChar, TRUE, FALSE);
+              UpdateCaret ();
+                         RecalcHorzScrollBar(TRUE);
+            }
+        }
+    }
+}
+
+void CMergeEditView::SelectDiff(int nDiff, BOOL bScroll /*=TRUE*/, BOOL bSelectText /*=TRUE*/)
+{
+       CMergeDoc *pd = GetDocument();
+       mf->m_pLeft->SelectNone();
+       mf->m_pRight->SelectNone();
+       pd->SetCurrentDiff(nDiff);
+       if (nDiff >= 0
+               && nDiff < (int)pd->m_nDiffs)
+       {
+               CPoint ptStart, ptEnd;
+               ptStart.x = 0;
+               ptStart.y = pd->m_diffs[nDiff].dbegin0;
+
+               if (bScroll)
+               {               
+                       int line = ptStart.y-CONTEXT_LINES;
+                       if (line<0)
+                               line=0;
+                       mf->m_pLeft->ScrollToLine(line);
+                       mf->m_pRight->ScrollToLine(line);
+                       SetCursorPos(ptStart);
+               }
+
+               if (bSelectText)
+               {
+                       ptEnd.y = pd->m_diffs[nDiff].dend0;
+                       ptEnd.x = mf->m_pLeft->GetLineLength(ptEnd.y);
+                       mf->m_pLeft->SetSelection(ptStart, ptEnd);
+
+                       ptEnd.x = mf->m_pRight->GetLineLength(ptEnd.y);
+                       mf->m_pRight->SetSelection(ptStart, ptEnd);
+                       UpdateCaret();
+               }
+               else
+               {
+                       mf->m_pLeft->Invalidate();
+                       mf->m_pRight->Invalidate();
+               }
+
+       }
+       UpdateStatusMessage();
+}
+
+void CMergeEditView::OnAllLeft() 
+{
+       // TODO: Add your command handler code here
+       
+}
+
+void CMergeEditView::OnUpdateAllLeft(CCmdUI* pCmdUI) 
+{
+       // TODO: Add your command update UI handler code here
+       
+}
+
+void CMergeEditView::OnAllRight() 
+{
+       // TODO: Add your command handler code here
+       
+}
+
+void CMergeEditView::OnUpdateAllRight(CCmdUI* pCmdUI) 
+{
+       // TODO: Add your command update UI handler code here
+       
+}
+
+void CMergeEditView::OnCurdiff() 
+{
+       CMergeDoc *pd = GetDocument();
+       if (pd->m_nDiffs > 0)
+       {
+               // get the diff location
+               int nDiff = pd->GetCurrentDiff();
+               if (nDiff != -1)
+               {
+                       // scroll to the first line of the first diff, with some context thrown in
+                       PushCursor();
+                       SelectDiff(nDiff, TRUE, FALSE);
+                       PopCursor();
+               }
+       }
+}
+
+void CMergeEditView::OnUpdateCurdiff(CCmdUI* pCmdUI) 
+{
+       CMergeDoc *pd = GetDocument();
+       pCmdUI->Enable(pd!=NULL && pd->GetCurrentDiff()!=-1);
+}
+
+void CMergeEditView::OnEditCopy() 
+{
+       CCrystalEditViewEx::Copy();
+}
+
+void CMergeEditView::OnUpdateEditCopy(CCmdUI* pCmdUI) 
+{
+       CCrystalEditViewEx::OnUpdateEditCopy(pCmdUI);
+}
+
+void CMergeEditView::OnEditCut() 
+{
+       CCrystalEditViewEx::Cut();
+       GetDocument()->FlushAndRescan();
+       m_pTextBuffer->SetModified(TRUE);
+}
+
+void CMergeEditView::OnUpdateEditCut(CCmdUI* pCmdUI) 
+{
+       CCrystalEditViewEx::OnUpdateEditCut(pCmdUI);
+}
+
+void CMergeEditView::OnEditPaste() 
+{
+       CCrystalEditViewEx::Paste();
+       GetDocument()->FlushAndRescan();
+       m_pTextBuffer->SetModified(TRUE);
+}
+
+void CMergeEditView::OnUpdateEditPaste(CCmdUI* pCmdUI) 
+{
+       CCrystalEditViewEx::OnUpdateEditPaste(pCmdUI);
+}
+
+void CMergeEditView::OnEditUndo() 
+{
+       // TODO: Add your command handler code here
+       
+}
+
+void CMergeEditView::OnUpdateEditUndo(CCmdUI* pCmdUI) 
+{
+       // TODO: Add your command update UI handler code here
+       
+}
+
+void CMergeEditView::OnFirstdiff() 
+{
+       CMergeDoc *pd = GetDocument();
+       if (pd->m_nDiffs > 0)
+       {
+               // scroll to the first line of the first diff, with some context thrown in
+               int line = max(0, pd->m_diffs[0].dbegin0-CONTEXT_LINES);
+               mf->m_pLeft->ScrollToLine(line);
+               mf->m_pRight->ScrollToLine(line);
+
+               // select the diff
+               SelectDiff(0, TRUE, FALSE);
+       }
+}
+
+void CMergeEditView::OnUpdateFirstdiff(CCmdUI* pCmdUI) 
+{
+       OnUpdatePrevdiff(pCmdUI);
+}
+
+void CMergeEditView::OnL2r() 
+{
+       CMergeDoc *pd = GetDocument();
+       pd->ListCopy(mf->m_pLeft, mf->m_pRight);
+}
+
+void CMergeEditView::OnUpdateL2r(CCmdUI* pCmdUI) 
+{
+       CMergeDoc *pd = GetDocument();
+       pCmdUI->Enable(pd!=NULL && pd->GetCurrentDiff()!=-1);
+}
+
+void CMergeEditView::OnLastdiff() 
+{
+       CMergeDoc *pd = GetDocument();
+       if (pd->m_nDiffs>0)
+               SelectDiff(pd->m_nDiffs-1, TRUE, FALSE);
+}
+
+void CMergeEditView::OnUpdateLastdiff(CCmdUI* pCmdUI) 
+{
+       OnUpdateNextdiff(pCmdUI);
+}
+
+void CMergeEditView::OnNextdiff() 
+{
+       CMergeDoc *pd = GetDocument();
+       int cnt = pd->m_ltBuf.GetLineCount();
+       if (cnt <= 0)
+               return;
+
+       int curDiff = pd->GetCurrentDiff();
+
+       if (curDiff+1 >= (int)pd->m_nDiffs)
+       {
+               // we're on the last diff already, so remove the selection
+               mf->m_pLeft->SelectNone();
+               mf->m_pRight->SelectNone();
+       }
+       else if (curDiff!=-1)
+       {
+               // we're on a diff, so just select the next one
+               SelectDiff(curDiff+1, TRUE, FALSE);
+       }
+       else
+       {
+               // we're not on a diff, so figure out which one to select
+               int line = GetCursorPos().y;
+               if (!IsValidTextPosY(CPoint(0,line)))
+                       line = m_nTopLine;
+               for (UINT i=0; i < pd->m_nDiffs; i++)
+               {
+                       if ((int)pd->m_diffs[i].dbegin0 >= line)
+                       {
+                               curDiff=i;
+                               SelectDiff(i, TRUE, FALSE);
+                               break;
+                       }               
+               }
+       }
+}
+
+void CMergeEditView::OnUpdateNextdiff(CCmdUI* pCmdUI) 
+{
+       CMergeDoc *pd = GetDocument();
+       CPoint pos = GetCursorPos();
+       pCmdUI->Enable(pd->m_nDiffs>0 && pos.y < (long)pd->m_diffs[pd->m_nDiffs-1].dbegin0);
+}
+
+void CMergeEditView::OnPrevdiff() 
+{
+       CMergeDoc *pd = GetDocument();
+       int cnt = pd->m_ltBuf.GetLineCount();
+       if (cnt <= 0)
+               return;
+
+       int curDiff = pd->GetCurrentDiff();
+
+       if (curDiff==0)
+       {
+               // we're on the first diff already, so remove the selection
+               mf->m_pLeft->SelectNone();
+               mf->m_pRight->SelectNone();
+       }
+       else if (curDiff!=-1)
+       {
+               // we're on a diff, so just select the next one
+               SelectDiff(curDiff-1, TRUE, FALSE);
+       }
+       else
+       {
+               // we're not on a diff, so figure out which one to select
+               int line = GetCursorPos().y;
+               if (!IsValidTextPosY(CPoint(0,line)))
+                       line = m_nTopLine;
+               for (int i=pd->m_nDiffs-1; i >= 0 ; i--)
+               {
+                       if ((int)pd->m_diffs[i].dend0 <= line)
+                       {
+                               curDiff=i;
+                               SelectDiff(i, TRUE, FALSE);
+                               break;
+                       }               
+               }
+       }
+}
+
+void CMergeEditView::OnUpdatePrevdiff(CCmdUI* pCmdUI) 
+{
+       CMergeDoc *pd = GetDocument();
+       CPoint pos = GetCursorPos();
+       pCmdUI->Enable(pd->m_nDiffs>0 && pos.y > (long)pd->m_diffs[0].dend0);
+}
+
+void CMergeEditView::OnR2l() 
+{
+       CMergeDoc *pd = GetDocument();
+       pd->ListCopy(mf->m_pRight, mf->m_pLeft);
+}
+
+void CMergeEditView::OnUpdateR2l(CCmdUI* pCmdUI) 
+{
+       CMergeDoc *pd = GetDocument();
+       pCmdUI->Enable(pd!=NULL && pd->GetCurrentDiff()!=-1);
+}
+
+void CMergeEditView::SelectNone()
+{
+       SetSelection (GetCursorPos(), GetCursorPos());
+       UpdateCaret();
+}
+
+void CMergeEditView::UpdateStatusMessage()
+{
+       CMergeDoc *pd = GetDocument();
+       if (pd != NULL)
+               mf->SetDiffStatus(pd->GetCurrentDiff(), pd->m_nDiffs);
+       else
+               mf->SetDiffStatus(-1,-1);
+}
+
+BOOL CMergeEditView::IsLineInCurrentDiff(int nLine)
+{
+       CMergeDoc *pd = GetDocument();
+       int cur = pd->GetCurrentDiff();
+       if (cur==-1)
+               return FALSE;
+       return (nLine >= (int)pd->m_diffs[cur].dbegin0 && nLine <= (int)pd->m_diffs[cur].dend0);
+}
+
+void CMergeEditView::OnLButtonDblClk(UINT nFlags, CPoint point) 
+{
+       CMergeDoc *pd = GetDocument();
+       CPoint pos = GetCursorPos();
+
+       int diff = pd->LineToDiff(pos.y);
+       if (diff!=-1)
+       {
+               SelectDiff(diff, FALSE, FALSE);
+               mf->m_pLeft->Invalidate();
+               mf->m_pRight->Invalidate();
+       }
+       
+       CCrystalEditViewEx::OnLButtonDblClk(nFlags, point);
+}
+
+void CMergeEditView::OnLButtonUp(UINT nFlags, CPoint point) 
+{
+       CMergeDoc *pd = GetDocument();
+       CCrystalEditViewEx::OnLButtonUp(nFlags, point);
+
+       CPoint pos = GetCursorPos();
+       if (!IsLineInCurrentDiff(pos.y))
+       {
+               pd->SetCurrentDiff(-1);
+               mf->m_pLeft->Invalidate();
+               mf->m_pRight->Invalidate();
+               UpdateStatusMessage();
+       }
+}
+
+void CMergeEditView::UpdateLineLengths()
+{
+       //m_nMaxLineLength=-1;
+       GetMaxLineLength();
+}
+
+void CMergeEditView::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
+{
+       
+       if (nChar == VK_RIGHT)
+       {
+               OnL2r();
+       }
+       else if (nChar == VK_LEFT)
+       {
+               OnR2l();
+       }
+       else if (nChar == VK_NEXT)
+       {
+               SCROLLINFO sif;
+               GetScrollInfo(SB_VERT, &sif);
+               ScrollToLine(max(0, min(sif.nMax, m_nTopLine+(int)sif.nPage-1)));
+               UpdateSiblingScrollPos(FALSE);
+       }
+       else if (nChar == VK_PRIOR)
+       {
+               SCROLLINFO sif;
+               GetScrollInfo(SB_VERT, &sif);
+               ScrollToLine(max(0, min(sif.nMax, m_nTopLine-(int)sif.nPage+1)));
+               UpdateSiblingScrollPos(FALSE);
+       }
+       else if (nChar == VK_DELETE)
+       {
+               CCrystalEditViewEx::OnEditDelete();
+               GetDocument()->FlushAndRescan();
+       }
+       else if (nChar == VK_BACK)
+       {
+               CCrystalEditViewEx::OnEditDeleteBack();
+               GetDocument()->FlushAndRescan();
+       }
+       /*else if (nChar == VK_HOME)
+       {
+               mf->m_pLeft->ScrollToLine(0);
+               mf->m_pRight->ScrollToLine(0);
+               SelectDiff(-1);
+       }
+       else if (nChar == VK_END)
+       {
+               mf->m_pLeft->ScrollToLine(m_nLines-1);
+               mf->m_pRight->ScrollToLine(m_nLines-1);
+               SelectDiff(-1);
+       }
+       else if (nChar == VK_PRIOR)
+       {
+               int cnt = m_pList->GetCountPerPage();
+               int top = m_pList->GetTopIndex();
+               mf->m_pLeft->ScrollToLine(max(0, top-cnt+1));
+               mf->m_pRight->ScrollToLine(max(0, top-cnt+1));
+               SelectDiff(-1);
+       }*/
+       else 
+               CCrystalEditViewEx::OnKeyUp(nChar, nRepCnt, nFlags);
+}
+
+void CMergeEditView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
+{
+
+       BOOL mod = m_pTextBuffer->IsModified();
+       m_pTextBuffer->SetModified(FALSE);
+
+       CCrystalEditViewEx::OnChar(nChar, nRepCnt, nFlags);
+
+       if (m_pTextBuffer->IsModified())
+       {
+               CPoint pos = GetCursorPos();
+               DWORD flags = m_pTextBuffer->GetLineFlags(pos.y);
+               if ((flags&LF_WINMERGE_FLAGS)==0)
+               {
+                       GetDocument()->FlushAndRescan();
+                       m_pTextBuffer->SetModified(TRUE);
+               }
+       }
+       else
+               m_pTextBuffer->SetModified(mod);
+}
+
+void CMergeEditView::OnSetFocus(CWnd* pOldWnd) 
+{
+       CCrystalEditViewEx::OnSetFocus(pOldWnd);
+       
+       UpdateStatusMessage();
+}
diff --git a/Src/MergeEditView.h b/Src/MergeEditView.h
new file mode 100644 (file)
index 0000000..228e7df
--- /dev/null
@@ -0,0 +1,125 @@
+#if !defined(AFX_MERGEEDITVIEW_H__0CE31CFD_4BEE_4378_ADB4_B7C9F50A9F53__INCLUDED_)
+#define AFX_MERGEEDITVIEW_H__0CE31CFD_4BEE_4378_ADB4_B7C9F50A9F53__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// MergeEditView.h : header file
+//
+
+#define CONTEXT_LINES   5
+
+static LPCTSTR crlfs[] =
+  {
+    _T ("\x0d\x0a"), //  DOS/Windows style
+    _T ("\x0a"),     //  UNIX style
+    _T ("\x0a")      //  Macintosh style
+  };
+
+/////////////////////////////////////////////////////////////////////////////
+// CMergeEditView view
+
+class CMergeEditView : public CCrystalEditViewEx
+{
+protected:
+       CMergeEditView();           // protected constructor used by dynamic creation
+       DECLARE_DYNCREATE(CMergeEditView)
+    CCrystalParser m_xParser;
+
+// Attributes
+public:
+       BOOL m_bIsLeft;
+       LONG m_nModifications;
+
+// Operations
+public:
+       void UpdateLineLengths();
+       BOOL IsLineInCurrentDiff(int nLine);
+       void UpdateStatusMessage();
+       void SelectNone();
+       void SelectDiff(int nDiff, BOOL bScroll =TRUE, BOOL bSelectText =TRUE);
+    virtual CCrystalTextBuffer *LocateTextBuffer ();
+       void ResetMod();
+       void AddMod();
+       CString GetSelectedText();
+       CString GetLineText(int idx);
+       void DoScroll(UINT code, UINT pos, BOOL bDoScroll);
+       BOOL SaveHelper();
+       CMergeDoc* GetDocument();
+       void UpdateResources();
+       BOOL IsModified() { return (LocateTextBuffer()->IsModified()); }
+       BOOL PrimeListWithFile(LPCTSTR szFilename);
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CMergeEditView)
+       public:
+       virtual void OnInitialUpdate();
+       protected:
+       virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+       virtual ~CMergeEditView();
+    virtual void GetLineColors (int nLineIndex, COLORREF & crBkgnd,
+                                COLORREF & crText, BOOL & bDrawWhitespace);
+       virtual void UpdateSiblingScrollPos (BOOL bHorz);
+       virtual void OnUpdateSibling (CCrystalTextView * pUpdateSource, BOOL bHorz);
+#ifdef _DEBUG
+       virtual void AssertValid() const;
+       virtual void Dump(CDumpContext& dc) const;
+#endif
+
+       // Generated message map functions
+protected:
+       //{{AFX_MSG(CMergeEditView)
+       afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+       afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+       afx_msg void OnAllLeft();
+       afx_msg void OnUpdateAllLeft(CCmdUI* pCmdUI);
+       afx_msg void OnAllRight();
+       afx_msg void OnUpdateAllRight(CCmdUI* pCmdUI);
+       afx_msg void OnCurdiff();
+       afx_msg void OnUpdateCurdiff(CCmdUI* pCmdUI);
+       afx_msg void OnEditCopy();
+       afx_msg void OnUpdateEditCopy(CCmdUI* pCmdUI);
+       afx_msg void OnEditCut();
+       afx_msg void OnUpdateEditCut(CCmdUI* pCmdUI);
+       afx_msg void OnEditPaste();
+       afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI);
+       afx_msg void OnEditUndo();
+       afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI);
+       afx_msg void OnFirstdiff();
+       afx_msg void OnUpdateFirstdiff(CCmdUI* pCmdUI);
+       afx_msg void OnL2r();
+       afx_msg void OnUpdateL2r(CCmdUI* pCmdUI);
+       afx_msg void OnLastdiff();
+       afx_msg void OnUpdateLastdiff(CCmdUI* pCmdUI);
+       afx_msg void OnNextdiff();
+       afx_msg void OnUpdateNextdiff(CCmdUI* pCmdUI);
+       afx_msg void OnPrevdiff();
+       afx_msg void OnUpdatePrevdiff(CCmdUI* pCmdUI);
+       afx_msg void OnR2l();
+       afx_msg void OnUpdateR2l(CCmdUI* pCmdUI);
+       afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
+       afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
+       afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
+       afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
+       afx_msg void OnSetFocus(CWnd* pOldWnd);
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+#ifndef _DEBUG  // debug version in DiffView.cpp
+inline CMergeDoc* CMergeEditView::GetDocument()
+   { return (CMergeDoc*)m_pDocument; }
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_MERGEEDITVIEW_H__0CE31CFD_4BEE_4378_ADB4_B7C9F50A9F53__INCLUDED_)
index d3c989c..3f7bc36 100644 (file)
 
 #include "stdafx.h"
 
+int
+xisspecial (int c)
+{
+  return (unsigned) c > (unsigned) _T ('\x7f') || c == _T ('_');
+//  return _tcschr (_T ("ì\9aèø\9eýáíéóúùï\9dò¾àå\9cäëöüÌ\8aÈØ\8eÝÁÍÉ´OÚÙÏ\8dÒ¼ÀÅ\8cÄËÖܧ"), c) != NULL;
+}
+
+int
+xisalpha (int c)
+{
+  return isalpha (c) || xisspecial (c);
+}
+
+int
+xisalnum (int c)
+{
+  return isalnum (c) || xisspecial (c);
+}
index 991f314..e847959 100644 (file)
 #include <afxtempl.h>
 #include <afxsock.h>
 #include <afxole.h>
+#include <afxtempl.h>
+#include <afxpriv.h>
+#include <afxole.h>
+#include <afxmt.h>
+#include <afxrich.h>
+
+#ifndef countof
+#define countof(array)  (sizeof(array)/sizeof((array)[0]))
+#endif /* countof */
+
+int xisspecial (int c);
+int xisalpha (int c);
+int xisalnum (int c);
 
+#include "edtlib.h"
 //{{AFX_INSERT_LOCATION}}
 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
 
diff --git a/Src/res/mg_cur.cur b/Src/res/mg_cur.cur
new file mode 100644 (file)
index 0000000..5691efb
Binary files /dev/null and b/Src/res/mg_cur.cur differ
index 1465be4..1d53b73 100644 (file)
 #define IDC_COMPANY                     1016
 #define IDC_COMMENTS                    1017
 #define IDC_VER_SYS                     1018
+#define IDC_HILITE_CHECK                1019
+#define IDR_MARGIN_CURSOR               22900
 #define IDD_LANGUAGE_SELECT             30000
+#define IDD_PROPSYNTAX                  30001
 #define IDS_AFRIKAANS                   30003
 #define IDS_ALBANIAN                    30004
 #define IDS_ARABIC_SAUDI                30005
 #define _APS_3D_CONTROLS                     1
 #define _APS_NEXT_RESOURCE_VALUE        135
 #define _APS_NEXT_COMMAND_VALUE         32806
-#define _APS_NEXT_CONTROL_VALUE         1019
+#define _APS_NEXT_CONTROL_VALUE         1020
 #define _APS_NEXT_SYMED_VALUE           106
 #endif
 #endif