refactor(options): option flags enum #30961

Problem: Currently we use macros with hardcoded flag values for option flags, which is messy and requires a lot of mental math for adding / removing option flags. Using macros for option flags also means that they cannot be used inside debuggers.

Solution: Create a new `OptFlags` enum that stores all the option flags in an organized way that is easier to understand.
This commit is contained in:
Famiu Haque
2024-10-28 19:49:16 +06:00
committed by GitHub
parent 0b7cc014fc
commit 34c44c3556
8 changed files with 144 additions and 150 deletions

View File

@@ -7,47 +7,6 @@
// option_vars.h: definition of global variables for settable options
// Option Flags
// #define P_ALLOCED 0x01U ///< Not used
#define P_EXPAND 0x02U ///< environment expansion. NOTE: P_EXPAND can
///< never be used for local or hidden options
#define P_NO_DEF_EXP 0x04U ///< do not expand default value
#define P_NODEFAULT 0x08U ///< don't set to default value
// #define P_DEF_ALLOCED 0x10U ///< Not used
#define P_WAS_SET 0x20U ///< option has been set/reset
#define P_NO_MKRC 0x40U ///< don't include in :mkvimrc output
// when option changed, what to display:
#define P_UI_OPTION 0x80U ///< send option to remote UI
#define P_RTABL 0x100U ///< redraw tabline
#define P_RSTAT 0x200U ///< redraw status lines
#define P_RWIN 0x400U ///< redraw current window and recompute text
#define P_RBUF 0x800U ///< redraw current buffer and recompute text
#define P_RALL 0xC00U ///< redraw all windows and recompute text
#define P_RCLR 0xE00U ///< clear and redraw all and recompute text
#define P_COMMA 0x1000U ///< comma separated list
#define P_ONECOMMA 0x3000U ///< P_COMMA and cannot have two consecutive
///< commas
#define P_NODUP 0x4000U ///< don't allow duplicate strings
#define P_FLAGLIST 0x8000U ///< list of single-char flags
#define P_SECURE 0x10000U ///< cannot change in modeline or secure mode
#define P_GETTEXT 0x20000U ///< expand default value with _()
#define P_NOGLOB 0x40000U ///< do not use local value for global vimrc
#define P_NFNAME 0x80000U ///< only normal file name chars allowed
#define P_INSECURE 0x100000U ///< option was set from a modeline
#define P_PRI_MKRC 0x200000U ///< priority for :mkvimrc (setting option
///< has side effects)
#define P_NO_ML 0x400000U ///< not allowed in modeline
#define P_CURSWANT 0x800000U ///< update curswant required; not needed
///< when there is a redraw flag
#define P_NDNAME 0x1000000U ///< only normal dir name chars allowed
#define P_HLONLY 0x2000000U ///< option only changes highlight, not text
#define P_MLE 0x4000000U ///< under control of 'modelineexpr'
#define P_FUNC 0x8000000U ///< accept a function reference or a lambda
#define P_COLON 0x10000000U ///< values use colons to create sublists
#define HIGHLIGHT_INIT \
"8:SpecialKey,~:EndOfBuffer,z:TermCursor,Z:TermCursorNC,@:NonText,d:Directory,e:ErrorMsg," \
"i:IncSearch,l:Search,y:CurSearch,m:MoreMsg,M:ModeMsg,n:LineNr,a:LineNrAbove,b:LineNrBelow," \