ops.h
Go to the documentation of this file.
1 #ifndef NVIM_OPS_H
2 #define NVIM_OPS_H
3 
4 #include <stdbool.h>
5 
6 #include "nvim/macros.h"
7 #include "nvim/ascii.h"
8 #include "nvim/types.h"
9 #include "nvim/eval/typval.h"
10 #include "nvim/os/time.h"
11 #include "nvim/normal.h" // for MotionType and oparg_T
12 #include "nvim/ex_cmds_defs.h" // for exarg_T
13 
14 typedef int (*Indenter)(void);
15 
16 /* flags for do_put() */
17 #define PUT_FIXINDENT 1 /* make indent look nice */
18 #define PUT_CURSEND 2 /* leave cursor after end of new text */
19 #define PUT_CURSLINE 4 /* leave cursor on last line of new text */
20 #define PUT_LINE 8 /* put register as lines */
21 #define PUT_LINE_SPLIT 16 /* split line for linewise register */
22 #define PUT_LINE_FORWARD 32 /* put linewise register below Visual sel. */
23 
24 /*
25  * Registers:
26  * 0 = register for latest (unnamed) yank
27  * 1..9 = registers '1' to '9', for deletes
28  * 10..35 = registers 'a' to 'z'
29  * 36 = delete register '-'
30  * 37 = selection register '*'
31  * 38 = clipboard register '+'
32  */
33 #define DELETION_REGISTER 36
34 #define NUM_SAVED_REGISTERS 37
35 // The following registers should not be saved in ShaDa file:
36 #define STAR_REGISTER 37
37 #define PLUS_REGISTER 38
38 #define NUM_REGISTERS 39
39 
40 // Operator IDs; The order must correspond to opchars[] in ops.c!
41 #define OP_NOP 0 // no pending operation
42 #define OP_DELETE 1 // "d" delete operator
43 #define OP_YANK 2 // "y" yank operator
44 #define OP_CHANGE 3 // "c" change operator
45 #define OP_LSHIFT 4 // "<" left shift operator
46 #define OP_RSHIFT 5 // ">" right shift operator
47 #define OP_FILTER 6 // "!" filter operator
48 #define OP_TILDE 7 // "g~" switch case operator
49 #define OP_INDENT 8 // "=" indent operator
50 #define OP_FORMAT 9 // "gq" format operator
51 #define OP_COLON 10 // ":" colon operator
52 #define OP_UPPER 11 // "gU" make upper case operator
53 #define OP_LOWER 12 // "gu" make lower case operator
54 #define OP_JOIN 13 // "J" join operator, only for Visual mode
55 #define OP_JOIN_NS 14 // "gJ" join operator, only for Visual mode
56 #define OP_ROT13 15 // "g?" rot-13 encoding
57 #define OP_REPLACE 16 // "r" replace chars, only for Visual mode
58 #define OP_INSERT 17 // "I" Insert column, only for Visual mode
59 #define OP_APPEND 18 // "A" Append column, only for Visual mode
60 #define OP_FOLD 19 // "zf" define a fold
61 #define OP_FOLDOPEN 20 // "zo" open folds
62 #define OP_FOLDOPENREC 21 // "zO" open folds recursively
63 #define OP_FOLDCLOSE 22 // "zc" close folds
64 #define OP_FOLDCLOSEREC 23 // "zC" close folds recursively
65 #define OP_FOLDDEL 24 // "zd" delete folds
66 #define OP_FOLDDELREC 25 // "zD" delete folds recursively
67 #define OP_FORMAT2 26 // "gw" format operator, keeps cursor pos
68 #define OP_FUNCTION 27 // "[email protected]" call 'operatorfunc'
69 #define OP_NR_ADD 28 // "<C-A>" Add to the number or alphabetic
70  // character (OP_ADD conflicts with Perl)
71 #define OP_NR_SUB 29 // "<C-X>" Subtract from the number or
72  // alphabetic character
73 
75 enum GRegFlags {
78  kGRegList = 4
79 };
80 
82 typedef struct yankreg {
84  size_t y_size;
89 } yankreg_T;
90 
96 static inline int op_reg_index(const int regname)
98 {
99  if (ascii_isdigit(regname)) {
100  return regname - '0';
101  } else if (ASCII_ISLOWER(regname)) {
102  return CharOrdLow(regname) + 10;
103  } else if (ASCII_ISUPPER(regname)) {
104  return CharOrdUp(regname) + 10;
105  } else if (regname == '-') {
106  return DELETION_REGISTER;
107  } else if (regname == '*') {
108  return STAR_REGISTER;
109  } else if (regname == '+') {
110  return PLUS_REGISTER;
111  } else {
112  return -1;
113  }
114 }
115 
116 #ifdef INCLUDE_GENERATED_DECLARATIONS
117 # include "ops.h.generated.h"
118 #endif
119 #endif // NVIM_OPS_H
#define CharOrdUp(x)
Definition: ascii.h:16
#define ASCII_ISUPPER(c)
Definition: macros.h:55
#define FUNC_ATTR_CONST
Definition: func_attr.h:234
MotionType
Definition: normal.h:17
Timestamp timestamp
Time when register was last modified.
Definition: ops.h:87
Return expression itself for "=" register.
Definition: ops.h:77
struct yankreg yankreg_T
Definition of one register.
dict_T * additional_data
Additional data from ShaDa file.
Definition: ops.h:88
#define PLUS_REGISTER
Definition: ops.h:37
Do not allow expression register.
Definition: ops.h:76
int colnr_T
Column number type.
Definition: pos.h:9
#define ASCII_ISLOWER(c)
Definition: macros.h:54
GRegFlags
Flags for get_reg_contents().
Definition: ops.h:75
Definition: coverity-model.c:40
MotionType y_type
Register type.
Definition: ops.h:85
#define STAR_REGISTER
Definition: ops.h:36
Definition of one register.
Definition: ops.h:82
char_u ** y_array
Pointer to an array of line pointers.
Definition: ops.h:83
#define DELETION_REGISTER
Definition: ops.h:33
Return list.
Definition: ops.h:78
unsigned char char_u
Definition: types.h:11
int(* Indenter)(void)
Definition: ops.h:14
#define CharOrdLow(x)
Definition: ascii.h:15
size_t y_size
Number of lines in y_array.
Definition: ops.h:84
colnr_T y_width
Register width (only valid for y_type == kBlockWise).
Definition: ops.h:86
uint64_t Timestamp
Definition: time.h:8