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