| 1 | #ifndef NVIM_CHARSET_H |
| 2 | #define NVIM_CHARSET_H |
| 3 | |
| 4 | #include "nvim/types.h" |
| 5 | #include "nvim/pos.h" |
| 6 | #include "nvim/buffer_defs.h" |
| 7 | #include "nvim/eval/typval.h" |
| 8 | #include "nvim/option_defs.h" |
| 9 | |
| 10 | /// Return the folded-case equivalent of the given character |
| 11 | /// |
| 12 | /// @param[in] c Character to transform. |
| 13 | /// |
| 14 | /// @return Folded variant. |
| 15 | #define CH_FOLD(c) \ |
| 16 | utf_fold((sizeof(c) == sizeof(char)) \ |
| 17 | ?((int)(uint8_t)(c)) \ |
| 18 | :((int)(c))) |
| 19 | |
| 20 | /// Flags for vim_str2nr() |
| 21 | typedef enum { |
| 22 | STR2NR_DEC = 0, |
| 23 | STR2NR_BIN = (1 << 0), ///< Allow binary numbers. |
| 24 | STR2NR_OCT = (1 << 1), ///< Allow octal numbers. |
| 25 | STR2NR_HEX = (1 << 2), ///< Allow hexadecimal numbers. |
| 26 | /// Force one of the above variants. |
| 27 | /// |
| 28 | /// STR2NR_FORCE|STR2NR_DEC is actually not different from supplying zero |
| 29 | /// as flags, but still present for completeness. |
| 30 | STR2NR_FORCE = (1 << 3), |
| 31 | /// Recognize all formats vim_str2nr() can recognize. |
| 32 | STR2NR_ALL = STR2NR_BIN | STR2NR_OCT | STR2NR_HEX, |
| 33 | } ChStr2NrFlags; |
| 34 | |
| 35 | #ifdef INCLUDE_GENERATED_DECLARATIONS |
| 36 | # include "charset.h.generated.h" |
| 37 | #endif |
| 38 | |
| 39 | static inline bool vim_isbreak(int c) |
| 40 | REAL_FATTR_CONST |
| 41 | REAL_FATTR_ALWAYS_INLINE; |
| 42 | |
| 43 | /// Check if `c` is one of the characters in 'breakat'. |
| 44 | /// Used very often if 'linebreak' is set |
| 45 | static inline bool vim_isbreak(int c) |
| 46 | { |
| 47 | return breakat_flags[(char_u)c]; |
| 48 | } |
| 49 | #endif // NVIM_CHARSET_H |
| 50 | |