robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
228e6ca32a
master
1#pragma once 2 3#include "nvim/ascii_defs.h" 4#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep 5#include "nvim/macros_defs.h" 6#include "nvim/register_defs.h" 7 8/// Used by TextPutPost/TextPutPre autocommands for the '.' register. If 9/// "add_last_insert" is == 1, then "stuff_inserted" will add the last inserted 10/// text to "last_insert_ga". 11EXTERN garray_T last_insert_ga INIT (= {0 ,0 ,1 ,64 ,NULL }); 12EXTERN int add_last_insert INIT (= 0 ); 13 14#include "register.h.generated.h" 15#include "register.h.inline.generated.h" 16 17/// @see get_yank_register 18/// @return true when register should be inserted literally 19/// (selection or clipboard) 20static inline bool is_literal_register (const int regname ) 21FUNC_ATTR_CONST 22{ 23return regname == '*' || regname == '+' || ASCII_ISALNUM (regname ); 24} 25 26/// Convert register name into register index 27/// 28/// @param[in] regname Register name. 29/// 30/// @return Index in y_regs array or -1 if register name was not recognized. 31static inline int op_reg_index (const int regname ) 32FUNC_ATTR_CONST 33{ 34if (ascii_isdigit (regname )) { 35return regname - '0' ; 36 }else if (ASCII_ISLOWER (regname )) { 37return CHAR_ORD_LOW (regname )+ 10 ; 38 }else if (ASCII_ISUPPER (regname )) { 39return CHAR_ORD_UP (regname )+ 10 ; 40 }else if (regname == '-' ) { 41return DELETION_REGISTER ; 42 }else if (regname == '*' ) { 43return STAR_REGISTER ; 44 }else if (regname == '+' ) { 45return PLUS_REGISTER ; 46 }else { 47return -1 ; 48 } 49} 50 51static inline bool is_append_register (int regname ) 52FUNC_ATTR_CONST 53{ 54return ASCII_ISUPPER (regname ); 55} 56 57/// @return the character name of the register with the given number 58static inline int get_register_name (int num ) 59FUNC_ATTR_CONST 60{ 61if (num == -1 ) { 62return '"' ; 63 }else if (num < 10 ) { 64return num + '0' ; 65 }else if (num == DELETION_REGISTER ) { 66return '-' ; 67 }else if (num == STAR_REGISTER ) { 68return '*' ; 69 }else if (num == PLUS_REGISTER ) { 70return '+' ; 71 }else { 72return num + 'a' - 10 ; 73 } 74} 75 76/// Check whether register is empty 77static inline bool reg_empty (const yankreg_T * const reg ) 78FUNC_ATTR_PURE 79{ 80return (reg -> y_array == NULL 81|| reg -> y_size == 0 82|| (reg -> y_size == 1 83&& reg -> y_type == kMTCharWise 84&& reg -> y_array [0 ].size == 0 )); 85}