Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a feature to save/restore the ”Ignore numbers” setting to/from a project file. #1068

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Src/Merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,8 @@ bool CMergeApp::LoadAndOpenProjectFile(const String& sProject, const String& sRe
GetOptionsMgr()->Set(OPT_CMP_IGNORE_CASE, projItem.GetIgnoreCase());
if (projItem.HasIgnoreEol())
GetOptionsMgr()->Set(OPT_CMP_IGNORE_EOL, projItem.GetIgnoreEol());
if (projItem.HasIgnoreNumbers())
GetOptionsMgr()->Set(OPT_CMP_IGNORE_NUMBERS, projItem.GetIgnoreNumbers());
if (projItem.HasIgnoreCodepage())
GetOptionsMgr()->Set(OPT_CMP_IGNORE_CODEPAGE, projItem.GetIgnoreCodepage());
if (projItem.HasFilterCommentsLines())
Expand Down
1 change: 1 addition & 0 deletions Src/Merge.rc
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ BEGIN
MENUITEM "Ignore &case", ID_PROJECT_DIFF_OPTIONS_IGNORE_CASE
MENUITEM "Igno&re carriage return differences (Windows/Unix/Mac)", ID_PROJECT_DIFF_OPTIONS_IGNORE_EOL
MENUITEM "Ignore codepage &differences", ID_PROJECT_DIFF_OPTIONS_IGNORE_CODEPAGE
MENUITEM "Ignore num&bers", ID_PROJECT_DIFF_OPTIONS_IGNORE_NUMBERS
MENUITEM "Ignore c&omment differences", ID_PROJECT_DIFF_OPTIONS_IGNORE_COMMENTS
MENUITEM SEPARATOR
POPUP "&Compare method:"
Expand Down
27 changes: 27 additions & 0 deletions Src/OpenView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ BEGIN_MESSAGE_MAP(COpenView, CFormView)
ON_UPDATE_COMMAND_UI(ID_PROJECT_DIFF_OPTIONS_IGNORE_CASE, OnUpdateDiffIgnoreCase)
ON_COMMAND(ID_PROJECT_DIFF_OPTIONS_IGNORE_EOL, OnDiffIgnoreEOL)
ON_UPDATE_COMMAND_UI(ID_PROJECT_DIFF_OPTIONS_IGNORE_EOL, OnUpdateDiffIgnoreEOL)
ON_COMMAND(ID_PROJECT_DIFF_OPTIONS_IGNORE_NUMBERS, OnDiffIgnoreNumbers)
ON_UPDATE_COMMAND_UI(ID_PROJECT_DIFF_OPTIONS_IGNORE_NUMBERS, OnUpdateDiffIgnoreNumbers)
ON_COMMAND(ID_PROJECT_DIFF_OPTIONS_IGNORE_CODEPAGE, OnDiffIgnoreCP)
ON_UPDATE_COMMAND_UI(ID_PROJECT_DIFF_OPTIONS_IGNORE_CODEPAGE, OnUpdateDiffIgnoreCP)
ON_COMMAND(ID_PROJECT_DIFF_OPTIONS_IGNORE_COMMENTS, OnDiffIgnoreComments)
Expand Down Expand Up @@ -135,6 +137,7 @@ COpenView::COpenView()
, m_bIgnoreBlankLines(false)
, m_bIgnoreCase(false)
, m_bIgnoreEol(false)
, m_bIgnoreNumbers(false)
, m_bIgnoreCodepage(false)
, m_bFilterCommentsLines(false)
, m_nCompareMethod(0)
Expand Down Expand Up @@ -309,6 +312,7 @@ void COpenView::OnInitialUpdate()
m_bIgnoreBlankLines = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_BLANKLINES);
m_bIgnoreCase = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_CASE);
m_bIgnoreEol = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_EOL);
m_bIgnoreNumbers = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_NUMBERS);
m_bIgnoreCodepage = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_CODEPAGE);
m_bFilterCommentsLines = GetOptionsMgr()->GetBool(OPT_CMP_FILTER_COMMENTLINES);
m_nCompareMethod = GetOptionsMgr()->GetInt(OPT_CMP_METHOD);
Expand All @@ -328,6 +332,7 @@ void COpenView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
m_bIgnoreBlankLines = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_BLANKLINES);
m_bIgnoreCase = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_CASE);
m_bIgnoreEol = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_EOL);
m_bIgnoreNumbers = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_NUMBERS);
m_bIgnoreCodepage = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_CODEPAGE);
m_bFilterCommentsLines = GetOptionsMgr()->GetBool(OPT_CMP_FILTER_COMMENTLINES);
m_nCompareMethod = GetOptionsMgr()->GetInt(OPT_CMP_METHOD);
Expand Down Expand Up @@ -681,6 +686,7 @@ void COpenView::OnCompare(UINT nID)
GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_BLANKLINES, m_bIgnoreBlankLines);
GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_CASE, m_bIgnoreCase);
GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_EOL, m_bIgnoreEol);
GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_NUMBERS, m_bIgnoreNumbers);
GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_CODEPAGE, m_bIgnoreCodepage);
GetOptionsMgr()->SaveOption(OPT_CMP_FILTER_COMMENTLINES, m_bFilterCommentsLines);
GetOptionsMgr()->SaveOption(OPT_CMP_METHOD, m_nCompareMethod);
Expand Down Expand Up @@ -830,6 +836,8 @@ void COpenView::OnLoadProject()
m_bIgnoreCase = projItem.GetIgnoreCase();
if (projItem.HasIgnoreEol())
m_bIgnoreEol = projItem.GetIgnoreEol();
if (projItem.HasIgnoreNumbers())
m_bIgnoreNumbers = projItem.GetIgnoreNumbers();
if (projItem.HasIgnoreCodepage())
m_bIgnoreCodepage = projItem.GetIgnoreCodepage();
if (projItem.HasFilterCommentsLines())
Expand Down Expand Up @@ -869,6 +877,7 @@ void COpenView::OnSaveProject()
projItem.SetSaveIgnoreBlankLines(bSaveCompareOptions);
projItem.SetSaveIgnoreCase(bSaveCompareOptions);
projItem.SetSaveIgnoreEol(bSaveCompareOptions);
projItem.SetSaveIgnoreNumbers(bSaveCompareOptions);
projItem.SetSaveIgnoreCodepage(bSaveCompareOptions);
projItem.SetSaveFilterCommentsLines(bSaveCompareOptions);
projItem.SetSaveCompareMethod(bSaveCompareOptions);
Expand Down Expand Up @@ -911,6 +920,7 @@ void COpenView::OnSaveProject()
projItem.SetIgnoreBlankLines(m_bIgnoreBlankLines);
projItem.SetIgnoreCase(m_bIgnoreCase);
projItem.SetIgnoreEol(m_bIgnoreEol);
projItem.SetIgnoreNumbers(m_bIgnoreNumbers);
projItem.SetIgnoreCodepage(m_bIgnoreCodepage);
projItem.SetFilterCommentsLines(m_bFilterCommentsLines);
projItem.SetCompareMethod(m_nCompareMethod);
Expand Down Expand Up @@ -1430,6 +1440,23 @@ void COpenView::OnUpdateDiffIgnoreEOL(CCmdUI* pCmdUI)
pCmdUI->SetCheck(m_bIgnoreEol);
}

/**
* @brief Toggle "Ignore numbers" setting.
*/
void COpenView::OnDiffIgnoreNumbers()
{
m_bIgnoreNumbers = !m_bIgnoreNumbers;
}

/**
* @brief Update "Ignore numbers" state.
* @param [in] pCmdUI UI component to update.
*/
void COpenView::OnUpdateDiffIgnoreNumbers(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_bIgnoreNumbers);
}

/**
* @brief Toggle "Ignore codepage differences" setting.
*/
Expand Down
3 changes: 3 additions & 0 deletions Src/OpenView.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class COpenView : public CFormView, public DlgUtils<COpenView>
bool m_bIgnoreBlankLines; /**< The value of the "Ignore blank lines" setting */
bool m_bIgnoreCase; /**< The value of the "Ignore case" setting */
bool m_bIgnoreEol; /**< The value of the "Ignore carriage return differences" setting */
bool m_bIgnoreNumbers; /**< The value of the "Ignore numbers" setting */
bool m_bIgnoreCodepage; /**< The value of the "Ignore codepage differences" setting */
bool m_bFilterCommentsLines; /**< The value of the "Ignore comment differences" setting */
int m_nCompareMethod; /**< The value of the "Compare method" setting */
Expand Down Expand Up @@ -140,6 +141,8 @@ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
afx_msg void OnUpdateDiffIgnoreCase(CCmdUI* pCmdUI);
afx_msg void OnDiffIgnoreEOL();
afx_msg void OnUpdateDiffIgnoreEOL(CCmdUI* pCmdUI);
afx_msg void OnDiffIgnoreNumbers();
afx_msg void OnUpdateDiffIgnoreNumbers(CCmdUI* pCmdUI);
afx_msg void OnDiffIgnoreCP();
afx_msg void OnUpdateDiffIgnoreCP(CCmdUI* pCmdUI);
afx_msg void OnDiffIgnoreComments();
Expand Down
11 changes: 11 additions & 0 deletions Src/ProjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const char White_spaces_element_name[] = "white-spaces";
const char Ignore_blank_lines_element_name[] = "ignore-blank-lines";
const char Ignore_case_element_name[] = "ignore-case";
const char Ignore_cr_diff_element_name[] = "ignore-carriage-return-diff";
const char Ignore_numbers_element_name[] = "ignore-numbers";
const char Ignore_codepage_diff_element_name[] = "ignore-codepage-diff";
const char Ignore_comment_diff_element_name[] = "ignore-comment-diff";
const char Compare_method_element_name[] = "compare-method";
Expand Down Expand Up @@ -160,6 +161,11 @@ class ProjectFileHandler: public ContentHandler
currentItem.m_bIgnoreEol = atoi(std::string(ch + start, length).c_str()) != 0;
currentItem.m_bHasIgnoreEol = true;
}
else if (nodename == Ignore_numbers_element_name)
{
currentItem.m_bIgnoreNumbers = atoi(std::string(ch + start, length).c_str()) != 0;
currentItem.m_bHasIgnoreNumbers = true;
}
else if (nodename == Ignore_codepage_diff_element_name)
{
currentItem.m_bIgnoreCodepage = atoi(std::string(ch + start, length).c_str()) != 0;
Expand Down Expand Up @@ -213,6 +219,8 @@ const String ProjectFile::PROJECTFILE_EXT = toTString("WinMerge");
, m_bIgnoreCase(false)
, m_bHasIgnoreEol(false)
, m_bIgnoreEol(false)
, m_bHasIgnoreNumbers(false)
, m_bIgnoreNumbers(false)
, m_bHasIgnoreCodepage(false)
, m_bIgnoreCodepage(false)
, m_bHasFilterCommentsLines(false)
Expand All @@ -226,6 +234,7 @@ const String ProjectFile::PROJECTFILE_EXT = toTString("WinMerge");
, m_bSaveIgnoreBlankLines(true)
, m_bSaveIgnoreCase(true)
, m_bSaveIgnoreEol(true)
, m_bSaveIgnoreNumbers(true)
, m_bSaveIgnoreCodepage(true)
, m_bSaveFilterCommentsLines(true)
, m_bSaveCompareMethod(true)
Expand Down Expand Up @@ -376,6 +385,8 @@ bool ProjectFile::Save(const String& path) const
writeElement(writer, Ignore_case_element_name, item.m_bIgnoreCase ? "1" : "0");
if (item.m_bSaveIgnoreEol)
writeElement(writer, Ignore_cr_diff_element_name, item.m_bIgnoreEol ? "1" : "0");
if (item.m_bSaveIgnoreNumbers)
writeElement(writer, Ignore_numbers_element_name, item.m_bIgnoreNumbers ? "1" : "0");
if (item.m_bSaveIgnoreCodepage)
writeElement(writer, Ignore_codepage_diff_element_name, item.m_bIgnoreCodepage ? "1" : "0");
if (item.m_bSaveFilterCommentsLines)
Expand Down
43 changes: 43 additions & 0 deletions Src/ProjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ProjectFileItem
bool HasIgnoreBlankLines() const;
bool HasIgnoreCase() const;
bool HasIgnoreEol() const;
bool HasIgnoreNumbers() const;
bool HasIgnoreCodepage() const;
bool HasFilterCommentsLines() const;
bool HasCompareMethod() const;
Expand All @@ -44,6 +45,7 @@ class ProjectFileItem
bool GetIgnoreBlankLines() const;
bool GetIgnoreCase() const;
bool GetIgnoreEol() const;
bool GetIgnoreNumbers() const;
bool GetIgnoreCodepage() const;
bool GetFilterCommentsLines() const;
int GetCompareMethod() const;
Expand All @@ -59,6 +61,7 @@ class ProjectFileItem
void SetIgnoreBlankLines(bool bIgnoreBlankLines);
void SetIgnoreCase(bool bIgnoreCase);
void SetIgnoreEol(bool bIgnoreEol);
void SetIgnoreNumbers(bool bIgnoreNumbers);
void SetIgnoreCodepage(bool bIgnoreCodepage);
void SetFilterCommentsLines(bool bFilterCommentsLines);
void SetCompareMethod(int nCompareMethod);
Expand All @@ -73,6 +76,7 @@ class ProjectFileItem
void SetSaveIgnoreBlankLines(bool bSaveIgnoreBlankLines);
void SetSaveIgnoreCase(bool bSaveIgnoreCase);
void SetSaveIgnoreEol(bool bSaveIgnoreEol);
void SetSaveIgnoreNumbers(bool bSaveIgnoreNumbers);
void SetSaveIgnoreCodepage(bool bSaveIgnoreCodepage);
void SetSaveFilterCommentsLines(bool bSaveFilterCommentsLines);
void SetSaveCompareMethod(bool bSaveCompareMethod);
Expand Down Expand Up @@ -101,6 +105,8 @@ class ProjectFileItem
bool m_bIgnoreCase; /**< The value of the "Ignore case" setting */
bool m_bHasIgnoreEol; /**< Has "Ignore carriage return differences" setting? */
bool m_bIgnoreEol; /**< The value of the "Ignore carriage return differences" setting */
bool m_bHasIgnoreNumbers; /**< Has "Ignore numbers" setting? */
bool m_bIgnoreNumbers; /**< The value of the "Ignore numbers" setting */
bool m_bHasIgnoreCodepage; /**< Has "Ignore codepage differences" setting? */
bool m_bIgnoreCodepage; /**< The value of the "Ignore codepage differences" setting */
bool m_bHasFilterCommentsLines; /**< Has "Ignore comment differences" setting? */
Expand All @@ -114,6 +120,7 @@ class ProjectFileItem
bool m_bSaveIgnoreBlankLines; /**< Save "Ignore blank lines" setting? */
bool m_bSaveIgnoreCase; /**< Save "Ignore case" setting? */
bool m_bSaveIgnoreEol; /**< Save "Ignore carriage return differences" setting? */
bool m_bSaveIgnoreNumbers; /**< Save "Ignore numbers" setting? */
bool m_bSaveIgnoreCodepage; /**< Save "Ignore codepage differences" setting? */
bool m_bSaveFilterCommentsLines; /**< Save "Ignore comment differences" setting? */
bool m_bSaveCompareMethod; /**< Save "Compare method" setting? */
Expand Down Expand Up @@ -236,6 +243,15 @@ inline bool ProjectFileItem::HasIgnoreEol() const
return m_bHasIgnoreEol;
}

/**
* @brief Returns if "Ignore numbers" setting is defined in projectfile.
* @return true if project file has "Ignore numbers" setting definition.
*/
inline bool ProjectFileItem::HasIgnoreNumbers() const
{
return m_bHasIgnoreNumbers;
}

/**
* @brief Returns if "Ignore codepage differences" setting is defined in projectfile.
* @return true if project file has "Ignore codepage differences" setting definition.
Expand Down Expand Up @@ -433,6 +449,24 @@ inline void ProjectFileItem::SetIgnoreEol(bool bIgnoreEol)
m_bIgnoreEol = bIgnoreEol;
}

/**
* @brief Returns the value of the "Ignore numbers" setting.
* @return The value of the "Ignore numbers" setting
*/
inline bool ProjectFileItem::GetIgnoreNumbers() const
{
return m_bIgnoreNumbers;
}

/**
* @brief Set the value of the "Ignore numbers" setting.
* @param [in] bIgnoreNumbers New value of the "Ignore numbers" setting to set.
*/
inline void ProjectFileItem::SetIgnoreNumbers(bool bIgnoreNumbers)
{
m_bIgnoreNumbers = bIgnoreNumbers;
}

/**
* @brief Returns the value of the "Ignore codepage differences" setting.
* @return The value of the "Ignore codepage differences" setting
Expand Down Expand Up @@ -562,6 +596,15 @@ inline void ProjectFileItem::SetSaveIgnoreEol(bool bSaveIgnoreEol)
m_bSaveIgnoreEol = bSaveIgnoreEol;
}

/**
* @brief Set whether to save "Ignore numbers" setting.
* @param [in] bSaveIgnoreNumbers Whether to save "Ignore numbers" setting.
*/
inline void ProjectFileItem::SetSaveIgnoreNumbers(bool bSaveIgnoreNumbers)
{
m_bSaveIgnoreNumbers = bSaveIgnoreNumbers;
}

/**
* @brief Set whether to save "Ignore codepage differences" setting.
* @param [in] bSaveIgnoreCodepage Whether to save "Ignore codepage differences" setting.
Expand Down
17 changes: 9 additions & 8 deletions Src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -827,14 +827,15 @@
#define ID_PROJECT_DIFF_OPTIONS_IGNORE_BLANKLINES 33127
#define ID_PROJECT_DIFF_OPTIONS_IGNORE_CASE 33128
#define ID_PROJECT_DIFF_OPTIONS_IGNORE_EOL 33129
#define ID_PROJECT_DIFF_OPTIONS_IGNORE_CODEPAGE 33130
#define ID_PROJECT_DIFF_OPTIONS_IGNORE_COMMENTS 33131
#define ID_PROJECT_DIFF_OPTIONS_COMPMETHOD_FULL_CONTENTS 33132
#define ID_PROJECT_DIFF_OPTIONS_COMPMETHOD_QUICK_CONTENTS 33133
#define ID_PROJECT_DIFF_OPTIONS_COMPMETHOD_BINARY_CONTENTS 33134
#define ID_PROJECT_DIFF_OPTIONS_COMPMETHOD_MODDATE 33135
#define ID_PROJECT_DIFF_OPTIONS_COMPMETHOD_DATESIZE 33136
#define ID_PROJECT_DIFF_OPTIONS_COMPMETHOD_SIZE 33137
#define ID_PROJECT_DIFF_OPTIONS_IGNORE_NUMBERS 33130
#define ID_PROJECT_DIFF_OPTIONS_IGNORE_CODEPAGE 33131
#define ID_PROJECT_DIFF_OPTIONS_IGNORE_COMMENTS 33132
#define ID_PROJECT_DIFF_OPTIONS_COMPMETHOD_FULL_CONTENTS 33133
#define ID_PROJECT_DIFF_OPTIONS_COMPMETHOD_QUICK_CONTENTS 33134
#define ID_PROJECT_DIFF_OPTIONS_COMPMETHOD_BINARY_CONTENTS 33135
#define ID_PROJECT_DIFF_OPTIONS_COMPMETHOD_MODDATE 33136
#define ID_PROJECT_DIFF_OPTIONS_COMPMETHOD_DATESIZE 33137
#define ID_PROJECT_DIFF_OPTIONS_COMPMETHOD_SIZE 33138
#define ID_EDIT_TOGGLE_BOOKMARK 33145
#define ID_EDIT_GOTO_NEXT_BOOKMARK 33146
#define ID_EDIT_GOTO_PREV_BOOKMARK 33147
Expand Down