From 15f3415a3f9e9e682f3a09b221c09376360ca617 Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Thu, 16 Mar 2023 22:49:32 +0900 Subject: [PATCH] refactor --- Externals/crystaledit/editlib/LineInfo.h | 4 ++-- Externals/crystaledit/editlib/SyntaxColors.h | 2 +- Externals/crystaledit/editlib/dialogs/memcombo.cpp | 2 +- Src/Common/RegOptionsMgr.cpp | 2 +- Src/DirView.h | 2 +- Src/Merge.h | 2 +- Src/MergeEditFrm.cpp | 2 +- Src/MergeEditView.h | 6 +++--- Src/MergeLineFlags.h | 18 +++++++++--------- Src/PropMergeColors.h | 2 +- Src/PropShell.cpp | 9 ++++++--- Src/SubeditList.cpp | 2 +- 12 files changed, 28 insertions(+), 25 deletions(-) diff --git a/Externals/crystaledit/editlib/LineInfo.h b/Externals/crystaledit/editlib/LineInfo.h index e7a0e9d2c..f7041a40d 100644 --- a/Externals/crystaledit/editlib/LineInfo.h +++ b/Externals/crystaledit/editlib/LineInfo.h @@ -11,8 +11,8 @@ #include // Line allocation granularity -#define CHAR_ALIGN 16 -#define ALIGN_BUF_SIZE(size) ((size) / CHAR_ALIGN) * CHAR_ALIGN + CHAR_ALIGN; +constexpr size_t CHAR_ALIGN = 16; +constexpr size_t ALIGN_BUF_SIZE(size_t size) { return ((size) / CHAR_ALIGN) * CHAR_ALIGN + CHAR_ALIGN; } typedef unsigned long lineflags_t; diff --git a/Externals/crystaledit/editlib/SyntaxColors.h b/Externals/crystaledit/editlib/SyntaxColors.h index ac8c52a89..5b2c87d8a 100644 --- a/Externals/crystaledit/editlib/SyntaxColors.h +++ b/Externals/crystaledit/editlib/SyntaxColors.h @@ -56,7 +56,7 @@ enum COLORINDEX COLORINDEX_MASK = 0xC0000000, }; -const int COLORINDEX_COUNT = COLORINDEX_LAST - COLORINDEX_NONE; +constexpr int COLORINDEX_COUNT = COLORINDEX_LAST - COLORINDEX_NONE; /** * @brief Wrapper for Syntax coloring colors. diff --git a/Externals/crystaledit/editlib/dialogs/memcombo.cpp b/Externals/crystaledit/editlib/dialogs/memcombo.cpp index 382cc2eeb..4fb18d4fb 100644 --- a/Externals/crystaledit/editlib/dialogs/memcombo.cpp +++ b/Externals/crystaledit/editlib/dialogs/memcombo.cpp @@ -22,7 +22,7 @@ #define new DEBUG_NEW #endif -#define REMEMBER_COUNT 64 +constexpr int REMEMBER_COUNT = 64; ///////////////////////////////////////////////////////////////////////////// // CMemComboBox diff --git a/Src/Common/RegOptionsMgr.cpp b/Src/Common/RegOptionsMgr.cpp index a3ac6c338..2cecf5cd0 100644 --- a/Src/Common/RegOptionsMgr.cpp +++ b/Src/Common/RegOptionsMgr.cpp @@ -13,7 +13,7 @@ #include "varprop.h" #include "OptionsMgr.h" -#define MAX_PATH_FULL 32767 +constexpr size_t MAX_PATH_FULL = 32767; struct AsyncWriterThreadParams { diff --git a/Src/DirView.h b/Src/DirView.h index 77a2a0f85..1e1c6e462 100644 --- a/Src/DirView.h +++ b/Src/DirView.h @@ -48,7 +48,7 @@ struct IListCtrl; const uintptr_t SPECIAL_ITEM_POS = (uintptr_t)(reinterpret_cast( - 1L)); /** Default column width in directory compare */ -const UINT DefColumnWidth = 111; +constexpr int DefColumnWidth = 111; /** * @brief Directory compare results view. diff --git a/Src/Merge.h b/Src/Merge.h index 2a5318b4a..b3ac310e1 100644 --- a/Src/Merge.h +++ b/Src/Merge.h @@ -15,7 +15,7 @@ #define WMU_CHILDFRAMEREMOVED (WM_APP + 11) #define WMU_CHILDFRAMEACTIVATE (WM_APP + 12) #define WMU_CHILDFRAMEACTIVATED (WM_APP + 13) -#define IDT_UPDATEMAINMENU 1 +constexpr UINT_PTR IDT_UPDATEMAINMENU = 1; #ifndef __AFXWIN_H__ #error include 'stdafx.h' before including this file for PCH diff --git a/Src/MergeEditFrm.cpp b/Src/MergeEditFrm.cpp index 274da3ca0..ab680ff8c 100644 --- a/Src/MergeEditFrm.cpp +++ b/Src/MergeEditFrm.cpp @@ -52,7 +52,7 @@ BEGIN_MESSAGE_MAP(CMergeEditFrame, CMergeFrameCommon) //}}AFX_MSG_MAP END_MESSAGE_MAP() -#define IDT_SAVEPOSITION 2 +constexpr UINT_PTR IDT_SAVEPOSITION = 2; ///////////////////////////////////////////////////////////////////////////// // CMergeEditFrame construction/destruction diff --git a/Src/MergeEditView.h b/Src/MergeEditView.h index f5b404190..94898dc18 100644 --- a/Src/MergeEditView.h +++ b/Src/MergeEditView.h @@ -14,15 +14,15 @@ /** * @brief Non-diff lines shown above diff when scrolling to it */ -const UINT CONTEXT_LINES_ABOVE = 5; +constexpr int CONTEXT_LINES_ABOVE = 5; /** * @brief Non-diff lines shown below diff when scrolling to it */ -const UINT CONTEXT_LINES_BELOW = 3; +constexpr int CONTEXT_LINES_BELOW = 3; -#define FLAG_RESCAN_WAITS_FOR_IDLE 1 +constexpr unsigned FLAG_RESCAN_WAITS_FOR_IDLE = 1; ///////////////////////////////////////////////////////////////////////////// diff --git a/Src/MergeLineFlags.h b/Src/MergeLineFlags.h index f7b9ca49f..df7b25a48 100644 --- a/Src/MergeLineFlags.h +++ b/Src/MergeLineFlags.h @@ -5,6 +5,8 @@ */ #pragma once +#include "LineInfo.h" + /** The Crystal Editor keeps a DWORD of flags for each line. It does not use all of the available bits. @@ -12,19 +14,17 @@ information; here are the list of WinMerge flags. So, these constants are used with the SetLineFlag(2) calls. */ -enum MERGE_LINEFLAGS : DWORD +enum MERGE_LINEFLAGS : lineflags_t { LF_DIFF = 0x00200000UL, -// LF_GHOST = 0x00400000UL, + // LF_GHOST = 0x00400000UL, LF_TRIVIAL = 0x00800000UL, LF_MOVED = 0x01000000UL, LF_SNP = 0x02000000UL, + // LF_WINMERGE_FLAGS is LF_DIFF | LF_GHOST | LF_TRIVIAL | LF_MOVED | LF_SNP + LF_WINMERGE_FLAGS = 0x03E00000UL, + // Flags for non-ignored difference + // Note that we must include ghost flag to include ghost lines + LF_NONTRIVIAL_DIFF = ((LF_DIFF | LF_GHOST) & (~LF_TRIVIAL)) }; - -// LF_WINMERGE_FLAGS is LF_DIFF | LF_GHOST | LF_TRIVIAL | LF_MOVED | LF_SNP -#define LF_WINMERGE_FLAGS 0x03E00000UL - -// Flags for non-ignored difference -// Note that we must include ghost flag to include ghost lines -#define LF_NONTRIVIAL_DIFF ((LF_DIFF | LF_GHOST) & (~LF_TRIVIAL)) diff --git a/Src/PropMergeColors.h b/Src/PropMergeColors.h index 5756265f3..d76b90d2a 100644 --- a/Src/PropMergeColors.h +++ b/Src/PropMergeColors.h @@ -12,7 +12,7 @@ class COptionsMgr; -const int CustomColorsAmount = 16; +constexpr int CustomColorsAmount = 16; /** @brief Property page for colors options; used in options property sheet */ class PropMergeColors : public OptionsPanel diff --git a/Src/PropShell.cpp b/Src/PropShell.cpp index ac43642ae..c1632f5d2 100644 --- a/Src/PropShell.cpp +++ b/Src/PropShell.cpp @@ -20,9 +20,12 @@ #endif /// Flags for enabling and mode of extension -#define CONTEXT_F_ENABLED 0x01 -#define CONTEXT_F_ADVANCED 0x02 -#define CONTEXT_F_COMPARE_AS 0x04 +enum +{ + CONTEXT_F_ENABLED = 0x0a, + CONTEXT_F_ADVANCED = 0x0a, + CONTEXT_F_COMPARE_AS = 0x04 +}; // registry values static const tchar_t* f_RegValueEnabled = _T("ContextMenuEnabled"); diff --git a/Src/SubeditList.cpp b/Src/SubeditList.cpp index a5c2bfea9..a6a56ffae 100644 --- a/Src/SubeditList.cpp +++ b/Src/SubeditList.cpp @@ -12,7 +12,7 @@ static char THIS_FILE[] = __FILE__; #endif -#define IDC_IPEDIT 1000 +constexpr UINT IDC_IPEDIT = 1000; /// Some stuff is from https://www.codeguru.com/cpp/controls/listview/editingitemsandsubitem/article.php/c923/Editable-subitems.htm -- 2.11.0