robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1#pragma once 2 3#include <stdbool.h> 4 5#include "nvim/pos_defs.h" 6#include "nvim/types_defs.h" 7 8// Values for cmd_flags. 9#define NV_NCH 0x01 // May need to get a second char. 10#define NV_NCH_NOP (0x02|NV_NCH) // Get second char when no operator pending. 11#define NV_NCH_ALW (0x04|NV_NCH) // Always get a second char. 12#define NV_LANG 0x08 // Second char needs language adjustment. 13#define NV_SS 0x10 // May start selection. 14#define NV_SSS 0x20 // May start selection with shift modifier. 15#define NV_STS 0x40 // May stop selection without shift modif. 16#define NV_RL 0x80 // 'rightleft' modifies command. 17#define NV_KEEPREG 0x100 // Don't clear regname. 18#define NV_NCW 0x200 // Not allowed in command-line window. 19#define NV_NCH_ARG 0x400 // Second char is a typed operand (mark/reg name), not part of 20// the name (see NV_LANG for f/t/r). 21#define NV_MOTION 0x800 // Cursor-relative motion. 22#define NV_JUMP 0x1000 // Absolute motion, target independent of the cursor ("G"). 23 24/// Motion types, used for operators and for yank/delete registers. 25/// 26/// The three valid numerical values must not be changed, as they 27/// are used in external communication and serialization. 28typedef enum { 29kMTCharWise = 0 ,///< character-wise movement/register 30kMTLineWise = 1 ,///< line-wise movement/register 31kMTBlockWise = 2 ,///< block-wise movement/register 32kMTUnknown = -1 ,///< Unknown or invalid motion type 33}MotionType ; 34 35/// Arguments for operators. 36typedef struct { 37int op_type ;///< current pending operator type 38int regname ;///< register to use for the operator 39MotionType motion_type ;///< type of the current cursor motion 40int motion_force ;///< force motion type: 'v', 'V' or CTRL-V 41bool use_reg_one ;///< true if delete uses reg 1 even when not 42///< linewise 43bool inclusive ;///< true if char motion is inclusive (only 44///< valid when motion_type is kMTCharWise) 45bool end_adjusted ;///< backuped b_op_end one char (only used by 46///< do_format()) 47pos_T start ;///< start of the operator 48pos_T end ;///< end of the operator 49pos_T cursor_start ;///< cursor position before motion for "gw" 50bool restore_cursor ;///< restore cursor after yank 51 52linenr_T line_count ;///< number of lines from op_start to op_end (inclusive) 53bool empty ;///< op_start and op_end the same (only used by op_change()) 54bool is_VIsual ;///< operator on Visual area 55bool from_visual ;///< Started in Visual. For "zq" (which ends Visual, to accept a motion). 56colnr_T start_vcol ;///< start col for block mode operator 57colnr_T end_vcol ;///< end col for block mode operator 58int prev_opcount ;///< ca.opcount saved for K_EVENT 59int prev_count0 ;///< ca.count0 saved for K_EVENT 60bool excl_tr_ws ;///< exclude trailing whitespace for yank of a block 61}oparg_T ; 62 63/// Arguments for Normal mode commands. 64typedef struct { 65oparg_T * oap ;///< Operator arguments 66int prechar ;///< prefix character (optional, always 'g') 67int cmdchar ;///< command character 68int nchar ;///< next command character (optional) 69char nchar_composing [MAX_SCHAR_SIZE ];///< next char with composing chars (optional) 70int nchar_len ;///< len of nchar_composing (when zero, use nchar instead) 71int extra_char ;///< yet another character (optional) 72int opcount ;///< count before an operator 73int count0 ;///< count before command, default 0 74int count1 ;///< count before command, default 1 75int arg ;///< extra argument from nv_cmds[] 76int retval ;///< return: CA_* values 77char * searchbuf ;///< return: pointer to search pattern or NULL 78}cmdarg_T ; 79 80/// values for retval: 81enum { 82CA_COMMAND_BUSY = 1 ,///< skip restarting edit() once 83CA_NO_ADJ_OP_END = 2 ,///< don't adjust operator end 84}; 85 86/// A Visual selection's mode and extent (line/column span, not absolute positions), so an 87/// equal-sized region can be re-applied starting at the cursor: {count}v reselect. 88typedef struct { 89int mode ;///< 'v', 'V', or Ctrl-V 90linenr_T line_count ;///< number of lines 91colnr_T vcol ;///< number of cols or end column (MAXCOL: to end of line) 92}VisualExtent ; 93 94/// Visual/Select mode state, as one global "group" (Visual). 95typedef struct { 96pos_T start ;///< Start position of the active Visual selection. 97bool active ;///< Whether Visual mode is active. 98bool select ;///< Whether Select mode is active. 99int select_reg ;///< Register name for Select mode. 100bool select_exclu_adj ;///< Cursor was incremented during exclusive selection. 101int restart_select ;///< Restart Select mode when next cmd finished. 102bool need_end ;///< End Visual mode when the cmd finishes. 103int reselect ;///< Restart the selection after a Select-mode mapping or menu. 104int mode ;///< Type of Visual mode: 'v', 'V', Ctrl-V. 105VisualExtent resel ;///< Previous Visual area's extent, for {count}v reselect. 106}VisualState ; 107 108/// Visual area. The region when Visual mode ended, or the active region (visualinfo()). 109typedef struct { 110pos_T vi_start ;///< Start pos. 111pos_T vi_end ;///< End position. 112int vi_mode ;///< Visual.mode. 113colnr_T vi_curswant ;///< MAXCOL from w_curswant. 114}visualinfo_T ; 115 116/// Replacement for nchar used by nv_replace(). 117enum { 118REPLACE_CR_NCHAR = -1 , 119REPLACE_NL_NCHAR = -2 , 120}; 121 122enum {SHOWCMD_COLS = 10 , };///< columns needed by shown command 123enum {SHOWCMD_BUFLEN = SHOWCMD_COLS + 1 + 30 , };