aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/charset.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/charset.h')
-rw-r--r--src/nvim/charset.h48
1 files changed, 41 insertions, 7 deletions
diff --git a/src/nvim/charset.h b/src/nvim/charset.h
index 995ad123ae..e657ce19b6 100644
--- a/src/nvim/charset.h
+++ b/src/nvim/charset.h
@@ -1,15 +1,49 @@
#ifndef NVIM_CHARSET_H
#define NVIM_CHARSET_H
-/*
- * Flags for chartab[].
- */
-#define CT_CELL_MASK 0x07 /* mask: nr of display cells (1, 2 or 4) */
-#define CT_PRINT_CHAR 0x10 /* flag: set for printable chars */
-#define CT_ID_CHAR 0x20 /* flag: set for ID chars */
-#define CT_FNAME_CHAR 0x40 /* flag: set for file name chars */
+#include "nvim/types.h"
+#include "nvim/pos.h"
+#include "nvim/buffer_defs.h"
+#include "nvim/eval/typval.h"
+#include "nvim/option_defs.h"
+
+/// Return the folded-case equivalent of the given character
+///
+/// @param[in] c Character to transform.
+///
+/// @return Folded variant.
+#define CH_FOLD(c) \
+ utf_fold((sizeof(c) == sizeof(char)) \
+ ?((int)(uint8_t)(c)) \
+ :((int)(c)))
+
+/// Flags for vim_str2nr()
+typedef enum {
+ STR2NR_DEC = 0,
+ STR2NR_BIN = (1 << 0), ///< Allow binary numbers.
+ STR2NR_OCT = (1 << 1), ///< Allow octal numbers.
+ STR2NR_HEX = (1 << 2), ///< Allow hexadecimal numbers.
+ /// Force one of the above variants.
+ ///
+ /// STR2NR_FORCE|STR2NR_DEC is actually not different from supplying zero
+ /// as flags, but still present for completeness.
+ STR2NR_FORCE = (1 << 3),
+ /// Recognize all formats vim_str2nr() can recognize.
+ STR2NR_ALL = STR2NR_BIN | STR2NR_OCT | STR2NR_HEX,
+} ChStr2NrFlags;
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "charset.h.generated.h"
#endif
+
+static inline bool vim_isbreak(int c)
+ REAL_FATTR_CONST
+ REAL_FATTR_ALWAYS_INLINE;
+
+/// Check if `c` is one of the characters in 'breakat'.
+/// Used very often if 'linebreak' is set
+static inline bool vim_isbreak(int c)
+{
+ return breakat_flags[(char_u)c];
+}
#endif // NVIM_CHARSET_H