Permalink
Browse files

Added Visual Diff

  • Loading branch information...
1 parent c5cdbcd commit 7c052206d75d85f981dd76594d9b60af59bae6c2 Alexander Stigsen committed Jul 22, 2009
View
@@ -37,6 +37,7 @@
#endif
#include <map>
#include <vector>
+#include <list>
#include "auto_vector.h"
#ifdef __WXMSW__
#pragma warning(pop)
@@ -108,7 +109,8 @@ enum cxFileResult {
enum cxChangeType {
cxINSERTION,
- cxDELETION
+ cxDELETION,
+ cxVERSIONCHANGE
};
struct cxBookmark {
@@ -223,6 +225,26 @@ struct cxUserMsg {
c4_Row rUser;
};
+class cxMatch {
+ public:
+ cxMatch(size_t start1, size_t end1, size_t start2, size_t WXUNUSED(end2))
+ : offset1(start1), offset2(start2), len(end1-start1) {};
+ cxMatch(size_t start1, size_t start2, size_t len)
+ : offset1(start1), offset2(start2), len(len) {};
+ void ExtendUp() {--offset1; --offset2; ++len;};
+ void ExtendDown() {++len;};
+ size_t start1() const {return offset1;};
+ size_t end1() const {return offset1+len;};
+ size_t start2() const {return offset2;};
+ size_t end2() const {return offset2+len;};
+ size_t length() const {return len;};
+ bool operator<(const cxMatch& m) const {return offset1 < m.offset1;};
+
+ size_t offset1;
+ size_t offset2;
+ size_t len;
+ };
+
// Constant db accessors
static const c4_IntProp pAuthor("author");
static const c4_BytesProp pAuthorBytes("author_bytes");
@@ -379,6 +401,9 @@ class Catalyst {
bool AddRevision(c4_RowRef& rSourceRev);
void SignRevision(const doc_id& di);
+ // Diff
+ void GetDiff(const Document& doc1, const Document& doc2, list<cxMatch>& matchList);
+
// Registration functions
bool IsRegistered() const;
bool IsExpired() const;
View
Binary file not shown.
View
Binary file not shown.
View
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ *
+ * Copyright (C) 2009, Alexander Stigsen, e-texteditor.com
+ *
+ * This software is licensed under the Open Company License as described
+ * in the file license.txt, which you should have received as part of this
+ * distribution. The terms are also available at http://opencompany.org/license.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ******************************************************************************/
+
+#include "CompareDlg.h"
+
+BEGIN_EVENT_TABLE(CompareDlg, wxDialog)
+ EVT_BUTTON(wxID_OK, CompareDlg::OnButtonOk)
+END_EVENT_TABLE()
+
+
+CompareDlg::CompareDlg(wxWindow *parent)
+: wxDialog (parent, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ) {
+ SetTitle (_("Compare Files..."));
+
+ // Create ctrls
+ m_leftPathCtrl = new wxFilePickerCtrl(this, wxID_ANY);
+ m_rightPathCtrl = new wxFilePickerCtrl(this, wxID_ANY);
+
+ // Create layout
+ wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
+ wxFlexGridSizer* pathsizer = new wxFlexGridSizer(2, 2);
+ pathsizer->AddGrowableCol(1, 1);
+ pathsizer->Add(new wxStaticText(this, wxID_ANY, _("Left:")), 0, wxALIGN_CENTER_VERTICAL);
+ pathsizer->Add(m_leftPathCtrl, 0, wxEXPAND);
+ pathsizer->Add(new wxStaticText(this, wxID_ANY, _("Right:")), 0, wxALIGN_CENTER_VERTICAL);
+ pathsizer->Add(m_rightPathCtrl, 0, wxEXPAND);
+ sizer->Add(pathsizer, 0, wxEXPAND|wxALL, 5);
+ sizer->Add(CreateButtonSizer(wxOK|wxCANCEL), 0, wxEXPAND|wxALL, 5);
+
+ SetSizerAndFit(sizer);
+ SetSize(400, -1);
+}
+
+void CompareDlg::OnButtonOk(wxCommandEvent& evt) {
+ const wxString leftPath = m_leftPathCtrl->GetPath();
+ if (leftPath.empty() || !wxFileExists(leftPath)) {
+ wxMessageBox(_("Left path is not valid"), _("Error"), wxICON_ERROR);
+ return;
+ }
+
+ const wxString rightPath = m_rightPathCtrl->GetPath();
+ if (rightPath.empty() || !wxFileExists(rightPath)) {
+ wxMessageBox(_("Right path is not valid"), _("Error"), wxICON_ERROR);
+ return;
+ }
+
+ // If we get here the paths are valid
+ evt.Skip();
+}
View
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ *
+ * Copyright (C) 2009, Alexander Stigsen, e-texteditor.com
+ *
+ * This software is licensed under the Open Company License as described
+ * in the file license.txt, which you should have received as part of this
+ * distribution. The terms are also available at http://opencompany.org/license.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ******************************************************************************/
+
+#ifndef __COMPAREDLG_H__
+#define __COMPAREDLG_H__
+
+#include "wx/wxprec.h" // For compilers that support precompilation, includes "wx/wx.h".
+#ifdef __WXGTK__
+ #include <wx/wx.h>
+#endif
+#include <wx/filepicker.h>
+
+class CompareDlg : public wxDialog {
+public:
+ CompareDlg(wxWindow *parent);
+
+ // Access to file paths
+ wxString GetLeftPath() const {return m_leftPathCtrl->GetPath();};
+ wxString GetRightPath() const {return m_rightPathCtrl->GetPath();};
+ void SetLeftPath(const wxString& path) {m_leftPathCtrl->SetPath(path);};
+ void SetRightPath(const wxString& path) {m_rightPathCtrl->SetPath(path);};
+
+private:
+ // Event handlers
+ void OnButtonOk(wxCommandEvent& evt);
+ DECLARE_EVENT_TABLE();
+
+ wxFilePickerCtrl* m_leftPathCtrl;
+ wxFilePickerCtrl* m_rightPathCtrl;
+};
+
+#endif // __COMPAREDLG_H__
Oops, something went wrong.

0 comments on commit 7c05220

Please sign in to comment.