OSDN Git Service

PATCH: [ 1241935 ] Implement Line Diff coloring on byte diffs
authorPerry Rapp <elsapo@users.sourceforge.net>
Sat, 26 Nov 2005 08:44:02 +0000 (08:44 +0000)
committerPerry Rapp <elsapo@users.sourceforge.net>
Sat, 26 Nov 2005 08:44:02 +0000 (08:44 +0000)
  Src: MergeDoc.cpp MergeDoc.h MergeDocLineDiffs.cpp PropEditor.cpp

Src/Changes.txt
Src/MergeDoc.cpp
Src/MergeDoc.h
Src/MergeDocLineDiffs.cpp
Src/PropEditor.cpp

index bd8930d..39ffa48 100644 (file)
@@ -1,3 +1,7 @@
+2005-11-26 Perry
+ PATCH: [ 1241935 ] Implement Line Diff coloring on byte diffs
+  Src: MergeDoc.cpp MergeDoc.h MergeDocLineDiffs.cpp PropEditor.cpp
+
 2005-11-23 WinMerge experimental release 2.5.0.2 (cvs)
 
 2005-11-22 Tim
index e43c316..b121a30 100644 (file)
@@ -3056,16 +3056,30 @@ void CMergeDoc::UpdateResources()
        GetRightView()->UpdateResources();
 }
 
+// Lookup named property and return as int
+BOOL CMergeDoc::GetOptionInt(LPCTSTR name) const
+{
+       // Currently options are held by the main frame, in a subobject called m_options
+       return mf->m_options.GetInt(name);
+}
 
 // Lookup named property and return as BOOL
 BOOL CMergeDoc::GetOptionBool(LPCTSTR name) const
 {
        // Currently options are held by the main frame, in a subobject called m_options
-       return mf->m_options.GetInt(name);
+       return mf->m_options.GetBool(name);
 }
 
 // Return current word breaking break type setting (whitespace only or include punctuation)
 bool CMergeDoc::GetBreakType() const
 {
-       return !!GetOptionBool(OPT_BREAK_TYPE);
+       return !!GetOptionInt(OPT_BREAK_TYPE);
 }
+
+// Return true to do line diff colors at the byte level (false to do them at word level)
+bool CMergeDoc::GetByteColoringOption() const
+{
+       // color at byte level if 'break_on_words' option not set
+       return !GetOptionBool(OPT_BREAK_ON_WORDS);
+}
+
index 6ae5020..ec60884 100644 (file)
@@ -293,8 +293,10 @@ public:
 
 // implementation methods
 private:
+       BOOL GetOptionInt(LPCTSTR name) const;
        BOOL GetOptionBool(LPCTSTR name) const;
        bool GetBreakType() const;
+       bool GetByteColoringOption() const;
 
 // Implementation data
 protected:
index 44b5e48..bea6a8f 100644 (file)
@@ -359,10 +359,25 @@ void CMergeDoc::GetWordDiffArray(int nLineIndex, wdiffarray *pworddiffs)
        // Options that affect comparison
        bool casitive = !diffOptions.bIgnoreCase;
        int xwhite = diffOptions.nIgnoreWhitespace;
-       int breakType = GetBreakType();
+       int breakType = GetBreakType(); // whitespace only or include punctuation
+       bool byteColoring = GetByteColoringOption();
 
-       // Make the call to stringdiffs, which does all the hard & tedious computations
-       sd_ComputeWordDiffs(str1, str2, casitive, xwhite, breakType, pworddiffs);
+       if (byteColoring)
+       {
+               int begin1, begin2, end1, end2;
+               sd_ComputeByteDiff(str1, str2, casitive, xwhite, begin1, begin2, end1, end2);
+               if (begin1 != -1 || begin2 != -1)
+               {
+                       wdiff wdf(begin1, end1, begin2, end2);
+                       pworddiffs->Add(wdf);
+
+               }
+       }
+       else
+       {
+               // Make the call to stringdiffs, which does all the hard & tedious computations
+               sd_ComputeWordDiffs(str1, str2, casitive, xwhite, breakType, pworddiffs);
+       }
 
        return;
 }
index 225da93..76396dc 100644 (file)
@@ -121,10 +121,6 @@ BOOL CPropEditor::OnInitDialog()
        LoadBreakTypeStrings();
        UpdateDataToWindow();
 
-       /// @TODO Need to implement the option controlled by this control, 2005-05-03, Perry
-       GetDlgItem(IDC_BREAK_ON_WORDS)->ShowWindow(SW_HIDE);
-
-
        return TRUE;  // return TRUE unless you set the focus to a control
                      // EXCEPTION: OCX Property Pages should return FALSE
 }