mirror of
https://github.com/neovim/neovim.git
synced 2025-10-03 08:28:34 +00:00
Merge pull request #35790 from janlazo/vim-8.1.1989
vim-patch:8.1.{2021,2077}
This commit is contained in:
@@ -74,6 +74,7 @@ defsfile:write(string.format(
|
||||
#include "nvim/os/lang.h"
|
||||
#include "nvim/profile.h"
|
||||
#include "nvim/quickfix.h"
|
||||
#include "nvim/register.h"
|
||||
#include "nvim/runtime.h"
|
||||
#include "nvim/sign.h"
|
||||
#include "nvim/spell.h"
|
||||
|
@@ -28,9 +28,9 @@
|
||||
#include "nvim/mbyte.h"
|
||||
#include "nvim/memory.h"
|
||||
#include "nvim/memory_defs.h"
|
||||
#include "nvim/ops.h"
|
||||
#include "nvim/pos_defs.h"
|
||||
#include "nvim/regexp.h"
|
||||
#include "nvim/register.h"
|
||||
#include "nvim/strings.h"
|
||||
#include "nvim/types_defs.h"
|
||||
#include "nvim/usercmd.h"
|
||||
|
@@ -65,7 +65,6 @@
|
||||
#include "nvim/msgpack_rpc/channel.h"
|
||||
#include "nvim/msgpack_rpc/channel_defs.h"
|
||||
#include "nvim/msgpack_rpc/unpacker.h"
|
||||
#include "nvim/ops.h"
|
||||
#include "nvim/option.h"
|
||||
#include "nvim/option_defs.h"
|
||||
#include "nvim/option_vars.h"
|
||||
@@ -75,6 +74,7 @@
|
||||
#include "nvim/os/proc.h"
|
||||
#include "nvim/popupmenu.h"
|
||||
#include "nvim/pos_defs.h"
|
||||
#include "nvim/register.h"
|
||||
#include "nvim/runtime.h"
|
||||
#include "nvim/sign_defs.h"
|
||||
#include "nvim/state.h"
|
||||
|
@@ -65,6 +65,7 @@
|
||||
#include "nvim/plines.h"
|
||||
#include "nvim/popupmenu.h"
|
||||
#include "nvim/pos_defs.h"
|
||||
#include "nvim/register.h"
|
||||
#include "nvim/search.h"
|
||||
#include "nvim/state.h"
|
||||
#include "nvim/state_defs.h"
|
||||
|
@@ -73,6 +73,7 @@
|
||||
#include "nvim/quickfix.h"
|
||||
#include "nvim/regexp.h"
|
||||
#include "nvim/regexp_defs.h"
|
||||
#include "nvim/register.h"
|
||||
#include "nvim/runtime.h"
|
||||
#include "nvim/runtime_defs.h"
|
||||
#include "nvim/strings.h"
|
||||
@@ -5865,7 +5866,7 @@ static list_T *string_to_list(const char *str, size_t len, const bool keepempty)
|
||||
}
|
||||
|
||||
/// os_system wrapper. Handles 'verbose', :profile, and v:shell_error.
|
||||
void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv, bool retlist)
|
||||
static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv, bool retlist)
|
||||
{
|
||||
proftime_T wait_time;
|
||||
bool profiling = do_profiling == PROF_YES;
|
||||
@@ -5963,6 +5964,17 @@ void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv, bool retlist
|
||||
}
|
||||
}
|
||||
|
||||
/// f_system - the Vimscript system() function
|
||||
void f_system(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
get_system_output_as_rettv(argvars, rettv, false);
|
||||
}
|
||||
|
||||
void f_systemlist(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
get_system_output_as_rettv(argvars, rettv, true);
|
||||
}
|
||||
|
||||
/// Get a callback from "arg". It can be a Funcref or a function name.
|
||||
bool callback_from_typval(Callback *const callback, const typval_T *const arg)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
|
||||
|
@@ -114,6 +114,7 @@
|
||||
#include "nvim/profile.h"
|
||||
#include "nvim/regexp.h"
|
||||
#include "nvim/regexp_defs.h"
|
||||
#include "nvim/register.h"
|
||||
#include "nvim/runtime.h"
|
||||
#include "nvim/runtime_defs.h"
|
||||
#include "nvim/search.h"
|
||||
@@ -7950,17 +7951,6 @@ static void f_synstack(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
}
|
||||
}
|
||||
|
||||
/// f_system - the Vimscript system() function
|
||||
static void f_system(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
get_system_output_as_rettv(argvars, rettv, false);
|
||||
}
|
||||
|
||||
static void f_systemlist(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
get_system_output_as_rettv(argvars, rettv, true);
|
||||
}
|
||||
|
||||
/// "tabpagebuflist()" function
|
||||
static void f_tabpagebuflist(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
|
@@ -36,10 +36,10 @@
|
||||
#include "nvim/macros_defs.h"
|
||||
#include "nvim/memory.h"
|
||||
#include "nvim/message.h"
|
||||
#include "nvim/ops.h"
|
||||
#include "nvim/option.h"
|
||||
#include "nvim/option_defs.h"
|
||||
#include "nvim/os/os.h"
|
||||
#include "nvim/register.h"
|
||||
#include "nvim/search.h"
|
||||
#include "nvim/strings.h"
|
||||
#include "nvim/types_defs.h"
|
||||
|
@@ -72,7 +72,6 @@
|
||||
#include "nvim/move.h"
|
||||
#include "nvim/normal.h"
|
||||
#include "nvim/normal_defs.h"
|
||||
#include "nvim/ops.h"
|
||||
#include "nvim/option.h"
|
||||
#include "nvim/option_defs.h"
|
||||
#include "nvim/option_vars.h"
|
||||
@@ -90,6 +89,7 @@
|
||||
#include "nvim/quickfix.h"
|
||||
#include "nvim/regexp.h"
|
||||
#include "nvim/regexp_defs.h"
|
||||
#include "nvim/register.h"
|
||||
#include "nvim/runtime.h"
|
||||
#include "nvim/runtime_defs.h"
|
||||
#include "nvim/search.h"
|
||||
|
@@ -70,6 +70,7 @@
|
||||
#include "nvim/profile.h"
|
||||
#include "nvim/regexp.h"
|
||||
#include "nvim/regexp_defs.h"
|
||||
#include "nvim/register.h"
|
||||
#include "nvim/search.h"
|
||||
#include "nvim/state.h"
|
||||
#include "nvim/state_defs.h"
|
||||
|
@@ -55,7 +55,6 @@
|
||||
#include "nvim/memory.h"
|
||||
#include "nvim/message.h"
|
||||
#include "nvim/move.h"
|
||||
#include "nvim/ops.h"
|
||||
#include "nvim/option.h"
|
||||
#include "nvim/option_defs.h"
|
||||
#include "nvim/option_vars.h"
|
||||
@@ -67,6 +66,7 @@
|
||||
#include "nvim/pos_defs.h"
|
||||
#include "nvim/regexp.h"
|
||||
#include "nvim/regexp_defs.h"
|
||||
#include "nvim/register.h"
|
||||
#include "nvim/search.h"
|
||||
#include "nvim/spell.h"
|
||||
#include "nvim/state.h"
|
||||
|
@@ -92,6 +92,7 @@
|
||||
#include "nvim/popupmenu.h"
|
||||
#include "nvim/profile.h"
|
||||
#include "nvim/quickfix.h"
|
||||
#include "nvim/register.h"
|
||||
#include "nvim/runtime.h"
|
||||
#include "nvim/runtime_defs.h"
|
||||
#include "nvim/shada.h"
|
||||
|
@@ -833,11 +833,11 @@ char *arena_memdupz(Arena *arena, const char *buf, size_t size)
|
||||
# include "nvim/grid.h"
|
||||
# include "nvim/mark.h"
|
||||
# include "nvim/msgpack_rpc/channel.h"
|
||||
# include "nvim/ops.h"
|
||||
# include "nvim/option.h"
|
||||
# include "nvim/os/os.h"
|
||||
# include "nvim/quickfix.h"
|
||||
# include "nvim/regexp.h"
|
||||
# include "nvim/register.h"
|
||||
# include "nvim/search.h"
|
||||
# include "nvim/spell.h"
|
||||
# include "nvim/tag.h"
|
||||
|
@@ -53,7 +53,6 @@
|
||||
#include "nvim/message.h"
|
||||
#include "nvim/message_defs.h"
|
||||
#include "nvim/mouse.h"
|
||||
#include "nvim/ops.h"
|
||||
#include "nvim/option.h"
|
||||
#include "nvim/option_vars.h"
|
||||
#include "nvim/os/fs.h"
|
||||
@@ -62,6 +61,7 @@
|
||||
#include "nvim/os/time.h"
|
||||
#include "nvim/pos_defs.h"
|
||||
#include "nvim/regexp.h"
|
||||
#include "nvim/register.h"
|
||||
#include "nvim/runtime.h"
|
||||
#include "nvim/runtime_defs.h"
|
||||
#include "nvim/state_defs.h"
|
||||
|
@@ -38,6 +38,7 @@
|
||||
#include "nvim/plines.h"
|
||||
#include "nvim/popupmenu.h"
|
||||
#include "nvim/pos_defs.h"
|
||||
#include "nvim/register.h"
|
||||
#include "nvim/search.h"
|
||||
#include "nvim/state.h"
|
||||
#include "nvim/state_defs.h"
|
||||
|
@@ -69,6 +69,7 @@
|
||||
#include "nvim/plines.h"
|
||||
#include "nvim/profile.h"
|
||||
#include "nvim/quickfix.h"
|
||||
#include "nvim/register.h"
|
||||
#include "nvim/search.h"
|
||||
#include "nvim/spell.h"
|
||||
#include "nvim/spell_defs.h"
|
||||
|
2973
src/nvim/ops.c
2973
src/nvim/ops.c
File diff suppressed because it is too large
Load Diff
105
src/nvim/ops.h
105
src/nvim/ops.h
@@ -12,54 +12,9 @@
|
||||
#include "nvim/option_defs.h" // IWYU pragma: keep
|
||||
#include "nvim/os/time_defs.h"
|
||||
#include "nvim/pos_defs.h"
|
||||
#include "nvim/register_defs.h"
|
||||
#include "nvim/types_defs.h"
|
||||
|
||||
/// structure used by block_prep, op_delete and op_yank for blockwise operators
|
||||
/// also op_change, op_shift, op_insert, op_replace - AKelly
|
||||
struct block_def {
|
||||
int startspaces; ///< 'extra' cols before first char
|
||||
int endspaces; ///< 'extra' cols after last char
|
||||
int textlen; ///< chars in block
|
||||
char *textstart; ///< pointer to 1st char (partially) in block
|
||||
colnr_T textcol; ///< index of chars (partially) in block
|
||||
colnr_T start_vcol; ///< start col of 1st char wholly inside block
|
||||
colnr_T end_vcol; ///< start col of 1st char wholly after block
|
||||
int is_short; ///< true if line is too short to fit in block
|
||||
int is_MAX; ///< true if curswant==MAXCOL when starting
|
||||
int is_oneChar; ///< true if block within one character
|
||||
int pre_whitesp; ///< screen cols of ws before block
|
||||
int pre_whitesp_c; ///< chars of ws before block
|
||||
colnr_T end_char_vcols; ///< number of vcols of post-block char
|
||||
colnr_T start_char_vcols; ///< number of vcols of pre-block char
|
||||
};
|
||||
|
||||
/// flags for do_put()
|
||||
enum {
|
||||
PUT_FIXINDENT = 1, ///< make indent look nice
|
||||
PUT_CURSEND = 2, ///< leave cursor after end of new text
|
||||
PUT_CURSLINE = 4, ///< leave cursor on last line of new text
|
||||
PUT_LINE = 8, ///< put register as lines
|
||||
PUT_LINE_SPLIT = 16, ///< split line for linewise register
|
||||
PUT_LINE_FORWARD = 32, ///< put linewise register below Visual sel.
|
||||
PUT_BLOCK_INNER = 64, ///< in block mode, do not add trailing spaces
|
||||
};
|
||||
|
||||
/// Registers:
|
||||
/// 0 = register for latest (unnamed) yank
|
||||
/// 1..9 = registers '1' to '9', for deletes
|
||||
/// 10..35 = registers 'a' to 'z'
|
||||
/// 36 = delete register '-'
|
||||
/// 37 = selection register '*'
|
||||
/// 38 = clipboard register '+'
|
||||
enum {
|
||||
DELETION_REGISTER = 36,
|
||||
NUM_SAVED_REGISTERS = 37,
|
||||
// The following registers should not be saved in ShaDa file:
|
||||
STAR_REGISTER = 37,
|
||||
PLUS_REGISTER = 38,
|
||||
NUM_REGISTERS = 39,
|
||||
};
|
||||
|
||||
/// Operator IDs; The order must correspond to opchars[] in ops.c!
|
||||
enum {
|
||||
OP_NOP = 0, ///< no pending operation
|
||||
@@ -94,65 +49,7 @@ enum {
|
||||
OP_NR_SUB = 29, ///< "<C-X>" Subtract from the number or alphabetic character
|
||||
};
|
||||
|
||||
/// Flags for get_reg_contents().
|
||||
enum GRegFlags {
|
||||
kGRegNoExpr = 1, ///< Do not allow expression register.
|
||||
kGRegExprSrc = 2, ///< Return expression itself for "=" register.
|
||||
kGRegList = 4, ///< Return list.
|
||||
};
|
||||
|
||||
/// Definition of one register
|
||||
typedef struct {
|
||||
String *y_array; ///< Pointer to an array of Strings.
|
||||
size_t y_size; ///< Number of lines in y_array.
|
||||
MotionType y_type; ///< Register type
|
||||
colnr_T y_width; ///< Register width (only valid for y_type == kBlockWise).
|
||||
Timestamp timestamp; ///< Time when register was last modified.
|
||||
AdditionalData *additional_data; ///< Additional data from ShaDa file.
|
||||
} yankreg_T;
|
||||
|
||||
/// Modes for get_yank_register()
|
||||
typedef enum {
|
||||
YREG_PASTE,
|
||||
YREG_YANK,
|
||||
YREG_PUT,
|
||||
} yreg_mode_t;
|
||||
|
||||
#include "ops.h.generated.h"
|
||||
#include "ops.h.inline.generated.h"
|
||||
|
||||
/// Convert register name into register index
|
||||
///
|
||||
/// @param[in] regname Register name.
|
||||
///
|
||||
/// @return Index in y_regs array or -1 if register name was not recognized.
|
||||
static inline int op_reg_index(const int regname)
|
||||
FUNC_ATTR_CONST
|
||||
{
|
||||
if (ascii_isdigit(regname)) {
|
||||
return regname - '0';
|
||||
} else if (ASCII_ISLOWER(regname)) {
|
||||
return CHAR_ORD_LOW(regname) + 10;
|
||||
} else if (ASCII_ISUPPER(regname)) {
|
||||
return CHAR_ORD_UP(regname) + 10;
|
||||
} else if (regname == '-') {
|
||||
return DELETION_REGISTER;
|
||||
} else if (regname == '*') {
|
||||
return STAR_REGISTER;
|
||||
} else if (regname == '+') {
|
||||
return PLUS_REGISTER;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/// @see get_yank_register
|
||||
/// @return true when register should be inserted literally
|
||||
/// (selection or clipboard)
|
||||
static inline bool is_literal_register(const int regname)
|
||||
FUNC_ATTR_CONST
|
||||
{
|
||||
return regname == '*' || regname == '+' || ASCII_ISALNUM(regname);
|
||||
}
|
||||
|
||||
EXTERN LuaRef repeat_luaref INIT( = LUA_NOREF); ///< LuaRef for "."
|
||||
|
2984
src/nvim/register.c
Normal file
2984
src/nvim/register.c
Normal file
File diff suppressed because it is too large
Load Diff
79
src/nvim/register.h
Normal file
79
src/nvim/register.h
Normal file
@@ -0,0 +1,79 @@
|
||||
#pragma once
|
||||
|
||||
#include "nvim/ascii_defs.h"
|
||||
#include "nvim/ex_cmds_defs.h"
|
||||
#include "nvim/macros_defs.h"
|
||||
#include "nvim/register_defs.h"
|
||||
|
||||
#include "register.h.generated.h"
|
||||
#include "register.h.inline.generated.h"
|
||||
|
||||
/// @see get_yank_register
|
||||
/// @return true when register should be inserted literally
|
||||
/// (selection or clipboard)
|
||||
static inline bool is_literal_register(const int regname)
|
||||
FUNC_ATTR_CONST
|
||||
{
|
||||
return regname == '*' || regname == '+' || ASCII_ISALNUM(regname);
|
||||
}
|
||||
|
||||
/// Convert register name into register index
|
||||
///
|
||||
/// @param[in] regname Register name.
|
||||
///
|
||||
/// @return Index in y_regs array or -1 if register name was not recognized.
|
||||
static inline int op_reg_index(const int regname)
|
||||
FUNC_ATTR_CONST
|
||||
{
|
||||
if (ascii_isdigit(regname)) {
|
||||
return regname - '0';
|
||||
} else if (ASCII_ISLOWER(regname)) {
|
||||
return CHAR_ORD_LOW(regname) + 10;
|
||||
} else if (ASCII_ISUPPER(regname)) {
|
||||
return CHAR_ORD_UP(regname) + 10;
|
||||
} else if (regname == '-') {
|
||||
return DELETION_REGISTER;
|
||||
} else if (regname == '*') {
|
||||
return STAR_REGISTER;
|
||||
} else if (regname == '+') {
|
||||
return PLUS_REGISTER;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool is_append_register(int regname)
|
||||
FUNC_ATTR_CONST
|
||||
{
|
||||
return ASCII_ISUPPER(regname);
|
||||
}
|
||||
|
||||
/// @return the character name of the register with the given number
|
||||
static inline int get_register_name(int num)
|
||||
FUNC_ATTR_CONST
|
||||
{
|
||||
if (num == -1) {
|
||||
return '"';
|
||||
} else if (num < 10) {
|
||||
return num + '0';
|
||||
} else if (num == DELETION_REGISTER) {
|
||||
return '-';
|
||||
} else if (num == STAR_REGISTER) {
|
||||
return '*';
|
||||
} else if (num == PLUS_REGISTER) {
|
||||
return '+';
|
||||
} else {
|
||||
return num + 'a' - 10;
|
||||
}
|
||||
}
|
||||
|
||||
/// Check whether register is empty
|
||||
static inline bool reg_empty(const yankreg_T *const reg)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
return (reg->y_array == NULL
|
||||
|| reg->y_size == 0
|
||||
|| (reg->y_size == 1
|
||||
&& reg->y_type == kMTCharWise
|
||||
&& reg->y_array[0].size == 0));
|
||||
}
|
75
src/nvim/register_defs.h
Normal file
75
src/nvim/register_defs.h
Normal file
@@ -0,0 +1,75 @@
|
||||
#pragma once
|
||||
|
||||
#include "nvim/api/private/defs.h"
|
||||
#include "nvim/normal_defs.h"
|
||||
#include "nvim/os/time_defs.h"
|
||||
|
||||
/// flags for do_put()
|
||||
enum {
|
||||
PUT_FIXINDENT = 1, ///< make indent look nice
|
||||
PUT_CURSEND = 2, ///< leave cursor after end of new text
|
||||
PUT_CURSLINE = 4, ///< leave cursor on last line of new text
|
||||
PUT_LINE = 8, ///< put register as lines
|
||||
PUT_LINE_SPLIT = 16, ///< split line for linewise register
|
||||
PUT_LINE_FORWARD = 32, ///< put linewise register below Visual sel.
|
||||
PUT_BLOCK_INNER = 64, ///< in block mode, do not add trailing spaces
|
||||
};
|
||||
|
||||
/// Registers:
|
||||
/// 0 = register for latest (unnamed) yank
|
||||
/// 1..9 = registers '1' to '9', for deletes
|
||||
/// 10..35 = registers 'a' to 'z'
|
||||
/// 36 = delete register '-'
|
||||
/// 37 = selection register '*'
|
||||
/// 38 = clipboard register '+'
|
||||
enum {
|
||||
DELETION_REGISTER = 36,
|
||||
NUM_SAVED_REGISTERS = 37,
|
||||
// The following registers should not be saved in ShaDa file:
|
||||
STAR_REGISTER = 37,
|
||||
PLUS_REGISTER = 38,
|
||||
NUM_REGISTERS = 39,
|
||||
};
|
||||
|
||||
/// Flags for get_reg_contents().
|
||||
enum GRegFlags {
|
||||
kGRegNoExpr = 1, ///< Do not allow expression register.
|
||||
kGRegExprSrc = 2, ///< Return expression itself for "=" register.
|
||||
kGRegList = 4, ///< Return list.
|
||||
};
|
||||
|
||||
/// structure used by block_prep, op_delete and op_yank for blockwise operators
|
||||
/// also op_change, op_shift, op_insert, op_replace - AKelly
|
||||
struct block_def {
|
||||
int startspaces; ///< 'extra' cols before first char
|
||||
int endspaces; ///< 'extra' cols after last char
|
||||
int textlen; ///< chars in block
|
||||
char *textstart; ///< pointer to 1st char (partially) in block
|
||||
colnr_T textcol; ///< index of chars (partially) in block
|
||||
colnr_T start_vcol; ///< start col of 1st char wholly inside block
|
||||
colnr_T end_vcol; ///< start col of 1st char wholly after block
|
||||
int is_short; ///< true if line is too short to fit in block
|
||||
int is_MAX; ///< true if curswant==MAXCOL when starting
|
||||
int is_oneChar; ///< true if block within one character
|
||||
int pre_whitesp; ///< screen cols of ws before block
|
||||
int pre_whitesp_c; ///< chars of ws before block
|
||||
colnr_T end_char_vcols; ///< number of vcols of post-block char
|
||||
colnr_T start_char_vcols; ///< number of vcols of pre-block char
|
||||
};
|
||||
|
||||
/// Definition of one register
|
||||
typedef struct {
|
||||
String *y_array; ///< Pointer to an array of Strings.
|
||||
size_t y_size; ///< Number of lines in y_array.
|
||||
MotionType y_type; ///< Register type
|
||||
colnr_T y_width; ///< Register width (only valid for y_type == kBlockWise).
|
||||
Timestamp timestamp; ///< Time when register was last modified.
|
||||
AdditionalData *additional_data; ///< Additional data from ShaDa file.
|
||||
} yankreg_T;
|
||||
|
||||
/// Modes for get_yank_register()
|
||||
typedef enum {
|
||||
YREG_PASTE,
|
||||
YREG_YANK,
|
||||
YREG_PUT,
|
||||
} yreg_mode_t;
|
@@ -43,7 +43,6 @@
|
||||
#include "nvim/msgpack_rpc/packer_defs.h"
|
||||
#include "nvim/msgpack_rpc/unpacker.h"
|
||||
#include "nvim/normal_defs.h"
|
||||
#include "nvim/ops.h"
|
||||
#include "nvim/option.h"
|
||||
#include "nvim/option_vars.h"
|
||||
#include "nvim/os/fileio.h"
|
||||
@@ -57,6 +56,7 @@
|
||||
#include "nvim/path.h"
|
||||
#include "nvim/pos_defs.h"
|
||||
#include "nvim/regexp.h"
|
||||
#include "nvim/register.h"
|
||||
#include "nvim/search.h"
|
||||
#include "nvim/shada.h"
|
||||
#include "nvim/strings.h"
|
||||
|
Reference in New Issue
Block a user