From e97204022d56f926d135871f42d68c0f1a2fb267 Mon Sep 17 00:00:00 2001 From: Jun Tajima <56220423+tjmprm77@users.noreply.github.com> Date: Sun, 5 Dec 2021 11:17:41 +0900 Subject: [PATCH] =?UTF-8?q?Add=20a=20feature=20to=20save/restore=20the=20?= =?UTF-8?q?=E2=80=9DIgnore=20numbers=E2=80=9D=20setting=20to/from=20a=20pr?= =?UTF-8?q?oject=20file.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Merge.cpp | 2 ++ Src/Merge.rc | 1 + Src/OpenView.cpp | 27 +++++++++++++++++++++++++++ Src/OpenView.h | 3 +++ Src/ProjectFile.cpp | 11 +++++++++++ Src/ProjectFile.h | 43 +++++++++++++++++++++++++++++++++++++++++++ Src/resource.h | 17 +++++++++-------- 7 files changed, 96 insertions(+), 8 deletions(-) diff --git a/Src/Merge.cpp b/Src/Merge.cpp index 982144478f2..515171d94ce 100644 --- a/Src/Merge.cpp +++ b/Src/Merge.cpp @@ -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()) diff --git a/Src/Merge.rc b/Src/Merge.rc index 616d8efa896..43e10490c5d 100644 --- a/Src/Merge.rc +++ b/Src/Merge.rc @@ -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:" diff --git a/Src/OpenView.cpp b/Src/OpenView.cpp index 7d4fc6aba9a..b4928ee370b 100644 --- a/Src/OpenView.cpp +++ b/Src/OpenView.cpp @@ -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) @@ -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) @@ -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); @@ -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); @@ -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); @@ -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()) @@ -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); @@ -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); @@ -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. */ diff --git a/Src/OpenView.h b/Src/OpenView.h index 7be6d202170..49bd41e6c42 100644 --- a/Src/OpenView.h +++ b/Src/OpenView.h @@ -85,6 +85,7 @@ class COpenView : public CFormView, public DlgUtils 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 */ @@ -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(); diff --git a/Src/ProjectFile.cpp b/Src/ProjectFile.cpp index ab5f45c507e..505dac55672 100755 --- a/Src/ProjectFile.cpp +++ b/Src/ProjectFile.cpp @@ -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"; @@ -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; @@ -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) @@ -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) @@ -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) diff --git a/Src/ProjectFile.h b/Src/ProjectFile.h index d74980a1876..397f619b9cd 100755 --- a/Src/ProjectFile.h +++ b/Src/ProjectFile.h @@ -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; @@ -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; @@ -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); @@ -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); @@ -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? */ @@ -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? */ @@ -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. @@ -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 @@ -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. diff --git a/Src/resource.h b/Src/resource.h index f6457844b68..80da01fad35 100644 --- a/Src/resource.h +++ b/Src/resource.h @@ -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