neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

normal_defs.h (3196B)


      1 #pragma once
      2 
      3 #include <stdbool.h>
      4 
      5 #include "nvim/pos_defs.h"
      6 #include "nvim/types_defs.h"
      7 
      8 /// Motion types, used for operators and for yank/delete registers.
      9 ///
     10 /// The three valid numerical values must not be changed, as they
     11 /// are used in external communication and serialization.
     12 typedef enum {
     13  kMTCharWise = 0,     ///< character-wise movement/register
     14  kMTLineWise = 1,     ///< line-wise movement/register
     15  kMTBlockWise = 2,    ///< block-wise movement/register
     16  kMTUnknown = -1,     ///< Unknown or invalid motion type
     17 } MotionType;
     18 
     19 /// Arguments for operators.
     20 typedef struct {
     21  int op_type;             ///< current pending operator type
     22  int regname;             ///< register to use for the operator
     23  MotionType motion_type;  ///< type of the current cursor motion
     24  int motion_force;        ///< force motion type: 'v', 'V' or CTRL-V
     25  bool use_reg_one;        ///< true if delete uses reg 1 even when not
     26                           ///< linewise
     27  bool inclusive;          ///< true if char motion is inclusive (only
     28                           ///< valid when motion_type is kMTCharWise)
     29  bool end_adjusted;       ///< backuped b_op_end one char (only used by
     30                           ///< do_format())
     31  pos_T start;             ///< start of the operator
     32  pos_T end;               ///< end of the operator
     33  pos_T cursor_start;      ///< cursor position before motion for "gw"
     34 
     35  linenr_T line_count;     ///< number of lines from op_start to op_end (inclusive)
     36  bool empty;              ///< op_start and op_end the same (only used by op_change())
     37  bool is_VIsual;          ///< operator on Visual area
     38  colnr_T start_vcol;      ///< start col for block mode operator
     39  colnr_T end_vcol;        ///< end col for block mode operator
     40  int prev_opcount;        ///< ca.opcount saved for K_EVENT
     41  int prev_count0;         ///< ca.count0 saved for K_EVENT
     42  bool excl_tr_ws;         ///< exclude trailing whitespace for yank of a block
     43 } oparg_T;
     44 
     45 /// Arguments for Normal mode commands.
     46 typedef struct {
     47  oparg_T *oap;     ///< Operator arguments
     48  int prechar;      ///< prefix character (optional, always 'g')
     49  int cmdchar;      ///< command character
     50  int nchar;        ///< next command character (optional)
     51  char nchar_composing[MAX_SCHAR_SIZE];  ///< next char with composing chars (optional)
     52  int nchar_len;    ///< len of nchar_composing (when zero, use nchar instead)
     53  int extra_char;   ///< yet another character (optional)
     54  int opcount;      ///< count before an operator
     55  int count0;       ///< count before command, default 0
     56  int count1;       ///< count before command, default 1
     57  int arg;          ///< extra argument from nv_cmds[]
     58  int retval;       ///< return: CA_* values
     59  char *searchbuf;  ///< return: pointer to search pattern or NULL
     60 } cmdarg_T;
     61 
     62 /// values for retval:
     63 enum {
     64  CA_COMMAND_BUSY  = 1,  ///< skip restarting edit() once
     65  CA_NO_ADJ_OP_END = 2,  ///< don't adjust operator end
     66 };
     67 
     68 /// Replacement for nchar used by nv_replace().
     69 enum {
     70  REPLACE_CR_NCHAR  = -1,
     71  REPLACE_NL_NCHAR  = -2,
     72 };
     73 
     74 enum { SHOWCMD_COLS = 10, };  ///< columns needed by shown command
     75 enum { SHOWCMD_BUFLEN = SHOWCMD_COLS + 1 + 30, };