OSDN Git Service

refactor
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Thu, 16 Mar 2023 13:49:32 +0000 (22:49 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Thu, 16 Mar 2023 13:49:32 +0000 (22:49 +0900)
12 files changed:
Externals/crystaledit/editlib/LineInfo.h
Externals/crystaledit/editlib/SyntaxColors.h
Externals/crystaledit/editlib/dialogs/memcombo.cpp
Src/Common/RegOptionsMgr.cpp
Src/DirView.h
Src/Merge.h
Src/MergeEditFrm.cpp
Src/MergeEditView.h
Src/MergeLineFlags.h
Src/PropMergeColors.h
Src/PropShell.cpp
Src/SubeditList.cpp

index e7a0e9d..f7041a4 100644 (file)
@@ -11,8 +11,8 @@
 #include <cstdint>
 
 //  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;
 
index ac8c52a..5b2c87d 100644 (file)
@@ -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.
index 382cc2e..4fb18d4 100644 (file)
@@ -22,7 +22,7 @@
 #define new DEBUG_NEW
 #endif
 
-#define REMEMBER_COUNT  64
+constexpr int REMEMBER_COUNT = 64;
 
 /////////////////////////////////////////////////////////////////////////////
 // CMemComboBox
index a3ac6c3..2cecf5c 100644 (file)
@@ -13,7 +13,7 @@
 #include "varprop.h"
 #include "OptionsMgr.h"
 
-#define MAX_PATH_FULL 32767
+constexpr size_t MAX_PATH_FULL = 32767;
 
 struct AsyncWriterThreadParams
 {
index 77a2a0f..1e1c6e4 100644 (file)
@@ -48,7 +48,7 @@ struct IListCtrl;
 const uintptr_t SPECIAL_ITEM_POS = (uintptr_t)(reinterpret_cast<DIFFITEM *>( - 1L));
 
 /** Default column width in directory compare */
-const UINT DefColumnWidth = 111;
+constexpr int DefColumnWidth = 111;
 
 /**
  * @brief Directory compare results view.
index 2a5318b..b3ac310 100644 (file)
@@ -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
index 274da3c..ab680ff 100644 (file)
@@ -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
index f5b4041..94898dc 100644 (file)
 /** 
  * @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;
 
 
 /////////////////////////////////////////////////////////////////////////////
index f7b9ca4..df7b25a 100644 (file)
@@ -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.
  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))
index 5756265..d76b90d 100644 (file)
@@ -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
index ac43642..c1632f5 100644 (file)
 #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");
index a5c2bfe..a6a56ff 100644 (file)
@@ -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