+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
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);
+}
+
// implementation methods
private:
+ BOOL GetOptionInt(LPCTSTR name) const;
BOOL GetOptionBool(LPCTSTR name) const;
bool GetBreakType() const;
+ bool GetByteColoringOption() const;
// Implementation data
protected:
// 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;
}
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
}