diff options
Diffstat (limited to 'src/nvim')
166 files changed, 3804 insertions, 3747 deletions
diff --git a/src/nvim/api/autocmd.c b/src/nvim/api/autocmd.c index 2e4d2a622d..768ed869cc 100644 --- a/src/nvim/api/autocmd.c +++ b/src/nvim/api/autocmd.c @@ -8,17 +8,16 @@ #include <stdlib.h> #include <string.h> +#include "klib/kvec.h" #include "lauxlib.h" #include "nvim/api/autocmd.h" +#include "nvim/api/keysets.h" #include "nvim/api/private/defs.h" -#include "nvim/api/private/dispatch.h" #include "nvim/api/private/helpers.h" #include "nvim/api/private/validate.h" -#include "nvim/ascii.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/globals.h" #include "nvim/lua/executor.h" diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index e8f9f809f2..64dddea5b8 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -4,7 +4,6 @@ // Some of this code was adapted from 'if_py_both.h' from the original // vim source -#include <assert.h> #include <lauxlib.h> #include <stdbool.h> #include <stddef.h> @@ -14,6 +13,7 @@ #include "klib/kvec.h" #include "lua.h" #include "nvim/api/buffer.h" +#include "nvim/api/keysets.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/api/private/validate.h" diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c index 808d4e0b8d..eb32f46143 100644 --- a/src/nvim/api/command.c +++ b/src/nvim/api/command.c @@ -9,6 +9,7 @@ #include "klib/kvec.h" #include "lauxlib.h" #include "nvim/api/command.h" +#include "nvim/api/keysets.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/dispatch.h" #include "nvim/api/private/helpers.h" diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c index f345edc52c..e0827012f6 100644 --- a/src/nvim/api/deprecated.c +++ b/src/nvim/api/deprecated.c @@ -1,13 +1,15 @@ // This is an open source non-commercial project. Dear PVS-Studio, please check // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com +#include <limits.h> #include <stdbool.h> #include <stdint.h> -#include <stdlib.h> +#include <string.h> #include "nvim/api/buffer.h" #include "nvim/api/deprecated.h" #include "nvim/api/extmark.h" +#include "nvim/api/keysets.h" #include "nvim/api/options.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" @@ -729,7 +731,7 @@ static void set_option_to(uint64_t channel_id, void *to, int type, String name, "Option '%s' value is out of range", name.data, { return; }); - optval = NUMBER_OPTVAL(value.data.integer); + optval = NUMBER_OPTVAL((OptInt)value.data.integer); } else { VALIDATE(value.type == kObjectTypeString, "Option '%s' value must be String", name.data, { return; diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c index 91e197bea7..14454b626e 100644 --- a/src/nvim/api/extmark.c +++ b/src/nvim/api/extmark.c @@ -9,8 +9,8 @@ #include "klib/kvec.h" #include "lauxlib.h" #include "nvim/api/extmark.h" +#include "nvim/api/keysets.h" #include "nvim/api/private/defs.h" -#include "nvim/api/private/dispatch.h" #include "nvim/api/private/helpers.h" #include "nvim/api/private/validate.h" #include "nvim/buffer_defs.h" @@ -20,6 +20,7 @@ #include "nvim/drawscreen.h" #include "nvim/extmark.h" #include "nvim/highlight_group.h" +#include "nvim/marktree.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c index eb80683365..5a75d10043 100644 --- a/src/nvim/api/options.c +++ b/src/nvim/api/options.c @@ -1,22 +1,24 @@ // This is an open source non-commercial project. Dear PVS-Studio, please check // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com +#include <assert.h> #include <inttypes.h> -#include <limits.h> #include <stdbool.h> +#include <stdlib.h> #include <string.h> +#include "nvim/api/keysets.h" #include "nvim/api/options.h" #include "nvim/api/private/defs.h" -#include "nvim/api/private/dispatch.h" #include "nvim/api/private/helpers.h" #include "nvim/api/private/validate.h" #include "nvim/autocmd.h" -#include "nvim/buffer_defs.h" +#include "nvim/buffer.h" #include "nvim/eval/window.h" #include "nvim/globals.h" #include "nvim/memory.h" #include "nvim/option.h" +#include "nvim/types.h" #include "nvim/vim.h" #include "nvim/window.h" @@ -165,7 +167,7 @@ static OptVal object_as_optval(Object o, bool *error) case kObjectTypeBoolean: return BOOLEAN_OPTVAL(o.data.boolean); case kObjectTypeInteger: - return NUMBER_OPTVAL(o.data.integer); + return NUMBER_OPTVAL((OptInt)o.data.integer); case kObjectTypeString: return STRING_OPTVAL(o.data.string); default: diff --git a/src/nvim/api/private/converter.c b/src/nvim/api/private/converter.c index 68939e609c..dc6928f4b9 100644 --- a/src/nvim/api/private/converter.c +++ b/src/nvim/api/private/converter.c @@ -15,7 +15,6 @@ #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" #include "nvim/eval/userfunc.h" -#include "nvim/garray.h" #include "nvim/lua/executor.h" #include "nvim/memory.h" #include "nvim/types.h" @@ -204,6 +203,7 @@ static inline void typval_encode_dict_end(EncodedData *const edata) #define TYPVAL_ENCODE_FIRST_ARG_TYPE EncodedData *const #define TYPVAL_ENCODE_FIRST_ARG_NAME edata #include "nvim/eval/typval_encode.c.h" + #undef TYPVAL_ENCODE_SCOPE #undef TYPVAL_ENCODE_NAME #undef TYPVAL_ENCODE_FIRST_ARG_TYPE diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 5463578b56..25e752bea8 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -20,7 +20,6 @@ #include "nvim/ascii.h" #include "nvim/buffer_defs.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/eval/vars.h" #include "nvim/ex_eval.h" #include "nvim/garray.h" @@ -34,6 +33,7 @@ #include "nvim/message.h" #include "nvim/msgpack_rpc/helpers.h" #include "nvim/pos.h" +#include "nvim/types.h" #include "nvim/ui.h" #include "nvim/version.h" diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h index 95e5cf67c8..e5ad30a10f 100644 --- a/src/nvim/api/private/helpers.h +++ b/src/nvim/api/private/helpers.h @@ -6,9 +6,11 @@ #include "klib/kvec.h" #include "nvim/api/private/defs.h" +#include "nvim/api/private/dispatch.h" #include "nvim/decoration.h" #include "nvim/ex_eval_defs.h" #include "nvim/getchar.h" +#include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/macros.h" #include "nvim/map.h" diff --git a/src/nvim/api/private/validate.c b/src/nvim/api/private/validate.c index c4dd5bcac8..cede32f72c 100644 --- a/src/nvim/api/private/validate.c +++ b/src/nvim/api/private/validate.c @@ -1,13 +1,15 @@ // This is an open source non-commercial project. Dear PVS-Studio, please check // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com +#include <inttypes.h> +#include <stdio.h> +#include <string.h> + #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/api/private/validate.h" - -#ifdef INCLUDE_GENERATED_DECLARATIONS -# include "api/private/validate.c.generated.h" -#endif +#include "nvim/ascii.h" +#include "nvim/globals.h" /// Creates "Invalid …" message and sets it on `err`. void api_err_invalid(Error *err, const char *name, const char *val_s, int64_t val_n, bool quote_val) diff --git a/src/nvim/api/private/validate.h b/src/nvim/api/private/validate.h index a3e77ea838..089b8d2f9c 100644 --- a/src/nvim/api/private/validate.h +++ b/src/nvim/api/private/validate.h @@ -1,8 +1,13 @@ #ifndef NVIM_API_PRIVATE_VALIDATE_H #define NVIM_API_PRIVATE_VALIDATE_H +#include <stdbool.h> +#include <stddef.h> + #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" +#include "nvim/assert.h" +#include "nvim/macros.h" #define VALIDATE(cond, fmt_, fmt_arg1, code) \ do { \ diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index 0ea2310042..e0b5e6ea57 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -21,6 +21,7 @@ #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/highlight.h" +#include "nvim/macros.h" #include "nvim/main.h" #include "nvim/map.h" #include "nvim/mbyte.h" diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 00641c633d..9d9a5080e4 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -14,6 +14,7 @@ #include "lauxlib.h" #include "nvim/api/buffer.h" #include "nvim/api/deprecated.h" +#include "nvim/api/keysets.h" #include "nvim/api/private/converter.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/dispatch.h" @@ -26,12 +27,13 @@ #include "nvim/channel.h" #include "nvim/context.h" #include "nvim/cursor.h" +#include "nvim/decoration.h" #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" +#include "nvim/fold.h" #include "nvim/getchar.h" #include "nvim/globals.h" #include "nvim/grid.h" @@ -53,6 +55,7 @@ #include "nvim/msgpack_rpc/unpacker.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/os/os_defs.h" @@ -1699,21 +1702,26 @@ static void write_msg(String message, bool to_err, bool writeln) { static StringBuilder out_line_buf = KV_INITIAL_VALUE; static StringBuilder err_line_buf = KV_INITIAL_VALUE; + StringBuilder *line_buf = to_err ? &err_line_buf : &out_line_buf; -#define PUSH_CHAR(c, line_buf, msg) \ - if (kv_max(line_buf) == 0) { \ - kv_resize(line_buf, LINE_BUFFER_MIN_SIZE); \ +#define PUSH_CHAR(c) \ + if (kv_max(*line_buf) == 0) { \ + kv_resize(*line_buf, LINE_BUFFER_MIN_SIZE); \ } \ if (c == NL) { \ - kv_push(line_buf, NUL); \ - msg(line_buf.items); \ + kv_push(*line_buf, NUL); \ + if (to_err) { \ + emsg(line_buf->items); \ + } else { \ + msg(line_buf->items, 0); \ + } \ msg_didout = true; \ - kv_drop(line_buf, kv_size(line_buf)); \ - kv_resize(line_buf, LINE_BUFFER_MIN_SIZE); \ + kv_drop(*line_buf, kv_size(*line_buf)); \ + kv_resize(*line_buf, LINE_BUFFER_MIN_SIZE); \ } else if (c == NUL) { \ - kv_push(line_buf, NL); \ + kv_push(*line_buf, NL); \ } else { \ - kv_push(line_buf, c); \ + kv_push(*line_buf, c); \ } no_wait_return++; @@ -1721,18 +1729,10 @@ static void write_msg(String message, bool to_err, bool writeln) if (got_int) { break; } - if (to_err) { - PUSH_CHAR(message.data[i], err_line_buf, emsg); - } else { - PUSH_CHAR(message.data[i], out_line_buf, msg); - } + PUSH_CHAR(message.data[i]); } if (writeln) { - if (to_err) { - PUSH_CHAR(NL, err_line_buf, emsg); - } else { - PUSH_CHAR(NL, out_line_buf, msg); - } + PUSH_CHAR(NL); } no_wait_return--; msg_end(); diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c index 4801562ad2..b09e4d7d87 100644 --- a/src/nvim/api/vimscript.c +++ b/src/nvim/api/vimscript.c @@ -8,21 +8,19 @@ #include <string.h> #include "klib/kvec.h" +#include "nvim/api/keysets.h" #include "nvim/api/private/converter.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/api/vimscript.h" #include "nvim/ascii.h" -#include "nvim/buffer_defs.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/eval/userfunc.h" #include "nvim/ex_docmd.h" #include "nvim/garray.h" #include "nvim/globals.h" #include "nvim/memory.h" -#include "nvim/pos.h" #include "nvim/runtime.h" #include "nvim/vim.h" #include "nvim/viml/parser/expressions.h" diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c index 60d32eb30d..ca7086ab7f 100644 --- a/src/nvim/api/win_config.c +++ b/src/nvim/api/win_config.c @@ -2,15 +2,17 @@ // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include <stdbool.h> +#include <stdlib.h> #include <string.h> #include "klib/kvec.h" #include "nvim/api/extmark.h" +#include "nvim/api/keysets.h" #include "nvim/api/private/defs.h" -#include "nvim/api/private/dispatch.h" #include "nvim/api/private/helpers.h" #include "nvim/api/win_config.h" #include "nvim/ascii.h" +#include "nvim/autocmd.h" #include "nvim/buffer_defs.h" #include "nvim/decoration.h" #include "nvim/drawscreen.h" diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index 001797add5..53095ab019 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -6,12 +6,12 @@ #include <stdint.h> #include <stdlib.h> +#include "nvim/api/keysets.h" #include "nvim/api/private/defs.h" -#include "nvim/api/private/dispatch.h" #include "nvim/api/private/helpers.h" #include "nvim/api/private/validate.h" #include "nvim/api/window.h" -#include "nvim/ascii.h" +#include "nvim/autocmd.h" #include "nvim/buffer_defs.h" #include "nvim/cursor.h" #include "nvim/drawscreen.h" @@ -20,7 +20,8 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/lua/executor.h" -#include "nvim/memline_defs.h" +#include "nvim/memory.h" +#include "nvim/message.h" #include "nvim/move.h" #include "nvim/plines.h" #include "nvim/pos.h" diff --git a/src/nvim/arabic.c b/src/nvim/arabic.c index 41024cafda..bab77a4a84 100644 --- a/src/nvim/arabic.c +++ b/src/nvim/arabic.c @@ -28,7 +28,7 @@ #include "nvim/ascii.h" #include "nvim/macros.h" #include "nvim/mbyte.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/vim.h" // Unicode values for Arabic characters. diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c index 9c2b3ba6d8..a4221a1562 100644 --- a/src/nvim/arglist.c +++ b/src/nvim/arglist.c @@ -11,6 +11,7 @@ #include "auto/config.h" #include "nvim/arglist.h" #include "nvim/ascii.h" +#include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/charset.h" #include "nvim/eval/typval.h" @@ -30,6 +31,7 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/input.h" #include "nvim/path.h" #include "nvim/pos.h" diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index ff0c2f063f..657760914f 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -34,7 +34,7 @@ #include "nvim/memline_defs.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/option_defs.h" +#include "nvim/option.h" #include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/os/os.h" @@ -228,7 +228,7 @@ static void au_show_for_event(int group, event_T event, const char *pat) } msg_col = 4; - msg_outtrans(ac->pat->pat); + msg_outtrans(ac->pat->pat, 0); } if (got_int) { @@ -253,12 +253,12 @@ static void au_show_for_event(int group, event_T event, const char *pat) } else { snprintf(msg, msglen, "%s [%s]", exec_to_string, ac->desc); } - msg_outtrans(msg); + msg_outtrans(msg, 0); XFREE_CLEAR(msg); } else if (ac->exec.type == CALLABLE_CB) { msg_puts_attr(exec_to_string, HL_ATTR(HLF_8)); } else { - msg_outtrans(exec_to_string); + msg_outtrans(exec_to_string, 0); } XFREE_CLEAR(exec_to_string); if (p_verbose > 0) { @@ -372,7 +372,7 @@ void aubuflocal_remove(buf_T *buf) if (p_verbose >= 6) { verbose_enter(); - smsg(_("auto-removing autocommand: %s <buffer=%d>"), event_nr2name(event), buf->b_fnum); + smsg(0, _("auto-removing autocommand: %s <buffer=%d>"), event_nr2name(event), buf->b_fnum); verbose_leave(); } } @@ -1150,7 +1150,7 @@ int do_doautocmd(char *arg_start, bool do_msg, bool *did_something) } if (nothing_done && do_msg && !aborting()) { - smsg(_("No matching autocommands: %s"), arg_start); + smsg(0, _("No matching autocommands: %s"), arg_start); } if (did_something != NULL) { *did_something = !nothing_done; @@ -1946,7 +1946,7 @@ static void aucmd_next(AutoPatCmd *apc) snprintf(namep, sourcing_name_len, s, name, ap->pat); if (p_verbose >= 8) { verbose_enter(); - smsg(_("Executing %s"), namep); + smsg(0, _("Executing %s"), namep); verbose_leave(); } @@ -2045,7 +2045,7 @@ char *getnextac(int c, void *cookie, int indent, bool do_concat) if (p_verbose >= 9) { verbose_enter_scroll(); char *exec_to_string = aucmd_exec_to_string(ac, ac->exec); - smsg(_("autocommand %s"), exec_to_string); + smsg(0, _("autocommand %s"), exec_to_string); msg_puts("\n"); // don't overwrite this either XFREE_CLEAR(exec_to_string); verbose_leave_scroll(); diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 7a3e65e10e..5025e86771 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -47,6 +47,7 @@ #include "nvim/digraph.h" #include "nvim/drawscreen.h" #include "nvim/eval.h" +#include "nvim/eval/typval_defs.h" #include "nvim/eval/vars.h" #include "nvim/ex_cmds.h" #include "nvim/ex_cmds2.h" @@ -71,12 +72,14 @@ #include "nvim/mapping.h" #include "nvim/mark.h" #include "nvim/mbyte.h" +#include "nvim/memfile_defs.h" #include "nvim/memline_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/move.h" #include "nvim/normal.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/fs_defs.h" #include "nvim/os/input.h" @@ -206,7 +209,7 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags_arg) int flags = flags_arg; int retval = OK; bufref_T old_curbuf; - long old_tw = curbuf->b_p_tw; + OptInt old_tw = curbuf->b_p_tw; int read_fifo = false; bool silent = shortmess(SHM_FILEINFO); @@ -354,6 +357,7 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags_arg) // Set last_changedtick to avoid triggering a TextChanged autocommand right // after it was added. curbuf->b_last_changedtick = buf_get_changedtick(curbuf); + curbuf->b_last_changedtick_i = buf_get_changedtick(curbuf); curbuf->b_last_changedtick_pum = buf_get_changedtick(curbuf); // require "!" to overwrite the file, because it wasn't read completely @@ -964,7 +968,7 @@ void goto_buffer(exarg_T *eap, int start, int dir, int count) void handle_swap_exists(bufref_T *old_curbuf) { cleanup_T cs; - long old_tw = curbuf->b_p_tw; + OptInt old_tw = curbuf->b_p_tw; buf_T *buf; if (swap_exists_action == SEA_QUIT) { @@ -1105,13 +1109,13 @@ char *do_bufdel(int command, char *arg, int addr_count, int start_bnr, int end_b errormsg = IObuff; } else if (deleted >= p_report) { if (command == DOBUF_UNLOAD) { - smsg(NGETTEXT("%d buffer unloaded", "%d buffers unloaded", deleted), + smsg(0, NGETTEXT("%d buffer unloaded", "%d buffers unloaded", deleted), deleted); } else if (command == DOBUF_DEL) { - smsg(NGETTEXT("%d buffer deleted", "%d buffers deleted", deleted), + smsg(0, NGETTEXT("%d buffer deleted", "%d buffers deleted", deleted), deleted); } else { - smsg(NGETTEXT("%d buffer wiped out", "%d buffers wiped out", deleted), + smsg(0, NGETTEXT("%d buffer wiped out", "%d buffers wiped out", deleted), deleted); } } @@ -1531,7 +1535,7 @@ void set_curbuf(buf_T *buf, int action) buf_T *prevbuf; int unload = (action == DOBUF_UNLOAD || action == DOBUF_DEL || action == DOBUF_WIPE); - long old_tw = curbuf->b_p_tw; + OptInt old_tw = curbuf->b_p_tw; setpcmark(); if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0) { @@ -2857,7 +2861,7 @@ void buflist_list(exarg_T *eap) buf == curbuf ? (int64_t)curwin->w_cursor.lnum : (int64_t)buflist_findlnum(buf)); } - msg_outtrans(IObuff); + msg_outtrans(IObuff, 0); line_breakcheck(); } @@ -3229,10 +3233,10 @@ void fileinfo(int fullname, int shorthelp, int dont_truncate) msg_start(); n = msg_scroll; msg_scroll = true; - msg(buffer); + msg(buffer, 0); msg_scroll = n; } else { - p = msg_trunc_attr(buffer, false, 0); + p = msg_trunc(buffer, false, 0); if (restart_edit != 0 || (msg_scrolled && !need_wait_return)) { // Need to repeat the message after redrawing when: // - When restart_edit is set (otherwise there will be a delay diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 562e0ba089..a9ad0051ed 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -28,7 +28,7 @@ typedef struct { #include "nvim/mapping_defs.h" #include "nvim/mark_defs.h" #include "nvim/marktree.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/pos.h" #include "nvim/statusline_defs.h" #include "nvim/undo_defs.h" @@ -125,18 +125,18 @@ typedef struct { #define w_p_fen_save w_onebuf_opt.wo_fen_save char *wo_fdi; #define w_p_fdi w_onebuf_opt.wo_fdi // 'foldignore' - long wo_fdl; + OptInt wo_fdl; #define w_p_fdl w_onebuf_opt.wo_fdl // 'foldlevel' - long wo_fdl_save; + OptInt wo_fdl_save; // 'foldlevel' state saved for diff mode #define w_p_fdl_save w_onebuf_opt.wo_fdl_save char *wo_fdm; #define w_p_fdm w_onebuf_opt.wo_fdm // 'foldmethod' char *wo_fdm_save; #define w_p_fdm_save w_onebuf_opt.wo_fdm_save // 'fdm' saved for diff mode - long wo_fml; + OptInt wo_fml; #define w_p_fml w_onebuf_opt.wo_fml // 'foldminlines' - long wo_fdn; + OptInt wo_fdn; #define w_p_fdn w_onebuf_opt.wo_fdn // 'foldnestmax' char *wo_fde; #define w_p_fde w_onebuf_opt.wo_fde // 'foldexpr' @@ -156,7 +156,7 @@ typedef struct { #define w_p_ve w_onebuf_opt.wo_ve // 'virtualedit' unsigned wo_ve_flags; #define w_ve_flags w_onebuf_opt.wo_ve_flags // flags for 'virtualedit' - long wo_nuw; + OptInt wo_nuw; #define w_p_nuw w_onebuf_opt.wo_nuw // 'numberwidth' int wo_wfh; #define w_p_wfh w_onebuf_opt.wo_wfh // 'winfixheight' @@ -168,7 +168,7 @@ typedef struct { #define w_p_rl w_onebuf_opt.wo_rl // 'rightleft' char *wo_rlc; #define w_p_rlc w_onebuf_opt.wo_rlc // 'rightleftcmd' - long wo_scr; + OptInt wo_scr; #define w_p_scr w_onebuf_opt.wo_scr // 'scroll' int wo_sms; #define w_p_sms w_onebuf_opt.wo_sms // 'smoothscroll' @@ -202,7 +202,7 @@ typedef struct { #define w_p_wrap_save w_onebuf_opt.wo_wrap_save char *wo_cocu; // 'concealcursor' #define w_p_cocu w_onebuf_opt.wo_cocu - long wo_cole; // 'conceallevel' + OptInt wo_cole; // 'conceallevel' #define w_p_cole w_onebuf_opt.wo_cole int wo_crb; #define w_p_crb w_onebuf_opt.wo_crb // 'cursorbind' @@ -210,9 +210,9 @@ typedef struct { #define w_p_crb_save w_onebuf_opt.wo_crb_save char *wo_scl; #define w_p_scl w_onebuf_opt.wo_scl // 'signcolumn' - long wo_siso; + OptInt wo_siso; #define w_p_siso w_onebuf_opt.wo_siso // 'sidescrolloff' local value - long wo_so; + OptInt wo_so; #define w_p_so w_onebuf_opt.wo_so // 'scrolloff' local value char *wo_winhl; #define w_p_winhl w_onebuf_opt.wo_winhl // 'winhighlight' @@ -220,7 +220,7 @@ typedef struct { #define w_p_lcs w_onebuf_opt.wo_lcs // 'listchars' char *wo_fcs; #define w_p_fcs w_onebuf_opt.wo_fcs // 'fillchars' - long wo_winbl; + OptInt wo_winbl; #define w_p_winbl w_onebuf_opt.wo_winbl // 'winblend' LastSet wo_script_ctx[WV_COUNT]; // SCTXs for window-local options @@ -418,10 +418,10 @@ struct file_buffer { /// This is a dictionary item used to store b:changedtick. ChangedtickDictItem changedtick_di; - varnumber_T b_last_changedtick; // b:changedtick when TextChanged or - // TextChangedI was last triggered. - varnumber_T b_last_changedtick_pum; // b:changedtick when TextChangedP was + varnumber_T b_last_changedtick; // b:changedtick when TextChanged was // last triggered. + varnumber_T b_last_changedtick_i; // b:changedtick for TextChangedI + varnumber_T b_last_changedtick_pum; // b:changedtick for TextChangedP bool b_saving; // Set to true if we are in the middle of // saving the buffer. @@ -504,8 +504,8 @@ struct file_buffer { bool b_scanned; // ^N/^P have scanned this buffer // flags for use of ":lmap" and IM control - long b_p_iminsert; // input mode for insert - long b_p_imsearch; // input mode for search + OptInt b_p_iminsert; // input mode for insert + OptInt b_p_imsearch; // input mode for search #define B_IMODE_USE_INSERT (-1) // Use b_p_iminsert value for search #define B_IMODE_NONE 0 // Input via none #define B_IMODE_LMAP 1 // Input via langmap @@ -534,7 +534,7 @@ struct file_buffer { char *b_p_bt; ///< 'buftype' int b_has_qf_entry; ///< quickfix exists for buffer int b_p_bl; ///< 'buflisted' - long b_p_channel; ///< 'channel' + OptInt b_p_channel; ///< 'channel' int b_p_cin; ///< 'cindent' char *b_p_cino; ///< 'cinoptions' char *b_p_cink; ///< 'cinkeys' @@ -587,27 +587,27 @@ struct file_buffer { int b_p_pi; ///< 'preserveindent' char *b_p_qe; ///< 'quoteescape' int b_p_ro; ///< 'readonly' - long b_p_sw; ///< 'shiftwidth' - long b_p_scbk; ///< 'scrollback' + OptInt b_p_sw; ///< 'shiftwidth' + OptInt b_p_scbk; ///< 'scrollback' int b_p_si; ///< 'smartindent' - long b_p_sts; ///< 'softtabstop' - long b_p_sts_nopaste; ///< b_p_sts saved for paste mode + OptInt b_p_sts; ///< 'softtabstop' + OptInt b_p_sts_nopaste; ///< b_p_sts saved for paste mode char *b_p_sua; ///< 'suffixesadd' int b_p_swf; ///< 'swapfile' - long b_p_smc; ///< 'synmaxcol' + OptInt b_p_smc; ///< 'synmaxcol' char *b_p_syn; ///< 'syntax' - long b_p_ts; ///< 'tabstop' - long b_p_tw; ///< 'textwidth' - long b_p_tw_nobin; ///< b_p_tw saved for binary mode - long b_p_tw_nopaste; ///< b_p_tw saved for paste mode - long b_p_wm; ///< 'wrapmargin' - long b_p_wm_nobin; ///< b_p_wm saved for binary mode - long b_p_wm_nopaste; ///< b_p_wm saved for paste mode + OptInt b_p_ts; ///< 'tabstop' + OptInt b_p_tw; ///< 'textwidth' + OptInt b_p_tw_nobin; ///< b_p_tw saved for binary mode + OptInt b_p_tw_nopaste; ///< b_p_tw saved for paste mode + OptInt b_p_wm; ///< 'wrapmargin' + OptInt b_p_wm_nobin; ///< b_p_wm saved for binary mode + OptInt b_p_wm_nopaste; ///< b_p_wm saved for paste mode char *b_p_vsts; ///< 'varsofttabstop' - long *b_p_vsts_array; ///< 'varsofttabstop' in internal format + colnr_T *b_p_vsts_array; ///< 'varsofttabstop' in internal format char *b_p_vsts_nopaste; ///< b_p_vsts saved for paste mode char *b_p_vts; ///< 'vartabstop' - long *b_p_vts_array; ///< 'vartabstop' in internal format + colnr_T *b_p_vts_array; ///< 'vartabstop' in internal format char *b_p_keymap; ///< 'keymap' // local values for options which are normally global @@ -624,7 +624,7 @@ struct file_buffer { char *b_p_tsr; ///< 'thesaurus' local value char *b_p_tsrfu; ///< 'thesaurusfunc' local value Callback b_tsrfu_cb; ///< 'thesaurusfunc' callback - long b_p_ul; ///< 'undolevels' local value + OptInt b_p_ul; ///< 'undolevels' local value int b_p_udf; ///< 'undofile' char *b_p_lw; ///< 'lispwords' local value @@ -789,16 +789,16 @@ struct diffblock_S { typedef struct tabpage_S tabpage_T; struct tabpage_S { handle_T handle; - tabpage_T *tp_next; ///< next tabpage or NULL - frame_T *tp_topframe; ///< topframe for the windows - win_T *tp_curwin; ///< current window in this Tab page - win_T *tp_prevwin; ///< previous window in this Tab page - win_T *tp_firstwin; ///< first window in this Tab page - win_T *tp_lastwin; ///< last window in this Tab page - long tp_old_Rows_avail; ///< ROWS_AVAIL when Tab page was left - long tp_old_Columns; ///< Columns when Tab page was left, -1 when - ///< calling win_new_screen_cols() postponed - long tp_ch_used; ///< value of 'cmdheight' when frame size was set + tabpage_T *tp_next; ///< next tabpage or NULL + frame_T *tp_topframe; ///< topframe for the windows + win_T *tp_curwin; ///< current window in this Tab page + win_T *tp_prevwin; ///< previous window in this Tab page + win_T *tp_firstwin; ///< first window in this Tab page + win_T *tp_lastwin; ///< last window in this Tab page + int64_t tp_old_Rows_avail; ///< ROWS_AVAIL when Tab page was left + int64_t tp_old_Columns; ///< Columns when Tab page was left, -1 when + ///< calling win_new_screen_cols() postponed + OptInt tp_ch_used; ///< value of 'cmdheight' when frame size was set diff_T *tp_first_diff; buf_T *(tp_diffbuf[DB_COUNT]); @@ -990,6 +990,45 @@ typedef struct { pos_T w_cursor_corr; // corrected cursor position } pos_save_T; +/// Characters from the 'listchars' option. +typedef struct { + int eol; + int ext; + int prec; + int nbsp; + int space; + int tab1; ///< first tab character + int tab2; ///< second tab character + int tab3; ///< third tab character + int lead; + int trail; + int *multispace; + int *leadmultispace; + int conceal; +} lcs_chars_T; + +/// Characters from the 'fillchars' option. +typedef struct { + int stl; + int stlnc; + int wbr; + int horiz; + int horizup; + int horizdown; + int vert; + int vertleft; + int vertright; + int verthoriz; + int fold; + int foldopen; ///< when fold is open + int foldclosed; ///< when fold is closed + int foldsep; ///< continuous fold marker + int diff; + int msgsep; + int eob; + int lastline; +} fcs_chars_T; + /// Structure which contains all information that belongs to a window. /// /// All row numbers are relative to the start of the window, except w_winrow. @@ -1045,44 +1084,11 @@ struct window_S { linenr_T w_last_cursor_lnum_rnu; ///< cursor lnum when 'rnu' was last redrawn - // 'listchars' characters. Defaults set in set_chars_option(). - struct { - int eol; - int ext; - int prec; - int nbsp; - int space; - int tab1; ///< first tab character - int tab2; ///< second tab character - int tab3; ///< third tab character - int lead; - int trail; - int *multispace; - int *leadmultispace; - int conceal; - } w_p_lcs_chars; - - // 'fillchars' characters. Defaults set in set_chars_option(). - struct { - int stl; - int stlnc; - int wbr; - int horiz; - int horizup; - int horizdown; - int vert; - int vertleft; - int vertright; - int verthoriz; - int fold; - int foldopen; ///< when fold is open - int foldclosed; ///< when fold is closed - int foldsep; ///< continuous fold marker - int diff; - int msgsep; - int eob; - int lastline; - } w_p_fcs_chars; + /// 'listchars' characters. Defaults set in set_chars_option(). + lcs_chars_T w_p_lcs_chars; + + /// 'fillchars' characters. Defaults set in set_chars_option(). + fcs_chars_T w_p_fcs_chars; // "w_topline", "w_leftcol" and "w_skipcol" specify the offsets for // displaying the buffer. diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index 0c95314c52..40b95e5790 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -37,6 +37,7 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/fs_defs.h" #include "nvim/os/input.h" #include "nvim/os/os.h" @@ -352,8 +353,7 @@ static int check_mtime(buf_T *buf, FileInfo *file_info) msg_scroll = true; // Don't overwrite messages here. msg_silent = 0; // Must give this prompt. // Don't use emsg() here, don't want to flush the buffers. - msg_attr(_("WARNING: The file has been changed since reading it!!!"), - HL_ATTR(HLF_E)); + msg(_("WARNING: The file has been changed since reading it!!!"), HL_ATTR(HLF_E)); if (ask_yesno(_("Do you really want to write to it"), true) == 'n') { return FAIL; } @@ -1721,7 +1721,7 @@ restore_backup: // This may take a while, if we were interrupted let the user // know we got the message. if (got_int) { - msg(_(e_interr)); + msg(_(e_interr), 0); ui_flush(); } @@ -1786,7 +1786,7 @@ restore_backup: } } - set_keep_msg(msg_trunc_attr(IObuff, false, 0), 0); + set_keep_msg(msg_trunc(IObuff, false, 0), 0); } // When written everything correctly: reset 'modified'. Unless not @@ -1797,8 +1797,8 @@ restore_backup: unchanged(buf, true, false); const varnumber_T changedtick = buf_get_changedtick(buf); if (buf->b_last_changedtick + 1 == changedtick) { - // b:changedtick may be incremented in unchanged() but that - // should not trigger a TextChanged event. + // b:changedtick may be incremented in unchanged() but that should not + // trigger a TextChanged event. buf->b_last_changedtick = changedtick; } u_unchanged(buf); diff --git a/src/nvim/change.c b/src/nvim/change.c index 084a8a1897..48dc02b65b 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -39,6 +39,7 @@ #include "nvim/message.h" #include "nvim/move.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/time.h" #include "nvim/plines.h" #include "nvim/pos.h" diff --git a/src/nvim/channel.c b/src/nvim/channel.c index 165e5e0cac..5c8e922f90 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -7,6 +7,7 @@ #include <stdio.h> #include <string.h> +#include "klib/kvec.h" #include "lauxlib.h" #include "nvim/api/private/converter.h" #include "nvim/api/private/defs.h" @@ -17,7 +18,6 @@ #include "nvim/eval.h" #include "nvim/eval/encode.h" #include "nvim/eval/typval.h" -#include "nvim/event/loop.h" #include "nvim/event/rstream.h" #include "nvim/event/socket.h" #include "nvim/event/wstream.h" @@ -788,7 +788,7 @@ void channel_terminal_open(buf_T *buf, Channel *chan) topts.write_cb = term_write; topts.resize_cb = term_resize; topts.close_cb = term_close; - buf->b_p_channel = (long)chan->id; // 'channel' option + buf->b_p_channel = (OptInt)chan->id; // 'channel' option Terminal *term = terminal_open(buf, topts); chan->term = term; channel_incref(chan); diff --git a/src/nvim/charset.c b/src/nvim/charset.c index c4ff712f3a..c2722af971 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -11,6 +11,7 @@ #include <limits.h> #include <stdlib.h> #include <string.h> +#include <sys/types.h> #include "auto/config.h" #include "klib/kvec.h" diff --git a/src/nvim/charset.h b/src/nvim/charset.h index cb5fbb22ed..d615012cd5 100644 --- a/src/nvim/charset.h +++ b/src/nvim/charset.h @@ -6,6 +6,8 @@ #include "nvim/buffer_defs.h" #include "nvim/eval/typval_defs.h" +#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/pos.h" #include "nvim/strings.h" diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 1e088ec7fc..d733ffe6ab 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -4,7 +4,6 @@ // cmdexpand.c: functions for command-line completion #include <assert.h> -#include <limits.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> @@ -49,6 +48,7 @@ #include "nvim/menu.h" #include "nvim/message.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/lang.h" #include "nvim/os/os.h" #include "nvim/path.h" @@ -598,17 +598,17 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m // Tricky: wildmenu can be drawn either over a status line, or at empty // scrolled space in the message output - ScreenGrid *grid = (wild_menu_showing == WM_SCROLLED) - ? &msg_grid_adj : &default_grid; + grid_line_start((wild_menu_showing == WM_SCROLLED) ? &msg_grid_adj : &default_grid, row); - grid_puts(grid, buf, -1, row, 0, attr); + grid_line_puts(0, buf, -1, attr); if (selstart != NULL && highlight) { *selend = NUL; - grid_puts(grid, selstart, -1, row, selstart_col, HL_ATTR(HLF_WM)); + grid_line_puts(selstart_col, selstart, -1, HL_ATTR(HLF_WM)); } - grid_fill(grid, row, row + 1, clen, Columns, - fillchar, fillchar, attr); + grid_line_fill(clen, Columns, fillchar, attr); + + grid_line_flush(); } win_redraw_last_status(topframe); @@ -617,7 +617,7 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m /// Get the next or prev cmdline completion match. The index of the match is set /// in "xp->xp_selected" -static char *get_next_or_prev_match(int mode, expand_T *xp, char *orig_save) +static char *get_next_or_prev_match(int mode, expand_T *xp) { if (xp->xp_numfiles <= 0) { return NULL; @@ -677,14 +677,14 @@ static char *get_next_or_prev_match(int mode, expand_T *xp, char *orig_save) // When wrapping around, return the original string, set findex to -1. if (findex < 0) { - if (orig_save == NULL) { + if (xp->xp_orig == NULL) { findex = xp->xp_numfiles - 1; } else { findex = -1; } } if (findex >= xp->xp_numfiles) { - if (orig_save == NULL) { + if (xp->xp_orig == NULL) { findex = 0; } else { findex = -1; @@ -698,7 +698,7 @@ static char *get_next_or_prev_match(int mode, expand_T *xp, char *orig_save) } xp->xp_selected = findex; - return xstrdup(findex == -1 ? orig_save : xp->xp_files[findex]); + return xstrdup(findex == -1 ? xp->xp_orig : xp->xp_files[findex]); } /// Start the command-line expansion and get the matches. @@ -805,8 +805,8 @@ static char *find_longest_match(expand_T *xp, int options) /// Return NULL for failure. /// /// "orig" is the originally expanded string, copied to allocated memory. It -/// should either be kept in orig_save or freed. When "mode" is WILD_NEXT or -/// WILD_PREV "orig" should be NULL. +/// should either be kept in "xp->xp_orig" or freed. When "mode" is WILD_NEXT +/// or WILD_PREV "orig" should be NULL. /// /// Results are cached in xp->xp_files and xp->xp_numfiles, except when "mode" /// is WILD_EXPAND_FREE or WILD_ALL. @@ -841,21 +841,20 @@ static char *find_longest_match(expand_T *xp, int options) char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode) { char *ss = NULL; - static char *orig_save = NULL; // kept value of orig int orig_saved = false; // first handle the case of using an old match if (mode == WILD_NEXT || mode == WILD_PREV || mode == WILD_PAGEUP || mode == WILD_PAGEDOWN || mode == WILD_PUM_WANT) { - return get_next_or_prev_match(mode, xp, orig_save); + return get_next_or_prev_match(mode, xp); } if (mode == WILD_CANCEL) { - ss = xstrdup(orig_save ? orig_save : ""); + ss = xstrdup(xp->xp_orig ? xp->xp_orig : ""); } else if (mode == WILD_APPLY) { ss = xstrdup(xp->xp_selected == -1 - ? (orig_save ? orig_save : "") + ? (xp->xp_orig ? xp->xp_orig : "") : xp->xp_files[xp->xp_selected]); } @@ -863,7 +862,7 @@ char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode) if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST) { FreeWild(xp->xp_numfiles, xp->xp_files); xp->xp_numfiles = -1; - XFREE_CLEAR(orig_save); + XFREE_CLEAR(xp->xp_orig); // The entries from xp_files may be used in the PUM, remove it. if (compl_match_array != NULL) { @@ -877,8 +876,8 @@ char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode) } if (xp->xp_numfiles == -1 && mode != WILD_APPLY && mode != WILD_CANCEL) { - xfree(orig_save); - orig_save = orig; + xfree(xp->xp_orig); + xp->xp_orig = orig; orig_saved = true; ss = ExpandOne_start(mode, xp, str, options); @@ -927,7 +926,7 @@ char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode) ExpandCleanup(xp); } - // Free "orig" if it wasn't stored in "orig_save". + // Free "orig" if it wasn't stored in "xp->xp_orig". if (!orig_saved) { xfree(orig); } @@ -952,6 +951,7 @@ void ExpandCleanup(expand_T *xp) FreeWild(xp->xp_numfiles, xp->xp_files); xp->xp_numfiles = -1; } + XFREE_CLEAR(xp->xp_orig); } /// Display one line of completion matches. Multiple matches are displayed in @@ -971,12 +971,12 @@ static void showmatches_oneline(expand_T *xp, char **matches, int numMatches, in int lastlen = 999; for (int j = linenr; j < numMatches; j += lines) { if (xp->xp_context == EXPAND_TAGS_LISTFILES) { - msg_outtrans_attr(matches[j], HL_ATTR(HLF_D)); + msg_outtrans(matches[j], HL_ATTR(HLF_D)); p = matches[j] + strlen(matches[j]) + 1; msg_advance(maxlen + 1); msg_puts(p); msg_advance(maxlen + 3); - msg_outtrans_long_attr(p + 2, HL_ATTR(HLF_D)); + msg_outtrans_long(p + 2, HL_ATTR(HLF_D)); break; } for (int i = maxlen - lastlen; --i >= 0;) { @@ -1013,7 +1013,7 @@ static void showmatches_oneline(expand_T *xp, char **matches, int numMatches, in isdir = false; p = SHOW_MATCH(j); } - lastlen = msg_outtrans_attr(p, isdir ? dir_attr : 0); + lastlen = msg_outtrans(p, isdir ? dir_attr : 0); } if (msg_col > 0) { // when not wrapped around msg_clr_eos(); diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c index 072898706b..50bdfd892f 100644 --- a/src/nvim/cmdhist.c +++ b/src/nvim/cmdhist.c @@ -22,7 +22,7 @@ #include "nvim/macros.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/pos.h" #include "nvim/regexp.h" #include "nvim/strings.h" @@ -610,7 +610,7 @@ void ex_history(exarg_T *eap) char *arg = eap->arg; if (hislen == 0) { - msg(_("'history' option is zero")); + msg(_("'history' option is zero"), 0); return; } @@ -672,7 +672,7 @@ void ex_history(exarg_T *eap) } else { xstrlcat(IObuff, hist[i].hisstr, IOSIZE); } - msg_outtrans(IObuff); + msg_outtrans(IObuff, 0); } if (i == idx) { break; diff --git a/src/nvim/context.c b/src/nvim/context.c index ca28ed9970..fe5a49faa2 100644 --- a/src/nvim/context.c +++ b/src/nvim/context.c @@ -9,6 +9,7 @@ #include <stdio.h> #include <string.h> +#include "nvim/api/keysets.h" #include "nvim/api/private/converter.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" @@ -16,7 +17,6 @@ #include "nvim/context.h" #include "nvim/eval/encode.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/eval/userfunc.h" #include "nvim/ex_docmd.h" #include "nvim/gettext.h" diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c index 418d49dfeb..ca309757f9 100644 --- a/src/nvim/cursor.c +++ b/src/nvim/cursor.c @@ -10,7 +10,6 @@ #include "nvim/assert.h" #include "nvim/buffer_defs.h" #include "nvim/change.h" -#include "nvim/charset.h" #include "nvim/cursor.h" #include "nvim/drawscreen.h" #include "nvim/fold.h" @@ -22,10 +21,10 @@ #include "nvim/memory.h" #include "nvim/move.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/plines.h" #include "nvim/pos.h" #include "nvim/state.h" -#include "nvim/types.h" #include "nvim/vim.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index 4e5886406a..fb2ca9ff8c 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -17,7 +17,7 @@ #include "nvim/log.h" #include "nvim/macros.h" #include "nvim/memory.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/strings.h" #include "nvim/ui.h" #include "nvim/vim.h" diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c index 1b1dea0d62..3d5f27e76c 100644 --- a/src/nvim/debugger.c +++ b/src/nvim/debugger.c @@ -11,13 +11,11 @@ #include <string.h> #include "nvim/ascii.h" -#include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/debugger.h" #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" @@ -35,7 +33,6 @@ #include "nvim/pos.h" #include "nvim/regexp.h" #include "nvim/runtime.h" -#include "nvim/types.h" #include "nvim/vim.h" /// batch mode debugging: don't save and restore typeahead. @@ -102,27 +99,27 @@ void do_debug(char *cmd) debug_mode = true; if (!debug_did_msg) { - msg(_("Entering Debug mode. Type \"cont\" to continue.")); + msg(_("Entering Debug mode. Type \"cont\" to continue."), 0); } if (debug_oldval != NULL) { - smsg(_("Oldval = \"%s\""), debug_oldval); + smsg(0, _("Oldval = \"%s\""), debug_oldval); xfree(debug_oldval); debug_oldval = NULL; } if (debug_newval != NULL) { - smsg(_("Newval = \"%s\""), debug_newval); + smsg(0, _("Newval = \"%s\""), debug_newval); xfree(debug_newval); debug_newval = NULL; } char *sname = estack_sfile(ESTACK_NONE); if (sname != NULL) { - msg(sname); + msg(sname, 0); } xfree(sname); if (SOURCING_LNUM != 0) { - smsg(_("line %" PRId64 ": %s"), (int64_t)SOURCING_LNUM, cmd); + smsg(0, _("line %" PRId64 ": %s"), (int64_t)SOURCING_LNUM, cmd); } else { - smsg(_("cmd: %s"), cmd); + smsg(0, _("cmd: %s"), cmd); } // Repeat getting a command and executing it. @@ -345,14 +342,14 @@ static void do_checkbacktracelevel(void) { if (debug_backtrace_level < 0) { debug_backtrace_level = 0; - msg(_("frame is zero")); + msg(_("frame is zero"), 0); } else { char *sname = estack_sfile(ESTACK_NONE); int max = get_maxbacktrace_level(sname); if (debug_backtrace_level > max) { debug_backtrace_level = max; - smsg(_("frame at highest level: %d"), max); + smsg(0, _("frame at highest level: %d"), max); } xfree(sname); } @@ -371,9 +368,9 @@ static void do_showbacktrace(char *cmd) *next = NUL; } if (i == max - debug_backtrace_level) { - smsg("->%d %s", max - i, cur); + smsg(0, "->%d %s", max - i, cur); } else { - smsg(" %d %s", max - i, cur); + smsg(0, " %d %s", max - i, cur); } i++; if (next == NULL) { @@ -386,9 +383,9 @@ static void do_showbacktrace(char *cmd) } if (SOURCING_LNUM != 0) { - smsg(_("line %" PRId64 ": %s"), (int64_t)SOURCING_LNUM, cmd); + smsg(0, _("line %" PRId64 ": %s"), (int64_t)SOURCING_LNUM, cmd); } else { - smsg(_("cmd: %s"), cmd); + smsg(0, _("cmd: %s"), cmd); } } @@ -432,7 +429,7 @@ void dbg_check_breakpoint(exarg_T *eap) } else { p = ""; } - smsg(_("Breakpoint in \"%s%s\" line %" PRId64), + smsg(0, _("Breakpoint in \"%s%s\" line %" PRId64), p, debug_breakpoint_name + (*p == NUL ? 0 : 3), (int64_t)debug_breakpoint_lnum); @@ -719,7 +716,7 @@ void ex_breakdel(exarg_T *eap) void ex_breaklist(exarg_T *eap) { if (GA_EMPTY(&dbg_breakp)) { - msg(_("No breakpoints defined")); + msg(_("No breakpoints defined"), 0); return; } @@ -729,13 +726,13 @@ void ex_breaklist(exarg_T *eap) home_replace(NULL, bp->dbg_name, NameBuff, MAXPATHL, true); } if (bp->dbg_type != DBG_EXPR) { - smsg(_("%3d %s %s line %" PRId64), + smsg(0, _("%3d %s %s line %" PRId64), bp->dbg_nr, bp->dbg_type == DBG_FUNC ? "func" : "file", bp->dbg_type == DBG_FUNC ? bp->dbg_name : NameBuff, (int64_t)bp->dbg_lnum); } else { - smsg(_("%3d expr %s"), bp->dbg_nr, bp->dbg_name); + smsg(0, _("%3d expr %s"), bp->dbg_nr, bp->dbg_name); } } } diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c index 9d391cde8c..59e0711906 100644 --- a/src/nvim/decoration.c +++ b/src/nvim/decoration.c @@ -2,6 +2,7 @@ // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include <assert.h> +#include <limits.h> #include "nvim/buffer.h" #include "nvim/decoration.h" diff --git a/src/nvim/decoration_provider.c b/src/nvim/decoration_provider.c index 63c9772fb8..1b0171a0a5 100644 --- a/src/nvim/decoration_provider.c +++ b/src/nvim/decoration_provider.c @@ -2,7 +2,6 @@ // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include <assert.h> -#include <stdio.h> #include <string.h> #include "klib/kvec.h" @@ -11,12 +10,13 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/buffer_defs.h" +#include "nvim/decoration.h" #include "nvim/decoration_provider.h" #include "nvim/globals.h" #include "nvim/highlight.h" #include "nvim/log.h" #include "nvim/lua/executor.h" -#include "nvim/memory.h" +#include "nvim/message.h" #include "nvim/pos.h" static kvec_t(DecorProvider) decor_providers = KV_INITIAL_VALUE; diff --git a/src/nvim/decoration_provider.h b/src/nvim/decoration_provider.h index fa32eb97fe..ad2cdd564d 100644 --- a/src/nvim/decoration_provider.h +++ b/src/nvim/decoration_provider.h @@ -2,6 +2,7 @@ #define NVIM_DECORATION_PROVIDER_H #include <stdbool.h> +#include <stdint.h> #include "klib/kvec.h" #include "nvim/buffer_defs.h" diff --git a/src/nvim/diff.c b/src/nvim/diff.c index c5783ef00e..3ab1da76f4 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -33,7 +33,6 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/extmark.h" -#include "nvim/extmark_defs.h" #include "nvim/fileio.h" #include "nvim/fold.h" #include "nvim/garray.h" @@ -48,6 +47,7 @@ #include "nvim/move.h" #include "nvim/normal.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/fs_defs.h" #include "nvim/os/os.h" @@ -764,7 +764,7 @@ static int diff_write_buffer(buf_T *buf, mmfile_t *m, linenr_T start, linenr_T e buf->b_diff_failed = true; if (p_verbose > 0) { verbose_enter(); - smsg(_("Not enough memory to use internal diff for buffer \"%s\""), + smsg(0, _("Not enough memory to use internal diff for buffer \"%s\""), buf->b_fname); verbose_leave(); } diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index 7a690d889f..1bcb21508b 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -17,7 +17,6 @@ #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" @@ -32,7 +31,7 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/normal.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/os/input.h" #include "nvim/runtime.h" #include "nvim/strings.h" @@ -1706,7 +1705,7 @@ static void digraph_header(const char *msg) if (msg_col > 0) { msg_putchar('\n'); } - msg_outtrans_attr(msg, HL_ATTR(HLF_CM)); + msg_outtrans(msg, HL_ATTR(HLF_CM)); msg_putchar('\n'); } @@ -1860,7 +1859,7 @@ static void printdigraph(const digr_T *dp, result_T *previous) *p++ = (char)dp->char2; *p++ = ' '; *p = NUL; - msg_outtrans(buf); + msg_outtrans(buf, 0); p = buf; // add a space to draw a composing char on @@ -1870,14 +1869,14 @@ static void printdigraph(const digr_T *dp, result_T *previous) p += utf_char2bytes(dp->result, p); *p = NUL; - msg_outtrans_attr(buf, HL_ATTR(HLF_8)); + msg_outtrans(buf, HL_ATTR(HLF_8)); p = buf; if (char2cells(dp->result) == 1) { *p++ = ' '; } assert(p >= buf); vim_snprintf(p, sizeof(buf) - (size_t)(p - buf), " %3d", dp->result); - msg_outtrans(buf); + msg_outtrans(buf, 0); } /// Get the two digraph characters from a typval. diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 9da421e79b..eef427a7b8 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -7,6 +7,7 @@ #include <assert.h> #include <limits.h> #include <stdbool.h> +#include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -25,7 +26,6 @@ #include "nvim/eval.h" #include "nvim/extmark_defs.h" #include "nvim/fold.h" -#include "nvim/garray.h" #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/highlight.h" @@ -38,6 +38,7 @@ #include "nvim/memory.h" #include "nvim/move.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/plines.h" #include "nvim/pos.h" #include "nvim/quickfix.h" @@ -1825,7 +1826,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl || (number_only && wlv.draw_state > WL_STC)) && wlv.filler_todo <= 0) { draw_virt_text(wp, buf, win_col_offset, &wlv.col, wp->w_p_rl ? -1 : grid->cols, wlv.row); - grid_put_linebuf(grid, wlv.row, 0, wlv.col, -grid->cols, wp->w_p_rl, wp, bg_attr, false); + win_put_linebuf(wp, wlv.row, 0, wlv.col, -grid->cols, bg_attr, false); // Pretend we have finished updating the window. Except when // 'cursorcolumn' is set. if (wp->w_p_cuc) { @@ -2956,7 +2957,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl wp->w_p_rl ? -1 : grid->cols, 0, wp->w_p_rl); } draw_virt_text(wp, buf, win_col_offset, &wlv.col, wp->w_p_rl ? -1 : grid->cols, wlv.row); - grid_put_linebuf(grid, wlv.row, 0, wlv.col, grid->cols, wp->w_p_rl, wp, bg_attr, false); + win_put_linebuf(wp, wlv.row, 0, wlv.col, grid->cols, bg_attr, false); wlv.row++; // Update w_cline_height and w_cline_folded if the cursor line was @@ -3229,7 +3230,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl draw_virt_text(wp, buf, win_col_offset, &draw_col, wp->w_p_rl ? -1 : grid->cols, wlv.row); } - grid_put_linebuf(grid, wlv.row, 0, draw_col, grid->cols, wp->w_p_rl, wp, bg_attr, wrap); + win_put_linebuf(wp, wlv.row, 0, draw_col, grid->cols, bg_attr, wrap); if (wrap) { ScreenGrid *current_grid = grid; int current_row = wlv.row, dummy_col = 0; // dummy_col unused @@ -3297,3 +3298,37 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl xfree(wlv.saved_p_extra_free); return wlv.row; } + +static void win_put_linebuf(win_T *wp, int row, int coloff, int endcol, int clear_width, + int bg_attr, bool wrap) +{ + ScreenGrid *grid = &wp->w_grid; + + // Take care of putting "<<<" on the first line for 'smoothscroll'. + if (row == 0 && wp->w_skipcol > 0 + // do not overwrite the 'showbreak' text with "<<<" + && *get_showbreak_value(wp) == NUL + // do not overwrite the 'listchars' "precedes" text with "<<<" + && !(wp->w_p_list && wp->w_p_lcs_chars.prec != 0)) { + int off = 0; + if (wp->w_p_nu && wp->w_p_rnu) { + // do not overwrite the line number, change "123 text" to "123<<<xt". + while (off < grid->cols && ascii_isdigit(schar_get_ascii(linebuf_char[off]))) { + off++; + } + } + + for (int i = 0; i < 3 && off < grid->cols; i++) { + if (off + 1 < grid->cols && linebuf_char[off + 1] == NUL) { + // When the first half of a double-width character is + // overwritten, change the second half to a space. + linebuf_char[off + 1] = schar_from_ascii(' '); + } + linebuf_char[off] = schar_from_ascii('<'); + linebuf_attr[off] = HL_ATTR(HLF_AT); + off++; + } + } + + grid_put_linebuf(grid, row, coloff, 0, endcol, clear_width, wp->w_p_rl, bg_attr, wrap, false); +} diff --git a/src/nvim/drawline.h b/src/nvim/drawline.h index 9a917df0c5..f35b15c474 100644 --- a/src/nvim/drawline.h +++ b/src/nvim/drawline.h @@ -8,6 +8,7 @@ #include "nvim/decoration_provider.h" #include "nvim/fold.h" #include "nvim/macros.h" +#include "nvim/pos.h" #include "nvim/types.h" // Maximum columns for terminal highlight attributes diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index 04918e9979..cc22accf2b 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -56,7 +56,10 @@ #include <assert.h> #include <inttypes.h> +#include <limits.h> #include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> #include <string.h> #include "klib/kvec.h" @@ -77,6 +80,8 @@ #include "nvim/ex_getln.h" #include "nvim/extmark_defs.h" #include "nvim/fold.h" +#include "nvim/getchar.h" +#include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/highlight.h" @@ -89,6 +94,8 @@ #include "nvim/move.h" #include "nvim/normal.h" #include "nvim/option.h" +#include "nvim/option_vars.h" +#include "nvim/os/os_defs.h" #include "nvim/plines.h" #include "nvim/popupmenu.h" #include "nvim/pos.h" @@ -98,6 +105,7 @@ #include "nvim/spell.h" #include "nvim/state.h" #include "nvim/statusline.h" +#include "nvim/strings.h" #include "nvim/syntax.h" #include "nvim/terminal.h" #include "nvim/types.h" @@ -771,20 +779,20 @@ static void win_redr_border(win_T *wp) if (adj[1]) { grid_line_put_schar(icol + adj[3], chars[2], attrs[2]); } - grid_line_flush(false); + grid_line_flush(); } for (int i = 0; i < irow; i++) { if (adj[3]) { grid_line_start(grid, i + adj[0]); grid_line_put_schar(0, chars[7], attrs[7]); - grid_line_flush(false); + grid_line_flush(); } if (adj[1]) { int ic = (i == 0 && !adj[0] && chars[2]) ? 2 : 3; grid_line_start(grid, i + adj[0]); grid_line_put_schar(icol + adj[3], chars[ic], attrs[ic]); - grid_line_flush(false); + grid_line_flush(); } } @@ -807,7 +815,7 @@ static void win_redr_border(win_T *wp) if (adj[1]) { grid_line_put_schar(icol + adj[3], chars[4], attrs[4]); } - grid_line_flush(false); + grid_line_flush(); } } @@ -1094,8 +1102,11 @@ int showmode(void) // If the current or last window has no status line and global statusline is disabled, // the ruler is after the mode message and must be redrawn win_T *ruler_win = curwin->w_status_height == 0 ? curwin : lastwin_nofloating(); - if (redrawing() && ruler_win->w_status_height == 0 && global_stl_height() == 0) { + if (redrawing() && ruler_win->w_status_height == 0 && global_stl_height() == 0 + && !(p_ch == 0 && !ui_has(kUIMessages))) { + grid_line_start(&msg_grid_adj, Rows - 1); win_redr_ruler(ruler_win); + grid_line_flush(); } redraw_cmdline = false; @@ -1367,25 +1378,25 @@ static void draw_sep_connectors_win(win_T *wp) bool bot_left = !(win_at_bottom || win_at_left); bool bot_right = !(win_at_bottom || win_at_right); - if (top_left || top_right) { + if (top_left) { grid_line_start(&default_grid, wp->w_winrow - 1); - if (top_left) { - grid_line_put_schar(wp->w_wincol - 1, get_corner_sep_connector(wp, WC_TOP_LEFT), hl); - } - if (top_right) { - grid_line_put_schar(W_ENDCOL(wp), get_corner_sep_connector(wp, WC_TOP_RIGHT), hl); - } - grid_line_flush(false); + grid_line_put_schar(wp->w_wincol - 1, get_corner_sep_connector(wp, WC_TOP_LEFT), hl); + grid_line_flush(); + } + if (top_right) { + grid_line_start(&default_grid, wp->w_winrow - 1); + grid_line_put_schar(W_ENDCOL(wp), get_corner_sep_connector(wp, WC_TOP_RIGHT), hl); + grid_line_flush(); } - if (bot_left || bot_right) { + if (bot_left) { grid_line_start(&default_grid, W_ENDROW(wp)); - if (bot_left) { - grid_line_put_schar(wp->w_wincol - 1, get_corner_sep_connector(wp, WC_BOTTOM_LEFT), hl); - } - if (bot_right) { - grid_line_put_schar(W_ENDCOL(wp), get_corner_sep_connector(wp, WC_BOTTOM_RIGHT), hl); - } - grid_line_flush(false); + grid_line_put_schar(wp->w_wincol - 1, get_corner_sep_connector(wp, WC_BOTTOM_LEFT), hl); + grid_line_flush(); + } + if (bot_right) { + grid_line_start(&default_grid, W_ENDROW(wp)); + grid_line_put_schar(W_ENDCOL(wp), get_corner_sep_connector(wp, WC_BOTTOM_RIGHT), hl); + grid_line_flush(); } } @@ -2391,8 +2402,11 @@ static void win_update(win_T *wp, DecorProviders *providers) int symbol = wp->w_p_fcs_chars.lastline; // Last line isn't finished: Display "@@@" at the end. - grid_fill(&wp->w_grid, wp->w_grid.rows - 1, wp->w_grid.rows, - MAX(start_col, 0), wp->w_grid.cols, symbol, symbol, at_attr); + // TODO(bfredl): this display ">@@@" when ">" was a left-halve + // maybe "@@@@" is preferred when this happens. + grid_line_start(&wp->w_grid, wp->w_grid.rows - 1); + grid_line_fill(MAX(start_col, 0), wp->w_grid.cols, symbol, at_attr); + grid_line_flush(); set_empty_rows(wp, srow); wp->w_botline = lnum; } else { diff --git a/src/nvim/drawscreen.h b/src/nvim/drawscreen.h index 398825f1bc..7fab7ebacf 100644 --- a/src/nvim/drawscreen.h +++ b/src/nvim/drawscreen.h @@ -3,6 +3,7 @@ #include <stdbool.h> +#include "nvim/buffer_defs.h" #include "nvim/drawline.h" #include "nvim/macros.h" diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 520d3bc2b3..7f29e615ab 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -48,12 +48,12 @@ #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/input.h" #include "nvim/plines.h" #include "nvim/popupmenu.h" #include "nvim/pos.h" #include "nvim/search.h" -#include "nvim/spell.h" #include "nvim/state.h" #include "nvim/strings.h" #include "nvim/syntax.h" @@ -878,6 +878,10 @@ static int insert_handle_key(InsertState *s) case K_EVENT: // some event state_handle_k_event(); + // If CTRL-G U was used apply it to the next typed key. + if (dont_sync_undo == kTrue) { + dont_sync_undo = kNone; + } goto check_pum; case K_COMMAND: // <Cmd>command<CR> @@ -1306,9 +1310,9 @@ void ins_redraw(bool ready) last_cursormoved = curwin->w_cursor; } - // Trigger TextChangedI if changedtick differs. + // Trigger TextChangedI if changedtick_i differs. if (ready && has_event(EVENT_TEXTCHANGEDI) - && curbuf->b_last_changedtick != buf_get_changedtick(curbuf) + && curbuf->b_last_changedtick_i != buf_get_changedtick(curbuf) && !pum_visible()) { aco_save_T aco; varnumber_T tick = buf_get_changedtick(curbuf); @@ -1317,16 +1321,16 @@ void ins_redraw(bool ready) aucmd_prepbuf(&aco, curbuf); apply_autocmds(EVENT_TEXTCHANGEDI, NULL, NULL, false, curbuf); aucmd_restbuf(&aco); - curbuf->b_last_changedtick = buf_get_changedtick(curbuf); + curbuf->b_last_changedtick_i = buf_get_changedtick(curbuf); if (tick != buf_get_changedtick(curbuf)) { // see ins_apply_autocmds() u_save(curwin->w_cursor.lnum, (linenr_T)(curwin->w_cursor.lnum + 1)); } } - // Trigger TextChangedP if changedtick differs. When the popupmenu closes - // TextChangedI will need to trigger for backwards compatibility, thus use - // different b_last_changedtick* variables. + // Trigger TextChangedP if changedtick_pum differs. When the popupmenu + // closes TextChangedI will need to trigger for backwards compatibility, + // thus use different b_last_changedtick* variables. if (ready && has_event(EVENT_TEXTCHANGEDP) && curbuf->b_last_changedtick_pum != buf_get_changedtick(curbuf) && pum_visible()) { @@ -3488,7 +3492,7 @@ static bool ins_esc(long *count, int cmdchar, bool nomove) showmode(); } else if (p_smd && (got_int || !skip_showmode()) && !(p_ch == 0 && !ui_has(kUIMessages))) { - msg(""); + msg("", 0); } // Exit Insert mode return true; @@ -4632,8 +4636,6 @@ static int ins_ctrl_ey(int tc) } else { c = ins_copychar(curwin->w_cursor.lnum + (c == Ctrl_Y ? -1 : 1)); if (c != NUL) { - long tw_save; - // The character must be taken literally, insert like it // was typed after a CTRL-V, and pretend 'textwidth' // wasn't set. Digits, 'o' and 'x' are special after a @@ -4641,7 +4643,7 @@ static int ins_ctrl_ey(int tc) if (c < 256 && !isalnum(c)) { AppendToRedobuff(CTRL_V_STR); } - tw_save = curbuf->b_p_tw; + OptInt tw_save = curbuf->b_p_tw; curbuf->b_p_tw = -1; insert_special(c, true, false); curbuf->b_p_tw = tw_save; diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 21c7cdee7d..0bf26b2451 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -10,6 +10,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/stat.h> #include "auto/config.h" #include "nvim/api/private/converter.h" @@ -30,7 +31,6 @@ #include "nvim/eval/typval.h" #include "nvim/eval/userfunc.h" #include "nvim/eval/vars.h" -#include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" #include "nvim/event/process.h" #include "nvim/ex_cmds.h" @@ -60,7 +60,7 @@ #include "nvim/msgpack_rpc/channel_defs.h" #include "nvim/ops.h" #include "nvim/option.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/fileio.h" #include "nvim/os/fs_defs.h" @@ -5731,7 +5731,7 @@ void get_user_input(const typval_T *const argvars, typval_T *const rettv, const p = lastnl + 1; msg_start(); msg_clr_eos(); - msg_puts_attr_len(prompt, p - prompt, echo_attr); + msg_puts_len(prompt, p - prompt, echo_attr); msg_didout = false; msg_starthere(); } @@ -5922,7 +5922,7 @@ void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv, bool retlist if (p_verbose > 3) { char *cmdstr = shell_argv_to_str(argv); verbose_enter_scroll(); - smsg(_("Executing command: \"%s\""), cmdstr); + smsg(0, _("Executing command: \"%s\""), cmdstr); msg_puts("\n\n"); verbose_leave_scroll(); xfree(cmdstr); @@ -8018,7 +8018,7 @@ void ex_echo(exarg_T *eap) char *tofree = encode_tv2echo(&rettv, NULL); if (*tofree != NUL) { msg_ext_set_kind("echo"); - msg_multiline_attr(tofree, echo_attr, true, &need_clear); + msg_multiline(tofree, echo_attr, true, &need_clear); } xfree(tofree); } @@ -8102,7 +8102,7 @@ void ex_execute(exarg_T *eap) if (eap->cmdidx == CMD_echomsg) { msg_ext_set_kind("echomsg"); - msg_attr(ga.ga_data, echo_attr); + msg(ga.ga_data, echo_attr); } else if (eap->cmdidx == CMD_echoerr) { // We don't want to abort following commands, restore did_emsg. int save_did_emsg = did_emsg; diff --git a/src/nvim/eval.h b/src/nvim/eval.h index 5fbfc4702c..be69cd5657 100644 --- a/src/nvim/eval.h +++ b/src/nvim/eval.h @@ -10,6 +10,7 @@ #include "nvim/event/time.h" #include "nvim/ex_cmds_defs.h" #include "nvim/hashtab.h" +#include "nvim/macros.h" #include "nvim/os/fileio.h" #include "nvim/os/stdpaths_defs.h" diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 858f7c8afd..23ad3d3787 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -7520,55 +7520,55 @@ M.funcs = { echo printf("%1$*2$.*3$f", 1.4142135, 6, 2) < 1.41 - *E1400* + *E1500* You cannot mix positional and non-positional arguments: >vim - echo printf("%s%1$s", "One", "Two") -< E1400: Cannot mix positional and non-positional - arguments: %s%1$s + echo printf("%s%1$s", "One", "Two") + < E1500: Cannot mix positional and non-positional + arguments: %s%1$s - *E1401* + *E1501* You cannot skip a positional argument in a format string: >vim echo printf("%3$s%1$s", "One", "Two", "Three") - < E1401: format argument 2 unused in $-style + < E1501: format argument 2 unused in $-style format: %3$s%1$s - *E1402* + *E1502* You can re-use a [field-width] (or [precision]) argument: >vim echo printf("%1$d at width %2$d is: %01$*2$d", 1, 2) < 1 at width 2 is: 01 However, you can't use it as a different type: >vim echo printf("%1$d at width %2$ld is: %01$*2$d", 1, 2) - < E1402: Positional argument 2 used as field + < E1502: Positional argument 2 used as field width reused as different type: long int/int - *E1403* + *E1503* When a positional argument is used, but not the correct number or arguments is given, an error is raised: >vim echo printf("%1$d at width %2$d is: %01$*2$.*3$d", 1, 2) - < E1403: Positional argument 3 out of bounds: + < E1503: Positional argument 3 out of bounds: %1$d at width %2$d is: %01$*2$.*3$d Only the first error is reported: >vim echo printf("%01$*2$.*3$d %4$d", 1, 2) - < E1403: Positional argument 3 out of bounds: + < E1503: Positional argument 3 out of bounds: %01$*2$.*3$d %4$d - *E1404* + *E1504* A positional argument can be used more than once: >vim echo printf("%1$s %2$s %1$s", "One", "Two") < One Two One However, you can't use a different type the second time: >vim echo printf("%1$s %2$s %1$d", "One", "Two") - < E1404: Positional argument 1 type used + < E1504: Positional argument 1 type used inconsistently: int/string - *E1405* + *E1505* Various other errors that lead to a format string being wrongly formatted lead to: >vim echo printf("%1$d at width %2$d is: %01$*2$.3$d", 1, 2) - < E1405: Invalid format specifier: + < E1505: Invalid format specifier: %1$d at width %2$d is: %01$*2$.3$d ]=], name = 'printf', diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c index 70a629ea91..9c47e06f69 100644 --- a/src/nvim/eval/decode.c +++ b/src/nvim/eval/decode.c @@ -19,7 +19,6 @@ #include "nvim/eval/typval_defs.h" #include "nvim/garray.h" #include "nvim/gettext.h" -#include "nvim/hashtab.h" #include "nvim/macros.h" #include "nvim/mbyte.h" #include "nvim/memory.h" diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 93075cf0e2..710d9c73a5 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -63,12 +63,12 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/grid.h" -#include "nvim/hashtab.h" #include "nvim/highlight_defs.h" #include "nvim/highlight_group.h" #include "nvim/indent.h" #include "nvim/indent_c.h" #include "nvim/input.h" +#include "nvim/insexpand.h" #include "nvim/keycodes.h" #include "nvim/lua/executor.h" #include "nvim/macros.h" @@ -76,12 +76,10 @@ #include "nvim/mark.h" #include "nvim/math.h" #include "nvim/mbyte.h" -#include "nvim/memfile_defs.h" #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/menu.h" #include "nvim/message.h" -#include "nvim/mouse.h" #include "nvim/move.h" #include "nvim/msgpack_rpc/channel.h" #include "nvim/msgpack_rpc/channel_defs.h" @@ -89,6 +87,7 @@ #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/dl.h" #include "nvim/os/fileio.h" diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index ba2c23ffe8..1ff90dd201 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -33,6 +33,7 @@ #include "nvim/message.h" #include "nvim/os/input.h" #include "nvim/pos.h" +#include "nvim/strings.h" #include "nvim/types.h" #include "nvim/vim.h" @@ -49,6 +50,14 @@ typedef struct { bool item_compare_func_err; } sortinfo_T; +/// Structure representing one list item, used for sort array. +typedef struct { + listitem_T *item; ///< Sorted list item. + int idx; ///< Sorted list item index. +} ListSortItem; + +typedef int (*ListSorter)(const void *, const void *); + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "eval/typval.c.generated.h" #endif diff --git a/src/nvim/eval/typval_defs.h b/src/nvim/eval/typval_defs.h index 4099877539..d5e8cb0109 100644 --- a/src/nvim/eval/typval_defs.h +++ b/src/nvim/eval/typval_defs.h @@ -273,6 +273,12 @@ typedef struct { linenr_T sc_lnum; ///< line number } sctx_T; +/// Stores an identifier of a script or channel that last set an option. +typedef struct { + sctx_T script_ctx; /// script context where the option was last set + uint64_t channel_id; /// Only used when script_id is SID_API_CLIENT. +} LastSet; + /// Maximum number of function arguments enum { MAX_FUNC_ARGS = 20, }; /// Short variable name length @@ -367,12 +373,4 @@ typedef struct list_stack_S { struct list_stack_S *prev; } list_stack_T; -/// Structure representing one list item, used for sort array. -typedef struct { - listitem_T *item; ///< Sorted list item. - int idx; ///< Sorted list item index. -} ListSortItem; - -typedef int (*ListSorter)(const void *, const void *); - #endif // NVIM_EVAL_TYPVAL_DEFS_H diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index a5d7ed2758..8d85c55e15 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -13,7 +13,6 @@ #include "lauxlib.h" #include "nvim/ascii.h" #include "nvim/autocmd.h" -#include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/debugger.h" #include "nvim/eval.h" @@ -26,18 +25,19 @@ #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" #include "nvim/ex_getln.h" +#include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" +#include "nvim/hashtab.h" #include "nvim/insexpand.h" #include "nvim/keycodes.h" #include "nvim/lua/executor.h" #include "nvim/macros.h" #include "nvim/mbyte.h" -#include "nvim/memline_defs.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/os/input.h" #include "nvim/path.h" #include "nvim/profile.h" @@ -1117,7 +1117,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett no_wait_return++; verbose_enter_scroll(); - smsg(_("calling %s"), SOURCING_NAME); + smsg(0, _("calling %s"), SOURCING_NAME); if (p_verbose >= 14) { msg_puts("("); for (int i = 0; i < argcount; i++) { @@ -1235,9 +1235,9 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett verbose_enter_scroll(); if (aborting()) { - smsg(_("%s aborted"), SOURCING_NAME); + smsg(0, _("%s aborted"), SOURCING_NAME); } else if (fc->fc_rettv->v_type == VAR_NUMBER) { - smsg(_("%s returning #%" PRId64 ""), + smsg(0, _("%s returning #%" PRId64 ""), SOURCING_NAME, (int64_t)fc->fc_rettv->vval.v_number); } else { char buf[MSG_BUF_LEN]; @@ -1254,7 +1254,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN); s = buf; } - smsg(_("%s returning %s"), SOURCING_NAME, s); + smsg(0, _("%s returning %s"), SOURCING_NAME, s); xfree(tofree); } } @@ -1277,7 +1277,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett no_wait_return++; verbose_enter_scroll(); - smsg(_("continuing in %s"), SOURCING_NAME); + smsg(0, _("continuing in %s"), SOURCING_NAME); msg_puts("\n"); // don't overwrite this either verbose_leave_scroll(); diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index 5d1da956ee..f9dcfb3d9d 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -8,6 +8,7 @@ #include <stdbool.h> #include <stddef.h> #include <stdint.h> +#include <stdlib.h> #include <string.h> #include "nvim/ascii.h" @@ -19,7 +20,6 @@ #include "nvim/eval/encode.h" #include "nvim/eval/funcs.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/eval/userfunc.h" #include "nvim/eval/vars.h" #include "nvim/eval/window.h" @@ -27,6 +27,7 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" +#include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/hashtab.h" @@ -35,6 +36,7 @@ #include "nvim/message.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/os.h" #include "nvim/search.h" #include "nvim/strings.h" @@ -801,8 +803,8 @@ static char *ex_let_option(char *arg, typval_T *const tv, const bool is_const, if (op != NULL && *op != '=') { if (!hidden && is_num) { // number or bool - Integer cur_n = curval.type == kOptValTypeNumber ? curval.data.number : curval.data.boolean; - Integer new_n = newval.type == kOptValTypeNumber ? newval.data.number : newval.data.boolean; + OptInt cur_n = curval.type == kOptValTypeNumber ? curval.data.number : curval.data.boolean; + OptInt new_n = newval.type == kOptValTypeNumber ? newval.data.number : newval.data.boolean; switch (*op) { case '+': @@ -1352,11 +1354,11 @@ static void list_one_var(dictitem_T *v, const char *prefix, int *first) static void list_one_var_a(const char *prefix, const char *name, const ptrdiff_t name_len, const VarType type, const char *string, int *first) { - // don't use msg() or msg_attr() to avoid overwriting "v:statusmsg" + // don't use msg() to avoid overwriting "v:statusmsg" msg_start(); msg_puts(prefix); if (name != NULL) { // "a:" vars don't have a name stored - msg_puts_attr_len(name, name_len, 0); + msg_puts_len(name, name_len, 0); } msg_putchar(' '); msg_advance(22); @@ -1378,7 +1380,7 @@ static void list_one_var_a(const char *prefix, const char *name, const ptrdiff_t msg_putchar(' '); } - msg_outtrans(string); + msg_outtrans(string, 0); if (type == VAR_FUNC || type == VAR_PARTIAL) { msg_puts("()"); @@ -1873,7 +1875,7 @@ static OptVal tv_to_optval(typval_T *tv, const char *option, uint32_t flags, boo semsg(_("E521: Number required: &%s = '%s'"), option, tv->vval.v_string); } } - value = (flags & P_NUM) ? NUMBER_OPTVAL(n) + value = (flags & P_NUM) ? NUMBER_OPTVAL((OptInt)n) : BOOLEAN_OPTVAL(n == 0 ? kFalse : (n >= 1 ? kTrue : kNone)); } else if ((flags & P_STRING) || is_tty_option(option)) { // Avoid setting string option to a boolean or a special value. diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c index 26f5414565..f64809f2ef 100644 --- a/src/nvim/eval/window.c +++ b/src/nvim/eval/window.c @@ -22,11 +22,9 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/macros.h" -#include "nvim/memline_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/move.h" -#include "nvim/option_defs.h" #include "nvim/pos.h" #include "nvim/types.h" #include "nvim/vim.h" diff --git a/src/nvim/eval/window.h b/src/nvim/eval/window.h index 995f0a55a9..671c8fbf79 100644 --- a/src/nvim/eval/window.h +++ b/src/nvim/eval/window.h @@ -11,6 +11,7 @@ #include "nvim/globals.h" #include "nvim/mark.h" #include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/os/os.h" #include "nvim/pos.h" #include "nvim/vim.h" diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index dc7136196e..127397d9fa 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -66,6 +66,7 @@ #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/fs_defs.h" #include "nvim/os/input.h" @@ -135,7 +136,7 @@ void do_ascii(const exarg_T *const eap) int cc[MAX_MCO]; int c = utfc_ptr2char(get_cursor_pos_ptr(), cc); if (c == NUL) { - msg("NUL"); + msg("NUL", 0); return; } @@ -233,7 +234,7 @@ void do_ascii(const exarg_T *const eap) xstrlcpy(IObuff + iobuff_len, " ...", sizeof(IObuff) - iobuff_len); } - msg(IObuff); + msg(IObuff, 0); } /// ":left", ":center" and ":right": align text. @@ -836,8 +837,8 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) ml_delete(line1 + extra, true); } if (!global_busy && num_lines > p_report) { - smsg(NGETTEXT("%" PRId64 " line moved", - "%" PRId64 " lines moved", num_lines), + smsg(0, NGETTEXT("%" PRId64 " line moved", + "%" PRId64 " lines moved", num_lines), (int64_t)num_lines); } @@ -1062,7 +1063,7 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out msg_start(); msg_putchar(':'); msg_putchar('!'); - msg_outtrans(newcmd); + msg_outtrans(newcmd, 0); msg_clr_eos(); ui_cursor_goto(msg_row, msg_col); @@ -1274,7 +1275,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char *cmd, b if (do_in) { vim_snprintf(msg_buf, sizeof(msg_buf), _("%" PRId64 " lines filtered"), (int64_t)linecount); - if (msg(msg_buf) && !msg_scroll) { + if (msg(msg_buf, 0) && !msg_scroll) { // save message to display it after redraw set_keep_msg(msg_buf, 0); } @@ -2148,7 +2149,6 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum bufref_T old_curbuf; char *free_fname = NULL; int retval = FAIL; - long n; pos_T orig_pos; linenr_T topline = 0; int newcol = -1; @@ -2158,7 +2158,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum bool did_get_winopts = false; int readfile_flags = 0; bool did_inc_redrawing_disabled = false; - long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so; + OptInt *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so; if (eap != NULL) { command = eap->do_ecmd_cmd; @@ -2719,7 +2719,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum RedrawingDisabled--; did_inc_redrawing_disabled = false; if (!skip_redraw) { - n = *so_ptr; + OptInt n = *so_ptr; if (topline == 0 && command == NULL) { *so_ptr = 999; // force cursor to be vertically centered in the window } @@ -3801,8 +3801,8 @@ static int do_sub(exarg_T *eap, const proftime_T timeout, const long cmdpreview_ // needed msg_no_more = true; msg_ext_set_kind("confirm_sub"); - smsg_attr(HL_ATTR(HLF_R), // Same highlight as wait_return(). - _("replace with %s (y/n/a/q/l/^E/^Y)?"), sub); + // Same highlight as wait_return(). + smsg(HL_ATTR(HLF_R), _("replace with %s (y/n/a/q/l/^E/^Y)?"), sub); msg_no_more = false; msg_scroll = (int)i; if (!ui_has(kUIMessages)) { @@ -4250,7 +4250,7 @@ skip: } } if (cmdpreview_ns <= 0 && !do_sub_msg(subflags.do_count) && subflags.do_ask && p_ch > 0) { - msg(""); + msg("", 0); } } else { global_need_beginline = true; @@ -4265,7 +4265,7 @@ skip: } else if (got_match) { // did find something but nothing substituted if (p_ch > 0) { - msg(""); + msg("", 0); } } else if (subflags.do_error) { // nothing found @@ -4339,7 +4339,7 @@ bool do_sub_msg(bool count_only) vim_snprintf_add(msg_buf, sizeof(msg_buf), NGETTEXT(msg_single, msg_plural, sub_nlines), (int64_t)sub_nsubs, (int64_t)sub_nlines); - if (msg(msg_buf)) { + if (msg(msg_buf, 0)) { // save message to display it after redraw set_keep_msg(msg_buf, 0); } @@ -4468,12 +4468,12 @@ void ex_global(exarg_T *eap) // pass 2: execute the command for each line that has been marked if (got_int) { - msg(_(e_interr)); + msg(_(e_interr), 0); } else if (ndone == 0) { if (type == 'v') { - smsg(_("Pattern found in every line: %s"), used_pat); + smsg(0, _("Pattern found in every line: %s"), used_pat); } else { - smsg(_("Pattern not found: %s"), used_pat); + smsg(0, _("Pattern not found: %s"), used_pat); } } else { global_exe(cmd); @@ -4775,7 +4775,7 @@ void ex_oldfiles(exarg_T *eap) long nr = 0; if (l == NULL) { - msg(_("No old files")); + msg(_("No old files"), 0); return; } @@ -4790,7 +4790,7 @@ void ex_oldfiles(exarg_T *eap) if (!message_filtered(fname)) { msg_outnum(nr); msg_puts(": "); - msg_outtrans(tv_get_string(TV_LIST_ITEM_TV(li))); + msg_outtrans(tv_get_string(TV_LIST_ITEM_TV(li)), 0); msg_clr_eos(); msg_putchar('\n'); os_breakcheck(); diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 86934a645a..199a5bdd43 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -20,7 +20,6 @@ #include "nvim/channel.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/eval/vars.h" #include "nvim/ex_cmds.h" #include "nvim/ex_cmds2.h" @@ -33,13 +32,11 @@ #include "nvim/highlight_defs.h" #include "nvim/macros.h" #include "nvim/mark.h" -#include "nvim/memline_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/move.h" #include "nvim/normal.h" -#include "nvim/option.h" -#include "nvim/optionstr.h" +#include "nvim/option_vars.h" #include "nvim/os/os_defs.h" #include "nvim/path.h" #include "nvim/pos.h" @@ -443,7 +440,7 @@ int buf_write_all(buf_T *buf, int forceit) false, forceit, true, false)); if (curbuf != old_curbuf) { msg_source(HL_ATTR(HLF_W)); - msg(_("Warning: Entered other buffer unexpectedly (check autocommands)")); + msg(_("Warning: Entered other buffer unexpectedly (check autocommands)"), 0); } return retval; } diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index d07532dc11..78f880db56 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -245,6 +245,7 @@ struct expand { int xp_numfiles; // number of files found by file name completion int xp_col; // cursor position in line int xp_selected; // selected index in completion + char *xp_orig; // originally expanded string char **xp_files; // list of files char *xp_line; // text being completed #define EXPAND_BUF_LEN 256 @@ -290,7 +291,7 @@ typedef struct { // values for undo_cmdmod() char *cmod_save_ei; ///< saved value of 'eventignore' int cmod_did_sandbox; ///< set when "sandbox" was incremented - long cmod_verbose_save; ///< if 'verbose' was set: value of p_verbose plus one + OptInt cmod_verbose_save; ///< if 'verbose' was set: value of p_verbose plus one int cmod_save_msg_silent; ///< if non-zero: saved value of msg_silent + 1 int cmod_save_msg_scroll; ///< for restoring msg_scroll int cmod_did_esilent; ///< incremented when emsg_silent is diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index ea93d0fe91..02783e032b 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -18,6 +18,7 @@ #include "nvim/ascii.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" +#include "nvim/buffer_defs.h" #include "nvim/change.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" @@ -28,7 +29,6 @@ #include "nvim/edit.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/eval/userfunc.h" #include "nvim/event/loop.h" #include "nvim/ex_cmds.h" @@ -48,11 +48,11 @@ #include "nvim/highlight_group.h" #include "nvim/input.h" #include "nvim/keycodes.h" +#include "nvim/lua/executor.h" #include "nvim/macros.h" #include "nvim/main.h" #include "nvim/mark.h" #include "nvim/mbyte.h" -#include "nvim/memfile_defs.h" #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/message.h" @@ -61,6 +61,7 @@ #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/os/os.h" @@ -209,7 +210,7 @@ void do_exmode(void) RedrawingDisabled++; // don't redisplay the window no_wait_return++; // don't wait for return - msg(_("Entering Ex mode. Type \"visual\" to go to Normal mode.")); + msg(_("Entering Ex mode. Type \"visual\" to go to Normal mode."), 0); while (exmode_active) { // Check for a ":normal" command and no more characters left. if (ex_normal_busy > 0 && typebuf.tb_len == 0) { @@ -273,9 +274,9 @@ static void msg_verbose_cmd(linenr_T lnum, char *cmd) verbose_enter_scroll(); if (lnum == 0) { - smsg(_("Executing: %s"), cmd); + smsg(0, _("Executing: %s"), cmd); } else { - smsg(_("line %" PRIdLINENR ": %s"), lnum, cmd); + smsg(0, _("line %" PRIdLINENR ": %s"), lnum, cmd); } if (msg_silent == 0) { msg_puts("\n"); // don't overwrite this @@ -4467,10 +4468,10 @@ static void ex_colorscheme(exarg_T *eap) xfree(expr); if (p != NULL) { - msg(p); + msg(p, 0); xfree(p); } else { - msg("default"); + msg("default", 0); } } else if (load_colors(eap->arg) == FAIL) { semsg(_("E185: Cannot find color scheme '%s'"), eap->arg); @@ -4480,7 +4481,7 @@ static void ex_colorscheme(exarg_T *eap) static void ex_highlight(exarg_T *eap) { if (*eap->arg == NUL && eap->cmd[2] == '!') { - msg(_("Greetings, Vim user!")); + msg(_("Greetings, Vim user!"), 0); } do_highlight(eap->arg, eap->forceit, false); } @@ -4751,7 +4752,7 @@ static void ex_tabonly(exarg_T *eap) } if (first_tabpage->tp_next == NULL) { - msg(_("Already only one tab page")); + msg(_("Already only one tab page"), 0); return; } @@ -5137,7 +5138,7 @@ static void ex_tabs(exarg_T *eap) msg_putchar('\n'); vim_snprintf(IObuff, IOSIZE, _("Tab page %d"), tabcount++); - msg_outtrans_attr(IObuff, HL_ATTR(HLF_T)); + msg_outtrans(IObuff, HL_ATTR(HLF_T)); os_breakcheck(); FOR_ALL_WINDOWS_IN_TAB(wp, tp) { @@ -5155,7 +5156,7 @@ static void ex_tabs(exarg_T *eap) } else { home_replace(wp->w_buffer, wp->w_buffer->b_fname, IObuff, IOSIZE, true); } - msg_outtrans(IObuff); + msg_outtrans(IObuff, 0); os_breakcheck(); } } @@ -5378,9 +5379,9 @@ static void ex_popup(exarg_T *eap) static void ex_swapname(exarg_T *eap) { if (curbuf->b_ml.ml_mfp == NULL || curbuf->b_ml.ml_mfp->mf_fname == NULL) { - msg(_("No swap file")); + msg(_("No swap file"), 0); } else { - msg(curbuf->b_ml.ml_mfp->mf_fname); + msg(curbuf->b_ml.ml_mfp->mf_fname, 0); } } @@ -5692,9 +5693,9 @@ static void ex_pwd(exarg_T *eap) } else if (curtab->tp_localdir != NULL) { context = "tabpage"; } - smsg("[%s] %s", context, NameBuff); + smsg(0, "[%s] %s", context, NameBuff); } else { - msg(NameBuff); + msg(NameBuff, 0); } } else { emsg(_("E187: Unknown")); @@ -5709,7 +5710,7 @@ static void ex_equal(exarg_T *eap) ex_lua(eap); } else { eap->nextcmd = find_nextcmd(eap->arg); - smsg("%" PRId64, (int64_t)eap->line2); + smsg(0, "%" PRId64, (int64_t)eap->line2); } } @@ -7121,7 +7122,7 @@ static void ex_filetype(exarg_T *eap) { if (*eap->arg == NUL) { // Print current status. - smsg("filetype detection:%s plugin:%s indent:%s", + smsg(0, "filetype detection:%s plugin:%s indent:%s", filetype_detect == kTrue ? "ON" : "OFF", filetype_plugin == kTrue ? (filetype_detect == kTrue ? "ON" : "(on)") : "OFF", filetype_indent == kTrue ? (filetype_detect == kTrue ? "ON" : "(on)") : "OFF"); @@ -7360,289 +7361,290 @@ void verify_command(char *cmd) if (strcmp("smile", cmd) != 0) { return; // acceptable non-existing command } + int a = HL_ATTR(HLF_E); msg(" #xxn` #xnxx` ,+x@##@Mz;` .xxx" - "xxxxxxnz+, znnnnnnnnnnnnnnnn."); + "xxxxxxnz+, znnnnnnnnnnnnnnnn.", a); msg(" n###z x####` :x##########W+` ,###" - "##########M; W################."); + "##########M; W################.", a); msg(" n####; x####` `z##############W: ,###" - "############# W################."); + "############# W################.", a); msg(" n####W. x####` ,W#################+ ,###" - "############## W################."); + "############## W################.", a); msg(" n#####n x####` @################### ,###" - "##############i W################."); + "##############i W################.", a); msg(" n######i x####` .#########@W@########* ,###" - "##############W`W################."); + "##############W`W################.", a); msg(" n######@. x####` x######W*. `;n#######: ,###" - "#x,,,,:*M######iW###@:,,,,,,,,,,,`"); + "#x,,,,:*M######iW###@:,,,,,,,,,,,`", a); msg(" n#######n x####` *######+` :M#####M ,###" - "#n `x#####xW###@`"); + "#n `x#####xW###@`", a); msg(" n########* x####``@####@; `x#####i ,###" - "#n ,#####@W###@`"); + "#n ,#####@W###@`", a); msg(" n########@ x####`*#####i `M####M ,###" - "#n x#########@`"); + "#n x#########@`", a); msg(" n######### x####`M####z :#####:,###" - "#n z#########@`"); + "#n z#########@`", a); msg(" n#########* x####,#####. n####+,###" - "#n n#########@`"); + "#n n#########@`", a); msg(" n####@####@, x####i####x ;####x,###" - "#n `W#####@####+++++++++++i"); + "#n `W#####@####+++++++++++i", a); msg(" n####*#####M` x#########* `####@,###" - "#n i#####MW###############W"); + "#n i#####MW###############W", a); msg(" n####.######+ x####z####; W####,###" - "#n i@######W###############W"); + "#n i@######W###############W", a); msg(" n####.`W#####: x####n####: M####:###" - "#@nnnnnW#######,W###############W"); + "#@nnnnnW#######,W###############W", a); msg(" n####. :#####M`x####z####; W####,###" - "##############z W###############W"); + "##############z W###############W", a); msg(" n####. #######x#########* `####W,###" - "#############W` W###############W"); + "#############W` W###############W", a); msg(" n####. `M#####W####i####x ;####x,###" - "############W, W####+**********i"); + "############W, W####+**********i", a); msg(" n####. ,##########,#####. n####+,###" - "###########n. W###@`"); + "###########n. W###@`", a); msg(" n####. ##########`M####z :#####:,###" - "########Wz: W###@`"); + "########Wz: W###@`", a); msg(" n####. x#########`*#####i `M####M ,###" - "#x.....` W###@`"); + "#x.....` W###@`", a); msg(" n####. ,@########``@####@; `x#####i ,###" - "#n W###@`"); + "#n W###@`", a); msg(" n####. *########` *#####@+` ,M#####M ,###" - "#n W###@`"); + "#n W###@`", a); msg(" n####. x#######` x######W*. `;n######@: ,###" - "#n W###@,,,,,,,,,,,,`"); + "#n W###@,,,,,,,,,,,,`", a); msg(" n####. .@######` .#########@W@########* ,###" - "#n W################,"); + "#n W################,", a); msg(" n####. i######` @################### ,###" - "#n W################,"); + "#n W################,", a); msg(" n####. n#####` ,W#################+ ,###" - "#n W################,"); + "#n W################,", a); msg(" n####. .@####` .n##############W; ,###" - "#n W################,"); + "#n W################,", a); msg(" n####. i####` :x##########W+` ,###" - "#n W################,"); + "#n W################,", a); msg(" +nnnn` +nnn` ,+x@##@Mz;` .nnn" - "n+ zxxxxxxxxxxxxxxxx."); - msg(" "); + "n+ zxxxxxxxxxxxxxxxx.", a); + msg(" ", a); msg(" " - " ,+M@#Mi"); + " ,+M@#Mi", a); msg(" " - " .z########"); + " .z########", a); msg(" " - " i@#########i"); + " i@#########i", a); msg(" " - " `############W`"); + " `############W`", a); msg(" " - " `n#############i"); + " `n#############i", a); msg(" " - " `n##############n"); + " `n##############n", a); msg(" `` " - " z###############@`"); + " z###############@`", a); msg(" `W@z, " - " ##################,"); + " ##################,", a); msg(" *#####` " - " i############@x@###i"); + " i############@x@###i", a); msg(" ######M. " - " :#############n`,W##+"); + " :#############n`,W##+", a); msg(" +######@: " - " .W#########M@##+ *##z"); + " .W#########M@##+ *##z", a); msg(" :#######@: " - " `x########@#x###* ,##n"); + " `x########@#x###* ,##n", a); msg(" `@#######@; " - " z#########M*@nW#i .##x"); + " z#########M*@nW#i .##x", a); msg(" z########@i " - " *###########WM#@#, `##x"); + " *###########WM#@#, `##x", a); msg(" i##########+ " - " ;###########*n###@ `##x"); + " ;###########*n###@ `##x", a); msg(" `@#MM#######x, " - " ,@#########zM,`z##M `@#x"); + " ,@#########zM,`z##M `@#x", a); msg(" n##M#W#######n. " - " `.:i*+#zzzz##+i:.` ,W#########Wii,`n@#@` n@##n"); + " `.:i*+#zzzz##+i:.` ,W#########Wii,`n@#@` n@##n", a); msg(" ;###@#x#######n `,i" - "#nW@#####@@WWW@@####@Mzi. ,W##########@z.. ;zM#+i####z"); + "#nW@#####@@WWW@@####@Mzi. ,W##########@z.. ;zM#+i####z", a); msg(" x####nz######## .;#x@##" - "@Wn#*;,.` ``,:*#x@##M+, ;@########xz@WM+#` `n@#######"); + "@Wn#*;,.` ``,:*#x@##M+, ;@########xz@WM+#` `n@#######", a); msg(" ,@####M########xi#@##@Mzi," - "` .+x###Mi:n##########Mz```.:i *@######*"); + "` .+x###Mi:n##########Mz```.:i *@######*", a); msg(" *#####W#########ix+:` " - " :n#############z: `*.`M######i"); + " :n#############z: `*.`M######i", a); msg(" i#W##nW@+@##@#M@; " - " ;W@@##########W, i`x@#####,"); + " ;W@@##########W, i`x@#####,", a); msg(" `@@n@Wn#@iMW*#*: " - " `iz#z@######x. M######`"); + " `iz#z@######x. M######`", a); msg(" z##zM###x`*, .` " - " `iW#####W;:` +#####M"); + " `iW#####W;:` +#####M", a); msg(" ,###nn##n` " - " ,#####x;` ,;@######"); + " ,#####x;` ,;@######", a); msg(" x###xz#. " - " in###+ `:######@."); + " in###+ `:######@.", a); msg(" ;####n+ " - " `Mnx##xi` , zM#######"); + " `Mnx##xi` , zM#######", a); msg(" `W####+ " - "i. `.+x###@#. :n,z######:"); + "i. `.+x###@#. :n,z######:", a); msg(" z####@` ;" - "#: .ii@###@;.*M*z####@`"); + "#: .ii@###@;.*M*z####@`", a); msg(" i####M ` `i@" - "#, :: +#n##@+@##W####n"); + "#, :: +#n##@+@##W####n", a); msg(" :####x ,i. ##xzM###" - "@` i. .@@, .z####x#######*"); + "@` i. .@@, .z####x#######*", a); msg(" ,###W; i##Wz########" - "# :## z##n ,@########x###:"); + "# :## z##n ,@########x###:", a); msg(" n##n `W###########M" - "`;n, i#x ,###@i *W########W#@`"); + "`;n, i#x ,###@i *W########W#@`", a); msg(" .@##+ `x###########@." - " z#+ .M#W``x#####n` `;#######@z#x"); + " z#+ .M#W``x#####n` `;#######@z#x", a); msg(" n###z :W############@ " - " z#* @##xM#######@n; `########nW+"); + " z#* @##xM#######@n; `########nW+", a); msg(" ;####nW##############W " - ":@#* `@#############* :########z@i`"); + ":@#* `@#############* :########z@i`", a); msg(" M##################### " - "M##: @#############@: *W########M#"); + "M##: @#############@: *W########M#", a); msg(" ;#####################i." - "##x` W#############W, :n########zx"); + "##x` W#############W, :n########zx", a); msg(" x####################@.`" - "x; @#############z. .@########W#"); + "x; @#############z. .@########W#", a); msg(" ,######################` " - " W###############x*,` W######zM#i"); + " W###############x*,` W######zM#i", a); msg(" #######################: " - " z##################@x+*#zzi `@#########."); + " z##################@x+*#zzi `@#########.", a); msg(" W########W#z#M#########; " - " *##########################z :@#######@`"); + " *##########################z :@#######@`", a); msg(" `@#######x`;#z ,x#######; " - " z###########M###xnM@########* :M######@"); + " z###########M###xnM@########* :M######@", a); msg(" i########, x#@` z######; " - " *##########i *#@` `+########+` n######."); + " *##########i *#@` `+########+` n######.", a); msg(" n#######@` M##, `W#####. " - " *#########z ###; z########M: :W####n"); + " *#########z ###; z########M: :W####n", a); msg(" M#######M n##. x####x " - " `x########: z##+ M#########@; .n###+"); + " `x########: z##+ M#########@; .n###+", a); msg(" W#######@` :#W `@####: " - " `@######W i### ;###########@. n##n"); + " `@######W i### ;###########@. n##n", a); msg(" W########z` ,, .x####z " - " @######@` `W#; `W############* *###;"); + " @######@` `W#; `W############* *###;", a); msg(" `@#########Mi,:*n@####W` " - " W#######* .. `n#############i i###x"); + " W#######* .. `n#############i i###x", a); msg(" .#####################z " - " `@#######@*` .x############n:` ;####."); + " `@#######@*` .x############n:` ;####.", a); msg(" :####################x`,,` " - " `W#########@x#+#@#############i ,####:"); + " `W#########@x#+#@#############i ,####:", a); msg(" ;###################x#@###x" - "i` *############################: `####i"); + "i` *############################: `####i", a); msg(" i##################+#######" - "#M, x##########################@` W###i"); + "#M, x##########################@` W###i", a); msg(" *################@; @######" - "##@, .W#########################@ x###:"); + "##@, .W#########################@ x###:", a); msg(" .+M#############z. M######" - "###x ,W########################@` ####."); + "###x ,W########################@` ####.", a); msg(" *M*;z@########x: :W#####" - "##i .M########################i i###:"); + "##i .M########################i i###:", a); msg(" *##@z;#@####x: :z###" - "@i `########################x .###;"); + "@i `########################x .###;", a); msg(" *#####n;#@## ;##" - "* ,x#####################@` W##*"); + "* ,x#####################@` W##*", a); msg(" *#######n;* :M##" - "W*, *W####################` n##z"); + "W*, *W####################` n##z", a); msg(" i########@. ,*n####" - "###M*` `###################M *##M"); + "###M*` `###################M *##M", a); msg(" i########n `z#####@@" - "#####Wi ,M################; ,##@`"); + "#####Wi ,M################; ,##@`", a); msg(" ;WMWW@###* .x##@ni.``" - ".:+zW##z` `n##############z @##,"); + ".:+zW##z` `n##############z @##,", a); msg(" .*++*i;;;. .M#@+` " - " .##n `x############x` n##i"); + " .##n `x############x` n##i", a); msg(" :########* x#W, " - " *#+ *###########M` +##+"); + " *#+ *###########M` +##+", a); msg(" ,######### :#@: " - " ##: #nzzzzzzzzzz. :##x"); + " ##: #nzzzzzzzzzz. :##x", a); msg(" .#####Wz+` ##+ " - " `MM` .znnnnnnnnn. `@#@`"); + " `MM` .znnnnnnnnn. `@#@`", a); msg(" `@@ni;*nMz` @W` " - " :#+ .x#######n x##,"); + " :#+ .x#######n x##,", a); msg(" i;z@#####, .#* " - " z#: ;;;*zW##; ###i"); + " z#: ;;;*zW##; ###i", a); msg(" z########: :#; " - " `Wx +###Wni;n. ;##z"); + " `Wx +###Wni;n. ;##z", a); msg(" n########W: .#* " - " ,#, ;#######@+ `@#M"); + " ,#, ;#######@+ `@#M", a); msg(" .###########n;.MM " - " n* ;iM#######* x#@`"); + " n* ;iM#######* x#@`", a); msg(" :#############@;; " - " .n` ,#W*iW#####W` +##,"); + " .n` ,#W*iW#####W` +##,", a); msg(" ,##############. " - " ix. `x###M;####### ,##i"); + " ix. `x###M;####### ,##i", a); msg(" .#############@` " - " x@n**#W######z;M###@. W##"); + " x@n**#W######z;M###@. W##", a); msg(" .##############W: " - " .x############@*;zW#; z#x"); + " .x############@*;zW#; z#x", a); msg(" ,###############@; " - " `##############@n*;. i#@"); + " `##############@n*;. i#@", a); msg(" ,#################i " - " :n##############W` .##,"); + " :n##############W` .##,", a); msg(" ,###################` " - " .+W##########W, `##i"); + " .+W##########W, `##i", a); msg(" :###################@zi,` " - " ;zM@@@WMn*` @#z"); + " ;zM@@@WMn*` @#z", a); msg(" :#######################@x+" - "*i;;:i#M, `` M#W"); + "*i;;:i#M, `` M#W", a); msg(" ;##########################" - "######@x. n##,"); + "######@x. n##,", a); msg(" i#####################@W@@@" - "@Wxz*:` *##+"); + "@Wxz*:` *##+", a); msg(" *######################+```" - " :##M"); + " :##M", a); msg(" ########################M; " - " `@##,"); + " `@##,", a); msg(" z#########################x" - ", z###"); + ", z###", a); msg(" n##########################" - "#n: ;##W`"); + "#n: ;##W`", a); msg(" x##########################" - "###Mz#++##* `W##i"); + "###Mz#++##* `W##i", a); msg(" M##########################" - "##########@` ###x"); + "##########@` ###x", a); msg(" W##########################" - "###########` .###,"); + "###########` .###,", a); msg(" @##########################" - "##########M n##z"); + "##########M n##z", a); msg(" @##################z*i@WMMM" - "x#x@#####,. :##@."); + "x#x@#####,. :##@.", a); msg(" `#####################@xi` " - " `::,* x##+"); + " `::,* x##+", a); msg(" .#####################@#M. " - " ;##@`"); + " ;##@`", a); msg(" ,#####################:. " - " M##i"); + " M##i", a); msg(" ;###################ni` " - " i##M"); + " i##M", a); msg(" *#################W#` " - " `W##,"); + " `W##,", a); msg(" z#################@Wx+. " - " +###"); + " +###", a); msg(" x######################z. " - " .@#@`"); + " .@#@`", a); msg(" `@#######################@; " - " z##;"); + " z##;", a); msg(" :##########################: " - " :##z"); + " :##z", a); msg(" +#########################W# " - " M#W"); + " M#W", a); msg(" W################@n+*i;:,` " - " +##,"); + " +##,", a); msg(" :##################WMxz+, " - " ,##i"); + " ,##i", a); msg(" n#######################W.., " - " W##"); + " W##", a); msg(" +#########################WW@+. .:. " - " z#x"); + " z#x", a); msg(" `@#############################@@###: " - " *#W"); + " *#W", a); msg(" #################################Wz: " - " :#@"); + " :#@", a); msg(",@###############################i " - " .##"); + " .##", a); msg("n@@@@@@@#########################+ " - " `##"); + " `##", a); msg("` `.:.`.,:iii;;;;;;;;iii;;;:` `.`` " - " `nW"); + " `nW", a); } /// Get argt of command with id diff --git a/src/nvim/ex_docmd.h b/src/nvim/ex_docmd.h index 711fc4ba52..0fd14c81d3 100644 --- a/src/nvim/ex_docmd.h +++ b/src/nvim/ex_docmd.h @@ -5,6 +5,7 @@ #include "nvim/buffer_defs.h" #include "nvim/ex_cmds_defs.h" +#include "nvim/getchar_defs.h" #include "nvim/globals.h" // flags for do_cmdline() diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 0704b47d40..b49563f44d 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -16,7 +16,6 @@ #include "nvim/debugger.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/eval/userfunc.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" @@ -26,12 +25,11 @@ #include "nvim/globals.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/pos.h" #include "nvim/regexp.h" #include "nvim/runtime.h" #include "nvim/strings.h" -#include "nvim/types.h" #include "nvim/vim.h" #ifdef INCLUDE_GENERATED_DECLARATIONS @@ -497,7 +495,7 @@ static int throw_exception(void *value, except_type_T type, char *cmdname) if (debug_break_level > 0 || *p_vfile == NUL) { msg_scroll = true; // always scroll up, don't overwrite } - smsg(_("Exception thrown: %s"), excp->value); + smsg(0, _("Exception thrown: %s"), excp->value); msg_puts("\n"); // don't overwrite this either if (debug_break_level > 0 || *p_vfile == NUL) { @@ -548,7 +546,7 @@ static void discard_exception(except_T *excp, bool was_finished) if (debug_break_level > 0 || *p_vfile == NUL) { msg_scroll = true; // always scroll up, don't overwrite } - smsg(was_finished ? _("Exception finished: %s") : _("Exception discarded: %s"), excp->value); + smsg(0, was_finished ? _("Exception finished: %s") : _("Exception discarded: %s"), excp->value); msg_puts("\n"); // don't overwrite this either if (debug_break_level > 0 || *p_vfile == NUL) { cmdline_row = msg_row; @@ -615,7 +613,7 @@ static void catch_exception(except_T *excp) if (debug_break_level > 0 || *p_vfile == NUL) { msg_scroll = true; // always scroll up, don't overwrite } - smsg(_("Exception caught: %s"), excp->value); + smsg(0, _("Exception caught: %s"), excp->value); msg_puts("\n"); // don't overwrite this either if (debug_break_level > 0 || *p_vfile == NUL) { @@ -732,7 +730,7 @@ static void report_pending(int action, int pending, void *value) } no_wait_return++; msg_scroll = true; // always scroll up, don't overwrite - smsg(mesg, s); + smsg(0, mesg, s); msg_puts("\n"); // don't overwrite this either cmdline_row = msg_row; no_wait_return--; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 09781f392a..6fa607d569 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -7,6 +7,7 @@ #include <inttypes.h> #include <limits.h> #include <stdbool.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> @@ -45,6 +46,7 @@ #include "nvim/highlight_group.h" #include "nvim/keycodes.h" #include "nvim/macros.h" +#include "nvim/map.h" #include "nvim/mapping.h" #include "nvim/mark.h" #include "nvim/mbyte.h" @@ -56,6 +58,8 @@ #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/os/os.h" @@ -127,7 +131,7 @@ typedef struct command_line_state { int ignore_drag_release; int break_ctrl_c; expand_T xpc; - long *b_im_ptr; + OptInt *b_im_ptr; buf_T *b_im_ptr_buf; ///< buffer where b_im_ptr is valid } CommandLineState; @@ -149,7 +153,7 @@ typedef struct cmdpreview_undo_info { typedef struct cmdpreview_buf_info { buf_T *buf; - long save_b_p_ul; + OptInt save_b_p_ul; int save_b_changed; varnumber_T save_changedtick; CpUndoInfo undo_info; @@ -1560,7 +1564,7 @@ static int command_line_erase_chars(CommandLineState *s) /// language :lmap mappings and/or Input Method. static void command_line_toggle_langmap(CommandLineState *s) { - long *b_im_ptr = buf_valid(s->b_im_ptr_buf) ? s->b_im_ptr : NULL; + OptInt *b_im_ptr = buf_valid(s->b_im_ptr_buf) ? s->b_im_ptr : NULL; if (map_to_exists_mode("", MODE_LANGMAP, false)) { // ":lmap" mappings exists, toggle use of mappings. State ^= MODE_LANGMAP; @@ -2664,7 +2668,7 @@ static void abandon_cmdline(void) if (msg_scrolled == 0) { compute_cmdrow(); } - msg(""); + msg("", 0); redraw_cmdline = true; } @@ -3400,7 +3404,7 @@ static void draw_cmdline(int start, int len) } } - msg_outtrans_len(arshape_buf, newlen); + msg_outtrans_len(arshape_buf, newlen, 0); } else { draw_cmdline_no_arabicshape: if (kv_size(ccline.last_colors.colors)) { @@ -3410,12 +3414,10 @@ draw_cmdline_no_arabicshape: continue; } const int chunk_start = MAX(chunk.start, start); - msg_outtrans_len_attr(ccline.cmdbuff + chunk_start, - chunk.end - chunk_start, - chunk.attr); + msg_outtrans_len(ccline.cmdbuff + chunk_start, chunk.end - chunk_start, chunk.attr); } } else { - msg_outtrans_len(ccline.cmdbuff + start, len); + msg_outtrans_len(ccline.cmdbuff + start, len, 0); } } } diff --git a/src/nvim/ex_getln.h b/src/nvim/ex_getln.h index b21fb0506d..aaafedcb4b 100644 --- a/src/nvim/ex_getln.h +++ b/src/nvim/ex_getln.h @@ -6,6 +6,7 @@ #include "klib/kvec.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" +#include "nvim/option_defs.h" #include "nvim/types.h" struct cmdline_info; diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index e2a4f73840..bbe57b486d 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -7,9 +7,7 @@ // :mkview // :mksession -#include <assert.h> #include <inttypes.h> -#include <limits.h> #include <stdbool.h> #include <stdio.h> #include <string.h> @@ -30,10 +28,10 @@ #include "nvim/globals.h" #include "nvim/macros.h" #include "nvim/mapping.h" -#include "nvim/mark_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/os.h" #include "nvim/path.h" #include "nvim/pos.h" diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c index 5140fe199e..fd9c2e8fe0 100644 --- a/src/nvim/extmark.c +++ b/src/nvim/extmark.c @@ -31,6 +31,7 @@ #include <assert.h> #include <sys/types.h> +#include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index b5cdeff21c..7a46341797 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -47,16 +47,15 @@ #include <inttypes.h> #include <limits.h> #include <stdbool.h> +#include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "nvim/ascii.h" #include "nvim/autocmd.h" -#include "nvim/buffer_defs.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/file_search.h" #include "nvim/gettext.h" #include "nvim/globals.h" @@ -65,12 +64,12 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/fs_defs.h" #include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/path.h" #include "nvim/strings.h" -#include "nvim/types.h" #include "nvim/vim.h" #include "nvim/window.h" @@ -615,7 +614,7 @@ char *vim_findfile(void *search_ctx_arg) #ifdef FF_VERBOSE if (p_verbose >= 5) { verbose_enter_scroll(); - smsg("Already Searched: %s (%s)", + smsg(0, "Already Searched: %s (%s)", stackp->ffs_fix_path, stackp->ffs_wc_path); msg_puts("\n"); // don't overwrite this either verbose_leave_scroll(); @@ -626,7 +625,7 @@ char *vim_findfile(void *search_ctx_arg) #ifdef FF_VERBOSE } else if (p_verbose >= 5) { verbose_enter_scroll(); - smsg("Searching: %s (%s)", + smsg(0, "Searching: %s (%s)", stackp->ffs_fix_path, stackp->ffs_wc_path); msg_puts("\n"); // don't overwrite this either verbose_leave_scroll(); @@ -798,7 +797,7 @@ char *vim_findfile(void *search_ctx_arg) file_path, "") == FAIL) { if (p_verbose >= 5) { verbose_enter_scroll(); - smsg("Already: %s", file_path); + smsg(0, "Already: %s", file_path); msg_puts("\n"); // don't overwrite this either verbose_leave_scroll(); } @@ -823,7 +822,7 @@ char *vim_findfile(void *search_ctx_arg) #ifdef FF_VERBOSE if (p_verbose >= 5) { verbose_enter_scroll(); - smsg("HIT: %s", file_path); + smsg(0, "HIT: %s", file_path); msg_puts("\n"); // don't overwrite this either verbose_leave_scroll(); } @@ -986,7 +985,7 @@ static ff_visited_list_hdr_T *ff_get_visited_list(char *filename, #ifdef FF_VERBOSE if (p_verbose >= 5) { verbose_enter_scroll(); - smsg("ff_get_visited_list: FOUND list for %s", filename); + smsg(0, "ff_get_visited_list: FOUND list for %s", filename); msg_puts("\n"); // don't overwrite this either verbose_leave_scroll(); } @@ -1000,7 +999,7 @@ static ff_visited_list_hdr_T *ff_get_visited_list(char *filename, #ifdef FF_VERBOSE if (p_verbose >= 5) { verbose_enter_scroll(); - smsg("ff_get_visited_list: new list for %s", filename); + smsg(0, "ff_get_visited_list: new list for %s", filename); msg_puts("\n"); // don't overwrite this either verbose_leave_scroll(); } diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 7ff3e0ec6e..4e8b7be4aa 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -47,6 +47,7 @@ #include "nvim/message.h" #include "nvim/move.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/fs_defs.h" #include "nvim/os/input.h" @@ -118,7 +119,7 @@ void filemess(buf_T *buf, char *name, char *s, int attr) msg_scroll = msg_scroll_save; msg_scrolled_ign = true; // may truncate the message to avoid a hit-return prompt - msg_outtrans_attr(msg_may_trunc(false, IObuff), attr); + msg_outtrans(msg_may_trunc(false, IObuff), attr); msg_clr_eos(); ui_flush(); msg_scrolled_ign = false; @@ -1762,7 +1763,7 @@ failed: if (msg_col > 0) { msg_putchar('\r'); // overwrite previous message } - p = (uint8_t *)msg_trunc_attr(IObuff, false, 0); + p = (uint8_t *)msg_trunc(IObuff, false, 0); } if (read_stdin || read_buffer || restart_edit != 0 @@ -2035,7 +2036,7 @@ static char *readfile_charconvert(char *fname, char *fenc, int *fdp) if (errmsg != NULL) { // Don't use emsg(), it breaks mappings, the retry with // another type of conversion might still work. - msg(errmsg); + msg(errmsg, 0); if (tmpname != NULL) { os_remove(tmpname); // delete converted file XFREE_CLEAR(tmpname); @@ -3279,12 +3280,18 @@ static void vim_mktempdir(void) char tmp[TEMP_FILE_PATH_MAXLEN]; char path[TEMP_FILE_PATH_MAXLEN]; char user[40] = { 0 }; + char appname[40] = { 0 }; (void)os_get_username(user, sizeof(user)); // Usernames may contain slashes! #19240 memchrsub(user, '/', '_', sizeof(user)); memchrsub(user, '\\', '_', sizeof(user)); + // Appname may be a relative path, replace slashes to make it name-like. + xstrlcpy(appname, get_appname(), sizeof(appname)); + memchrsub(appname, '/', '%', sizeof(appname)); + memchrsub(appname, '\\', '%', sizeof(appname)); + // Make sure the umask doesn't remove the executable bit. // "repl" has been reported to use "0177". mode_t umask_save = umask(0077); @@ -3298,7 +3305,6 @@ static void vim_mktempdir(void) // "/tmp/" exists, now try to create "/tmp/nvim.<user>/". add_pathsep(tmp); - const char *appname = get_appname(); xstrlcat(tmp, appname, sizeof(tmp)); xstrlcat(tmp, ".", sizeof(tmp)); xstrlcat(tmp, user, sizeof(tmp)); @@ -3358,7 +3364,7 @@ int readdir_core(garray_T *gap, const char *path, void *context, CheckItem check Directory dir; if (!os_scandir(&dir, path)) { - smsg(_(e_notopen), path); + smsg(0, _(e_notopen), path); return FAIL; } diff --git a/src/nvim/fold.c b/src/nvim/fold.c index d874e904d0..6a9dbe9edc 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -12,7 +12,10 @@ #include <stdlib.h> #include <string.h> +#include "klib/kvec.h" #include "nvim/api/extmark.h" +#include "nvim/api/private/defs.h" +#include "nvim/api/private/helpers.h" #include "nvim/ascii.h" #include "nvim/buffer_defs.h" #include "nvim/buffer_updates.h" @@ -24,7 +27,6 @@ #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_session.h" #include "nvim/extmark.h" #include "nvim/fold.h" @@ -39,9 +41,10 @@ #include "nvim/message.h" #include "nvim/move.h" #include "nvim/ops.h" -#include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/input.h" #include "nvim/plines.h" +#include "nvim/pos.h" #include "nvim/search.h" #include "nvim/strings.h" #include "nvim/syntax.h" diff --git a/src/nvim/fold.h b/src/nvim/fold.h index cf44cf14c3..ee7501f845 100644 --- a/src/nvim/fold.h +++ b/src/nvim/fold.h @@ -4,6 +4,7 @@ #include <stdio.h> #include "nvim/buffer_defs.h" +#include "nvim/fold_defs.h" #include "nvim/garray.h" #include "nvim/macros.h" #include "nvim/pos.h" diff --git a/src/nvim/garray.c b/src/nvim/garray.c index aa9a44d410..4df6ec2431 100644 --- a/src/nvim/garray.c +++ b/src/nvim/garray.c @@ -5,6 +5,7 @@ /// /// Functions for handling growing arrays. +#include <stdint.h> #include <string.h> #include "nvim/garray.h" @@ -12,7 +13,6 @@ #include "nvim/memory.h" #include "nvim/path.h" #include "nvim/strings.h" -#include "nvim/types.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "garray.c.generated.h" // IWYU pragma: export diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua index cb6f9b6af9..0932a1357f 100644 --- a/src/nvim/generators/gen_options.lua +++ b/src/nvim/generators/gen_options.lua @@ -188,7 +188,19 @@ local function dump_option(i, o) w(' },') end -w('static vimoption_T options[] = {') +w([[ +#include "nvim/ex_getln.h" +#include "nvim/insexpand.h" +#include "nvim/mapping.h" +#include "nvim/ops.h" +#include "nvim/option.h" +#include "nvim/optionstr.h" +#include "nvim/quickfix.h" +#include "nvim/runtime.h" +#include "nvim/tag.h" +#include "nvim/window.h" + +static vimoption_T options[] = {]]) for i, o in ipairs(options.options) do dump_option(i, o) end diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 779ba0f90d..b696f8ab37 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -5,9 +5,10 @@ // file, manipulations with redo buffer and stuff buffer. #include <assert.h> -#include <inttypes.h> +#include <limits.h> #include <stdbool.h> #include <stddef.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -24,7 +25,6 @@ #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" -#include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" #include "nvim/ex_cmds.h" #include "nvim/ex_docmd.h" @@ -48,7 +48,7 @@ #include "nvim/move.h" #include "nvim/normal.h" #include "nvim/ops.h" -#include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/fileio.h" #include "nvim/os/input.h" #include "nvim/os/os.h" @@ -2695,9 +2695,9 @@ static int vgetorpeek(bool advance) // blocking wait wait_time = -1L; } else if (keylen == KEYLEN_PART_KEY && p_ttm >= 0) { - wait_time = p_ttm; + wait_time = (long)p_ttm; } else { - wait_time = p_tm; + wait_time = (long)p_tm; } } diff --git a/src/nvim/grid.c b/src/nvim/grid.c index 2eeefab27d..712688368b 100644 --- a/src/nvim/grid.c +++ b/src/nvim/grid.c @@ -13,17 +13,23 @@ #include <assert.h> #include <limits.h> +#include <stdint.h> #include <stdlib.h> +#include <string.h> +#include "nvim/api/private/defs.h" #include "nvim/arabic.h" +#include "nvim/ascii.h" #include "nvim/buffer_defs.h" #include "nvim/drawscreen.h" #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/highlight.h" #include "nvim/log.h" +#include "nvim/map.h" +#include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/types.h" #include "nvim/ui.h" #include "nvim/vim.h" @@ -190,21 +196,16 @@ void grid_invalidate(ScreenGrid *grid) (void)memset(grid->attrs, -1, sizeof(sattr_T) * (size_t)grid->rows * (size_t)grid->cols); } -bool grid_invalid_row(ScreenGrid *grid, int row) +static bool grid_invalid_row(ScreenGrid *grid, int row) { return grid->attrs[grid->line_offset[row]] < 0; } -static int line_off2cells(schar_T *line, size_t off, size_t max_off) -{ - return (off + 1 < max_off && line[off + 1] == 0) ? 2 : 1; -} - /// Return number of display cells for char at grid->chars[off]. /// We make sure that the offset used is less than "max_off". static int grid_off2cells(ScreenGrid *grid, size_t off, size_t max_off) { - return line_off2cells(grid->chars, off, max_off); + return (off + 1 < max_off && grid->chars[off + 1] == 0) ? 2 : 1; } /// Return true if the character at "row"/"col" on the screen is the left side @@ -261,18 +262,12 @@ void grid_getbytes(ScreenGrid *grid, int row, int col, char *bytes, int *attrp) schar_get(bytes, grid->chars[off]); } -static bool check_grid(ScreenGrid *grid, int row, int col) -{ - grid_adjust(&grid, &row, &col); - // Safety check. The check for negative row and column is to fix issue - // vim/vim#4102. TODO(neovim): find out why row/col could be negative. - if (grid->chars == NULL - || row >= grid->rows || row < 0 - || col >= grid->cols || col < 0) { - return false; - } - return true; -} +static ScreenGrid *grid_line_grid = NULL; +static int grid_line_row = -1; +static int grid_line_coloff = 0; +static int grid_line_maxcol = 0; +static int grid_line_first = INT_MAX; +static int grid_line_last = 0; /// put string 'text' on the window grid at position 'row' and 'col', with /// attributes 'attr', and update contents of 'grid' @@ -280,26 +275,32 @@ static bool check_grid(ScreenGrid *grid, int row, int col) /// Note: only outputs within one row! int grid_puts(ScreenGrid *grid, const char *text, int textlen, int row, int col, int attr) { - if (!check_grid(grid, row, col)) { + grid_line_start(grid, row); + + // Safety check. The check for negative row and column is to fix issue + // vim/vim#4102. TODO(neovim): find out why row/col could be negative. + int off_col = grid_line_coloff + col; + if (grid_line_grid->chars == NULL + || grid_line_row >= grid_line_grid->rows || grid_line_row < 0 + || off_col >= grid_line_grid->cols || off_col < 0) { if (rdb_flags & RDB_INVALID) { abort(); + } else { + grid_line_grid = NULL; + return 0; } - return 0; } - grid_line_start(grid, row); int len = grid_line_puts(col, text, textlen, attr); - grid_line_flush(true); + if (grid_line_last > grid_line_first) { + // TODO(bfredl): this is bullshit. message.c should manage its own cursor movements + int col_pos = MIN(grid_line_coloff + grid_line_last, grid_line_grid->cols - 1); + ui_grid_cursor_goto(grid_line_grid->handle, grid_line_row, col_pos); + } + grid_line_flush(); return len; } -static ScreenGrid *grid_line_grid = NULL; -static int grid_line_row = -1; -static int grid_line_coloff = 0; -static int grid_line_first = INT_MAX; -static int grid_line_last = 0; -static bool grid_line_was_invalid = false; - /// Start a group of grid_line_puts calls that builds a single grid line. /// /// Must be matched with a grid_line_flush call before moving to @@ -308,56 +309,46 @@ void grid_line_start(ScreenGrid *grid, int row) { int col = 0; grid_adjust(&grid, &row, &col); - assert(grid_line_row == -1); + assert(grid_line_grid == NULL); grid_line_row = row; grid_line_grid = grid; grid_line_coloff = col; - // TODO(bfredl): ugly hackaround, will be fixed in STAGE 2 - grid_line_was_invalid = grid != &default_grid && grid_invalid_row(grid, row); + grid_line_first = (int)linebuf_size; + grid_line_maxcol = grid->cols - grid_line_coloff; + grid_line_last = 0; } void grid_line_put_schar(int col, schar_T schar, int attr) { - assert(grid_line_row >= 0); - ScreenGrid *grid = grid_line_grid; + assert(grid_line_grid); - size_t off = grid->line_offset[grid_line_row] + (size_t)col; - if (grid->attrs[off] != attr || grid->chars[off] != schar || rdb_flags & RDB_NODELTA) { - grid->chars[off] = schar; - grid->attrs[off] = attr; + linebuf_char[col] = schar; + linebuf_attr[col] = attr; - grid_line_first = MIN(grid_line_first, col); - // TODO(bfredl): Y U NO DOUBLEWIDTH? - grid_line_last = MAX(grid_line_last, col + 1); - } - grid->vcols[off] = -1; + grid_line_first = MIN(grid_line_first, col); + // TODO(bfredl): Y U NO DOUBLEWIDTH? + grid_line_last = MAX(grid_line_last, col + 1); + linebuf_vcol[col] = -1; } /// like grid_puts(), but output "text[len]". When "len" is -1 output up to /// a NUL. int grid_line_puts(int col, const char *text, int textlen, int attr) { - size_t off; const char *ptr = text; int len = textlen; int c; - size_t max_off; int u8cc[MAX_MCO]; - bool clear_next_cell = false; int prev_c = 0; // previous Arabic character int pc, nc, nc1; int pcc[MAX_MCO]; - assert(grid_line_row >= 0); - ScreenGrid *grid = grid_line_grid; - int row = grid_line_row; - col += grid_line_coloff; + assert(grid_line_grid); - off = grid->line_offset[row] + (size_t)col; int start_col = col; - max_off = grid->line_offset[row] + (size_t)grid->cols; - while (col < grid->cols + int max_col = grid_line_maxcol; + while (col < max_col && (len < 0 || (int)(ptr - text) < len) && *ptr != NUL) { c = (unsigned char)(*ptr); @@ -394,7 +385,7 @@ int grid_line_puts(int col, const char *text, int textlen, int attr) } else { prev_c = u8c; } - if (col + mbyte_cells > grid->cols) { + if (col + mbyte_cells > max_col) { // Only 1 cell left, but character requires 2 cells: // display a '>' in the last column to avoid wrapping. */ c = '>'; @@ -408,55 +399,29 @@ int grid_line_puts(int col, const char *text, int textlen, int attr) // an edge case, treat it as such.. buf = schar_from_cc(u8c, u8cc); - int need_redraw = grid->chars[off] != buf - || (mbyte_cells == 2 && grid->chars[off + 1] != 0) - || grid->attrs[off] != attr - || exmode_active - || rdb_flags & RDB_NODELTA; - - if (need_redraw) { - // When at the end of the text and overwriting a two-cell - // character with a one-cell character, need to clear the next - // cell. Also when overwriting the left half of a two-cell char - // with the right half of a two-cell char. Do this only once - // (utf8_off2cells() may return 2 on the right half). - if (clear_next_cell) { - clear_next_cell = false; - } else if ((len < 0 ? ptr[mbyte_blen] == NUL : ptr + mbyte_blen >= text + len) - && ((mbyte_cells == 1 - && grid_off2cells(grid, off, max_off) > 1) - || (mbyte_cells == 2 - && grid_off2cells(grid, off, max_off) == 1 - && grid_off2cells(grid, off + 1, max_off) > 1))) { - clear_next_cell = true; - } - - // When at the start of the text and overwriting the right half of a - // two-cell character in the same grid, truncate that into a '>'. - if (ptr == text && col > 0 && grid->chars[off] == 0) { - grid->chars[off - 1] = schar_from_ascii('>'); - } + // When at the start of the text and overwriting the right half of a + // two-cell character in the same grid, truncate that into a '>'. + if (ptr == text && col > grid_line_first && col < grid_line_last + && linebuf_char[col] == 0) { + linebuf_char[col - 1] = schar_from_ascii('>'); + } - grid->chars[off] = buf; - grid->attrs[off] = attr; - grid->vcols[off] = -1; - if (mbyte_cells == 2) { - grid->chars[off + 1] = 0; - grid->attrs[off + 1] = attr; - grid->vcols[off + 1] = -1; - } - grid_line_first = MIN(grid_line_first, col); - grid_line_last = MAX(grid_line_last, col + mbyte_cells); + linebuf_char[col] = buf; + linebuf_attr[col] = attr; + linebuf_vcol[col] = -1; + if (mbyte_cells == 2) { + linebuf_char[col + 1] = 0; + linebuf_attr[col + 1] = attr; + linebuf_vcol[col + 1] = -1; } - off += (size_t)mbyte_cells; col += mbyte_cells; ptr += mbyte_blen; - if (clear_next_cell) { - // This only happens at the end, display one space next. - ptr = " "; - len = -1; - } + } + + if (col > start_col) { + grid_line_first = MIN(grid_line_first, start_col); + grid_line_last = MAX(grid_line_last, col); } return col - start_col; @@ -464,56 +429,30 @@ int grid_line_puts(int col, const char *text, int textlen, int attr) void grid_line_fill(int start_col, int end_col, int c, int attr) { - ScreenGrid *grid = grid_line_grid; - size_t lineoff = grid->line_offset[grid_line_row]; - start_col += grid_line_coloff; - end_col += grid_line_coloff; - schar_T sc = schar_from_char(c); for (int col = start_col; col < end_col; col++) { - size_t off = lineoff + (size_t)col; - if (grid->chars[off] != sc || grid->attrs[off] != attr || rdb_flags & RDB_NODELTA) { - grid->chars[off] = sc; - grid->attrs[off] = attr; - grid_line_first = MIN(grid_line_first, col); - grid_line_last = MAX(grid_line_last, col + 1); - } - grid->vcols[off] = -1; + linebuf_char[col] = sc; + linebuf_attr[col] = attr; + linebuf_vcol[col] = -1; } + grid_line_first = MIN(grid_line_first, start_col); + grid_line_last = MAX(grid_line_last, end_col); } /// End a group of grid_line_puts calls and send the screen buffer to the UI layer. -/// -/// @param set_cursor Move the visible cursor to the end of the changed region. -/// This is a workaround for not yet refactored code paths -/// and shouldn't be used in new code. -void grid_line_flush(bool set_cursor) +void grid_line_flush(void) { - assert(grid_line_row != -1); - if (grid_line_first < grid_line_last) { - // When drawing over the right half of a double-wide char clear out the - // left half. Only needed in a terminal. - if (grid_line_was_invalid && grid_line_first == 0) { - // redraw the previous cell, make it empty - grid_line_first = -1; - } - if (set_cursor) { - ui_grid_cursor_goto(grid_line_grid->handle, grid_line_row, - MIN(grid_line_last, grid_line_grid->cols - 1)); - } - if (!grid_line_grid->throttled) { - ui_line(grid_line_grid, grid_line_row, grid_line_first, grid_line_last, - grid_line_last, 0, false); - } else if (grid_line_grid->dirty_col) { - if (grid_line_last > grid_line_grid->dirty_col[grid_line_row]) { - grid_line_grid->dirty_col[grid_line_row] = grid_line_last; - } - } - grid_line_first = INT_MAX; - grid_line_last = 0; - } - grid_line_row = -1; + ScreenGrid *grid = grid_line_grid; grid_line_grid = NULL; + if (!(grid_line_first < grid_line_last)) { + return; + } + + int row = grid_line_row; + + bool invalid_row = grid != &default_grid && grid_invalid_row(grid, row) && grid_line_first == 0; + grid_put_linebuf(grid, row, grid_line_coloff, grid_line_first, grid_line_last, grid_line_last, + false, 0, false, invalid_row); } /// Fill the grid from "start_row" to "end_row" (exclusive), from "start_col" @@ -607,13 +546,14 @@ void grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col, int /// - the attributes are different /// - the character is multi-byte and the next byte is different /// - the character is two cells wide and the second cell differs. -static int grid_char_needs_redraw(ScreenGrid *grid, size_t off_from, size_t off_to, int cols) +static int grid_char_needs_redraw(ScreenGrid *grid, int col, size_t off_to, int cols) { return (cols > 0 - && ((linebuf_char[off_from] != grid->chars[off_to] - || linebuf_attr[off_from] != grid->attrs[off_to] - || (line_off2cells(linebuf_char, off_from, off_from + (size_t)cols) > 1 - && linebuf_char[off_from + 1] != grid->chars[off_to + 1])) + && ((linebuf_char[col] != grid->chars[off_to] + || linebuf_attr[col] != grid->attrs[off_to] + || (cols > 1 && linebuf_char[col + 1] == 0 + && linebuf_char[col + 1] != grid->chars[off_to + 1])) + || exmode_active // TODO(bfredl): what in the actual fuck || rdb_flags & RDB_NODELTA)); } @@ -623,30 +563,27 @@ static int grid_char_needs_redraw(ScreenGrid *grid, size_t off_from, size_t off_ /// "endcol" gives the columns where valid characters are. /// "clear_width" is the width of the window. It's > 0 if the rest of the line /// needs to be cleared, negative otherwise. -/// "rlflag" is true in a rightleft window: +/// "rl" is true for rightleft text, like a window with 'rightleft' option set /// When true and "clear_width" > 0, clear columns 0 to "endcol" /// When false and "clear_width" > 0, clear columns "endcol" to "clear_width" /// If "wrap" is true, then hint to the UI that "row" contains a line /// which has wrapped into the next row. -void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int clear_width, - int rlflag, win_T *wp, int bg_attr, bool wrap) +void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int col, int endcol, int clear_width, + int rl, int bg_attr, bool wrap, bool invalid_row) { - int col = 0; bool redraw_next; // redraw_this for next character bool clear_next = false; - bool topline = row == 0; int char_cells; // 1: normal char // 2: occupies two display cells int start_dirty = -1, end_dirty = 0; - assert(row < grid->rows); + assert(0 <= row && row < grid->rows); // TODO(bfredl): check all callsites and eliminate // Check for illegal col, just in case if (endcol > grid->cols) { endcol = grid->cols; } - const size_t max_off_from = (size_t)grid->cols; grid_adjust(&grid, &row, &coloff); // Safety check. Avoids clang warnings down the call stack. @@ -655,45 +592,21 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int cle return; } - size_t off_from = 0; size_t off_to = grid->line_offset[row] + (size_t)coloff; const size_t max_off_to = grid->line_offset[row] + (size_t)grid->cols; - // Take care of putting "<<<" on the first line for 'smoothscroll'. - if (topline && wp->w_skipcol > 0 - // do not overwrite the 'showbreak' text with "<<<" - && *get_showbreak_value(wp) == NUL - // do not overwrite the 'listchars' "precedes" text with "<<<" - && !(wp->w_p_list && wp->w_p_lcs_chars.prec != 0)) { - size_t off = 0; - size_t skip = 0; - if (wp->w_p_nu && wp->w_p_rnu) { - // do not overwrite the line number, change "123 text" to - // "123<<<xt". - while (skip < max_off_from && ascii_isdigit(schar_get_ascii(linebuf_char[off]))) { - off++; - skip++; - } - } - - for (size_t i = 0; i < 3 && i + skip < max_off_from; i++) { - if (line_off2cells(linebuf_char, off, max_off_from) > 1) { - // When the first half of a double-width character is - // overwritten, change the second half to a space. - linebuf_char[off + 1] = schar_from_ascii(' '); - } - linebuf_char[off] = schar_from_ascii('<'); - linebuf_attr[off] = HL_ATTR(HLF_AT); - off++; - } + // When at the start of the text and overwriting the right half of a + // two-cell character in the same grid, truncate that into a '>'. + if (col > 0 && grid->chars[off_to + (size_t)col] == 0) { + linebuf_char[col - 1] = schar_from_ascii('>'); + col--; } - if (rlflag) { + if (rl) { // Clear rest first, because it's left of the text. if (clear_width > 0) { - while (col <= endcol && grid->chars[off_to] == schar_from_ascii(' ') - && grid->attrs[off_to] == bg_attr) { - off_to++; + while (col <= endcol && grid->chars[off_to + (size_t)col] == schar_from_ascii(' ') + && grid->attrs[off_to + (size_t)col] == bg_attr) { col++; } if (col <= endcol) { @@ -701,28 +614,26 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int cle } } col = endcol + 1; - off_to = grid->line_offset[row] + (size_t)col + (size_t)coloff; - off_from += (size_t)col; endcol = (clear_width > 0 ? clear_width : -clear_width); } if (bg_attr) { - assert(off_from == (size_t)col); for (int c = col; c < endcol; c++) { linebuf_attr[c] = hl_combine_attr(bg_attr, linebuf_attr[c]); } } - redraw_next = grid_char_needs_redraw(grid, off_from, off_to, endcol - col); + redraw_next = grid_char_needs_redraw(grid, col, (size_t)col + off_to, endcol - col); while (col < endcol) { char_cells = 1; - if (col + 1 < endcol) { - char_cells = line_off2cells(linebuf_char, off_from, max_off_from); + if (col + 1 < endcol && linebuf_char[col + 1] == 0) { + char_cells = 2; } bool redraw_this = redraw_next; // Does character need redraw? - redraw_next = grid_char_needs_redraw(grid, off_from + (size_t)char_cells, - off_to + (size_t)char_cells, + size_t off = (size_t)col + off_to; + redraw_next = grid_char_needs_redraw(grid, col + char_cells, + off + (size_t)char_cells, endcol - col - char_cells); if (redraw_this) { @@ -737,53 +648,52 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int cle // char over the left half of an existing one if (col + char_cells == endcol && ((char_cells == 1 - && grid_off2cells(grid, off_to, max_off_to) > 1) + && grid_off2cells(grid, off, max_off_to) > 1) || (char_cells == 2 - && grid_off2cells(grid, off_to, max_off_to) == 1 - && grid_off2cells(grid, off_to + 1, max_off_to) > 1))) { + && grid_off2cells(grid, off, max_off_to) == 1 + && grid_off2cells(grid, off + 1, max_off_to) > 1))) { clear_next = true; } - grid->chars[off_to] = linebuf_char[off_from]; + grid->chars[off] = linebuf_char[col]; if (char_cells == 2) { - grid->chars[off_to + 1] = linebuf_char[off_from + 1]; + grid->chars[off + 1] = linebuf_char[col + 1]; } - grid->attrs[off_to] = linebuf_attr[off_from]; + grid->attrs[off] = linebuf_attr[col]; // For simplicity set the attributes of second half of a // double-wide character equal to the first half. if (char_cells == 2) { - grid->attrs[off_to + 1] = linebuf_attr[off_from]; + grid->attrs[off + 1] = linebuf_attr[col]; } } - grid->vcols[off_to] = linebuf_vcol[off_from]; + grid->vcols[off] = linebuf_vcol[col]; if (char_cells == 2) { - grid->vcols[off_to + 1] = linebuf_vcol[off_from + 1]; + grid->vcols[off + 1] = linebuf_vcol[col + 1]; } - off_to += (size_t)char_cells; - off_from += (size_t)char_cells; col += char_cells; } if (clear_next) { // Clear the second half of a double-wide character of which the left // half was overwritten with a single-wide character. - grid->chars[off_to] = schar_from_ascii(' '); + grid->chars[(size_t)col + off_to] = schar_from_ascii(' '); end_dirty++; } int clear_end = -1; - if (clear_width > 0 && !rlflag) { + if (clear_width > 0 && !rl) { // blank out the rest of the line // TODO(bfredl): we could cache winline widths while (col < clear_width) { - if (grid->chars[off_to] != schar_from_ascii(' ') - || grid->attrs[off_to] != bg_attr + size_t off = (size_t)col + off_to; + if (grid->chars[off] != schar_from_ascii(' ') + || grid->attrs[off] != bg_attr || rdb_flags & RDB_NODELTA) { - grid->chars[off_to] = schar_from_ascii(' '); - grid->attrs[off_to] = bg_attr; + grid->chars[off] = schar_from_ascii(' '); + grid->attrs[off] = bg_attr; if (start_dirty == -1) { start_dirty = col; end_dirty = col; @@ -792,9 +702,8 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int cle } clear_end = col + 1; } - grid->vcols[off_to] = MAXCOL; + grid->vcols[off] = MAXCOL; col++; - off_to++; } } @@ -805,8 +714,22 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int cle start_dirty = end_dirty; } if (clear_end > start_dirty) { - ui_line(grid, row, coloff + start_dirty, coloff + end_dirty, coloff + clear_end, - bg_attr, wrap); + if (!grid->throttled) { + int start_pos = coloff + start_dirty; + // When drawing over the right half of a double-wide char clear out the + // left half. Only needed in a terminal. + if (invalid_row && start_pos == 0) { + start_pos = -1; + } + ui_line(grid, row, start_pos, coloff + end_dirty, coloff + clear_end, + bg_attr, wrap); + } else if (grid->dirty_col) { + // TODO(bfredl): really get rid of the extra psuedo terminal in message.c + // by using a linebuf_char copy for "throttled message line" + if (clear_end > grid->dirty_col[row]) { + grid->dirty_col[row] = clear_end; + } + } } } @@ -953,6 +876,7 @@ void win_grid_alloc(win_T *wp) if ((resizing_screen || was_resized) && want_allocation) { ui_call_grid_resize(grid_allocated->handle, grid_allocated->cols, grid_allocated->rows); + ui_check_cursor_grid(grid_allocated->handle); } } diff --git a/src/nvim/grid.h b/src/nvim/grid.h index 9cdc6c6677..6591d8acc0 100644 --- a/src/nvim/grid.h +++ b/src/nvim/grid.h @@ -10,6 +10,7 @@ #include "nvim/macros.h" #include "nvim/mbyte.h" #include "nvim/memory.h" +#include "nvim/pos.h" /// By default, all windows are drawn on a single rectangular grid, represented by /// this ScreenGrid instance. In multigrid mode each window will have its own diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c index 5b987e7c34..8f82220942 100644 --- a/src/nvim/hashtab.c +++ b/src/nvim/hashtab.c @@ -27,10 +27,10 @@ #include <string.h> #include "nvim/ascii.h" +#include "nvim/gettext.h" #include "nvim/hashtab.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/types.h" #include "nvim/vim.h" // Magic value for algorithm that walks through the array. diff --git a/src/nvim/help.c b/src/nvim/help.c index 698eda8468..d8b6afec27 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -4,6 +4,7 @@ // help.c: functions for Vim help #include <stdbool.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -16,6 +17,7 @@ #include "nvim/ex_cmds.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" +#include "nvim/extmark_defs.h" #include "nvim/fileio.h" #include "nvim/garray.h" #include "nvim/gettext.h" @@ -28,6 +30,7 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/os/os.h" @@ -148,7 +151,7 @@ void ex_help(exarg_T *eap) // There is no help window yet. // Try to open the file specified by the "helpfile" option. if ((helpfd = os_fopen(p_hf, READBIN)) == NULL) { - smsg(_("Sorry, help file \"%s\" not found"), p_hf); + smsg(0, _("Sorry, help file \"%s\" not found"), p_hf); goto erret; } fclose(helpfd); diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c index 3728db31d8..14239f44cc 100644 --- a/src/nvim/highlight.c +++ b/src/nvim/highlight.c @@ -5,11 +5,10 @@ #include <assert.h> #include <inttypes.h> -#include <limits.h> #include <string.h> -#include "klib/kvec.h" #include "lauxlib.h" +#include "nvim/api/keysets.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/dispatch.h" #include "nvim/api/private/helpers.h" @@ -22,7 +21,6 @@ #include "nvim/highlight.h" #include "nvim/highlight_defs.h" #include "nvim/highlight_group.h" -#include "nvim/log.h" #include "nvim/lua/executor.h" #include "nvim/macros.h" #include "nvim/map.h" diff --git a/src/nvim/highlight.h b/src/nvim/highlight.h index 5a4a90035c..fc311b4269 100644 --- a/src/nvim/highlight.h +++ b/src/nvim/highlight.h @@ -8,6 +8,7 @@ #include "nvim/buffer_defs.h" #include "nvim/highlight_defs.h" #include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/ui.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index eeed58a9ab..080dc79e0e 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -10,12 +10,13 @@ #include <stdlib.h> #include <string.h> +#include "klib/kvec.h" +#include "nvim/api/keysets.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/api/private/validate.h" #include "nvim/ascii.h" #include "nvim/autocmd.h" -#include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cursor_shape.h" #include "nvim/decoration_provider.h" @@ -28,7 +29,6 @@ #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" -#include "nvim/grid_defs.h" #include "nvim/highlight.h" #include "nvim/highlight_group.h" #include "nvim/lua/executor.h" @@ -37,6 +37,7 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/time.h" #include "nvim/runtime.h" #include "nvim/strings.h" @@ -1523,7 +1524,7 @@ static void highlight_list_one(const int id) didh = true; msg_puts_attr("links to", HL_ATTR(HLF_D)); msg_putchar(' '); - msg_outtrans(hl_table[hl_table[id - 1].sg_link - 1].sg_name); + msg_outtrans(hl_table[hl_table[id - 1].sg_link - 1].sg_name, 0); } if (!didh) { @@ -1656,7 +1657,7 @@ static bool highlight_list_arg(const int id, bool didh, const int type, int iarg msg_puts_attr(name, HL_ATTR(HLF_D)); msg_puts_attr("=", HL_ATTR(HLF_D)); } - msg_outtrans(ts); + msg_outtrans(ts, 0); } return didh; } @@ -1786,7 +1787,7 @@ bool syn_list_header(const bool did_header, const int outlen, const int id, bool if (got_int) { return true; } - msg_outtrans(hl_table[id - 1].sg_name); + msg_outtrans(hl_table[id - 1].sg_name, 0); name_col = msg_col; endcol = 15; } else if ((ui_has(kUIMessages) || msg_silent) && !force_newline) { diff --git a/src/nvim/indent.c b/src/nvim/indent.c index c16a94f06c..b7bc23cda5 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -4,6 +4,7 @@ #include <assert.h> #include <limits.h> #include <stdbool.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> @@ -31,6 +32,7 @@ #include "nvim/message.h" #include "nvim/move.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/plines.h" @@ -51,7 +53,7 @@ /// "array" will be set, caller must free it if needed. /// /// @return false for an error. -bool tabstop_set(char *var, long **array) +bool tabstop_set(char *var, colnr_T **array) { long valcount = 1; int t; @@ -87,8 +89,8 @@ bool tabstop_set(char *var, long **array) return false; } - *array = (long *)xmalloc((unsigned)(valcount + 1) * sizeof(long)); - (*array)[0] = valcount; + *array = (colnr_T *)xmalloc((unsigned)(valcount + 1) * sizeof(long)); + (*array)[0] = (colnr_T)valcount; t = 1; for (cp = var; *cp != NUL;) { @@ -115,9 +117,9 @@ bool tabstop_set(char *var, long **array) /// Calculate the number of screen spaces a tab will occupy. /// If "vts" is set then the tab widths are taken from that array, /// otherwise the value of ts is used. -int tabstop_padding(colnr_T col, long ts_arg, const long *vts) +int tabstop_padding(colnr_T col, OptInt ts_arg, const colnr_T *vts) { - long ts = ts_arg == 0 ? 8 : ts_arg; + OptInt ts = ts_arg == 0 ? 8 : ts_arg; colnr_T tabcol = 0; int t; long padding = 0; @@ -129,7 +131,7 @@ int tabstop_padding(colnr_T col, long ts_arg, const long *vts) const long tabcount = vts[0]; for (t = 1; t <= tabcount; t++) { - tabcol += (colnr_T)vts[t]; + tabcol += vts[t]; if (tabcol > col) { padding = tabcol - col; break; @@ -143,7 +145,7 @@ int tabstop_padding(colnr_T col, long ts_arg, const long *vts) } /// Find the size of the tab that covers a particular column. -int tabstop_at(colnr_T col, long ts, const long *vts) +int tabstop_at(colnr_T col, OptInt ts, const colnr_T *vts) { colnr_T tabcol = 0; int t; @@ -155,7 +157,7 @@ int tabstop_at(colnr_T col, long ts, const long *vts) const long tabcount = vts[0]; for (t = 1; t <= tabcount; t++) { - tabcol += (colnr_T)vts[t]; + tabcol += vts[t]; if (tabcol > col) { tab_size = vts[t]; break; @@ -169,7 +171,7 @@ int tabstop_at(colnr_T col, long ts, const long *vts) } /// Find the column on which a tab starts. -colnr_T tabstop_start(colnr_T col, long ts, long *vts) +colnr_T tabstop_start(colnr_T col, long ts, colnr_T *vts) { colnr_T tabcol = 0; int t; @@ -180,26 +182,26 @@ colnr_T tabstop_start(colnr_T col, long ts, long *vts) const long tabcount = vts[0]; for (t = 1; t <= tabcount; t++) { - tabcol += (colnr_T)vts[t]; + tabcol += vts[t]; if (tabcol > col) { - return (int)(tabcol - vts[t]); + return (tabcol - vts[t]); } } - const int excess = (int)(tabcol % vts[tabcount]); - return (int)(excess + ((col - excess) / vts[tabcount]) * vts[tabcount]); + const int excess = (tabcol % vts[tabcount]); + return (excess + ((col - excess) / vts[tabcount]) * vts[tabcount]); } /// Find the number of tabs and spaces necessary to get from one column /// to another. -void tabstop_fromto(colnr_T start_col, colnr_T end_col, long ts_arg, const long *vts, int *ntabs, +void tabstop_fromto(colnr_T start_col, colnr_T end_col, long ts_arg, const colnr_T *vts, int *ntabs, int *nspcs) { int spaces = end_col - start_col; colnr_T tabcol = 0; long padding = 0; int t; - long ts = ts_arg == 0 ? curbuf->b_p_ts : ts_arg; + long ts = ts_arg == 0 ? (long)curbuf->b_p_ts : ts_arg; assert(ts != 0); // suppress clang "Division by zero" if (vts == NULL || vts[0] == 0) { @@ -221,7 +223,7 @@ void tabstop_fromto(colnr_T start_col, colnr_T end_col, long ts_arg, const long // Find the padding needed to reach the next tabstop. const long tabcount = vts[0]; for (t = 1; t <= tabcount; t++) { - tabcol += (colnr_T)vts[t]; + tabcol += vts[t]; if (tabcol > start_col) { padding = tabcol - start_col; break; @@ -257,7 +259,7 @@ void tabstop_fromto(colnr_T start_col, colnr_T end_col, long ts_arg, const long } /// See if two tabstop arrays contain the same values. -bool tabstop_eq(const long *ts1, const long *ts2) +bool tabstop_eq(const colnr_T *ts1, const colnr_T *ts2) { int t; @@ -299,13 +301,13 @@ int *tabstop_copy(const long *oldts) } /// Return a count of the number of tabstops. -int tabstop_count(long *ts) +int tabstop_count(colnr_T *ts) { return ts != NULL ? (int)ts[0] : 0; } /// Return the first tabstop, or 8 if there are no tabstops defined. -int tabstop_first(long *ts) +int tabstop_first(colnr_T *ts) { return ts != NULL ? (int)ts[1] : 8; } @@ -343,7 +345,7 @@ long get_sw_value_indent(buf_T *buf) /// Idem, using virtual column "col". long get_sw_value_col(buf_T *buf, colnr_T col) { - return buf->b_p_sw ? buf->b_p_sw + return buf->b_p_sw ? (long)buf->b_p_sw : tabstop_at(col, buf->b_p_ts, buf->b_p_vts_array); } @@ -351,9 +353,8 @@ long get_sw_value_col(buf_T *buf, colnr_T col) /// using the shiftwidth value when 'softtabstop' is negative. int get_sts_value(void) { - long result = curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts; - assert(result >= 0 && result <= INT_MAX); - return (int)result; + int result = curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : (int)curbuf->b_p_sts; + return result; } // Count the size (in window cells) of the indent in the current line. @@ -413,7 +414,7 @@ int get_indent_str(const char *ptr, int ts, bool list) /// Count the size (in window cells) of the indent in line "ptr", using /// variable tabstops. /// if "list" is true, count only screen size for tabs. -int get_indent_str_vtab(const char *ptr, long ts, long *vts, bool list) +int get_indent_str_vtab(const char *ptr, OptInt ts, colnr_T *vts, bool list) { int count = 0; @@ -800,11 +801,11 @@ int get_breakindent_win(win_T *wp, char *line) FUNC_ATTR_NONNULL_ALL { static int prev_indent = 0; // cached indent value - static long prev_ts = 0L; // cached tabstop value + static OptInt prev_ts = 0L; // cached tabstop value static int prev_fnum = 0; // cached buffer number static char *prev_line = NULL; // cached copy of "line" static varnumber_T prev_tick = 0; // changedtick of cached value - static long *prev_vts = NULL; // cached vartabs values + static colnr_T *prev_vts = NULL; // cached vartabs values static int prev_list = 0; // cached list value static int prev_listopt = 0; // cached w_p_briopt_list value static char *prev_flp = NULL; // cached formatlistpat value @@ -945,7 +946,7 @@ void ex_retab(exarg_T *eap) long start_vcol = 0; // For start of white-space string long old_len; char *new_line = (char *)1; // init to non-NULL - long *new_vts_array = NULL; + colnr_T *new_vts_array = NULL; char *new_ts_str; // string value of tab argument int save_list; @@ -1000,7 +1001,7 @@ void ex_retab(exarg_T *eap) int t, s; tabstop_fromto((colnr_T)start_vcol, (colnr_T)vcol, - curbuf->b_p_ts, new_vts_array, &t, &s); + (long)curbuf->b_p_ts, new_vts_array, &t, &s); num_tabs = t; num_spaces = s; } @@ -1091,7 +1092,7 @@ void ex_retab(exarg_T *eap) if (new_ts_str != NULL) { // set the new tabstop // If 'vartabstop' is in use or if the value given to retab has more // than one tabstop then update 'vartabstop'. - long *old_vts_ary = curbuf->b_p_vts_array; + colnr_T *old_vts_ary = curbuf->b_p_vts_array; if (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_vts_array) > 1) { set_string_option_direct("vts", -1, new_ts_str, OPT_FREE | OPT_LOCAL, 0); diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 1671bf009a..7f67a24ef1 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -20,6 +20,7 @@ #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/plines.h" #include "nvim/pos.h" #include "nvim/search.h" diff --git a/src/nvim/input.c b/src/nvim/input.c index 4fd6297019..955cb0a21c 100644 --- a/src/nvim/input.c +++ b/src/nvim/input.c @@ -5,6 +5,7 @@ // like yes/no or number prompts. #include <stdbool.h> +#include <stdint.h> #include <string.h> #include "nvim/ascii.h" @@ -21,7 +22,6 @@ #include "nvim/message.h" #include "nvim/mouse.h" #include "nvim/os/input.h" -#include "nvim/types.h" #include "nvim/ui.h" #include "nvim/vim.h" @@ -56,7 +56,7 @@ int ask_yesno(const char *const str, const bool direct) int r = ' '; while (r != 'y' && r != 'n') { // same highlighting as for wait_return() - smsg_attr(HL_ATTR(HLF_R), "%s (y/n)?", str); + smsg(HL_ATTR(HLF_R), "%s (y/n)?", str); if (direct) { r = get_keystroke(NULL); } else { diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index d961d6664a..4a6c819015 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -23,7 +23,6 @@ #include "nvim/edit.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/eval/userfunc.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" @@ -47,6 +46,8 @@ #include "nvim/message.h" #include "nvim/move.h" #include "nvim/option.h" +#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/os/fs.h" #include "nvim/os/input.h" #include "nvim/os/time.h" @@ -467,9 +468,8 @@ bool check_compl_option(bool dict_opt) && *curbuf->b_p_tsrfu == NUL && *p_tsrfu == NUL)) { ctrl_x_mode = CTRL_X_NORMAL; edit_submode = NULL; - msg_attr((dict_opt - ? _("'dictionary' option is empty") - : _("'thesaurus' option is empty")), HL_ATTR(HLF_E)); + msg((dict_opt ? _("'dictionary' option is empty") : _("'thesaurus' option is empty")), + HL_ATTR(HLF_E)); if (emsg_silent == 0 && !in_assert_fails) { vim_beep(BO_COMPL); setcursor(); @@ -1452,10 +1452,10 @@ static void ins_compl_files(int count, char **files, int thesaurus, int flags, r for (i = 0; i < count && !got_int && !compl_interrupted; i++) { fp = os_fopen(files[i], "r"); // open dictionary file if (flags != DICT_EXACT && !shortmess(SHM_COMPLETIONSCAN)) { - msg_hist_off = true; // reset in msg_trunc_attr() + msg_hist_off = true; // reset in msg_trunc() vim_snprintf(IObuff, IOSIZE, _("Scanning dictionary: %s"), files[i]); - (void)msg_trunc_attr(IObuff, true, HL_ATTR(HLF_R)); + (void)msg_trunc(IObuff, true, HL_ATTR(HLF_R)); } if (fp == NULL) { @@ -2878,14 +2878,14 @@ static int process_next_cpt_value(ins_compl_next_state_T *st, int *compl_type_ar st->dict_f = DICT_EXACT; } if (!shortmess(SHM_COMPLETIONSCAN)) { - msg_hist_off = true; // reset in msg_trunc_attr() + msg_hist_off = true; // reset in msg_trunc() vim_snprintf(IObuff, IOSIZE, _("Scanning: %s"), st->ins_buf->b_fname == NULL ? buf_spname(st->ins_buf) : st->ins_buf->b_sfname == NULL ? st->ins_buf->b_fname : st->ins_buf->b_sfname); - (void)msg_trunc_attr(IObuff, true, HL_ATTR(HLF_R)); + (void)msg_trunc(IObuff, true, HL_ATTR(HLF_R)); } } else if (*st->e_cpt == NUL) { status = INS_COMPL_CPT_END; @@ -2909,9 +2909,9 @@ static int process_next_cpt_value(ins_compl_next_state_T *st, int *compl_type_ar } else if (*st->e_cpt == ']' || *st->e_cpt == 't') { compl_type = CTRL_X_TAGS; if (!shortmess(SHM_COMPLETIONSCAN)) { - msg_hist_off = true; // reset in msg_trunc_attr() + msg_hist_off = true; // reset in msg_trunc() vim_snprintf(IObuff, IOSIZE, "%s", _("Scanning tags.")); - (void)msg_trunc_attr(IObuff, true, HL_ATTR(HLF_R)); + (void)msg_trunc(IObuff, true, HL_ATTR(HLF_R)); } } @@ -3490,7 +3490,7 @@ static void ins_compl_show_filename(void) msg_hist_off = true; vim_snprintf(IObuff, IOSIZE, "%s %s%s", lead, s > compl_shown_match->cp_fname ? "<" : "", s); - msg(IObuff); + msg(IObuff, 0); msg_hist_off = false; redraw_cmdline = false; // don't overwrite! } @@ -4317,9 +4317,8 @@ static void ins_compl_show_statusmsg(void) if (edit_submode_extra != NULL) { if (!p_smd) { msg_hist_off = true; - msg_attr(edit_submode_extra, - (edit_submode_highl < HLF_COUNT - ? HL_ATTR(edit_submode_highl) : 0)); + msg(edit_submode_extra, (edit_submode_highl < HLF_COUNT + ? HL_ATTR(edit_submode_highl) : 0)); msg_hist_off = false; } } else { diff --git a/src/nvim/insexpand.h b/src/nvim/insexpand.h index 83ba14e0d2..e09004f032 100644 --- a/src/nvim/insexpand.h +++ b/src/nvim/insexpand.h @@ -4,6 +4,7 @@ #include <stdbool.h> #include "nvim/macros.h" +#include "nvim/option_defs.h" #include "nvim/vim.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/keycodes.c b/src/nvim/keycodes.c index 55cd22f181..d23fcaf368 100644 --- a/src/nvim/keycodes.c +++ b/src/nvim/keycodes.c @@ -15,14 +15,12 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/keycodes.h" -#include "nvim/log.h" #include "nvim/macros.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/mouse.h" #include "nvim/strings.h" -#include "nvim/types.h" #include "nvim/vim.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/keycodes.h b/src/nvim/keycodes.h index 7c143fc99e..9806808438 100644 --- a/src/nvim/keycodes.h +++ b/src/nvim/keycodes.h @@ -5,6 +5,7 @@ #include "nvim/ascii.h" #include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/strings.h" // Keycode definitions for special keys. diff --git a/src/nvim/linematch.c b/src/nvim/linematch.c index e22cc2d9a1..897a263bf2 100644 --- a/src/nvim/linematch.c +++ b/src/nvim/linematch.c @@ -5,6 +5,7 @@ #include <math.h> #include <stdbool.h> #include <stddef.h> +#include <stdint.h> #include <string.h> #include "nvim/linematch.h" diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index 385ac11546..c041fdb26c 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -22,7 +22,6 @@ #include "nvim/eval/typval_defs.h" #include "nvim/eval/typval_encode.h" #include "nvim/eval/userfunc.h" -#include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/lua/converter.h" #include "nvim/lua/executor.h" diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index f2efd866f8..18da7af416 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -7,6 +7,8 @@ #include <lua.h> #include <lualib.h> #include <stddef.h> +#include <stdio.h> +#include <stdlib.h> #include <string.h> #include <tree_sitter/api.h> #include <uv.h> @@ -17,7 +19,6 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/ascii.h" -#include "nvim/buffer_defs.h" #include "nvim/change.h" #include "nvim/cursor.h" #include "nvim/drawscreen.h" @@ -48,7 +49,7 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/msgpack_rpc/channel.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/os/fileio.h" #include "nvim/os/os.h" #include "nvim/path.h" @@ -59,7 +60,6 @@ #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/usercmd.h" -#include "nvim/version.h" #include "nvim/vim.h" #include "nvim/window.h" @@ -953,11 +953,11 @@ static void nlua_print_event(void **argv) } break; } - msg(str + start); + msg(str + start, 0); msg_didout = true; // Make blank lines work properly } if (len && str[len - 1] == NUL) { // Last was newline - msg(""); + msg("", 0); } xfree(str); } diff --git a/src/nvim/lua/executor.h b/src/nvim/lua/executor.h index f340d9d0d8..b132a0d147 100644 --- a/src/nvim/lua/executor.h +++ b/src/nvim/lua/executor.h @@ -13,6 +13,7 @@ #include "nvim/func_attr.h" #include "nvim/lua/converter.h" #include "nvim/macros.h" +#include "nvim/map.h" #include "nvim/types.h" #include "nvim/usercmd.h" diff --git a/src/nvim/lua/secure.c b/src/nvim/lua/secure.c index 30d5a95fc0..194c80fdc9 100644 --- a/src/nvim/lua/secure.c +++ b/src/nvim/lua/secure.c @@ -1,13 +1,17 @@ // This is an open source non-commercial project. Dear PVS-Studio, please check // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com -#include <lauxlib.h> #include <lua.h> -#include <lualib.h> +#include <stdbool.h> +#include <string.h> #include "nvim/charset.h" +#include "nvim/ex_cmds_defs.h" +#include "nvim/gettext.h" +#include "nvim/globals.h" #include "nvim/lua/executor.h" #include "nvim/lua/secure.h" +#include "nvim/memory.h" #include "nvim/message.h" #ifdef INCLUDE_GENERATED_DECLARATIONS @@ -76,11 +80,11 @@ static bool nlua_trust(const char *action, const char *path) if (msg != NULL) { if (success) { if (strcmp(action, "allow") == 0) { - smsg("Allowed \"%s\" in trust database.", msg); + smsg(0, "Allowed \"%s\" in trust database.", msg); } else if (strcmp(action, "deny") == 0) { - smsg("Denied \"%s\" in trust database.", msg); + smsg(0, "Denied \"%s\" in trust database.", msg); } else if (strcmp(action, "remove") == 0) { - smsg("Removed \"%s\" from trust database.", msg); + smsg(0, "Removed \"%s\" from trust database.", msg); } } else { semsg(e_trustfile, msg); diff --git a/src/nvim/lua/spell.c b/src/nvim/lua/spell.c index 37f1c5216d..04304719d0 100644 --- a/src/nvim/lua/spell.c +++ b/src/nvim/lua/spell.c @@ -16,7 +16,6 @@ #include "nvim/lua/spell.h" #include "nvim/message.h" #include "nvim/spell.h" -#include "nvim/types.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "lua/spell.c.generated.h" // IWYU pragma: export diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c index f175a7abb0..7690853d57 100644 --- a/src/nvim/lua/stdlib.c +++ b/src/nvim/lua/stdlib.c @@ -15,7 +15,6 @@ # include "bit.h" #endif -#include "auto/config.h" #include "cjson/lua_cjson.h" #include "mpack/lmpack.h" #include "nvim/api/private/defs.h" @@ -23,7 +22,6 @@ #include "nvim/ascii.h" #include "nvim/buffer_defs.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/eval/vars.h" #include "nvim/ex_eval.h" #include "nvim/fold.h" diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c index d255dd56e5..265c4bf5ca 100644 --- a/src/nvim/lua/treesitter.c +++ b/src/nvim/lua/treesitter.c @@ -6,6 +6,7 @@ // trees and nodes, and could be broken out as a reusable lua package #include <assert.h> +#include <ctype.h> #include <lauxlib.h> #include <limits.h> #include <lua.h> @@ -20,7 +21,6 @@ #include "nvim/api/private/helpers.h" #include "nvim/buffer_defs.h" #include "nvim/globals.h" -#include "nvim/lua/executor.h" #include "nvim/lua/treesitter.h" #include "nvim/macros.h" #include "nvim/map.h" diff --git a/src/nvim/lua/xdiff.c b/src/nvim/lua/xdiff.c index b5575fe202..000aad85d1 100644 --- a/src/nvim/lua/xdiff.c +++ b/src/nvim/lua/xdiff.c @@ -4,6 +4,7 @@ #include <lauxlib.h> #include <lua.h> #include <stdbool.h> +#include <stdint.h> #include <string.h> #include "luaconf.h" diff --git a/src/nvim/main.c b/src/nvim/main.c index 4b3244de12..2d7b2f231e 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -10,13 +10,13 @@ #include <assert.h> #include <limits.h> #include <msgpack/pack.h> +#include <sanitizer/asan_interface.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "auto/config.h" #include "nvim/arglist.h" #include "nvim/ascii.h" #include "nvim/autocmd.h" @@ -29,7 +29,6 @@ #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/eval/userfunc.h" #include "nvim/event/multiqueue.h" #include "nvim/event/stream.h" @@ -53,7 +52,6 @@ #include "nvim/macros.h" #include "nvim/main.h" #include "nvim/mark.h" -#include "nvim/memfile_defs.h" #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/message.h" @@ -62,14 +60,13 @@ #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/fileio.h" #include "nvim/os/input.h" #include "nvim/os/lang.h" #include "nvim/os/os.h" #include "nvim/os/stdpaths_defs.h" -#include "nvim/os/time.h" #include "nvim/path.h" #include "nvim/popupmenu.h" #include "nvim/pos.h" @@ -251,7 +248,7 @@ int main(int argc, char **argv) argv0 = argv[0]; if (!appname_is_valid()) { - os_errmsg("$NVIM_APPNAME is not a valid file name.\n"); + os_errmsg("$NVIM_APPNAME must be a name or relative path.\n"); exit(1); } @@ -367,7 +364,7 @@ int main(int argc, char **argv) } assert(p_ch >= 0 && Rows >= p_ch && Rows - p_ch <= INT_MAX); - cmdline_row = (int)(Rows - p_ch); + cmdline_row = Rows - (int)p_ch; msg_row = cmdline_row; default_grid_alloc(); // allocate screen buffers set_init_2(headless_mode); @@ -1265,7 +1262,7 @@ static void command_line_scan(mparm_T *parmp) // "-w {scriptout}" write to script if (ascii_isdigit((argv[0])[argv_idx])) { n = get_number_arg(argv[0], &argv_idx, 10); - set_option_value_give_err("window", NUMBER_OPTVAL(n), 0); + set_option_value_give_err("window", NUMBER_OPTVAL((OptInt)n), 0); break; } want_argument = true; @@ -1407,7 +1404,7 @@ scripterror: if (ascii_isdigit(*(argv[0]))) { argv_idx = 0; n = get_number_arg(argv[0], &argv_idx, 10); - set_option_value_give_err("window", NUMBER_OPTVAL(n), 0); + set_option_value_give_err("window", NUMBER_OPTVAL((OptInt)n), 0); argv_idx = -1; break; } diff --git a/src/nvim/map.c b/src/nvim/map.c index 54f1969df8..87b4d10314 100644 --- a/src/nvim/map.c +++ b/src/nvim/map.c @@ -9,11 +9,9 @@ // Map and Set does not make its own copy of the key or value. #include <stdbool.h> -#include <stdlib.h> #include <string.h> #include "auto/config.h" -#include "nvim/gettext.h" #include "nvim/map.h" #include "nvim/memory.h" diff --git a/src/nvim/map_glyph_cache.c b/src/nvim/map_glyph_cache.c index 6dcbfe0532..0d0f5ddd73 100644 --- a/src/nvim/map_glyph_cache.c +++ b/src/nvim/map_glyph_cache.c @@ -8,8 +8,18 @@ // are always NUL terminated, though. Thus, it is enough to store an index into // this array, and use strlen(), to retrive an interned key. +#include <assert.h> +#include <stdbool.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> + +#include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" +#include "nvim/ascii.h" +#include "nvim/macros.h" #include "nvim/map.h" +#include "nvim/memory.h" uint32_t mh_find_bucket_glyph(Set(glyph) *set, String key, bool put) { diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index 35a728314c..1fb91d85b4 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -4,14 +4,16 @@ // mapping.c: Code for mappings and abbreviations. #include <assert.h> -#include <inttypes.h> #include <lauxlib.h> #include <limits.h> #include <stdbool.h> +#include <stddef.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "nvim/api/keysets.h" #include "nvim/api/private/converter.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" @@ -37,11 +39,14 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/pos.h" #include "nvim/regexp.h" +#include "nvim/regexp_defs.h" #include "nvim/runtime.h" #include "nvim/search.h" #include "nvim/strings.h" +#include "nvim/types.h" #include "nvim/vim.h" /// List used for abbreviations. @@ -877,9 +882,9 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev, // print entries if (!did_it && !did_local) { if (is_abbrev) { - msg(_("No abbreviation found")); + msg(_("No abbreviation found"), 0); } else { - msg(_("No mapping found")); + msg(_("No mapping found"), 0); } } goto theend; // listing finished @@ -2504,7 +2509,7 @@ void ex_map(exarg_T *eap) // If we are in a secure mode we print the mappings for security reasons. if (secure) { secure = 2; - msg_outtrans(eap->cmd); + msg_outtrans(eap->cmd, 0); msg_putchar('\n'); } do_exmap(eap, false); diff --git a/src/nvim/mark.c b/src/nvim/mark.c index 0dc1be526b..913c9b2a29 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -17,7 +17,6 @@ #include "nvim/diff.h" #include "nvim/edit.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/extmark.h" #include "nvim/extmark_defs.h" @@ -32,7 +31,7 @@ #include "nvim/message.h" #include "nvim/move.h" #include "nvim/normal.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/path.h" @@ -40,7 +39,6 @@ #include "nvim/sign.h" #include "nvim/strings.h" #include "nvim/textobject.h" -#include "nvim/undo_defs.h" #include "nvim/vim.h" // This file contains routines to maintain and manipulate marks. @@ -881,7 +879,7 @@ static void show_one_mark(int c, char *arg, pos_T *p, char *name_arg, int curren did_title = false; } else { if (arg == NULL) { - msg(_("No marks set")); + msg(_("No marks set"), 0); } else { semsg(_("E283: No marks matching \"%s\""), arg); } @@ -903,9 +901,9 @@ static void show_one_mark(int c, char *arg, pos_T *p, char *name_arg, int curren msg_putchar('\n'); if (!got_int) { snprintf(IObuff, IOSIZE, " %c %6" PRIdLINENR " %4d ", c, p->lnum, p->col); - msg_outtrans(IObuff); + msg_outtrans(IObuff, 0); if (name != NULL) { - msg_outtrans_attr(name, current ? HL_ATTR(HLF_D) : 0); + msg_outtrans(name, current ? HL_ATTR(HLF_D) : 0); } } } @@ -1033,10 +1031,9 @@ void ex_jumps(exarg_T *eap) i == curwin->w_jumplistidx ? '>' : ' ', i > curwin->w_jumplistidx ? i - curwin->w_jumplistidx : curwin->w_jumplistidx - i, curwin->w_jumplist[i].fmark.mark.lnum, curwin->w_jumplist[i].fmark.mark.col); - msg_outtrans(IObuff); - msg_outtrans_attr(name, - curwin->w_jumplist[i].fmark.fnum == curbuf->b_fnum - ? HL_ATTR(HLF_D) : 0); + msg_outtrans(IObuff, 0); + msg_outtrans(name, + curwin->w_jumplist[i].fmark.fnum == curbuf->b_fnum ? HL_ATTR(HLF_D) : 0); xfree(name); os_breakcheck(); } @@ -1072,9 +1069,9 @@ void ex_changes(exarg_T *eap) i > curwin->w_changelistidx ? i - curwin->w_changelistidx : curwin->w_changelistidx - i, (long)curbuf->b_changelist[i].mark.lnum, curbuf->b_changelist[i].mark.col); - msg_outtrans(IObuff); + msg_outtrans(IObuff, 0); name = mark_line(&curbuf->b_changelist[i].mark, 17); - msg_outtrans_attr(name, HL_ATTR(HLF_D)); + msg_outtrans(name, HL_ATTR(HLF_D)); xfree(name); os_breakcheck(); } diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c index 627efa9e96..197cc21308 100644 --- a/src/nvim/marktree.c +++ b/src/nvim/marktree.c @@ -46,6 +46,7 @@ // at the repo root. #include <assert.h> +#include <inttypes.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -55,9 +56,10 @@ #include "nvim/marktree.h" #include "nvim/memory.h" #include "nvim/pos.h" - // only for debug functions +#include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" +#include "nvim/macros.h" #define T MT_BRANCH_FACTOR #define ILEN (sizeof(MTNode) + (2 * T) * sizeof(void *)) diff --git a/src/nvim/marktree.h b/src/nvim/marktree.h index f53a54f3cc..6f157936cb 100644 --- a/src/nvim/marktree.h +++ b/src/nvim/marktree.h @@ -12,7 +12,6 @@ #include "nvim/map.h" #include "nvim/pos.h" #include "nvim/types.h" - // only for debug functions: #include "api/private/defs.h" diff --git a/src/nvim/match.c b/src/nvim/match.c index 6d5873bc85..d54e2ce58a 100644 --- a/src/nvim/match.c +++ b/src/nvim/match.c @@ -15,7 +15,6 @@ #include "nvim/drawscreen.h" #include "nvim/eval/funcs.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/eval/window.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" @@ -30,7 +29,7 @@ #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/pos.h" #include "nvim/profile.h" #include "nvim/regexp.h" diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 6182646fe7..7b7c822b3b 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -31,6 +31,7 @@ #include <iconv.h> #include <locale.h> #include <stdbool.h> +#include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -59,7 +60,7 @@ #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/os.h" #include "nvim/os/os_defs.h" @@ -1527,7 +1528,7 @@ void show_utf8(void) char *line = get_cursor_pos_ptr(); int len = utfc_ptr2len(line); if (len == 0) { - msg("NUL"); + msg("NUL", 0); return; } @@ -1552,7 +1553,7 @@ void show_utf8(void) } } - msg(IObuff); + msg(IObuff, 0); } /// Return offset from "p" to the start of a character, including composing characters. diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c index 6722d6bd8a..8c36a890de 100644 --- a/src/nvim/memfile.c +++ b/src/nvim/memfile.c @@ -45,13 +45,14 @@ #include <stdbool.h> #include <stdio.h> #include <string.h> +#include <sys/stat.h> #include "nvim/assert.h" #include "nvim/buffer_defs.h" #include "nvim/fileio.h" #include "nvim/gettext.h" #include "nvim/globals.h" -#include "nvim/macros.h" +#include "nvim/map.h" #include "nvim/memfile.h" #include "nvim/memfile_defs.h" #include "nvim/memline.h" diff --git a/src/nvim/memline.c b/src/nvim/memline.c index dc9173910e..7bfa6db4ef 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -39,6 +39,7 @@ #include <fcntl.h> #include <inttypes.h> #include <stdbool.h> +#include <stddef.h> #include <stdio.h> #include <string.h> #include <time.h> @@ -55,7 +56,6 @@ #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/fileio.h" #include "nvim/getchar.h" @@ -65,6 +65,7 @@ #include "nvim/input.h" #include "nvim/macros.h" #include "nvim/main.h" +#include "nvim/map.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memfile.h" @@ -72,6 +73,7 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/fs.h" #include "nvim/os/input.h" #include "nvim/os/os.h" @@ -82,7 +84,6 @@ #include "nvim/spell.h" #include "nvim/statusline.h" #include "nvim/strings.h" -#include "nvim/types.h" #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/version.h" @@ -845,7 +846,7 @@ void ml_recover(bool checkext) if ((hp = mf_get(mfp, 0, 1)) == NULL) { msg_start(); msg_puts_attr(_("Unable to read block 0 from "), attr | MSG_HIST); - msg_outtrans_attr(mfp->mf_fname, attr | MSG_HIST); + msg_outtrans(mfp->mf_fname, attr | MSG_HIST); msg_puts_attr(_("\nMaybe no changes were made or Vim did not update the swap file."), attr | MSG_HIST); msg_end(); @@ -854,7 +855,7 @@ void ml_recover(bool checkext) b0p = hp->bh_data; if (strncmp(b0p->b0_version, "VIM 3.0", 7) == 0) { msg_start(); - msg_outtrans_attr(mfp->mf_fname, MSG_HIST); + msg_outtrans(mfp->mf_fname, MSG_HIST); msg_puts_attr(_(" cannot be used with this version of Vim.\n"), MSG_HIST); msg_puts_attr(_("Use Vim version 3.0.\n"), MSG_HIST); @@ -867,7 +868,7 @@ void ml_recover(bool checkext) } if (b0_magic_wrong(b0p)) { msg_start(); - msg_outtrans_attr(mfp->mf_fname, attr | MSG_HIST); + msg_outtrans(mfp->mf_fname, attr | MSG_HIST); msg_puts_attr(_(" cannot be used on this computer.\n"), attr | MSG_HIST); msg_puts_attr(_("The file was created on "), attr | MSG_HIST); @@ -887,7 +888,7 @@ void ml_recover(bool checkext) mf_new_page_size(mfp, (unsigned)char_to_long(b0p->b0_page_size)); if (mfp->mf_page_size < previous_page_size) { msg_start(); - msg_outtrans_attr(mfp->mf_fname, attr | MSG_HIST); + msg_outtrans(mfp->mf_fname, attr | MSG_HIST); msg_puts_attr(_(" has been damaged (page size is smaller than minimum value).\n"), attr | MSG_HIST); msg_end(); @@ -918,14 +919,14 @@ void ml_recover(bool checkext) } home_replace(NULL, mfp->mf_fname, NameBuff, MAXPATHL, true); - smsg(_("Using swap file \"%s\""), NameBuff); + smsg(0, _("Using swap file \"%s\""), NameBuff); if (buf_spname(curbuf) != NULL) { xstrlcpy(NameBuff, buf_spname(curbuf), MAXPATHL); } else { home_replace(NULL, curbuf->b_ffname, NameBuff, MAXPATHL, true); } - smsg(_("Original file \"%s\""), NameBuff); + smsg(0, _("Original file \"%s\""), NameBuff); msg_putchar('\n'); // check date of swap file and original file @@ -1196,18 +1197,18 @@ void ml_recover(bool checkext) emsg(_("E311: Recovery Interrupted")); } else if (error) { no_wait_return++; - msg(">>>>>>>>>>>>>"); + msg(">>>>>>>>>>>>>", 0); emsg(_("E312: Errors detected while recovering; look for lines starting with ???")); no_wait_return--; - msg(_("See \":help E312\" for more information.")); - msg(">>>>>>>>>>>>>"); + msg(_("See \":help E312\" for more information."), 0); + msg(">>>>>>>>>>>>>", 0); } else { if (curbuf->b_changed) { - msg(_("Recovery completed. You should check if everything is OK.")); + msg(_("Recovery completed. You should check if everything is OK."), 0); msg_puts(_("\n(You might want to write out this file under another name\n")); msg_puts(_("and run diff with the original file to check for changes)")); } else { - msg(_("Recovery completed. Buffer contents equals file contents.")); + msg(_("Recovery completed. Buffer contents equals file contents."), 0); } msg_puts(_("\nYou may want to delete the .swp file now.")); if (swapfile_process_running(b0p, fname_used)) { @@ -1283,7 +1284,7 @@ int recover_names(char *fname, bool do_list, list_T *ret_list, int nr, char **fn if (do_list) { // use msg() to start the scrolling properly - msg(_("Swap files found:")); + msg(_("Swap files found:"), 0); msg_putchar('\n'); } @@ -1515,7 +1516,7 @@ static time_t swapfile_info(char *fname) // print name of owner of the file if (os_get_uname((uv_uid_t)file_info.stat.st_uid, uname, B0_UNAME_SIZE) == OK) { msg_puts(_(" owned by: ")); - msg_outtrans(uname); + msg_outtrans(uname, 0); msg_puts(_(" dated: ")); } else { msg_puts(_(" dated: ")); @@ -1543,7 +1544,7 @@ static time_t swapfile_info(char *fname) if (b0.b0_fname[0] == NUL) { msg_puts(_("[No Name]")); } else { - msg_outtrans(b0.b0_fname); + msg_outtrans(b0.b0_fname, 0); } msg_puts(_("\n modified: ")); @@ -1551,7 +1552,7 @@ static time_t swapfile_info(char *fname) if (*(b0.b0_uname) != NUL) { msg_puts(_("\n user name: ")); - msg_outtrans(b0.b0_uname); + msg_outtrans(b0.b0_uname, 0); } if (*(b0.b0_hname) != NUL) { @@ -1560,7 +1561,7 @@ static time_t swapfile_info(char *fname) } else { msg_puts(_("\n host name: ")); } - msg_outtrans(b0.b0_hname); + msg_outtrans(b0.b0_hname, 0); } if (char_to_long(b0.b0_pid) != 0L) { @@ -1785,7 +1786,7 @@ theend: if (message) { if (status == OK) { - msg(_("File preserved")); + msg(_("File preserved"), 0); } else { emsg(_("E314: Preserve failed")); } @@ -3226,7 +3227,7 @@ static void attention_message(buf_T *buf, char *fname) msg_puts("\"\n"); const time_t swap_mtime = swapfile_info(fname); msg_puts(_("While opening file \"")); - msg_outtrans(buf->b_fname); + msg_outtrans(buf->b_fname, 0); msg_puts("\"\n"); FileInfo file_info; if (!os_fileinfo(buf->b_fname, &file_info)) { @@ -3248,10 +3249,10 @@ static void attention_message(buf_T *buf, char *fname) " Quit, or continue with caution.\n")); msg_puts(_("(2) An edit session for this file crashed.\n")); msg_puts(_(" If this is the case, use \":recover\" or \"vim -r ")); - msg_outtrans(buf->b_fname); + msg_outtrans(buf->b_fname, 0); msg_puts(_("\"\n to recover the changes (see \":help recovery\").\n")); msg_puts(_(" If you did this already, delete the swap file \"")); - msg_outtrans(fname); + msg_outtrans(fname, 0); msg_puts(_("\"\n to avoid this message.\n")); cmdline_row = msg_row; no_wait_return--; diff --git a/src/nvim/memory.c b/src/nvim/memory.c index 6b4d290863..997f465f02 100644 --- a/src/nvim/memory.c +++ b/src/nvim/memory.c @@ -29,6 +29,7 @@ #include "nvim/memfile.h" #include "nvim/memory.h" #include "nvim/message.h" +#include "nvim/option_vars.h" #include "nvim/sign.h" #include "nvim/ui.h" #include "nvim/usercmd.h" @@ -656,7 +657,6 @@ char *arena_memdupz(Arena *arena, const char *buf, size_t size) # include "nvim/cmdhist.h" # include "nvim/diff.h" # include "nvim/edit.h" -# include "nvim/eval/typval.h" # include "nvim/ex_cmds.h" # include "nvim/ex_docmd.h" # include "nvim/ex_getln.h" diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 3b2e45e2a4..2204a0a291 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -11,12 +11,10 @@ #include "nvim/ascii.h" #include "nvim/autocmd.h" -#include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cursor.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/garray.h" @@ -31,14 +29,13 @@ #include "nvim/menu.h" #include "nvim/menu_defs.h" #include "nvim/message.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/popupmenu.h" #include "nvim/pos.h" #include "nvim/state.h" #include "nvim/strings.h" #include "nvim/types.h" #include "nvim/ui.h" -#include "nvim/undo_defs.h" #include "nvim/vim.h" #define MENUDEPTH 10 // maximum depth of menus @@ -824,7 +821,7 @@ static void show_menus_recursive(vimmenu_T *menu, int modes, int depth) msg_puts(" "); } // Same highlighting as for directories!? - msg_outtrans_attr(menu->name, HL_ATTR(HLF_D)); + msg_outtrans(menu->name, HL_ATTR(HLF_D)); } if (menu != NULL && menu->children == NULL) { diff --git a/src/nvim/message.c b/src/nvim/message.c index dba4dba600..68ea49d53b 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -20,7 +20,6 @@ #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/event/defs.h" #include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" @@ -44,8 +43,10 @@ #include "nvim/mouse.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/input.h" #include "nvim/os/os.h" +#include "nvim/os/time.h" #include "nvim/pos.h" #include "nvim/regexp.h" #include "nvim/runtime.h" @@ -212,15 +213,6 @@ void msg_grid_validate(void) } } -/// Displays the string 's' on the status line -/// When terminal not initialized (yet) os_errmsg(..) is used. -/// -/// @return true if wait_return() not called -int msg(const char *s) -{ - return msg_attr_keep(s, 0, false, false); -} - /// Like msg() but keep it silent when 'verbosefile' is set. int verb_msg(const char *s) { @@ -231,14 +223,18 @@ int verb_msg(const char *s) return n; } -int msg_attr(const char *s, const int attr) +/// Displays the string 's' on the status line +/// When terminal not initialized (yet) os_errmsg(..) is used. +/// +/// @return true if wait_return() not called +int msg(const char *s, const int attr) FUNC_ATTR_NONNULL_ARG(1) { return msg_attr_keep(s, attr, false, false); } -/// Similar to msg_outtrans_attr, but support newlines and tabs. -void msg_multiline_attr(const char *s, int attr, bool check_int, bool *need_clear) +/// Similar to msg_outtrans, but support newlines and tabs. +void msg_multiline(const char *s, int attr, bool check_int, bool *need_clear) FUNC_ATTR_NONNULL_ALL { const char *next_spec = s; @@ -251,7 +247,7 @@ void msg_multiline_attr(const char *s, int attr, bool check_int, bool *need_clea if (next_spec != NULL) { // Printing all char that are before the char found by strpbrk - msg_outtrans_len_attr(s, (int)(next_spec - s), attr); + msg_outtrans_len(s, (int)(next_spec - s), attr); if (*next_spec != TAB && *need_clear) { msg_clr_eos(); @@ -265,7 +261,7 @@ void msg_multiline_attr(const char *s, int attr, bool check_int, bool *need_clea // Print the rest of the message. We know there is no special // character because strpbrk returned NULL if (*s != NUL) { - msg_outtrans_attr(s, attr); + msg_outtrans(s, attr); } } @@ -278,7 +274,7 @@ void msg_multiattr(HlMessage hl_msg, const char *kind, bool history) msg_ext_set_kind(kind); for (uint32_t i = 0; i < kv_size(hl_msg); i++) { HlMessageChunk chunk = kv_A(hl_msg, i); - msg_multiline_attr(chunk.text.data, chunk.attr, true, &need_clear); + msg_multiline(chunk.text.data, chunk.attr, true, &need_clear); } if (history && kv_size(hl_msg)) { add_msg_hist_multiattr(NULL, 0, 0, true, hl_msg); @@ -339,9 +335,9 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline) bool need_clear = true; if (multiline) { - msg_multiline_attr(s, attr, false, &need_clear); + msg_multiline(s, attr, false, &need_clear); } else { - msg_outtrans_attr(s, attr); + msg_outtrans(s, attr); } if (need_clear) { msg_clr_eos(); @@ -479,22 +475,8 @@ void trunc_string(const char *s, char *buf, int room_in, int buflen) } } -// Note: Caller of smsg() and smsg_attr() must check the resulting string is -// shorter than IOSIZE!!! - -int smsg(const char *s, ...) - FUNC_ATTR_PRINTF(1, 2) -{ - va_list arglist; - - va_start(arglist, s); - vim_vsnprintf(IObuff, IOSIZE, s, arglist); - va_end(arglist); - - return msg(IObuff); -} - -int smsg_attr(int attr, const char *s, ...) +// Note: Caller of smsg() must check the resulting string is shorter than IOSIZE!!! +int smsg(int attr, const char *s, ...) FUNC_ATTR_PRINTF(2, 3) { va_list arglist; @@ -502,7 +484,7 @@ int smsg_attr(int attr, const char *s, ...) va_start(arglist, s); vim_vsnprintf(IObuff, IOSIZE, s, arglist); va_end(arglist); - return msg_attr(IObuff, attr); + return msg(IObuff, attr); } int smsg_attr_keep(int attr, const char *s, ...) @@ -604,12 +586,12 @@ void msg_source(int attr) char *p = get_emsg_source(); if (p != NULL) { msg_scroll = true; // this will take more than one line - msg_attr(p, attr); + msg(p, attr); xfree(p); } p = get_emsg_lnum(); if (p != NULL) { - msg_attr(p, HL_ATTR(HLF_N)); + msg(p, HL_ATTR(HLF_N)); xfree(p); last_sourcing_lnum = SOURCING_LNUM; // only once for each line } @@ -908,7 +890,7 @@ void msg_schedule_semsg_multiline(const char *const fmt, ...) /// Careful: The string may be changed by msg_may_trunc()! /// /// @return a pointer to the printed message, if wait_return() not called. -char *msg_trunc_attr(char *s, bool force, int attr) +char *msg_trunc(char *s, bool force, int attr) { int n; @@ -918,7 +900,7 @@ char *msg_trunc_attr(char *s, bool force, int attr) char *ts = msg_may_trunc(force, s); msg_hist_off = true; - n = msg_attr(ts, attr); + n = msg(ts, attr); msg_hist_off = false; if (n) { @@ -1400,7 +1382,7 @@ void msgmore(long n) if (got_int) { xstrlcat(msg_buf, _(" (Interrupted)"), MSG_BUF_LEN); } - if (msg(msg_buf)) { + if (msg(msg_buf, 0)) { set_keep_msg(msg_buf, 0); keep_msg_more = true; } @@ -1520,7 +1502,7 @@ void msg_home_replace_hl(const char *fname) static void msg_home_replace_attr(const char *fname, int attr) { char *name = home_replace_save(NULL, fname); - msg_outtrans_attr(name, attr); + msg_outtrans(name, attr); xfree(name); } @@ -1529,19 +1511,9 @@ static void msg_home_replace_attr(const char *fname, int attr) /// Use attributes 'attr'. /// /// @return the number of characters it takes on the screen. -int msg_outtrans(const char *str) -{ - return msg_outtrans_attr(str, 0); -} - -int msg_outtrans_attr(const char *str, int attr) -{ - return msg_outtrans_len_attr(str, (int)strlen(str), attr); -} - -int msg_outtrans_len(const char *str, int len) +int msg_outtrans(const char *str, int attr) { - return msg_outtrans_len_attr(str, len, 0); + return msg_outtrans_len(str, (int)strlen(str), attr); } /// Output one character at "p". @@ -1553,14 +1525,14 @@ const char *msg_outtrans_one(const char *p, int attr) int l; if ((l = utfc_ptr2len(p)) > 1) { - msg_outtrans_len_attr(p, l, attr); + msg_outtrans_len(p, l, attr); return p + l; } msg_puts_attr(transchar_byte_buf(NULL, (uint8_t)(*p)), attr); return p + 1; } -int msg_outtrans_len_attr(const char *msgstr, int len, int attr) +int msg_outtrans_len(const char *msgstr, int len, int attr) { int retval = 0; const char *str = msgstr; @@ -1605,7 +1577,7 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr) // Unprintable multi-byte char: print the printable chars so // far and the translation of the unprintable char. if (str > plain_start) { - msg_puts_attr_len(plain_start, str - plain_start, attr); + msg_puts_len(plain_start, str - plain_start, attr); } plain_start = str + mb_l; msg_puts_attr(transchar_buf(NULL, c), attr == 0 ? HL_ATTR(HLF_8) : attr); @@ -1619,7 +1591,7 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr) // Unprintable char: print the printable chars so far and the // translation of the unprintable char. if (str > plain_start) { - msg_puts_attr_len(plain_start, str - plain_start, attr); + msg_puts_len(plain_start, str - plain_start, attr); } plain_start = str + 1; msg_puts_attr(s, attr == 0 ? HL_ATTR(HLF_8) : attr); @@ -1633,7 +1605,7 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr) if (str > plain_start && !got_int) { // Print the printable chars at the end. - msg_puts_attr_len(plain_start, str - plain_start, attr); + msg_puts_len(plain_start, str - plain_start, attr); } got_int |= save_got_int; @@ -2039,29 +2011,23 @@ void msg_puts_title(const char *s) /// Show a message in such a way that it always fits in the line. Cut out a /// part in the middle and replace it with "..." when necessary. /// Does not handle multi-byte characters! -void msg_outtrans_long_attr(const char *longstr, int attr) -{ - msg_outtrans_long_len_attr(longstr, (int)strlen(longstr), attr); -} - -void msg_outtrans_long_len_attr(const char *longstr, int len, int attr) +void msg_outtrans_long(const char *longstr, int attr) { + int len = (int)strlen(longstr); int slen = len; - int room; - - room = Columns - msg_col; + int room = Columns - msg_col; if (len > room && room >= 20) { slen = (room - 3) / 2; - msg_outtrans_len_attr(longstr, slen, attr); + msg_outtrans_len(longstr, slen, attr); msg_puts_attr("...", HL_ATTR(HLF_8)); } - msg_outtrans_len_attr(longstr + len - slen, slen, attr); + msg_outtrans_len(longstr + len - slen, slen, attr); } /// Basic function for writing a message with highlight attributes. void msg_puts_attr(const char *const s, const int attr) { - msg_puts_attr_len(s, -1, attr); + msg_puts_len(s, -1, attr); } /// Write a message with highlight attributes @@ -2069,7 +2035,7 @@ void msg_puts_attr(const char *const s, const int attr) /// @param[in] str NUL-terminated message string. /// @param[in] len Length of the string or -1. /// @param[in] attr Highlight attribute. -void msg_puts_attr_len(const char *const str, const ptrdiff_t len, int attr) +void msg_puts_len(const char *const str, const ptrdiff_t len, int attr) FUNC_ATTR_NONNULL_ALL { assert(len < 0 || memchr(str, 0, (size_t)len) == NULL); @@ -2145,7 +2111,7 @@ void msg_printf_attr(const int attr, const char *const fmt, ...) va_end(ap); msg_scroll = true; - msg_puts_attr_len(msgbuf, (ptrdiff_t)len, attr); + msg_puts_len(msgbuf, (ptrdiff_t)len, attr); } static void msg_ext_emit_chunk(void) @@ -2162,7 +2128,7 @@ static void msg_ext_emit_chunk(void) ADD(msg_ext_chunks, ARRAY_OBJ(chunk)); } -/// The display part of msg_puts_attr_len(). +/// The display part of msg_puts_len(). /// May be called recursively to display scroll-back text. static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) { @@ -2702,7 +2668,7 @@ static msgchunk_T *disp_sb_line(int row, msgchunk_T *smp) return mp->sb_next; } -/// Output any postponed text for msg_puts_attr_len(). +/// Output any postponed text for msg_puts_len(). static void t_puts(int *t_col, const char *t_s, const char *s, int attr) { attr = hl_combine_attr(HL_ATTR(HLF_MSG), attr); @@ -3467,7 +3433,7 @@ void give_warning(const char *message, bool hl) msg_ext_set_kind("wmsg"); } - if (msg_attr(message, keep_msg_attr) && msg_scrolled == 0) { + if (msg(message, keep_msg_attr) && msg_scrolled == 0) { set_keep_msg(message, keep_msg_attr); } msg_didout = false; // Overwrite this message. diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index 9b09a3fdf3..0433031393 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -16,7 +16,6 @@ #include "nvim/edit.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_docmd.h" #include "nvim/fold.h" #include "nvim/getchar.h" @@ -34,6 +33,7 @@ #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/plines.h" #include "nvim/popupmenu.h" #include "nvim/pos.h" @@ -41,7 +41,6 @@ #include "nvim/state.h" #include "nvim/statusline.h" #include "nvim/strings.h" -#include "nvim/syntax.h" #include "nvim/types.h" #include "nvim/ui.h" #include "nvim/ui_compositor.h" diff --git a/src/nvim/move.c b/src/nvim/move.c index 3978539df6..8efb038a55 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -14,16 +14,16 @@ #include <limits.h> #include <stdbool.h> #include <stddef.h> +#include <stdint.h> #include "nvim/ascii.h" #include "nvim/buffer.h" -#include "nvim/charset.h" #include "nvim/cursor.h" #include "nvim/diff.h" +#include "nvim/drawline.h" #include "nvim/drawscreen.h" #include "nvim/edit.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/eval/window.h" #include "nvim/fold.h" #include "nvim/getchar.h" @@ -33,11 +33,12 @@ #include "nvim/highlight.h" #include "nvim/macros.h" #include "nvim/mbyte.h" -#include "nvim/memline_defs.h" +#include "nvim/memline.h" #include "nvim/message.h" #include "nvim/mouse.h" #include "nvim/move.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/plines.h" #include "nvim/popupmenu.h" #include "nvim/pos.h" @@ -213,8 +214,8 @@ static void reset_skipcol(win_T *wp) void update_topline(win_T *wp) { bool check_botline = false; - long *so_ptr = wp->w_p_so >= 0 ? &wp->w_p_so : &p_so; - long save_so = *so_ptr; + OptInt *so_ptr = wp->w_p_so >= 0 ? &wp->w_p_so : &p_so; + OptInt save_so = *so_ptr; // Cursor is updated instead when this is true for 'splitkeep'. if (skip_update_topline) { @@ -288,7 +289,7 @@ void update_topline(win_T *wp) if (halfheight < 2) { halfheight = 2; } - long n; + int64_t n; if (hasAnyFolding(wp)) { // Count the number of logical lines between the cursor and // topline + p_so (approximation of how much will be @@ -371,7 +372,7 @@ void update_topline(win_T *wp) } } if (check_botline) { - long line_count = 0; + int line_count = 0; if (hasAnyFolding(wp)) { // Count the number of logical lines between the cursor and // botline - p_so (approximation of how much will be @@ -386,7 +387,7 @@ void update_topline(win_T *wp) (void)hasFolding(lnum, &lnum, NULL); } } else { - line_count = wp->w_cursor.lnum - wp->w_botline + 1 + *so_ptr; + line_count = wp->w_cursor.lnum - wp->w_botline + 1 + (int)(*so_ptr); } if (line_count <= wp->w_height_inner + 1) { scroll_cursor_bot(scrolljump_value(), false); @@ -427,9 +428,8 @@ void update_topline(win_T *wp) // When 'scrolljump' is negative use it as a percentage of the window height. static int scrolljump_value(void) { - long result = p_sj >= 0 ? p_sj : (curwin->w_height_inner * -p_sj) / 100; - assert(result <= INT_MAX); - return (int)result; + int result = p_sj >= 0 ? (int)p_sj : (curwin->w_height_inner * (int)(-p_sj)) / 100; + return result; } // Return true when there are not 'scrolloff' lines above the cursor for the diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index b753d46d64..597aa56fa7 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -24,6 +24,7 @@ #include "nvim/event/rstream.h" #include "nvim/event/stream.h" #include "nvim/event/wstream.h" +#include "nvim/globals.h" #include "nvim/log.h" #include "nvim/main.h" #include "nvim/map.h" @@ -348,6 +349,7 @@ static void parse_msgpack(Channel *channel) "id %" PRIu32 ". Ensure the client is properly synchronized", channel->id, (unsigned)channel->rpc.client_type, p->request_id); chan_close_with_error(channel, buf, LOGLVL_ERR); + return; } frame->returned = true; frame->errored = (p->error.type != kObjectTypeNil); diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c index 9afa3ea02a..5a3f31b7f5 100644 --- a/src/nvim/msgpack_rpc/helpers.c +++ b/src/nvim/msgpack_rpc/helpers.c @@ -11,7 +11,6 @@ #include "klib/kvec.h" #include "msgpack/pack.h" -#include "nvim/api/keysets.h" #include "nvim/api/private/helpers.h" #include "nvim/assert.h" #include "nvim/event/wstream.h" diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 309b6e2568..715b98377a 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -17,7 +17,6 @@ #include <string.h> #include <time.h> -#include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/ascii.h" #include "nvim/autocmd.h" @@ -57,6 +56,7 @@ #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/input.h" #include "nvim/os/time.h" #include "nvim/plines.h" @@ -73,7 +73,6 @@ #include "nvim/tag.h" #include "nvim/textformat.h" #include "nvim/textobject.h" -#include "nvim/types.h" #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/vim.h" @@ -689,7 +688,7 @@ static void normal_redraw_mode_message(NormalState *s) keep_msg = kmsg; kmsg = xstrdup(keep_msg); - msg_attr(kmsg, keep_msg_attr); + msg(kmsg, keep_msg_attr); xfree(kmsg); } setcursor(); @@ -803,13 +802,13 @@ static void normal_get_additional_char(NormalState *s) && s->ca.cmdchar == 'g') { s->ca.oap->op_type = get_op_type(*cp, NUL); } else if (*cp == Ctrl_BSL) { - long towait = (p_ttm >= 0 ? p_ttm : p_tm); + int towait = (p_ttm >= 0 ? (int)p_ttm : (int)p_tm); // There is a busy wait here when typing "f<C-\>" and then // something different from CTRL-N. Can't be avoided. - while ((s->c = vpeekc()) <= 0 && towait > 0L) { - do_sleep(towait > 50L ? 50L : towait); - towait -= 50L; + while ((s->c = vpeekc()) <= 0 && towait > 0) { + do_sleep(towait > 50 ? 50 : towait); + towait -= 50; } if (s->c > 0) { s->c = plain_vgetc(); @@ -1377,7 +1376,7 @@ static void normal_redraw(NormalState *s) // check for duplicates. Never put this message in // history. msg_hist_off = true; - msg_attr(p, keep_msg_attr); + msg(p, keep_msg_attr); msg_hist_off = false; xfree(p); } @@ -2087,7 +2086,7 @@ static void display_showcmd(void) // clear the rest of an old message by outputting up to SHOWCMD_COLS spaces grid_line_puts(sc_col + len, (char *)" " + len, -1, HL_ATTR(HLF_MSG)); - grid_line_flush(false); + grid_line_flush(); } /// When "check" is false, prepare for commands that scroll the window. @@ -2785,7 +2784,7 @@ static void nv_zet(cmdarg_T *cap) { colnr_T col; int nchar = cap->nchar; - long old_fdl = curwin->w_p_fdl; + long old_fdl = (long)curwin->w_p_fdl; int old_fen = curwin->w_p_fen; int siso = get_sidescrolloff_value(curwin); @@ -6140,9 +6139,9 @@ static void nv_esc(cmdarg_T *cap) if (restart_edit == 0 && cmdwin_type == 0 && !VIsual_active && no_reason) { if (anyBufIsChanged()) { msg(_("Type :qa! and press <Enter> to abandon all changes" - " and exit Nvim")); + " and exit Nvim"), 0); } else { - msg(_("Type :qa and press <Enter> to exit Nvim")); + msg(_("Type :qa and press <Enter> to exit Nvim"), 0); } } diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 96deae228f..5d3e285e3b 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -49,6 +49,8 @@ #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/os/input.h" #include "nvim/os/time.h" #include "nvim/plines.h" @@ -656,7 +658,7 @@ void op_reindent(oparg_T *oap, Indenter how) if (i > 1 && (i % 50 == 0 || i == oap->line_count - 1) && oap->line_count > p_report) { - smsg(_("%" PRId64 " lines to indent... "), (int64_t)i); + smsg(0, _("%" PRId64 " lines to indent... "), (int64_t)i); } // Be vi-compatible: For lisp indenting the first line is not @@ -699,9 +701,7 @@ void op_reindent(oparg_T *oap, Indenter how) if (oap->line_count > p_report) { i = oap->line_count - (i + 1); - smsg(NGETTEXT("%" PRId64 " line indented ", - "%" PRId64 " lines indented ", i), - (int64_t)i); + smsg(0, NGETTEXT("%" PRId64 " line indented ", "%" PRId64 " lines indented ", i), (int64_t)i); } if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) { // set '[ and '] marks @@ -938,7 +938,7 @@ int do_record(int c) if (p_ch == 0 || ui_has(kUIMessages)) { showmode(); } else { - msg(""); + msg("", 0); } if (p == NULL) { retval = FAIL; @@ -2109,8 +2109,7 @@ void op_tilde(oparg_T *oap) } if (oap->line_count > p_report) { - smsg(NGETTEXT("%" PRId64 " line changed", - "%" PRId64 " lines changed", oap->line_count), + smsg(0, NGETTEXT("%" PRId64 " line changed", "%" PRId64 " lines changed", oap->line_count), (int64_t)oap->line_count); } } @@ -2783,12 +2782,12 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append) update_screen(); } if (yank_type == kMTBlockWise) { - smsg(NGETTEXT("block of %" PRId64 " line yanked%s", - "block of %" PRId64 " lines yanked%s", yanklines), + smsg(0, NGETTEXT("block of %" PRId64 " line yanked%s", + "block of %" PRId64 " lines yanked%s", yanklines), (int64_t)yanklines, namebuf); } else { - smsg(NGETTEXT("%" PRId64 " line yanked%s", - "%" PRId64 " lines yanked%s", yanklines), + smsg(0, NGETTEXT("%" PRId64 " line yanked%s", + "%" PRId64 " lines yanked%s", yanklines), (int64_t)yanklines, namebuf); } } @@ -3182,7 +3181,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) if (cur_ve_flags == VE_ALL && y_type == kMTCharWise) { if (gchar_cursor() == TAB) { int viscol = getviscol(); - long ts = curbuf->b_p_ts; + OptInt ts = curbuf->b_p_ts; // Don't need to insert spaces when "p" on the last position of a // tab or "P" on the first position. if (dir == FORWARD @@ -3838,7 +3837,7 @@ void ex_display(exarg_T *eap) for (p = yb->y_array[j]; *p != NUL && (n -= ptr2cells(p)) >= 0; p++) { // -V1019 clen = utfc_ptr2len(p); - msg_outtrans_len(p, clen); + msg_outtrans_len(p, clen, 0); p += clen - 1; } } @@ -3913,10 +3912,10 @@ static void dis_msg(const char *p, bool skip_esc) && (n -= ptr2cells(p)) >= 0) { int l; if ((l = utfc_ptr2len(p)) > 1) { - msg_outtrans_len(p, l); + msg_outtrans_len(p, l, 0); p += l; } else { - msg_outtrans_len(p++, 1); + msg_outtrans_len(p++, 1, 0); } } os_breakcheck(); @@ -4452,8 +4451,7 @@ void op_addsub(oparg_T *oap, linenr_T Prenum1, bool g_cmd) } if (change_cnt > p_report) { - smsg(NGETTEXT("%" PRId64 " lines changed", - "%" PRId64 " lines changed", change_cnt), + smsg(0, NGETTEXT("%" PRId64 " lines changed", "%" PRId64 " lines changed", change_cnt), (int64_t)change_cnt); } } @@ -5333,7 +5331,7 @@ void cursor_pos_info(dict_T *dict) // Compute the length of the file in characters. if (curbuf->b_ml.ml_flags & ML_EMPTY) { if (dict == NULL) { - msg(_(no_lines_msg)); + msg(_(no_lines_msg), 0); return; } } else { @@ -5538,7 +5536,7 @@ void cursor_pos_info(dict_T *dict) msg_start(); msg_scroll = true; } - msg(IObuff); + msg(IObuff, 0); p_shm = p; } } @@ -6452,7 +6450,7 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing) clipboard_didwarn = true; // Do NOT error (emsg()) here--if it interrupts :redir we get into // a weird state, stuck in "redirect mode". - msg(MSG_NO_CLIP); + msg(MSG_NO_CLIP, 0); } // ... else, be silent (don't flood during :while, :redir, etc.). goto end; diff --git a/src/nvim/ops.h b/src/nvim/ops.h index e378d2f7b5..ae8b8b53e8 100644 --- a/src/nvim/ops.h +++ b/src/nvim/ops.h @@ -11,6 +11,7 @@ #include "nvim/extmark.h" #include "nvim/macros.h" #include "nvim/normal.h" +#include "nvim/option_defs.h" #include "nvim/os/time.h" #include "nvim/pos.h" #include "nvim/types.h" diff --git a/src/nvim/option.c b/src/nvim/option.c index c34999ed32..eef5e66aeb 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -21,7 +21,6 @@ #define IN_OPTION_C #include <assert.h> -#include <ctype.h> #include <inttypes.h> #include <limits.h> #include <stdbool.h> @@ -30,6 +29,7 @@ #include <string.h> #include "auto/config.h" +#include "klib/kvec.h" #include "nvim/api/extmark.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" @@ -46,7 +46,6 @@ #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" @@ -77,6 +76,7 @@ #include "nvim/ops.h" #include "nvim/option.h" #include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/os/lang.h" @@ -84,7 +84,6 @@ #include "nvim/path.h" #include "nvim/popupmenu.h" #include "nvim/pos.h" -#include "nvim/quickfix.h" #include "nvim/regexp.h" #include "nvim/runtime.h" #include "nvim/search.h" @@ -92,7 +91,6 @@ #include "nvim/spell.h" #include "nvim/spellfile.h" #include "nvim/spellsuggest.h" -#include "nvim/statusline.h" #include "nvim/strings.h" #include "nvim/tag.h" #include "nvim/terminal.h" @@ -125,15 +123,15 @@ static char *p_ttytype = NULL; // Saved values for when 'bin' is set. static int p_et_nobin; static int p_ml_nobin; -static long p_tw_nobin; -static long p_wm_nobin; +static OptInt p_tw_nobin; +static OptInt p_wm_nobin; // Saved values for when 'paste' is set. static int p_ai_nopaste; static int p_et_nopaste; -static long p_sts_nopaste; -static long p_tw_nopaste; -static long p_wm_nopaste; +static OptInt p_sts_nopaste; +static OptInt p_tw_nopaste; +static OptInt p_wm_nopaste; static char *p_vsts_nopaste; #define OPTION_COUNT ARRAY_SIZE(options) @@ -172,7 +170,7 @@ void set_init_tablocal(void) { // susy baka: cmdheight calls itself OPT_GLOBAL but is really tablocal! int ch_idx = findoption("cmdheight"); - p_ch = (long)options[ch_idx].def_val; + p_ch = (OptInt)(intptr_t)options[ch_idx].def_val; } /// Initialize the 'shell' option to a default value. @@ -449,19 +447,18 @@ static void set_option_default(const int opt_idx, int opt_flags) if (opt->indir == PV_SCROLL) { win_comp_scroll(curwin); } else { - long def_val = (long)opt->def_val; - if ((long *)varp == &curwin->w_p_so - || (long *)varp == &curwin->w_p_siso) { + OptInt def_val = (OptInt)(intptr_t)opt->def_val; + if ((OptInt *)varp == &curwin->w_p_so + || (OptInt *)varp == &curwin->w_p_siso) { // 'scrolloff' and 'sidescrolloff' local values have a // different default value than the global default. - *(long *)varp = -1; + *(OptInt *)varp = -1; } else { - *(long *)varp = def_val; + *(OptInt *)varp = def_val; } // May also set global value for local option. if (both) { - *(long *)get_varp_scope(opt, OPT_GLOBAL) = - def_val; + *(OptInt *)get_varp_scope(opt, OPT_GLOBAL) = def_val; } } } else { // P_BOOL @@ -802,25 +799,25 @@ static void do_set_num(int opt_idx, int opt_flags, char **argp, int nextchar, co if (nextchar == '&') { value = (long)(intptr_t)options[opt_idx].def_val; } else if (nextchar == '<') { - if ((long *)varp == &curbuf->b_p_ul && opt_flags == OPT_LOCAL) { + if ((OptInt *)varp == &curbuf->b_p_ul && opt_flags == OPT_LOCAL) { // for 'undolevels' NO_LOCAL_UNDOLEVEL means using the global value value = NO_LOCAL_UNDOLEVEL; } else if (opt_flags == OPT_LOCAL - && ((long *)varp == &curwin->w_p_siso - || (long *)varp == &curwin->w_p_so)) { + && ((OptInt *)varp == &curwin->w_p_siso + || (OptInt *)varp == &curwin->w_p_so)) { // for 'scrolloff'/'sidescrolloff' -1 means using the global value value = -1; } else { - value = *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL); + value = *(OptInt *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL); } - } else if (((long *)varp == &p_wc - || (long *)varp == &p_wcm) + } else if (((OptInt *)varp == &p_wc + || (OptInt *)varp == &p_wcm) && (*arg == '<' || *arg == '^' || (*arg != NUL && (!arg[1] || ascii_iswhite(arg[1])) && !ascii_isdigit(*arg)))) { value = string_to_key(arg); - if (value == 0 && (long *)varp != &p_wcm) { + if (value == 0 && (OptInt *)varp != &p_wcm) { *errmsg = e_invarg; return; } @@ -838,13 +835,13 @@ static void do_set_num(int opt_idx, int opt_flags, char **argp, int nextchar, co } if (op == OP_ADDING) { - value = *(long *)varp + value; + value = *(OptInt *)varp + value; } if (op == OP_PREPENDING) { - value = *(long *)varp * value; + value = *(OptInt *)varp * value; } if (op == OP_REMOVING) { - value = *(long *)varp - value; + value = *(OptInt *)varp - value; } *errmsg = set_num_option(opt_idx, (void *)varp, (long)value, errbuf, errbuflen, opt_flags); @@ -1979,7 +1976,7 @@ void set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx) } /// Apply the OptionSet autocommand. -static void apply_optionset_autocmd(int opt_idx, long opt_flags, long oldval, long oldval_g, +static void apply_optionset_autocmd(int opt_idx, long opt_flags, OptInt oldval, OptInt oldval_g, long newval, const char *errmsg) { // Don't do this while starting up, failure or recursively. @@ -1989,8 +1986,8 @@ static void apply_optionset_autocmd(int opt_idx, long opt_flags, long oldval, lo char buf_old[12], buf_old_global[12], buf_new[12], buf_type[12]; - vim_snprintf(buf_old, sizeof(buf_old), "%ld", oldval); - vim_snprintf(buf_old_global, sizeof(buf_old_global), "%ld", oldval_g); + vim_snprintf(buf_old, sizeof(buf_old), "%" PRId64, oldval); + vim_snprintf(buf_old_global, sizeof(buf_old_global), "%" PRId64, oldval_g); vim_snprintf(buf_new, sizeof(buf_new), "%ld", newval); vim_snprintf(buf_type, sizeof(buf_type), "%s", (opt_flags & OPT_LOCAL) ? "local" : "global"); @@ -2040,74 +2037,149 @@ static const char *did_set_force_off(bool *doskip) return NULL; } -/// Process the updated 'langremap' option value. -static const char *did_set_langremap(optset_T *args FUNC_ATTR_UNUSED) +/// Process the updated 'arabic' option value. +static const char *did_set_arabic(optset_T *args) { - // 'langremap' -> !'langnoremap' - p_lnr = !p_lrm; + win_T *win = (win_T *)args->os_win; + const char *errmsg = NULL; + + if (win->w_p_arab) { + // 'arabic' is set, handle various sub-settings. + if (!p_tbidi) { + // set rightleft mode + if (!win->w_p_rl) { + win->w_p_rl = true; + changed_window_setting(); + } + + // Enable Arabic shaping (major part of what Arabic requires) + if (!p_arshape) { + p_arshape = true; + redraw_all_later(UPD_NOT_VALID); + } + } + + // Arabic requires a utf-8 encoding, inform the user if it's not + // set. + if (strcmp(p_enc, "utf-8") != 0) { + static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); + + msg_source(HL_ATTR(HLF_W)); + msg(_(w_arabic), HL_ATTR(HLF_W)); + set_vim_var_string(VV_WARNINGMSG, _(w_arabic), -1); + } + + // set 'delcombine' + p_deco = true; + + // Force-set the necessary keymap for arabic. + errmsg = set_option_value("keymap", STATIC_CSTR_AS_OPTVAL("arabic"), OPT_LOCAL); + } else { + // 'arabic' is reset, handle various sub-settings. + if (!p_tbidi) { + // reset rightleft mode + if (win->w_p_rl) { + win->w_p_rl = false; + changed_window_setting(); + } + + // 'arabicshape' isn't reset, it is a global option and + // another window may still need it "on". + } + + // 'delcombine' isn't reset, it is a global option and another + // window may still want it "on". + + // Revert to the default keymap + curbuf->b_p_iminsert = B_IMODE_NONE; + curbuf->b_p_imsearch = B_IMODE_USE_INSERT; + } + + return errmsg; +} + +/// Process the updated 'autochdir' option value. +static const char *did_set_autochdir(optset_T *args FUNC_ATTR_UNUSED) +{ + // Change directories when the 'acd' option is set now. + do_autochdir(); return NULL; } -/// Process the updated 'langnoremap' option value. -static const char *did_set_langnoremap(optset_T *args FUNC_ATTR_UNUSED) +/// Process the updated 'binary' option value. +static const char *did_set_binary(optset_T *args) { - // 'langnoremap' -> !'langremap' - p_lrm = !p_lnr; + buf_T *buf = (buf_T *)args->os_buf; + + // when 'bin' is set also set some other options + set_options_bin((int)args->os_oldval.boolean, buf->b_p_bin, args->os_flags); + redraw_titles(); + return NULL; } -/// Process the updated 'undofile' option value. -static const char *did_set_undofile(optset_T *args) +/// Called when the 'breakat' option changes value. +static const char *did_set_breakat(optset_T *args FUNC_ATTR_UNUSED) { - // Only take action when the option was set. - if (!curbuf->b_p_udf && !p_udf) { - return NULL; + for (int i = 0; i < 256; i++) { + breakat_flags[i] = false; } - // When reset we do not delete the undo file, the option may be set again - // without making any changes in between. - uint8_t hash[UNDO_HASH_SIZE]; - - FOR_ALL_BUFFERS(bp) { - // When 'undofile' is set globally: for every buffer, otherwise - // only for the current buffer: Try to read in the undofile, - // if one exists, the buffer wasn't changed and the buffer was - // loaded - if ((curbuf == bp - || (args->os_flags & OPT_GLOBAL) || args->os_flags == 0) - && !bufIsChanged(bp) && bp->b_ml.ml_mfp != NULL) { - u_compute_hash(bp, hash); - u_read_undo(NULL, hash, bp->b_fname); + if (p_breakat != NULL) { + for (char *p = p_breakat; *p; p++) { + breakat_flags[(uint8_t)(*p)] = true; } } return NULL; } -/// Process the updated 'readonly' option value. -static const char *did_set_readonly(optset_T *args) +/// Process the updated 'buflisted' option value. +static const char *did_set_buflisted(optset_T *args) { - // when 'readonly' is reset globally, also reset readonlymode - if (!curbuf->b_p_ro && (args->os_flags & OPT_LOCAL) == 0) { - readonlymode = false; + buf_T *buf = (buf_T *)args->os_buf; + + // when 'buflisted' changes, trigger autocommands + if (args->os_oldval.boolean != buf->b_p_bl) { + apply_autocmds(buf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, + NULL, NULL, true, buf); } + return NULL; +} - // when 'readonly' is set may give W10 again - if (curbuf->b_p_ro) { - curbuf->b_did_warn = false; +/// Process the new 'cmdheight' option value. +static const char *did_set_cmdheight(optset_T *args) +{ + OptInt old_value = args->os_oldval.number; + + if (ui_has(kUIMessages)) { + p_ch = 0; + } + if (p_ch > Rows - min_rows() + 1) { + p_ch = Rows - min_rows() + 1; } - redraw_titles(); + // if p_ch changed value, change the command line height + // Only compute the new window layout when startup has been + // completed. Otherwise the frame sizes may be wrong. + if ((p_ch != old_value + || tabline_height() + global_stl_height() + topframe->fr_height != Rows - p_ch) + && full_screen) { + command_height(); + } return NULL; } -/// Process the updated 'modifiable' option value. -static const char *did_set_modifiable(optset_T *args FUNC_ATTR_UNUSED) +/// Process the updated 'diff' option value. +static const char *did_set_diff(optset_T *args) { - // when 'modifiable' is changed, redraw the window title - redraw_titles(); - + win_T *win = (win_T *)args->os_win; + // May add or remove the buffer from the list of diff buffers. + diff_buf_adjust(win); + if (foldmethodIsDiff(win)) { + foldUpdateAll(win); + } return NULL; } @@ -2120,46 +2192,175 @@ static const char *did_set_eof_eol_fixeol_bomb(optset_T *args FUNC_ATTR_UNUSED) return NULL; } -/// Process the updated 'binary' option value. -static const char *did_set_binary(optset_T *args) +/// Process the updated 'equalalways' option value. +static const char *did_set_equalalways(optset_T *args) +{ + win_T *win = (win_T *)args->os_win; + if (p_ea && !args->os_oldval.boolean) { + win_equal(win, false, 0); + } + + return NULL; +} + +/// Process the new 'foldlevel' option value. +static const char *did_set_foldlevel(optset_T *args FUNC_ATTR_UNUSED) +{ + newFoldLevel(); + return NULL; +} + +/// Process the new 'foldminlines' option value. +static const char *did_set_foldminlines(optset_T *args) +{ + win_T *win = (win_T *)args->os_win; + foldUpdateAll(win); + return NULL; +} + +/// Process the new 'foldnestmax' option value. +static const char *did_set_foldnestmax(optset_T *args) +{ + win_T *win = (win_T *)args->os_win; + if (foldmethodIsSyntax(win) || foldmethodIsIndent(win)) { + foldUpdateAll(win); + } + return NULL; +} + +/// Process the new 'helpheight' option value. +static const char *did_set_helpheight(optset_T *args) +{ + // Change window height NOW + if (!ONE_WINDOW) { + buf_T *buf = (buf_T *)args->os_buf; + win_T *win = (win_T *)args->os_win; + if (buf->b_help && win->w_height < p_hh) { + win_setheight((int)p_hh); + } + } + + return NULL; +} + +/// Process the updated 'hlsearch' option value. +static const char *did_set_hlsearch(optset_T *args FUNC_ATTR_UNUSED) +{ + // when 'hlsearch' is set or reset: reset no_hlsearch + set_no_hlsearch(false); + return NULL; +} + +/// Process the updated 'ignorecase' option value. +static const char *did_set_ignorecase(optset_T *args FUNC_ATTR_UNUSED) +{ + // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw + if (p_hls) { + redraw_all_later(UPD_SOME_VALID); + } + return NULL; +} + +/// Process the new 'iminset' option value. +static const char *did_set_iminsert(optset_T *args FUNC_ATTR_UNUSED) +{ + showmode(); + // Show/unshow value of 'keymap' in status lines. + status_redraw_curbuf(); + + return NULL; +} + +/// Process the updated 'langnoremap' option value. +static const char *did_set_langnoremap(optset_T *args FUNC_ATTR_UNUSED) +{ + // 'langnoremap' -> !'langremap' + p_lrm = !p_lnr; + return NULL; +} + +/// Process the updated 'langremap' option value. +static const char *did_set_langremap(optset_T *args FUNC_ATTR_UNUSED) +{ + // 'langremap' -> !'langnoremap' + p_lnr = !p_lrm; + return NULL; +} + +/// Process the new 'laststatus' option value. +static const char *did_set_laststatus(optset_T *args) +{ + OptInt old_value = args->os_oldval.number; + OptInt value = args->os_newval.number; + + // When switching to global statusline, decrease topframe height + // Also clear the cmdline to remove the ruler if there is one + if (value == 3 && old_value != 3) { + frame_new_height(topframe, topframe->fr_height - STATUS_HEIGHT, false, false); + (void)win_comp_pos(); + clear_cmdline = true; + } + // When switching from global statusline, increase height of topframe by STATUS_HEIGHT + // in order to to re-add the space that was previously taken by the global statusline + if (old_value == 3 && value != 3) { + frame_new_height(topframe, topframe->fr_height + STATUS_HEIGHT, false, false); + (void)win_comp_pos(); + } + + last_status(false); // (re)set last window status line. + return NULL; +} + +/// Process the updated 'lisp' option value. +static const char *did_set_lisp(optset_T *args) { buf_T *buf = (buf_T *)args->os_buf; + // When 'lisp' option changes include/exclude '-' in keyword characters. + (void)buf_init_chartab(buf, false); // ignore errors + return NULL; +} - // when 'bin' is set also set some other options - set_options_bin((int)args->os_oldval.boolean, buf->b_p_bin, args->os_flags); +/// Process the updated 'modifiable' option value. +static const char *did_set_modifiable(optset_T *args FUNC_ATTR_UNUSED) +{ + // when 'modifiable' is changed, redraw the window title redraw_titles(); return NULL; } -/// Process the updated 'buflisted' option value. -static const char *did_set_buflisted(optset_T *args) +/// Process the updated 'modified' option value. +static const char *did_set_modified(optset_T *args) { buf_T *buf = (buf_T *)args->os_buf; - - // when 'buflisted' changes, trigger autocommands - if (args->os_oldval.boolean != buf->b_p_bl) { - apply_autocmds(buf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, - NULL, NULL, true, buf); + if (!args->os_newval.boolean) { + save_file_ff(buf); // Buffer is unchanged } + redraw_titles(); + modified_was_set = (int)args->os_newval.boolean; return NULL; } -/// Process the updated 'swapfile' option value. -static const char *did_set_swapfile(optset_T *args) +/// Process the updated 'number' or 'relativenumber' option value. +static const char *did_set_number_relativenumber(optset_T *args) { - buf_T *buf = (buf_T *)args->os_buf; - // when 'swf' is set, create swapfile, when reset remove swapfile - if (buf->b_p_swf && p_uc) { - ml_open_file(buf); // create the swap file - } else { - // no need to reset curbuf->b_may_swap, ml_open_file() will check - // buf->b_p_swf - mf_close_file(buf, true); // remove the swap file + win_T *win = (win_T *)args->os_win; + if (*win->w_p_stc != NUL) { + // When 'relativenumber'/'number' is changed and 'statuscolumn' is set, reset width. + win->w_nrwidth_line_count = 0; } return NULL; } +/// Process the new 'numberwidth' option value. +static const char *did_set_numberwidth(optset_T *args) +{ + win_T *win = (win_T *)args->os_win; + win->w_nrwidth_line_count = 0; // trigger a redraw + + return NULL; +} + /// Process the updated 'paste' option value. static const char *did_set_paste(optset_T *args FUNC_ATTR_UNUSED) { @@ -2289,39 +2490,6 @@ static const char *did_set_paste(optset_T *args FUNC_ATTR_UNUSED) return NULL; } -/// Process the updated 'ignorecase' option value. -static const char *did_set_ignorecase(optset_T *args FUNC_ATTR_UNUSED) -{ - // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw - if (p_hls) { - redraw_all_later(UPD_SOME_VALID); - } - return NULL; -} - -/// Process the updated 'hlsearch' option value. -static const char *did_set_hlsearch(optset_T *args FUNC_ATTR_UNUSED) -{ - // when 'hlsearch' is set or reset: reset no_hlsearch - set_no_hlsearch(false); - return NULL; -} - -/// Process the updated 'scrollbind' option value. -static const char *did_set_scrollbind(optset_T *args) -{ - win_T *win = (win_T *)args->os_win; - - // when 'scrollbind' is set: snapshot the current position to avoid a jump - // at the end of normal_cmd() - if (!win->w_p_scb) { - return NULL; - } - do_check_scrollbind(false); - win->w_scbind_pos = win->w_topline; - return NULL; -} - /// Process the updated 'previewwindow' option value. static const char *did_set_previewwindow(optset_T *args) { @@ -2343,32 +2511,63 @@ static const char *did_set_previewwindow(optset_T *args) return NULL; } -/// Process the updated 'lisp' option value. -static const char *did_set_lisp(optset_T *args) +/// Process the new 'pumblend' option value. +static const char *did_set_pumblend(optset_T *args FUNC_ATTR_UNUSED) { - buf_T *buf = (buf_T *)args->os_buf; - // When 'lisp' option changes include/exclude '-' in keyword characters. - (void)buf_init_chartab(buf, false); // ignore errors + p_pb = MAX(MIN(p_pb, 100), 0); + hl_invalidate_blends(); + pum_grid.blending = (p_pb > 0); + if (pum_drawn()) { + pum_redraw(); + } + return NULL; } -/// Process the updated 'title' or the 'icon' option value. -static const char *did_set_title_icon(optset_T *args FUNC_ATTR_UNUSED) +/// Process the updated 'readonly' option value. +static const char *did_set_readonly(optset_T *args) { - // when 'title' changed, may need to change the title; same for 'icon' - did_set_title(); + // when 'readonly' is reset globally, also reset readonlymode + if (!curbuf->b_p_ro && (args->os_flags & OPT_LOCAL) == 0) { + readonlymode = false; + } + + // when 'readonly' is set may give W10 again + if (curbuf->b_p_ro) { + curbuf->b_did_warn = false; + } + + redraw_titles(); + return NULL; } -/// Process the updated 'modified' option value. -static const char *did_set_modified(optset_T *args) +/// Process the new 'scrollback' option value. +static const char *did_set_scrollback(optset_T *args) { buf_T *buf = (buf_T *)args->os_buf; - if (!args->os_newval.boolean) { - save_file_ff(buf); // Buffer is unchanged + OptInt old_value = args->os_oldval.number; + OptInt value = args->os_newval.number; + + if (buf->terminal && value < old_value) { + // Force the scrollback to take immediate effect only when decreasing it. + on_scrollback_option_changed(buf->terminal); } - redraw_titles(); - modified_was_set = (int)args->os_newval.boolean; + return NULL; +} + +/// Process the updated 'scrollbind' option value. +static const char *did_set_scrollbind(optset_T *args) +{ + win_T *win = (win_T *)args->os_win; + + // when 'scrollbind' is set: snapshot the current position to avoid a jump + // at the end of normal_cmd() + if (!win->w_p_scb) { + return NULL; + } + do_check_scrollbind(false); + win->w_scbind_pos = win->w_topline; return NULL; } @@ -2394,46 +2593,43 @@ static const char *did_set_shellslash(optset_T *args FUNC_ATTR_UNUSED) } #endif -/// Process the updated 'wrap' option value. -static const char *did_set_wrap(optset_T *args) +/// Process the new 'shiftwidth' or the 'tabstop' option value. +static const char *did_set_shiftwidth_tabstop(optset_T *args) { + buf_T *buf = (buf_T *)args->os_buf; win_T *win = (win_T *)args->os_win; + OptInt *pp = (OptInt *)args->os_varp; - // If 'wrap' is set, set w_leftcol to zero. - if (win->w_p_wrap) { - win->w_leftcol = 0; + if (foldmethodIsIndent(win)) { + foldUpdateAll(win); } - return NULL; -} - -/// Process the updated 'equalalways' option value. -static const char *did_set_equalalways(optset_T *args) -{ - win_T *win = (win_T *)args->os_win; - if (p_ea && !args->os_oldval.boolean) { - win_equal(win, false, 0); + // When 'shiftwidth' changes, or it's zero and 'tabstop' changes: + // parse 'cinoptions'. + if (pp == &buf->b_p_sw || buf->b_p_sw == 0) { + parse_cino(buf); } return NULL; } -/// Process the updated 'autochdir' option value. -static const char *did_set_autochdir(optset_T *args FUNC_ATTR_UNUSED) +/// Process the new 'showtabline' option value. +static const char *did_set_showtabline(optset_T *args FUNC_ATTR_UNUSED) { - // Change directories when the 'acd' option is set now. - do_autochdir(); + // (re)set tab page line + win_new_screen_rows(); // recompute window positions and heights return NULL; } -/// Process the updated 'diff' option value. -static const char *did_set_diff(optset_T *args) +/// Process the updated 'smoothscroll' option value. +static const char *did_set_smoothscroll(optset_T *args FUNC_ATTR_UNUSED) { win_T *win = (win_T *)args->os_win; - // May add or remove the buffer from the list of diff buffers. - diff_buf_adjust(win); - if (foldmethodIsDiff(win)) { - foldUpdateAll(win); + if (win->w_p_sms) { + return NULL; } + + win->w_skipcol = 0; + changed_line_abv_curs_win(win); return NULL; } @@ -2448,74 +2644,189 @@ static const char *did_set_spell(optset_T *args) return NULL; } -/// Process the updated 'arabic' option value. -static const char *did_set_arabic(optset_T *args) +/// Process the updated 'swapfile' option value. +static const char *did_set_swapfile(optset_T *args) { - win_T *win = (win_T *)args->os_win; - const char *errmsg = NULL; + buf_T *buf = (buf_T *)args->os_buf; + // when 'swf' is set, create swapfile, when reset remove swapfile + if (buf->b_p_swf && p_uc) { + ml_open_file(buf); // create the swap file + } else { + // no need to reset curbuf->b_may_swap, ml_open_file() will check + // buf->b_p_swf + mf_close_file(buf, true); // remove the swap file + } + return NULL; +} - if (win->w_p_arab) { - // 'arabic' is set, handle various sub-settings. - if (!p_tbidi) { - // set rightleft mode - if (!win->w_p_rl) { - win->w_p_rl = true; - changed_window_setting(); - } +/// Process the new 'textwidth' option value. +static const char *did_set_textwidth(optset_T *args FUNC_ATTR_UNUSED) +{ + FOR_ALL_TAB_WINDOWS(tp, wp) { + check_colorcolumn(wp); + } - // Enable Arabic shaping (major part of what Arabic requires) - if (!p_arshape) { - p_arshape = true; - redraw_all_later(UPD_NOT_VALID); - } - } + return NULL; +} - // Arabic requires a utf-8 encoding, inform the user if it's not - // set. - if (strcmp(p_enc, "utf-8") != 0) { - static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); +/// Process the updated 'title' or the 'icon' option value. +static const char *did_set_title_icon(optset_T *args FUNC_ATTR_UNUSED) +{ + // when 'title' changed, may need to change the title; same for 'icon' + did_set_title(); + return NULL; +} - msg_source(HL_ATTR(HLF_W)); - msg_attr(_(w_arabic), HL_ATTR(HLF_W)); - set_vim_var_string(VV_WARNINGMSG, _(w_arabic), -1); - } +/// Process the new 'titlelen' option value. +static const char *did_set_titlelen(optset_T *args) +{ + OptInt old_value = args->os_oldval.number; - // set 'delcombine' - p_deco = true; + // if 'titlelen' has changed, redraw the title + if (starting != NO_SCREEN && old_value != p_titlelen) { + need_maketitle = true; + } - // Force-set the necessary keymap for arabic. - errmsg = set_option_value("keymap", STATIC_CSTR_AS_OPTVAL("arabic"), OPT_LOCAL); - } else { - // 'arabic' is reset, handle various sub-settings. - if (!p_tbidi) { - // reset rightleft mode - if (win->w_p_rl) { - win->w_p_rl = false; - changed_window_setting(); - } + return NULL; +} - // 'arabicshape' isn't reset, it is a global option and - // another window may still need it "on". +/// Process the updated 'undofile' option value. +static const char *did_set_undofile(optset_T *args) +{ + // Only take action when the option was set. + if (!curbuf->b_p_udf && !p_udf) { + return NULL; + } + + // When reset we do not delete the undo file, the option may be set again + // without making any changes in between. + uint8_t hash[UNDO_HASH_SIZE]; + + FOR_ALL_BUFFERS(bp) { + // When 'undofile' is set globally: for every buffer, otherwise + // only for the current buffer: Try to read in the undofile, + // if one exists, the buffer wasn't changed and the buffer was + // loaded + if ((curbuf == bp + || (args->os_flags & OPT_GLOBAL) || args->os_flags == 0) + && !bufIsChanged(bp) && bp->b_ml.ml_mfp != NULL) { + u_compute_hash(bp, hash); + u_read_undo(NULL, hash, bp->b_fname); } + } - // 'delcombine' isn't reset, it is a global option and another - // window may still want it "on". + return NULL; +} - // Revert to the default keymap - curbuf->b_p_iminsert = B_IMODE_NONE; - curbuf->b_p_imsearch = B_IMODE_USE_INSERT; +/// Process the new global 'undolevels' option value. +const char *did_set_global_undolevels(OptInt value, OptInt old_value) +{ + // sync undo before 'undolevels' changes + // use the old value, otherwise u_sync() may not work properly + p_ul = old_value; + u_sync(true); + p_ul = value; + return NULL; +} + +/// Process the new buffer local 'undolevels' option value. +const char *did_set_buflocal_undolevels(buf_T *buf, OptInt value, OptInt old_value) +{ + // use the old value, otherwise u_sync() may not work properly + buf->b_p_ul = old_value; + u_sync(true); + buf->b_p_ul = value; + return NULL; +} + +/// Process the new 'undolevels' option value. +static const char *did_set_undolevels(optset_T *args) +{ + buf_T *buf = (buf_T *)args->os_buf; + OptInt *pp = (OptInt *)args->os_varp; + + if (pp == &p_ul) { // global 'undolevels' + did_set_global_undolevels(args->os_newval.number, args->os_oldval.number); + } else if (pp == &curbuf->b_p_ul) { // buffer local 'undolevels' + did_set_buflocal_undolevels(buf, args->os_newval.number, args->os_oldval.number); } - return errmsg; + return NULL; } -/// Process the updated 'number' or 'relativenumber' option value. -static const char *did_set_number_relativenumber(optset_T *args) +/// Process the new 'updatecount' option value. +static const char *did_set_updatecount(optset_T *args) +{ + OptInt old_value = args->os_oldval.number; + + // when 'updatecount' changes from zero to non-zero, open swap files + if (p_uc && !old_value) { + ml_open_files(); + } + + return NULL; +} + +/// Process the new 'winblend' option value. +static const char *did_set_winblend(optset_T *args) { win_T *win = (win_T *)args->os_win; - if (*win->w_p_stc != NUL) { - // When 'relativenumber'/'number' is changed and 'statuscolumn' is set, reset width. - win->w_nrwidth_line_count = 0; + OptInt old_value = args->os_oldval.number; + OptInt value = args->os_newval.number; + + if (value != old_value) { + win->w_p_winbl = MAX(MIN(win->w_p_winbl, 100), 0); + win->w_hl_needs_update = true; + check_blending(curwin); + } + + return NULL; +} + +/// Process the new 'window' option value. +static const char *did_set_window(optset_T *args FUNC_ATTR_UNUSED) +{ + if (p_window < 1) { + p_window = Rows - 1; + } else if (p_window >= Rows) { + p_window = Rows - 1; + } + return NULL; +} + +/// Process the new 'winheight' value. +static const char *did_set_winheight(optset_T *args) +{ + // Change window height NOW + if (!ONE_WINDOW) { + win_T *win = (win_T *)args->os_win; + if (win->w_height < p_wh) { + win_setheight((int)p_wh); + } + } + + return NULL; +} + +/// Process the new 'winwidth' option value. +static const char *did_set_winwidth(optset_T *args) +{ + win_T *win = (win_T *)args->os_win; + + if (!ONE_WINDOW && win->w_width < p_wiw) { + win_setwidth((int)p_wiw); + } + return NULL; +} + +/// Process the updated 'wrap' option value. +static const char *did_set_wrap(optset_T *args) +{ + win_T *win = (win_T *)args->os_win; + + // If 'wrap' is set, set w_leftcol to zero. + if (win->w_p_wrap) { + win->w_leftcol = 0; } return NULL; } @@ -2609,307 +2920,9 @@ static const char *set_bool_option(const int opt_idx, char *const varp, const in return errmsg; } -/// Process the new 'winheight' value. -static const char *did_set_winheight(optset_T *args) -{ - // Change window height NOW - if (!ONE_WINDOW) { - win_T *win = (win_T *)args->os_win; - if (win->w_height < p_wh) { - win_setheight((int)p_wh); - } - } - - return NULL; -} - -/// Process the new 'helpheight' option value. -static const char *did_set_helpheight(optset_T *args) -{ - // Change window height NOW - if (!ONE_WINDOW) { - buf_T *buf = (buf_T *)args->os_buf; - win_T *win = (win_T *)args->os_win; - if (buf->b_help && win->w_height < p_hh) { - win_setheight((int)p_hh); - } - } - - return NULL; -} - -/// Process the new 'winwidth' option value. -static const char *did_set_winwidth(optset_T *args) -{ - win_T *win = (win_T *)args->os_win; - - if (!ONE_WINDOW && win->w_width < p_wiw) { - win_setwidth((int)p_wiw); - } - return NULL; -} - -/// Process the new 'laststatus' option value. -static const char *did_set_laststatus(optset_T *args) -{ - long old_value = args->os_oldval.number; - long value = args->os_newval.number; - - // When switching to global statusline, decrease topframe height - // Also clear the cmdline to remove the ruler if there is one - if (value == 3 && old_value != 3) { - frame_new_height(topframe, topframe->fr_height - STATUS_HEIGHT, false, false); - (void)win_comp_pos(); - clear_cmdline = true; - } - // When switching from global statusline, increase height of topframe by STATUS_HEIGHT - // in order to to re-add the space that was previously taken by the global statusline - if (old_value == 3 && value != 3) { - frame_new_height(topframe, topframe->fr_height + STATUS_HEIGHT, false, false); - (void)win_comp_pos(); - } - - last_status(false); // (re)set last window status line. - return NULL; -} - -/// Process the new 'showtabline' option value. -static const char *did_set_showtabline(optset_T *args FUNC_ATTR_UNUSED) -{ - // (re)set tab page line - win_new_screen_rows(); // recompute window positions and heights - return NULL; -} - -/// Process the updated 'smoothscroll' option value. -static const char *did_set_smoothscroll(optset_T *args FUNC_ATTR_UNUSED) -{ - win_T *win = (win_T *)args->os_win; - if (win->w_p_sms) { - return NULL; - } - - win->w_skipcol = 0; - changed_line_abv_curs_win(win); - return NULL; -} - -/// Process the new 'foldlevel' option value. -static const char *did_set_foldlevel(optset_T *args FUNC_ATTR_UNUSED) -{ - newFoldLevel(); - return NULL; -} - -/// Process the new 'foldminlines' option value. -static const char *did_set_foldminlines(optset_T *args) -{ - win_T *win = (win_T *)args->os_win; - foldUpdateAll(win); - return NULL; -} - -/// Process the new 'foldnestmax' option value. -static const char *did_set_foldnestmax(optset_T *args) -{ - win_T *win = (win_T *)args->os_win; - if (foldmethodIsSyntax(win) || foldmethodIsIndent(win)) { - foldUpdateAll(win); - } - return NULL; -} - -/// Process the new 'shiftwidth' or the 'tabstop' option value. -static const char *did_set_shiftwidth_tabstop(optset_T *args) -{ - buf_T *buf = (buf_T *)args->os_buf; - win_T *win = (win_T *)args->os_win; - long *pp = (long *)args->os_varp; - - if (foldmethodIsIndent(win)) { - foldUpdateAll(win); - } - // When 'shiftwidth' changes, or it's zero and 'tabstop' changes: - // parse 'cinoptions'. - if (pp == &buf->b_p_sw || buf->b_p_sw == 0) { - parse_cino(buf); - } - - return NULL; -} - -/// Process the new 'iminset' option value. -static const char *did_set_iminsert(optset_T *args FUNC_ATTR_UNUSED) -{ - showmode(); - // Show/unshow value of 'keymap' in status lines. - status_redraw_curbuf(); - - return NULL; -} - -/// Process the new 'window' option value. -static const char *did_set_window(optset_T *args FUNC_ATTR_UNUSED) -{ - if (p_window < 1) { - p_window = Rows - 1; - } else if (p_window >= Rows) { - p_window = Rows - 1; - } - return NULL; -} - -/// Process the new 'titlelen' option value. -static const char *did_set_titlelen(optset_T *args) -{ - long old_value = args->os_oldval.number; - - // if 'titlelen' has changed, redraw the title - if (starting != NO_SCREEN && old_value != p_titlelen) { - need_maketitle = true; - } - - return NULL; -} - -/// Process the new 'cmdheight' option value. -static const char *did_set_cmdheight(optset_T *args) -{ - long old_value = args->os_oldval.number; - - if (ui_has(kUIMessages)) { - p_ch = 0; - } - if (p_ch > Rows - min_rows() + 1) { - p_ch = Rows - min_rows() + 1; - } - - // if p_ch changed value, change the command line height - // Only compute the new window layout when startup has been - // completed. Otherwise the frame sizes may be wrong. - if ((p_ch != old_value - || tabline_height() + global_stl_height() + topframe->fr_height != Rows - p_ch) - && full_screen) { - command_height(); - } - - return NULL; -} - -/// Process the new 'updatecount' option value. -static const char *did_set_updatecount(optset_T *args) -{ - long old_value = args->os_oldval.number; - - // when 'updatecount' changes from zero to non-zero, open swap files - if (p_uc && !old_value) { - ml_open_files(); - } - - return NULL; -} - -/// Process the new 'pumblend' option value. -static const char *did_set_pumblend(optset_T *args FUNC_ATTR_UNUSED) -{ - p_pb = MAX(MIN(p_pb, 100), 0); - hl_invalidate_blends(); - pum_grid.blending = (p_pb > 0); - if (pum_drawn()) { - pum_redraw(); - } - - return NULL; -} - -/// Process the new global 'undolevels' option value. -const char *did_set_global_undolevels(long value, long old_value) -{ - // sync undo before 'undolevels' changes - // use the old value, otherwise u_sync() may not work properly - p_ul = old_value; - u_sync(true); - p_ul = value; - return NULL; -} - -/// Process the new buffer local 'undolevels' option value. -const char *did_set_buflocal_undolevels(buf_T *buf, long value, long old_value) -{ - // use the old value, otherwise u_sync() may not work properly - buf->b_p_ul = old_value; - u_sync(true); - buf->b_p_ul = value; - return NULL; -} - -/// Process the new 'scrollback' option value. -static const char *did_set_scrollback(optset_T *args) -{ - buf_T *buf = (buf_T *)args->os_buf; - long old_value = args->os_oldval.number; - long value = args->os_newval.number; - - if (buf->terminal && value < old_value) { - // Force the scrollback to take immediate effect only when decreasing it. - on_scrollback_option_changed(buf->terminal); - } - return NULL; -} - -/// Process the new 'numberwidth' option value. -static const char *did_set_numberwidth(optset_T *args) -{ - win_T *win = (win_T *)args->os_win; - win->w_nrwidth_line_count = 0; // trigger a redraw - - return NULL; -} - -/// Process the new 'textwidth' option value. -static const char *did_set_textwidth(optset_T *args FUNC_ATTR_UNUSED) -{ - FOR_ALL_TAB_WINDOWS(tp, wp) { - check_colorcolumn(wp); - } - - return NULL; -} - -/// Process the new 'winblend' option value. -static const char *did_set_winblend(optset_T *args) -{ - win_T *win = (win_T *)args->os_win; - long old_value = args->os_oldval.number; - long value = args->os_newval.number; - - if (value != old_value) { - win->w_p_winbl = MAX(MIN(win->w_p_winbl, 100), 0); - win->w_hl_needs_update = true; - check_blending(curwin); - } - - return NULL; -} - -/// Process the new 'undolevels' option value. -static const char *did_set_undolevels(optset_T *args) -{ - buf_T *buf = (buf_T *)args->os_buf; - long *pp = (long *)args->os_varp; - - if (pp == &p_ul) { // global 'undolevels' - did_set_global_undolevels(args->os_newval.number, args->os_oldval.number); - } else if (pp == &curbuf->b_p_ul) { // buffer local 'undolevels' - did_set_buflocal_undolevels(buf, args->os_newval.number, args->os_oldval.number); - } - - return NULL; -} - /// Check the bounds of numeric options. -static const char *check_num_option_bounds(long *pp, long old_value, long old_Rows, char *errbuf, - size_t errbuflen, const char *errmsg) +static const char *check_num_option_bounds(OptInt *pp, OptInt old_value, long old_Rows, + char *errbuf, size_t errbuflen, const char *errmsg) { // Check the (new) bounds for Rows and Columns here. if (p_lines < min_rows() && full_screen) { @@ -2984,7 +2997,7 @@ static const char *check_num_option_bounds(long *pp, long old_value, long old_Ro } /// Options that need some validation. -static const char *validate_num_option(const long *pp, long *valuep) +static const char *validate_num_option(const OptInt *pp, long *valuep) { long value = *valuep; @@ -3147,10 +3160,10 @@ static const char *validate_num_option(const long *pp, long *valuep) static const char *set_num_option(int opt_idx, void *varp, long value, char *errbuf, size_t errbuflen, int opt_flags) { - long old_value = *(long *)varp; - long old_global_value = 0; // only used when setting a local and global option + OptInt old_value = *(OptInt *)varp; + OptInt old_global_value = 0; // only used when setting a local and global option long old_Rows = Rows; // remember old Rows - long *pp = (long *)varp; + OptInt *pp = (OptInt *)varp; // Disallow changing some options from secure mode. if ((secure || sandbox != 0) && (options[opt_idx].flags & P_SECURE)) { @@ -3161,7 +3174,7 @@ static const char *set_num_option(int opt_idx, void *varp, long value, char *err // a global-only option setting the "local value" in fact sets the global // value (since there is only one value). if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) { - old_global_value = *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL); + old_global_value = *(OptInt *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL); } const char *errmsg = validate_num_option(pp, &value); @@ -3171,7 +3184,7 @@ static const char *set_num_option(int opt_idx, void *varp, long value, char *err return errmsg; } - *pp = value; + *pp = (OptInt)value; // Remember where the option was set. set_option_sctx_idx(opt_idx, opt_flags, current_sctx); @@ -3182,7 +3195,7 @@ static const char *set_num_option(int opt_idx, void *varp, long value, char *err .os_varp = varp, .os_flags = opt_flags, .os_oldval.number = old_value, - .os_newval.number = value, + .os_newval.number = (OptInt)value, .os_errbuf = NULL, .os_errbuflen = 0, .os_buf = curbuf, @@ -3196,7 +3209,7 @@ static const char *set_num_option(int opt_idx, void *varp, long value, char *err // May set global value for local option. if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) { - *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; + *(OptInt *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; } options[opt_idx].flags |= P_WAS_SET; @@ -3581,7 +3594,7 @@ OptVal get_option_value(const char *name, uint32_t *flagsp, int scope, bool *hid } if (options[opt_idx].flags & P_NUM) { - return NUMBER_OPTVAL(varp == NULL ? 0 : (*(long *)varp)); + return NUMBER_OPTVAL(varp == NULL ? 0 : (*(OptInt *)varp)); } else { // Special case: 'modified' is b_changed, but we also want to consider // it set when 'ff' or 'fenc' changed. @@ -3709,7 +3722,7 @@ int get_option_value_strict(char *name, int64_t *numval, char **stringval, int o if (p->flags & P_STRING) { *stringval = *(char **)(varp); } else if (p->flags & P_NUM) { - *numval = *(long *)varp; + *numval = *(OptInt *)varp; } else { *numval = *(int *)varp; } @@ -3745,10 +3758,10 @@ static OptVal clear_optval(const char *name, uint32_t flags, void *varp, buf_T * } } else if (flags & P_NUM) { v.type = kOptValTypeNumber; - if ((long *)varp == &curbuf->b_p_ul) { + if ((OptInt *)varp == &curbuf->b_p_ul) { // The one true special case v.data.number = NO_LOCAL_UNDOLEVEL; - } else if ((long *)varp == &win->w_p_so || (long *)varp == &win->w_p_siso) { + } else if ((OptInt *)varp == &win->w_p_so || (OptInt *)varp == &win->w_p_siso) { // TODO(lewis6991): replace this with a more general condition that // indicates we are setting the local value of a global-local option v.data.number = -1; @@ -3996,7 +4009,7 @@ static int optval_default(vimoption_T *p, const void *varp) return true; // hidden option is always at default } if (p->flags & P_NUM) { - return *(long *)varp == (long)(intptr_t)p->def_val; + return *(OptInt *)varp == (OptInt)(intptr_t)p->def_val; } if (p->flags & P_BOOL) { return *(int *)varp == (int)(intptr_t)p->def_val; @@ -4019,7 +4032,7 @@ void ui_refresh_options(void) if (flags & P_BOOL) { value = BOOLEAN_OBJ(*(int *)varp); } else if (flags & P_NUM) { - value = INTEGER_OBJ(*(long *)varp); + value = INTEGER_OBJ(*(OptInt *)varp); } else if (flags & P_STRING) { // cstr_as_string handles NULL string value = CSTR_AS_OBJ(*(char **)varp); @@ -4058,7 +4071,7 @@ static void showoneopt(vimoption_T *p, int opt_flags) msg_putchar('='); // put value string in NameBuff option_value2string(p, opt_flags); - msg_outtrans(NameBuff); + msg_outtrans(NameBuff, 0); } silent_mode = save_silent; @@ -4160,7 +4173,7 @@ int makeset(FILE *fd, int opt_flags, int local_only) return FAIL; } } else if (p->flags & P_NUM) { - if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) { + if (put_setnum(fd, cmd, p->fullname, (OptInt *)varp) == FAIL) { return FAIL; } } else { // P_STRING @@ -4273,12 +4286,12 @@ fail: return FAIL; } -static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep) +static int put_setnum(FILE *fd, char *cmd, char *name, OptInt *valuep) { if (fprintf(fd, "%s %s=", cmd, name) < 0) { return FAIL; } - long wc; + OptInt wc; if (wc_use_keyname(valuep, &wc)) { // print 'wildchar' and 'wildcharm' as a key name if (fputs(get_special_key_name((int)wc, 0), fd) < 0) { @@ -5647,7 +5660,7 @@ static void option_value2string(vimoption_T *opp, int scope) void *varp = get_varp_scope(opp, scope); if (opp->flags & P_NUM) { - long wc = 0; + OptInt wc = 0; if (wc_use_keyname(varp, &wc)) { xstrlcpy(NameBuff, get_special_key_name((int)wc, 0), sizeof(NameBuff)); @@ -5657,7 +5670,7 @@ static void option_value2string(vimoption_T *opp, int scope) snprintf(NameBuff, sizeof(NameBuff), "%" PRId64, - (int64_t)(*(long *)varp)); + (int64_t)(*(OptInt *)varp)); } } else { // P_STRING varp = *(char **)(varp); @@ -5674,10 +5687,10 @@ static void option_value2string(vimoption_T *opp, int scope) /// Return true if "varp" points to 'wildchar' or 'wildcharm' and it can be /// printed as a keyname. /// "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'. -static int wc_use_keyname(const void *varp, long *wcp) +static int wc_use_keyname(const void *varp, OptInt *wcp) { - if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm)) { - *wcp = *(long *)varp; + if (((OptInt *)varp == &p_wc) || ((OptInt *)varp == &p_wcm)) { + *wcp = *(OptInt *)varp; if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)(*wcp)) >= 0) { return true; } @@ -5747,22 +5760,6 @@ void reset_option_was_set(const char *name) options[idx].flags &= ~P_WAS_SET; } -/// Called when the 'breakat' option changes value. -static const char *did_set_breakat(optset_T *args FUNC_ATTR_UNUSED) -{ - for (int i = 0; i < 256; i++) { - breakat_flags[i] = false; - } - - if (p_breakat != NULL) { - for (char *p = p_breakat; *p; p++) { - breakat_flags[(uint8_t)(*p)] = true; - } - } - - return NULL; -} - /// fill_culopt_flags() -- called when 'culopt' changes value int fill_culopt_flags(char *val, win_T *wp) { @@ -6158,7 +6155,7 @@ dict_T *get_winbuf_options(const int bufopt) *(const char **)varp); } else if (opt->flags & P_NUM) { tv_dict_add_nr(d, opt->fullname, strlen(opt->fullname), - *(long *)varp); + *(OptInt *)varp); } else { tv_dict_add_nr(d, opt->fullname, strlen(opt->fullname), *(int *)varp); } diff --git a/src/nvim/option.h b/src/nvim/option.h index 4b8329ad1c..9e3bf25bc3 100644 --- a/src/nvim/option.h +++ b/src/nvim/option.h @@ -1,15 +1,95 @@ #ifndef NVIM_OPTION_H #define NVIM_OPTION_H +#include <stdint.h> + #include "nvim/api/private/helpers.h" +#include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" +#include "nvim/option_defs.h" + +/// The options that are local to a window or buffer have "indir" set to one of +/// these values. Special values: +/// PV_NONE: global option. +/// PV_WIN is added: window-local option +/// PV_BUF is added: buffer-local option +/// PV_BOTH is added: global option which also has a local value. +enum { + PV_BOTH = 0x1000, + PV_WIN = 0x2000, + PV_BUF = 0x4000, + PV_MASK = 0x0fff, +}; +#define OPT_WIN(x) (idopt_T)(PV_WIN + (int)(x)) +#define OPT_BUF(x) (idopt_T)(PV_BUF + (int)(x)) +#define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x)) + +/// WV_ and BV_ values get typecasted to this for the "indir" field +typedef enum { + PV_NONE = 0, + PV_MAXVAL = 0xffff, ///< to avoid warnings for value out of range +} idopt_T; + +// Options local to a window have a value local to a buffer and global to all +// buffers. Indicate this by setting "var" to VAR_WIN. +#define VAR_WIN ((char *)-1) + +typedef struct vimoption { + char *fullname; ///< full option name + char *shortname; ///< permissible abbreviation + uint32_t flags; ///< see above + void *var; ///< global option: pointer to variable; + ///< window-local option: VAR_WIN; + ///< buffer-local option: global value + idopt_T indir; ///< global option: PV_NONE; + ///< local option: indirect option index + ///< callback function to invoke after an option is modified to validate and + ///< apply the new value. + opt_did_set_cb_T opt_did_set_cb; + void *def_val; ///< default values for variable (neovim!!) + LastSet last_set; ///< script in which the option was last set +} vimoption_T; + +/// flags for buf_copy_options() +enum { + BCO_ENTER = 1, ///< going to enter the buffer + BCO_ALWAYS = 2, ///< always copy the options + BCO_NOHELP = 4, ///< don't touch the help related options +}; + +/// Flags for option-setting functions +/// +/// When OPT_GLOBAL and OPT_LOCAL are both missing, set both local and global +/// values, get local value. +typedef enum { + OPT_FREE = 0x01, ///< Free old value if it was allocated. + OPT_GLOBAL = 0x02, ///< Use global value. + OPT_LOCAL = 0x04, ///< Use local value. + OPT_MODELINE = 0x08, ///< Option in modeline. + OPT_WINONLY = 0x10, ///< Only set window-local options. + OPT_NOWIN = 0x20, ///< Don’t set window-local options. + OPT_ONECOLUMN = 0x40, ///< list options one per line + OPT_NO_REDRAW = 0x80, ///< ignore redraw flags on option + OPT_SKIPRTP = 0x100, ///< "skiprtp" in 'sessionoptions' +} OptionFlags; -// flags for buf_copy_options() -#define BCO_ENTER 1 // going to enter the buffer -#define BCO_ALWAYS 2 // always copy the options -#define BCO_NOHELP 4 // don't touch the help related options +/// Return value from get_option_value_strict +enum { + SOPT_BOOL = 0x01, ///< Boolean option + SOPT_NUM = 0x02, ///< Number option + SOPT_STRING = 0x04, ///< String option + SOPT_GLOBAL = 0x08, ///< Option has global value + SOPT_WIN = 0x10, ///< Option has window-local value + SOPT_BUF = 0x20, ///< Option has buffer-local value + SOPT_UNSET = 0x40, ///< Option does not have local value set +}; -#define MAX_NUMBERWIDTH 20 // used for 'numberwidth' and 'statuscolumn' +/// Option types for various functions in option.c +enum { + SREQ_GLOBAL = 0, ///< Request global option value + SREQ_WIN = 1, ///< Request window-local option value + SREQ_BUF = 2, ///< Request buffer-local option value +}; // OptVal helper macros. #define NIL_OPTVAL ((OptVal) { .type = kOptValTypeNil }) diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 317bc989e5..f078f6073c 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -3,1019 +3,69 @@ #include "nvim/api/private/defs.h" #include "nvim/eval/typval_defs.h" -#include "nvim/macros.h" #include "nvim/types.h" -// option_defs.h: definition of global variables for settable options - -// Option Flags -#define P_BOOL 0x01U ///< the option is boolean -#define P_NUM 0x02U ///< the option is numeric -#define P_STRING 0x04U ///< the option is a string -#define P_ALLOCED 0x08U ///< the string option is in allocated memory, - ///< must use free_string_option() when - ///< assigning new value. Not set if default is - ///< the same. -#define P_EXPAND 0x10U ///< environment expansion. NOTE: P_EXPAND can - ///< never be used for local or hidden options -#define P_NODEFAULT 0x40U ///< don't set to default value -#define P_DEF_ALLOCED 0x80U ///< default value is in allocated memory, must - ///< use free() when assigning new value -#define P_WAS_SET 0x100U ///< option has been set/reset -#define P_NO_MKRC 0x200U ///< don't include in :mkvimrc output - -// when option changed, what to display: -#define P_UI_OPTION 0x400U ///< send option to remote UI -#define P_RTABL 0x800U ///< redraw tabline -#define P_RSTAT 0x1000U ///< redraw status lines -#define P_RWIN 0x2000U ///< redraw current window and recompute text -#define P_RBUF 0x4000U ///< redraw current buffer and recompute text -#define P_RALL 0x6000U ///< redraw all windows -#define P_RCLR 0x7000U ///< clear and redraw all - -#define P_COMMA 0x8000U ///< comma separated list -#define P_ONECOMMA 0x18000U ///< P_COMMA and cannot have two consecutive - ///< commas -#define P_NODUP 0x20000U ///< don't allow duplicate strings -#define P_FLAGLIST 0x40000U ///< list of single-char flags - -#define P_SECURE 0x80000U ///< cannot change in modeline or secure mode -#define P_GETTEXT 0x100000U ///< expand default value with _() -#define P_NOGLOB 0x200000U ///< do not use local value for global vimrc -#define P_NFNAME 0x400000U ///< only normal file name chars allowed -#define P_INSECURE 0x800000U ///< option was set from a modeline -#define P_PRI_MKRC 0x1000000U ///< priority for :mkvimrc (setting option - ///< has side effects) -#define P_NO_ML 0x2000000U ///< not allowed in modeline -#define P_CURSWANT 0x4000000U ///< update curswant required; not needed - ///< when there is a redraw flag -#define P_NDNAME 0x8000000U ///< only normal dir name chars allowed -#define P_RWINONLY 0x10000000U ///< only redraw current window -#define P_MLE 0x20000000U ///< under control of 'modelineexpr' -#define P_FUNC 0x40000000U ///< accept a function reference or a lambda - -#define P_NO_DEF_EXP 0x80000000U ///< Do not expand default value. - -/// Flags for option-setting functions -/// -/// When OPT_GLOBAL and OPT_LOCAL are both missing, set both local and global -/// values, get local value. +/// Option value type typedef enum { - OPT_FREE = 0x01, ///< Free old value if it was allocated. - OPT_GLOBAL = 0x02, ///< Use global value. - OPT_LOCAL = 0x04, ///< Use local value. - OPT_MODELINE = 0x08, ///< Option in modeline. - OPT_WINONLY = 0x10, ///< Only set window-local options. - OPT_NOWIN = 0x20, ///< Don’t set window-local options. - OPT_ONECOLUMN = 0x40, ///< list options one per line - OPT_NO_REDRAW = 0x80, ///< ignore redraw flags on option - OPT_SKIPRTP = 0x100, ///< "skiprtp" in 'sessionoptions' -} OptionFlags; - -// Return value from get_option_value_strict -#define SOPT_BOOL 0x01 // Boolean option -#define SOPT_NUM 0x02 // Number option -#define SOPT_STRING 0x04 // String option -#define SOPT_GLOBAL 0x08 // Option has global value -#define SOPT_WIN 0x10 // Option has window-local value -#define SOPT_BUF 0x20 // Option has buffer-local value -#define SOPT_UNSET 0x40 // Option does not have local value set - -// Option types for various functions in option.c -#define SREQ_GLOBAL 0 // Request global option value -#define SREQ_WIN 1 // Request window-local option value -#define SREQ_BUF 2 // Request buffer-local option value - -#define HIGHLIGHT_INIT \ - "8:SpecialKey,~:EndOfBuffer,z:TermCursor,Z:TermCursorNC,@:NonText,d:Directory,e:ErrorMsg," \ - "i:IncSearch,l:Search,y:CurSearch,m:MoreMsg,M:ModeMsg,n:LineNr,a:LineNrAbove,b:LineNrBelow," \ - "N:CursorLineNr,G:CursorLineSign,O:CursorLineFold" \ - "r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg," \ - "W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn," \ - "-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel," \ - "[:PmenuKind,]:PmenuKindSel,{:PmenuExtra,}:PmenuExtraSel,x:PmenuSbar,X:PmenuThumb," \ - "*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn," \ - "q:QuickFixLine,0:Whitespace,I:NormalNC" - -// Default values for 'errorformat'. -// The "%f|%l| %m" one is used for when the contents of the quickfix window is -// written to a file. -#ifdef MSWIN -# define DFLT_EFM \ - "%f(%l) \\=: %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f(%l) \\=: %m,%*[^ ] %f %l: %m,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,%f|%l| %m" -#else -# define DFLT_EFM \ - "%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%-Gg%\\?make[%*\\d]: *** [%f:%l:%m,%-Gg%\\?make: *** [%f:%l:%m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%-GIn file included from %f:%l:%c:,%-GIn file included from %f:%l:%c\\,,%-GIn file included from %f:%l:%c,%-GIn file included from %f:%l,%-G%*[ ]from %f:%l:%c,%-G%*[ ]from %f:%l:,%-G%*[ ]from %f:%l\\,,%-G%*[ ]from %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory %*[`']%f',%X%*\\a[%*\\d]: Leaving directory %*[`']%f',%D%*\\a: Entering directory %*[`']%f',%X%*\\a: Leaving directory %*[`']%f',%DMaking %*\\a in %f,%f|%l| %m" -#endif - -#define DFLT_GREPFORMAT "%f:%l:%m,%f:%l%m,%f %l%m" - -// default values for b_p_ff 'fileformat' and p_ffs 'fileformats' -#define FF_DOS "dos" -#define FF_MAC "mac" -#define FF_UNIX "unix" - -#ifdef USE_CRNL -# define DFLT_FF "dos" -# define DFLT_FFS_VIM "dos,unix" -# define DFLT_FFS_VI "dos,unix" // also autodetect in compatible mode -#else -# define DFLT_FF "unix" -# define DFLT_FFS_VIM "unix,dos" -# define DFLT_FFS_VI "" -#endif - -// Possible values for 'encoding' -#define ENC_UCSBOM "ucs-bom" // check for BOM at start of file - -// default value for 'encoding' -#define ENC_DFLT "utf-8" - -// end-of-line style -#define EOL_UNKNOWN (-1) // not defined yet -#define EOL_UNIX 0 // NL -#define EOL_DOS 1 // CR NL -#define EOL_MAC 2 // CR - -// Formatting options for p_fo 'formatoptions' -#define FO_WRAP 't' -#define FO_WRAP_COMS 'c' -#define FO_RET_COMS 'r' -#define FO_OPEN_COMS 'o' -#define FO_NO_OPEN_COMS '/' -#define FO_Q_COMS 'q' -#define FO_Q_NUMBER 'n' -#define FO_Q_SECOND '2' -#define FO_INS_VI 'v' -#define FO_INS_LONG 'l' -#define FO_INS_BLANK 'b' -#define FO_MBYTE_BREAK 'm' // break before/after multi-byte char -#define FO_MBYTE_JOIN 'M' // no space before/after multi-byte char -#define FO_MBYTE_JOIN2 'B' // no space between multi-byte chars -#define FO_ONE_LETTER '1' -#define FO_WHITE_PAR 'w' // trailing white space continues paragr. -#define FO_AUTO 'a' // automatic formatting -#define FO_RIGOROUS_TW ']' // respect textwidth rigorously -#define FO_REMOVE_COMS 'j' // remove comment leaders when joining lines -#define FO_PERIOD_ABBR 'p' // don't break a single space after a period - -#define DFLT_FO_VI "vt" -#define DFLT_FO_VIM "tcqj" -#define FO_ALL "tcro/q2vlb1mMBn,aw]jp" // for do_set() - -// characters for the p_cpo option: -#define CPO_ALTREAD 'a' // ":read" sets alternate file name -#define CPO_ALTWRITE 'A' // ":write" sets alternate file name -#define CPO_BAR 'b' // "\|" ends a mapping -#define CPO_BSLASH 'B' // backslash in mapping is not special -#define CPO_SEARCH 'c' -#define CPO_CONCAT 'C' // Don't concatenate sourced lines -#define CPO_DOTTAG 'd' // "./tags" in 'tags' is in current dir -#define CPO_DIGRAPH 'D' // No digraph after "r", "f", etc. -#define CPO_EXECBUF 'e' -#define CPO_EMPTYREGION 'E' // operating on empty region is an error -#define CPO_FNAMER 'f' // set file name for ":r file" -#define CPO_FNAMEW 'F' // set file name for ":w file" -#define CPO_INTMOD 'i' // interrupt a read makes buffer modified -#define CPO_INDENT 'I' // remove auto-indent more often -#define CPO_ENDOFSENT 'J' // need two spaces to detect end of sentence -#define CPO_KOFFSET 'K' // don't wait for key code in mappings -#define CPO_LITERAL 'l' // take char after backslash in [] literal -#define CPO_LISTWM 'L' // 'list' changes wrapmargin -#define CPO_SHOWMATCH 'm' -#define CPO_MATCHBSL 'M' // "%" ignores use of backslashes -#define CPO_NUMCOL 'n' // 'number' column also used for text -#define CPO_LINEOFF 'o' -#define CPO_OVERNEW 'O' // silently overwrite new file -#define CPO_LISP 'p' // 'lisp' indenting -#define CPO_FNAMEAPP 'P' // set file name for ":w >>file" -#define CPO_JOINCOL 'q' // with "3J" use column after first join -#define CPO_REDO 'r' -#define CPO_REMMARK 'R' // remove marks when filtering -#define CPO_BUFOPT 's' -#define CPO_BUFOPTGLOB 'S' -#define CPO_TAGPAT 't' // tag pattern is used for "n" -#define CPO_UNDO 'u' // "u" undoes itself -#define CPO_BACKSPACE 'v' // "v" keep deleted text -#define CPO_FWRITE 'W' // "w!" doesn't overwrite readonly files -#define CPO_ESC 'x' -#define CPO_REPLCNT 'X' // "R" with a count only deletes chars once -#define CPO_YANK 'y' -#define CPO_KEEPRO 'Z' // don't reset 'readonly' on ":w!" -#define CPO_DOLLAR '$' -#define CPO_FILTER '!' -#define CPO_MATCH '%' -#define CPO_PLUS '+' // ":write file" resets 'modified' -#define CPO_REGAPPEND '>' // insert NL when appending to a register -#define CPO_SCOLON ';' // using "," and ";" will skip over char if - // cursor would not move -#define CPO_CHANGEW '_' // "cw" special-case -// default values for Vim and Vi -#define CPO_VIM "aABceFs_" -#define CPO_VI "aAbBcCdDeEfFiIJKlLmMnoOpPqrRsStuvWxXyZ$!%+>;_" - -// characters for p_ww option: -#define WW_ALL "bshl<>[],~" - -// characters for p_mouse option: -#define MOUSE_NORMAL 'n' // use mouse in Normal mode -#define MOUSE_VISUAL 'v' // use mouse in Visual/Select mode -#define MOUSE_INSERT 'i' // use mouse in Insert mode -#define MOUSE_COMMAND 'c' // use mouse in Command-line mode -#define MOUSE_HELP 'h' // use mouse in help buffers -#define MOUSE_RETURN 'r' // use mouse for hit-return message -#define MOUSE_A "nvich" // used for 'a' flag -#define MOUSE_ALL "anvichr" // all possible characters -#define MOUSE_NONE ' ' // don't use Visual selection -#define MOUSE_NONEF 'x' // forced modeless selection - -// default vertical and horizontal mouse scroll values. -// Note: This should be in sync with the default mousescroll option. -#define MOUSESCROLL_VERT_DFLT 3 -#define MOUSESCROLL_HOR_DFLT 6 - -#define COCU_ALL "nvic" // flags for 'concealcursor' - -/// characters for p_shm option: -enum { - SHM_RO = 'r', ///< Readonly. - SHM_MOD = 'm', ///< Modified. - SHM_LINES = 'l', ///< "L" instead of "lines". - SHM_WRI = 'w', ///< "[w]" instead of "written". - SHM_ABBREVIATIONS = 'a', ///< Use abbreviations from #SHM_ALL_ABBREVIATIONS. - SHM_WRITE = 'W', ///< Don't use "written" at all. - SHM_TRUNC = 't', ///< Truncate file messages. - SHM_TRUNCALL = 'T', ///< Truncate all messages. - SHM_OVER = 'o', ///< Overwrite file messages. - SHM_OVERALL = 'O', ///< Overwrite more messages. - SHM_SEARCH = 's', ///< No search hit bottom messages. - SHM_ATTENTION = 'A', ///< No ATTENTION messages. - SHM_INTRO = 'I', ///< Intro messages. - SHM_COMPLETIONMENU = 'c', ///< Completion menu messages. - SHM_COMPLETIONSCAN = 'C', ///< Completion scanning messages. - SHM_RECORDING = 'q', ///< Short recording message. - SHM_FILEINFO = 'F', ///< No file info messages. - SHM_SEARCHCOUNT = 'S', ///< No search stats: '[1/10]' -}; -/// Represented by 'a' flag. -#define SHM_ALL_ABBREVIATIONS ((char[]) { \ - SHM_RO, SHM_MOD, SHM_LINES, SHM_WRI, \ - 0 }) - -// characters for p_go: -#define GO_ASEL 'a' // autoselect -#define GO_ASELML 'A' // autoselect modeless selection -#define GO_BOT 'b' // use bottom scrollbar -#define GO_CONDIALOG 'c' // use console dialog -#define GO_DARKTHEME 'd' // use dark theme variant -#define GO_TABLINE 'e' // may show tabline -#define GO_FORG 'f' // start GUI in foreground -#define GO_GREY 'g' // use grey menu items -#define GO_HORSCROLL 'h' // flexible horizontal scrolling -#define GO_ICON 'i' // use Vim icon -#define GO_LEFT 'l' // use left scrollbar -#define GO_VLEFT 'L' // left scrollbar with vert split -#define GO_MENUS 'm' // use menu bar -#define GO_NOSYSMENU 'M' // don't source system menu -#define GO_POINTER 'p' // pointer enter/leave callbacks -#define GO_ASELPLUS 'P' // autoselectPlus -#define GO_RIGHT 'r' // use right scrollbar -#define GO_VRIGHT 'R' // right scrollbar with vert split -#define GO_TOOLBAR 'T' // add toolbar -#define GO_FOOTER 'F' // add footer -#define GO_VERTICAL 'v' // arrange dialog buttons vertically -#define GO_KEEPWINSIZE 'k' // keep GUI window size -#define GO_ALL "!aAbcdefFghilLmMpPrRtTvk" // all possible flags for 'go' - -// flags for 'comments' option -#define COM_NEST 'n' // comments strings nest -#define COM_BLANK 'b' // needs blank after string -#define COM_START 's' // start of comment -#define COM_MIDDLE 'm' // middle of comment -#define COM_END 'e' // end of comment -#define COM_AUTO_END 'x' // last char of end closes comment -#define COM_FIRST 'f' // first line comment only -#define COM_LEFT 'l' // left adjusted -#define COM_RIGHT 'r' // right adjusted -#define COM_NOBACK 'O' // don't use for "O" command -#define COM_ALL "nbsmexflrO" // all flags for 'comments' option -#define COM_MAX_LEN 50 // maximum length of a part - -/// 'statusline' option flags -enum { - STL_FILEPATH = 'f', ///< Path of file in buffer. - STL_FULLPATH = 'F', ///< Full path of file in buffer. - STL_FILENAME = 't', ///< Last part (tail) of file path. - STL_COLUMN = 'c', ///< Column og cursor. - STL_VIRTCOL = 'v', ///< Virtual column. - STL_VIRTCOL_ALT = 'V', ///< - with 'if different' display. - STL_LINE = 'l', ///< Line number of cursor. - STL_NUMLINES = 'L', ///< Number of lines in buffer. - STL_BUFNO = 'n', ///< Current buffer number. - STL_KEYMAP = 'k', ///< 'keymap' when active. - STL_OFFSET = 'o', ///< Offset of character under cursor. - STL_OFFSET_X = 'O', ///< - in hexadecimal. - STL_BYTEVAL = 'b', ///< Byte value of character. - STL_BYTEVAL_X = 'B', ///< - in hexadecimal. - STL_ROFLAG = 'r', ///< Readonly flag. - STL_ROFLAG_ALT = 'R', ///< - other display. - STL_HELPFLAG = 'h', ///< Window is showing a help file. - STL_HELPFLAG_ALT = 'H', ///< - other display. - STL_FILETYPE = 'y', ///< 'filetype'. - STL_FILETYPE_ALT = 'Y', ///< - other display. - STL_PREVIEWFLAG = 'w', ///< Window is showing the preview buf. - STL_PREVIEWFLAG_ALT = 'W', ///< - other display. - STL_MODIFIED = 'm', ///< Modified flag. - STL_MODIFIED_ALT = 'M', ///< - other display. - STL_QUICKFIX = 'q', ///< Quickfix window description. - STL_PERCENTAGE = 'p', ///< Percentage through file. - STL_ALTPERCENT = 'P', ///< Percentage as TOP BOT ALL or NN%. - STL_ARGLISTSTAT = 'a', ///< Argument list status as (x of y). - STL_PAGENUM = 'N', ///< Page number (when printing). - STL_SHOWCMD = 'S', ///< 'showcmd' buffer - STL_FOLDCOL = 'C', ///< Fold column for 'statuscolumn' - STL_SIGNCOL = 's', ///< Sign column for 'statuscolumn' - STL_VIM_EXPR = '{', ///< Start of expression to substitute. - STL_SEPARATE = '=', ///< Separation between alignment sections. - STL_TRUNCMARK = '<', ///< Truncation mark if line is too long. - STL_USER_HL = '*', ///< Highlight from (User)1..9 or 0. - STL_HIGHLIGHT = '#', ///< Highlight name. - STL_TABPAGENR = 'T', ///< Tab page label nr. - STL_TABCLOSENR = 'X', ///< Tab page close nr. - STL_CLICK_FUNC = '@', ///< Click region start. -}; -/// C string containing all 'statusline' option flags -#define STL_ALL ((char[]) { \ - STL_FILEPATH, STL_FULLPATH, STL_FILENAME, STL_COLUMN, STL_VIRTCOL, \ - STL_VIRTCOL_ALT, STL_LINE, STL_NUMLINES, STL_BUFNO, STL_KEYMAP, STL_OFFSET, \ - STL_OFFSET_X, STL_BYTEVAL, STL_BYTEVAL_X, STL_ROFLAG, STL_ROFLAG_ALT, \ - STL_HELPFLAG, STL_HELPFLAG_ALT, STL_FILETYPE, STL_FILETYPE_ALT, \ - STL_PREVIEWFLAG, STL_PREVIEWFLAG_ALT, STL_MODIFIED, STL_MODIFIED_ALT, \ - STL_QUICKFIX, STL_PERCENTAGE, STL_ALTPERCENT, STL_ARGLISTSTAT, STL_PAGENUM, \ - STL_SHOWCMD, STL_FOLDCOL, STL_SIGNCOL, STL_VIM_EXPR, STL_SEPARATE, \ - STL_TRUNCMARK, STL_USER_HL, STL_HIGHLIGHT, STL_TABPAGENR, STL_TABCLOSENR, \ - STL_CLICK_FUNC, STL_TABPAGENR, STL_TABCLOSENR, STL_CLICK_FUNC, \ - 0, }) - -// flags used for parsed 'wildmode' -#define WIM_FULL 0x01 -#define WIM_LONGEST 0x02 -#define WIM_LIST 0x04 -#define WIM_BUFLASTUSED 0x08 - -// arguments for can_bs() -// each defined char should be unique over all values -// except for BS_START, that intentionally also matches BS_NOSTOP -// because BS_NOSTOP behaves exactly the same except it -// does not stop at the start of the insert point -#define BS_INDENT 'i' // "Indent" -#define BS_EOL 'l' // "eoL" -#define BS_START 's' // "Start" -#define BS_NOSTOP 'p' // "nostoP - -// flags for the 'culopt' option -#define CULOPT_LINE 0x01 // Highlight complete line -#define CULOPT_SCRLINE 0x02 // Highlight screen line -#define CULOPT_NBR 0x04 // Highlight Number column - -#define LISPWORD_VALUE \ - "defun,define,defmacro,set!,lambda,if,case,let,flet,let*,letrec,do,do*,define-syntax,let-syntax,letrec-syntax,destructuring-bind,defpackage,defparameter,defstruct,deftype,defvar,do-all-symbols,do-external-symbols,do-symbols,dolist,dotimes,ecase,etypecase,eval-when,labels,macrolet,multiple-value-bind,multiple-value-call,multiple-value-prog1,multiple-value-setq,prog1,progv,typecase,unless,unwind-protect,when,with-input-from-string,with-open-file,with-open-stream,with-output-to-string,with-package-iterator,define-condition,handler-bind,handler-case,restart-bind,restart-case,with-simple-restart,store-value,use-value,muffle-warning,abort,continue,with-slots,with-slots*,with-accessors,with-accessors*,defclass,defmethod,print-unreadable-object" - -// The following are actual variables for the options - -EXTERN char *p_ambw; ///< 'ambiwidth' -EXTERN int p_acd; ///< 'autochdir' -EXTERN int p_ai; ///< 'autoindent' -EXTERN int p_bin; ///< 'binary' -EXTERN int p_bomb; ///< 'bomb' -EXTERN int p_bl; ///< 'buflisted' -EXTERN int p_cin; ///< 'cindent' -EXTERN long p_channel; ///< 'channel' -EXTERN char *p_cink; ///< 'cinkeys' -EXTERN char *p_cinsd; ///< 'cinscopedecls' -EXTERN char *p_cinw; ///< 'cinwords' -EXTERN char *p_cfu; ///< 'completefunc' -EXTERN char *p_ofu; ///< 'omnifunc' -EXTERN char *p_tsrfu; ///< 'thesaurusfunc' -EXTERN int p_ci; ///< 'copyindent' -EXTERN int p_ar; // 'autoread' -EXTERN int p_aw; // 'autowrite' -EXTERN int p_awa; // 'autowriteall' -EXTERN char *p_bs; // 'backspace' -EXTERN char *p_bg; // 'background' -EXTERN int p_bk; // 'backup' -EXTERN char *p_bkc; // 'backupcopy' -EXTERN unsigned bkc_flags; ///< flags from 'backupcopy' -#define BKC_YES 0x001 -#define BKC_AUTO 0x002 -#define BKC_NO 0x004 -#define BKC_BREAKSYMLINK 0x008 -#define BKC_BREAKHARDLINK 0x010 -EXTERN char *p_bdir; // 'backupdir' -EXTERN char *p_bex; // 'backupext' -EXTERN char *p_bo; // 'belloff' -EXTERN char breakat_flags[256]; // which characters are in 'breakat' -EXTERN unsigned bo_flags; - -// values for the 'belloff' option -#define BO_ALL 0x0001 -#define BO_BS 0x0002 -#define BO_CRSR 0x0004 -#define BO_COMPL 0x0008 -#define BO_COPY 0x0010 -#define BO_CTRLG 0x0020 -#define BO_ERROR 0x0040 -#define BO_ESC 0x0080 -#define BO_EX 0x0100 -#define BO_HANGUL 0x0200 -#define BO_IM 0x0400 -#define BO_LANG 0x0800 -#define BO_MESS 0x1000 -#define BO_MATCH 0x2000 -#define BO_OPER 0x4000 -#define BO_REG 0x8000 -#define BO_SH 0x10000 -#define BO_SPELL 0x20000 -#define BO_WILD 0x40000 - -EXTERN char *p_bsk; // 'backupskip' -EXTERN char *p_breakat; // 'breakat' -EXTERN char *p_bh; ///< 'bufhidden' -EXTERN char *p_bt; ///< 'buftype' -EXTERN char *p_cmp; // 'casemap' -EXTERN unsigned cmp_flags; -#define CMP_INTERNAL 0x001 -#define CMP_KEEPASCII 0x002 -EXTERN char *p_enc; // 'encoding' -EXTERN int p_deco; // 'delcombine' -EXTERN char *p_ccv; // 'charconvert' -EXTERN char *p_cino; ///< 'cinoptions' -EXTERN char *p_cedit; // 'cedit' -EXTERN char *p_cb; // 'clipboard' -EXTERN unsigned cb_flags; -#define CB_UNNAMED 0x001 -#define CB_UNNAMEDPLUS 0x002 -#define CB_UNNAMEDMASK (CB_UNNAMED | CB_UNNAMEDPLUS) -EXTERN long p_cwh; // 'cmdwinheight' -EXTERN long p_ch; // 'cmdheight' -EXTERN char *p_cms; ///< 'commentstring' -EXTERN char *p_cpt; ///< 'complete' -EXTERN long p_columns; // 'columns' -EXTERN int p_confirm; // 'confirm' -EXTERN char *p_cot; // 'completeopt' -#ifdef BACKSLASH_IN_FILENAME -EXTERN char *p_csl; // 'completeslash' -#endif -EXTERN long p_pb; // 'pumblend' -EXTERN long p_ph; // 'pumheight' -EXTERN long p_pw; // 'pumwidth' -EXTERN char *p_com; ///< 'comments' -EXTERN char *p_cpo; // 'cpoptions' -EXTERN char *p_debug; // 'debug' -EXTERN char *p_def; // 'define' -EXTERN char *p_inc; -EXTERN char *p_dip; // 'diffopt' -EXTERN char *p_dex; // 'diffexpr' -EXTERN char *p_dict; // 'dictionary' -EXTERN int p_dg; // 'digraph' -EXTERN char *p_dir; // 'directory' -EXTERN char *p_dy; // 'display' -EXTERN unsigned dy_flags; -#define DY_LASTLINE 0x001 -#define DY_TRUNCATE 0x002 -#define DY_UHEX 0x004 -// legacy flag, not used -#define DY_MSGSEP 0x008 -EXTERN int p_ed; // 'edcompatible' -EXTERN char *p_ead; // 'eadirection' -EXTERN int p_emoji; // 'emoji' -EXTERN int p_ea; // 'equalalways' -EXTERN char *p_ep; // 'equalprg' -EXTERN int p_eb; // 'errorbells' -EXTERN char *p_ef; // 'errorfile' -EXTERN char *p_efm; // 'errorformat' -EXTERN char *p_gefm; // 'grepformat' -EXTERN char *p_gp; // 'grepprg' -EXTERN int p_eof; ///< 'endoffile' -EXTERN int p_eol; ///< 'endofline' -EXTERN char *p_ei; // 'eventignore' -EXTERN int p_et; ///< 'expandtab' -EXTERN int p_exrc; // 'exrc' -EXTERN char *p_fenc; ///< 'fileencoding' -EXTERN char *p_fencs; // 'fileencodings' -EXTERN char *p_ff; ///< 'fileformat' -EXTERN char *p_ffs; // 'fileformats' -EXTERN int p_fic; // 'fileignorecase' -EXTERN char *p_ft; ///< 'filetype' -EXTERN char *p_fcs; ///< 'fillchar' -EXTERN int p_fixeol; ///< 'fixendofline' -EXTERN char *p_fcl; // 'foldclose' -EXTERN long p_fdls; // 'foldlevelstart' -EXTERN char *p_fdo; // 'foldopen' -EXTERN unsigned fdo_flags; -#define FDO_ALL 0x001 -#define FDO_BLOCK 0x002 -#define FDO_HOR 0x004 -#define FDO_MARK 0x008 -#define FDO_PERCENT 0x010 -#define FDO_QUICKFIX 0x020 -#define FDO_SEARCH 0x040 -#define FDO_TAG 0x080 -#define FDO_INSERT 0x100 -#define FDO_UNDO 0x200 -#define FDO_JUMP 0x400 -EXTERN char *p_fex; ///< 'formatexpr' -EXTERN char *p_flp; ///< 'formatlistpat' -EXTERN char *p_fo; ///< 'formatoptions' -EXTERN char *p_fp; // 'formatprg' -EXTERN int p_fs; // 'fsync' -EXTERN int p_gd; // 'gdefault' -EXTERN char *p_guicursor; // 'guicursor' -EXTERN char *p_guifont; // 'guifont' -EXTERN char *p_guifontwide; // 'guifontwide' -EXTERN char *p_hf; // 'helpfile' -EXTERN long p_hh; // 'helpheight' -EXTERN char *p_hlg; // 'helplang' -EXTERN int p_hid; // 'hidden' -EXTERN char *p_hl; // 'highlight' -EXTERN int p_hls; // 'hlsearch' -EXTERN long p_hi; // 'history' -EXTERN int p_arshape; // 'arabicshape' -EXTERN int p_icon; // 'icon' -EXTERN char *p_iconstring; // 'iconstring' -EXTERN int p_ic; // 'ignorecase' -EXTERN long p_iminsert; ///< 'iminsert' -EXTERN long p_imsearch; ///< 'imsearch' -EXTERN int p_inf; ///< 'infercase' -EXTERN char *p_inex; ///< 'includeexpr' -EXTERN int p_is; // 'incsearch' -EXTERN char *p_inde; ///< 'indentexpr' -EXTERN char *p_indk; ///< 'indentkeys' -EXTERN char *p_icm; // 'inccommand' -EXTERN char *p_isf; // 'isfname' -EXTERN char *p_isi; // 'isident' -EXTERN char *p_isk; ///< 'iskeyword' -EXTERN char *p_isp; // 'isprint' -EXTERN int p_js; // 'joinspaces' -EXTERN char *p_jop; // 'jumpooptions' -EXTERN unsigned jop_flags; -#define JOP_STACK 0x01 -#define JOP_VIEW 0x02 -EXTERN char *p_keymap; ///< 'keymap' -EXTERN char *p_kp; // 'keywordprg' -EXTERN char *p_km; // 'keymodel' -EXTERN char *p_langmap; // 'langmap' -EXTERN int p_lnr; // 'langnoremap' -EXTERN int p_lrm; // 'langremap' -EXTERN char *p_lm; // 'langmenu' -EXTERN long p_lines; // 'lines' -EXTERN long p_linespace; // 'linespace' -EXTERN int p_lisp; ///< 'lisp' -EXTERN char *p_lop; ///< 'lispoptions' -EXTERN char *p_lispwords; // 'lispwords' -EXTERN long p_ls; // 'laststatus' -EXTERN long p_stal; // 'showtabline' -EXTERN char *p_lcs; // 'listchars' - -EXTERN int p_lz; // 'lazyredraw' -EXTERN int p_lpl; // 'loadplugins' -EXTERN int p_magic; // 'magic' -EXTERN char *p_menc; // 'makeencoding' -EXTERN char *p_mef; // 'makeef' -EXTERN char *p_mp; // 'makeprg' -EXTERN char *p_mps; ///< 'matchpairs' -EXTERN long p_mat; // 'matchtime' -EXTERN long p_mco; // 'maxcombine' -EXTERN long p_mfd; // 'maxfuncdepth' -EXTERN long p_mmd; // 'maxmapdepth' -EXTERN long p_mmp; // 'maxmempattern' -EXTERN long p_mis; // 'menuitems' -EXTERN char *p_msm; // 'mkspellmem' -EXTERN int p_ml; ///< 'modeline' -EXTERN int p_mle; // 'modelineexpr' -EXTERN long p_mls; // 'modelines' -EXTERN int p_ma; ///< 'modifiable' -EXTERN int p_mod; ///< 'modified' -EXTERN char *p_mouse; // 'mouse' -EXTERN char *p_mousem; // 'mousemodel' -EXTERN int p_mousemev; ///< 'mousemoveevent' -EXTERN int p_mousef; // 'mousefocus' -EXTERN char *p_mousescroll; // 'mousescroll' -EXTERN long p_mousescroll_vert INIT(= MOUSESCROLL_VERT_DFLT); -EXTERN long p_mousescroll_hor INIT(= MOUSESCROLL_HOR_DFLT); -EXTERN long p_mouset; // 'mousetime' -EXTERN int p_more; // 'more' -EXTERN char *p_nf; ///< 'nrformats' -EXTERN char *p_opfunc; // 'operatorfunc' -EXTERN char *p_para; // 'paragraphs' -EXTERN int p_paste; // 'paste' -EXTERN char *p_pex; // 'patchexpr' -EXTERN char *p_pm; // 'patchmode' -EXTERN char *p_path; // 'path' -EXTERN char *p_cdpath; // 'cdpath' -EXTERN int p_pi; ///< 'preserveindent' -EXTERN long p_pyx; // 'pyxversion' -EXTERN char *p_qe; ///< 'quoteescape' -EXTERN int p_ro; ///< 'readonly' -EXTERN char *p_rdb; // 'redrawdebug' -EXTERN unsigned rdb_flags; -#define RDB_COMPOSITOR 0x001 -#define RDB_NOTHROTTLE 0x002 -#define RDB_INVALID 0x004 -#define RDB_NODELTA 0x008 -#define RDB_LINE 0x010 -#define RDB_FLUSH 0x020 -#define RDB_INTERSECT 0x040 - -EXTERN long p_rdt; // 'redrawtime' -EXTERN long p_re; // 'regexpengine' -EXTERN long p_report; // 'report' -EXTERN long p_pvh; // 'previewheight' -EXTERN int p_ari; // 'allowrevins' -EXTERN int p_ri; // 'revins' -EXTERN int p_ru; // 'ruler' -EXTERN char *p_ruf; // 'rulerformat' -EXTERN char *p_pp; // 'packpath' -EXTERN char *p_qftf; // 'quickfixtextfunc' -EXTERN char *p_rtp; // 'runtimepath' -EXTERN long p_scbk; // 'scrollback' -EXTERN long p_sj; // 'scrolljump' -EXTERN long p_so; // 'scrolloff' -EXTERN char *p_sbo; // 'scrollopt' -EXTERN char *p_sections; // 'sections' -EXTERN int p_secure; // 'secure' -EXTERN char *p_sel; // 'selection' -EXTERN char *p_slm; // 'selectmode' -EXTERN char *p_ssop; // 'sessionoptions' -EXTERN unsigned ssop_flags; - -#define SSOP_BUFFERS 0x001 -#define SSOP_WINPOS 0x002 -#define SSOP_RESIZE 0x004 -#define SSOP_WINSIZE 0x008 -#define SSOP_LOCALOPTIONS 0x010 -#define SSOP_OPTIONS 0x020 -#define SSOP_HELP 0x040 -#define SSOP_BLANK 0x080 -#define SSOP_GLOBALS 0x100 -#define SSOP_SLASH 0x200 // Deprecated, always set. -#define SSOP_UNIX 0x400 // Deprecated, always set. -#define SSOP_SESDIR 0x800 -#define SSOP_CURDIR 0x1000 -#define SSOP_FOLDS 0x2000 -#define SSOP_CURSOR 0x4000 -#define SSOP_TABPAGES 0x8000 -#define SSOP_TERMINAL 0x10000 -#define SSOP_SKIP_RTP 0x20000 - -EXTERN char *p_sh; // 'shell' -EXTERN char *p_shcf; // 'shellcmdflag' -EXTERN char *p_sp; // 'shellpipe' -EXTERN char *p_shq; // 'shellquote' -EXTERN char *p_sxq; // 'shellxquote' -EXTERN char *p_sxe; // 'shellxescape' -EXTERN char *p_srr; // 'shellredir' -EXTERN int p_stmp; // 'shelltemp' -#ifdef BACKSLASH_IN_FILENAME -EXTERN int p_ssl; // 'shellslash' -#endif -EXTERN char *p_stl; // 'statusline' -EXTERN char *p_wbr; // 'winbar' -EXTERN int p_sr; // 'shiftround' -EXTERN long p_sw; ///< 'shiftwidth' -EXTERN char *p_shm; // 'shortmess' -EXTERN char *p_sbr; // 'showbreak' -EXTERN int p_sc; // 'showcmd' -EXTERN char *p_sloc; // 'showcmdloc' -EXTERN int p_sft; // 'showfulltag' -EXTERN int p_sm; // 'showmatch' -EXTERN int p_smd; // 'showmode' -EXTERN long p_ss; // 'sidescroll' -EXTERN long p_siso; // 'sidescrolloff' -EXTERN int p_scs; // 'smartcase' -EXTERN int p_si; ///< 'smartindent' -EXTERN int p_sta; // 'smarttab' -EXTERN long p_sts; ///< 'softtabstop' -EXTERN int p_sb; // 'splitbelow' -EXTERN char *p_sua; ///< 'suffixesadd' -EXTERN int p_swf; ///< 'swapfile' -EXTERN long p_smc; ///< 'synmaxcol' -EXTERN long p_tpm; // 'tabpagemax' -EXTERN char *p_tal; // 'tabline' -EXTERN char *p_tpf; // 'termpastefilter' -EXTERN unsigned tpf_flags; ///< flags from 'termpastefilter' -#define TPF_BS 0x001 -#define TPF_HT 0x002 -#define TPF_FF 0x004 -#define TPF_ESC 0x008 -#define TPF_DEL 0x010 -#define TPF_C0 0x020 -#define TPF_C1 0x040 -EXTERN char *p_tfu; ///< 'tagfunc' -EXTERN char *p_spc; ///< 'spellcapcheck' -EXTERN char *p_spf; ///< 'spellfile' -EXTERN char *p_spk; ///< 'splitkeep' -EXTERN char *p_spl; ///< 'spelllang' -EXTERN char *p_spo; // 'spelloptions' -EXTERN unsigned spo_flags; -EXTERN char *p_sps; // 'spellsuggest' -EXTERN int p_spr; // 'splitright' -EXTERN int p_sol; // 'startofline' -EXTERN char *p_su; // 'suffixes' -EXTERN char *p_swb; // 'switchbuf' -EXTERN unsigned swb_flags; -// Keep in sync with p_swb_values in optionstr.c -#define SWB_USEOPEN 0x001 -#define SWB_USETAB 0x002 -#define SWB_SPLIT 0x004 -#define SWB_NEWTAB 0x008 -#define SWB_VSPLIT 0x010 -#define SWB_USELAST 0x020 -EXTERN char *p_syn; ///< 'syntax' -EXTERN long p_ts; ///< 'tabstop' -EXTERN int p_tbs; ///< 'tagbsearch' -EXTERN char *p_tc; ///< 'tagcase' -EXTERN unsigned tc_flags; ///< flags from 'tagcase' -#define TC_FOLLOWIC 0x01 -#define TC_IGNORE 0x02 -#define TC_MATCH 0x04 -#define TC_FOLLOWSCS 0x08 -#define TC_SMART 0x10 -EXTERN long p_tl; ///< 'taglength' -EXTERN int p_tr; ///< 'tagrelative' -EXTERN char *p_tags; ///< 'tags' -EXTERN int p_tgst; ///< 'tagstack' -EXTERN int p_tbidi; ///< 'termbidi' -EXTERN long p_tw; ///< 'textwidth' -EXTERN int p_to; ///< 'tildeop' -EXTERN int p_timeout; ///< 'timeout' -EXTERN long p_tm; ///< 'timeoutlen' -EXTERN int p_title; ///< 'title' -EXTERN long p_titlelen; ///< 'titlelen' -EXTERN char *p_titleold; ///< 'titleold' -EXTERN char *p_titlestring; ///< 'titlestring' -EXTERN char *p_tsr; ///< 'thesaurus' -EXTERN int p_tgc; ///< 'termguicolors' -EXTERN int p_ttimeout; ///< 'ttimeout' -EXTERN long p_ttm; ///< 'ttimeoutlen' -EXTERN char *p_udir; ///< 'undodir' -EXTERN int p_udf; ///< 'undofile' -EXTERN long p_ul; ///< 'undolevels' -EXTERN long p_ur; ///< 'undoreload' -EXTERN long p_uc; ///< 'updatecount' -EXTERN long p_ut; ///< 'updatetime' -EXTERN char *p_shada; ///< 'shada' -EXTERN char *p_shadafile; ///< 'shadafile' -EXTERN char *p_vsts; ///< 'varsofttabstop' -EXTERN char *p_vts; ///< 'vartabstop' -EXTERN char *p_vdir; ///< 'viewdir' -EXTERN char *p_vop; ///< 'viewoptions' -EXTERN unsigned vop_flags; ///< uses SSOP_ flags -EXTERN int p_vb; ///< 'visualbell' -EXTERN char *p_ve; ///< 'virtualedit' -EXTERN unsigned ve_flags; -#define VE_BLOCK 5U // includes "all" -#define VE_INSERT 6U // includes "all" -#define VE_ALL 4U -#define VE_ONEMORE 8U -#define VE_NONE 16U // "none" -#define VE_NONEU 32U // "NONE" -EXTERN long p_verbose; // 'verbose' -#ifdef IN_OPTION_C -char *p_vfile = ""; // used before options are initialized -#else -extern char *p_vfile; // 'verbosefile' -#endif -EXTERN int p_warn; // 'warn' -EXTERN char *p_wop; // 'wildoptions' -EXTERN unsigned wop_flags; -#define WOP_TAGFILE 0x01 -#define WOP_PUM 0x02 -#define WOP_FUZZY 0x04 -EXTERN long p_window; // 'window' -EXTERN char *p_wak; // 'winaltkeys' -EXTERN char *p_wig; // 'wildignore' -EXTERN char *p_ww; // 'whichwrap' -EXTERN long p_wc; // 'wildchar' -EXTERN long p_wcm; // 'wildcharm' -EXTERN int p_wic; // 'wildignorecase' -EXTERN char *p_wim; // 'wildmode' -EXTERN int p_wmnu; // 'wildmenu' -EXTERN long p_wh; // 'winheight' -EXTERN long p_wmh; // 'winminheight' -EXTERN long p_wmw; // 'winminwidth' -EXTERN long p_wiw; // 'winwidth' -EXTERN long p_wm; ///< 'wrapmargin' -EXTERN int p_ws; // 'wrapscan' -EXTERN int p_write; // 'write' -EXTERN int p_wa; // 'writeany' -EXTERN int p_wb; // 'writebackup' -EXTERN long p_wd; // 'writedelay' -EXTERN int p_cdh; // 'cdhome' - -EXTERN int p_force_on; ///< options that cannot be turned off. -EXTERN int p_force_off; ///< options that cannot be turned on. - -// -// "indir" values for buffer-local options. -// These need to be defined globally, so that the BV_COUNT can be used with -// b_p_scriptID[]. -// -enum { - BV_AI = 0, - BV_AR, - BV_BH, - BV_BKC, - BV_BT, - BV_EFM, - BV_GP, - BV_MP, - BV_BIN, - BV_BL, - BV_BOMB, - BV_CHANNEL, - BV_CI, - BV_CIN, - BV_CINK, - BV_CINO, - BV_CINW, - BV_CINSD, - BV_CM, - BV_CMS, - BV_COM, - BV_CPT, - BV_DICT, - BV_TSR, - BV_CSL, - BV_CFU, - BV_DEF, - BV_INC, - BV_EOF, - BV_EOL, - BV_FIXEOL, - BV_EP, - BV_ET, - BV_FENC, - BV_FP, - BV_BEXPR, - BV_FEX, - BV_FF, - BV_FLP, - BV_FO, - BV_FT, - BV_IMI, - BV_IMS, - BV_INDE, - BV_INDK, - BV_INEX, - BV_INF, - BV_ISK, - BV_KMAP, - BV_KP, - BV_LISP, - BV_LOP, - BV_LW, - BV_MENC, - BV_MA, - BV_ML, - BV_MOD, - BV_MPS, - BV_NF, - BV_OFU, - BV_PATH, - BV_PI, - BV_QE, - BV_RO, - BV_SCBK, - BV_SI, - BV_SMC, - BV_SYN, - BV_SPC, - BV_SPF, - BV_SPL, - BV_SPO, - BV_STS, - BV_SUA, - BV_SW, - BV_SWF, - BV_TFU, - BV_TSRFU, - BV_TAGS, - BV_TC, - BV_TS, - BV_TW, - BV_TX, - BV_UDF, - BV_UL, - BV_WM, - BV_VSTS, - BV_VTS, - BV_COUNT, // must be the last one -}; - -// "indir" values for window-local options. -// These need to be defined globally, so that the WV_COUNT can be used in the -// window structure. -enum { - WV_LIST = 0, - WV_ARAB, - WV_COCU, - WV_COLE, - WV_CRBIND, - WV_BRI, - WV_BRIOPT, - WV_DIFF, - WV_FDC, - WV_FEN, - WV_FDI, - WV_FDL, - WV_FDM, - WV_FML, - WV_FDN, - WV_FDE, - WV_FDT, - WV_FMR, - WV_LBR, - WV_NU, - WV_RNU, - WV_VE, - WV_NUW, - WV_PVW, - WV_RL, - WV_RLC, - WV_SCBIND, - WV_SCROLL, - WV_SMS, - WV_SISO, - WV_SO, - WV_SPELL, - WV_CUC, - WV_CUL, - WV_CULOPT, - WV_CC, - WV_SBR, - WV_STC, - WV_STL, - WV_WFH, - WV_WFW, - WV_WRAP, - WV_SCL, - WV_WINHL, - WV_LCS, - WV_FCS, - WV_WINBL, - WV_WBR, - WV_COUNT, // must be the last one -}; - -// Value for b_p_ul indicating the global value must be used. -#define NO_LOCAL_UNDOLEVEL (-123456) + kOptValTypeNil = 0, + kOptValTypeBoolean, + kOptValTypeNumber, + kOptValTypeString, +} OptValType; -#define SB_MAX 100000 // Maximum 'scrollback' value. +/// Option value +typedef struct { + OptValType type; -#define TABSTOP_MAX 9999 + union { + // boolean options are actually tri-states because they have a third "None" value. + TriState boolean; + OptInt number; + String string; + } data; +} OptVal; -// Argument for the callback function (opt_did_set_cb_T) invoked after an -// option value is modified. +/// Argument for the callback function (opt_did_set_cb_T) invoked after an +/// option value is modified. typedef struct { - // Pointer to the option variable. The variable can be a long (numeric - // option), an int (boolean option) or a char pointer (string option). + /// Pointer to the option variable. The variable can be an OptInt (numeric + /// option), an int (boolean option) or a char pointer (string option). void *os_varp; int os_idx; int os_flags; - // old value of the option (can be a string, number or a boolean) + /// old value of the option (can be a string, number or a boolean) union { - const long number; + const OptInt number; const bool boolean; const char *string; } os_oldval; - // new value of the option (can be a string, number or a boolean) + /// new value of the option (can be a string, number or a boolean) union { - const long number; + const OptInt number; const bool boolean; const char *string; } os_newval; - // When set by the called function: Stop processing the option further. - // Currently only used for boolean options. - int os_doskip; + /// When set by the called function: Stop processing the option further. + /// Currently only used for boolean options. + bool os_doskip; - // Option value was checked to be safe, no need to set P_INSECURE - // Used for the 'keymap', 'filetype' and 'syntax' options. + /// Option value was checked to be safe, no need to set P_INSECURE + /// Used for the 'keymap', 'filetype' and 'syntax' options. bool os_value_checked; - // Option value changed. Used for the 'filetype' and 'syntax' options. + /// Option value changed. Used for the 'filetype' and 'syntax' options. bool os_value_changed; - // Used by the 'isident', 'iskeyword', 'isprint' and 'isfname' options. - // Set to true if the character table is modified when processing the - // option and need to be restored because of a failure. - int os_restore_chartab; + /// Used by the 'isident', 'iskeyword', 'isprint' and 'isfname' options. + /// Set to true if the character table is modified when processing the + /// option and need to be restored because of a failure. + bool os_restore_chartab; - // If the value specified for an option is not valid and the error message - // is parameterized, then the "os_errbuf" buffer is used to store the error - // message (when it is not NULL). + /// If the value specified for an option is not valid and the error message + /// is parameterized, then the "os_errbuf" buffer is used to store the error + /// message (when it is not NULL). char *os_errbuf; size_t os_errbuflen; @@ -1030,70 +80,4 @@ typedef struct { /// Otherwise returns an error message. typedef const char *(*opt_did_set_cb_T)(optset_T *args); -/// Stores an identifier of a script or channel that last set an option. -typedef struct { - sctx_T script_ctx; /// script context where the option was last set - uint64_t channel_id; /// Only used when script_id is SID_API_CLIENT. -} LastSet; - -// WV_ and BV_ values get typecasted to this for the "indir" field -typedef enum { - PV_NONE = 0, - PV_MAXVAL = 0xffff, // to avoid warnings for value out of range -} idopt_T; - -typedef struct vimoption { - char *fullname; // full option name - char *shortname; // permissible abbreviation - uint32_t flags; // see above - void *var; // global option: pointer to variable; - // window-local option: VAR_WIN; - // buffer-local option: global value - idopt_T indir; // global option: PV_NONE; - // local option: indirect option index - // callback function to invoke after an option is modified to validate and - // apply the new value. - opt_did_set_cb_T opt_did_set_cb; - void *def_val; // default values for variable (neovim!!) - LastSet last_set; // script in which the option was last set -} vimoption_T; - -// The options that are local to a window or buffer have "indir" set to one of -// these values. Special values: -// PV_NONE: global option. -// PV_WIN is added: window-local option -// PV_BUF is added: buffer-local option -// PV_BOTH is added: global option which also has a local value. -#define PV_BOTH 0x1000 -#define PV_WIN 0x2000 -#define PV_BUF 0x4000 -#define PV_MASK 0x0fff -#define OPT_WIN(x) (idopt_T)(PV_WIN + (int)(x)) -#define OPT_BUF(x) (idopt_T)(PV_BUF + (int)(x)) -#define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x)) - -// Options local to a window have a value local to a buffer and global to all -// buffers. Indicate this by setting "var" to VAR_WIN. -#define VAR_WIN ((char *)-1) - -// Option value type -typedef enum { - kOptValTypeNil = 0, - kOptValTypeBoolean, - kOptValTypeNumber, - kOptValTypeString, -} OptValType; - -// Option value -typedef struct { - OptValType type; - - union { - // Vim boolean options are actually tri-states because they have a third "None" value. - TriState boolean; - Integer number; - String string; - } data; -} OptVal; - #endif // NVIM_OPTION_DEFS_H diff --git a/src/nvim/option_vars.h b/src/nvim/option_vars.h new file mode 100644 index 0000000000..d8bbce21b3 --- /dev/null +++ b/src/nvim/option_vars.h @@ -0,0 +1,946 @@ +#ifndef NVIM_OPTION_VARS_H +#define NVIM_OPTION_VARS_H + +#include "nvim/macros.h" +#include "nvim/types.h" + +// option_vars.h: definition of global variables for settable options + +// Option Flags +#define P_BOOL 0x01U ///< the option is boolean +#define P_NUM 0x02U ///< the option is numeric +#define P_STRING 0x04U ///< the option is a string +#define P_ALLOCED 0x08U ///< the string option is in allocated memory, + ///< must use free_string_option() when + ///< assigning new value. Not set if default is + ///< the same. +#define P_EXPAND 0x10U ///< environment expansion. NOTE: P_EXPAND can + ///< never be used for local or hidden options +#define P_NODEFAULT 0x40U ///< don't set to default value +#define P_DEF_ALLOCED 0x80U ///< default value is in allocated memory, must + ///< use free() when assigning new value +#define P_WAS_SET 0x100U ///< option has been set/reset +#define P_NO_MKRC 0x200U ///< don't include in :mkvimrc output + +// when option changed, what to display: +#define P_UI_OPTION 0x400U ///< send option to remote UI +#define P_RTABL 0x800U ///< redraw tabline +#define P_RSTAT 0x1000U ///< redraw status lines +#define P_RWIN 0x2000U ///< redraw current window and recompute text +#define P_RBUF 0x4000U ///< redraw current buffer and recompute text +#define P_RALL 0x6000U ///< redraw all windows +#define P_RCLR 0x7000U ///< clear and redraw all + +#define P_COMMA 0x8000U ///< comma separated list +#define P_ONECOMMA 0x18000U ///< P_COMMA and cannot have two consecutive + ///< commas +#define P_NODUP 0x20000U ///< don't allow duplicate strings +#define P_FLAGLIST 0x40000U ///< list of single-char flags + +#define P_SECURE 0x80000U ///< cannot change in modeline or secure mode +#define P_GETTEXT 0x100000U ///< expand default value with _() +#define P_NOGLOB 0x200000U ///< do not use local value for global vimrc +#define P_NFNAME 0x400000U ///< only normal file name chars allowed +#define P_INSECURE 0x800000U ///< option was set from a modeline +#define P_PRI_MKRC 0x1000000U ///< priority for :mkvimrc (setting option + ///< has side effects) +#define P_NO_ML 0x2000000U ///< not allowed in modeline +#define P_CURSWANT 0x4000000U ///< update curswant required; not needed + ///< when there is a redraw flag +#define P_NDNAME 0x8000000U ///< only normal dir name chars allowed +#define P_RWINONLY 0x10000000U ///< only redraw current window +#define P_MLE 0x20000000U ///< under control of 'modelineexpr' +#define P_FUNC 0x40000000U ///< accept a function reference or a lambda + +#define P_NO_DEF_EXP 0x80000000U ///< Do not expand default value. + +#define HIGHLIGHT_INIT \ + "8:SpecialKey,~:EndOfBuffer,z:TermCursor,Z:TermCursorNC,@:NonText,d:Directory,e:ErrorMsg," \ + "i:IncSearch,l:Search,y:CurSearch,m:MoreMsg,M:ModeMsg,n:LineNr,a:LineNrAbove,b:LineNrBelow," \ + "N:CursorLineNr,G:CursorLineSign,O:CursorLineFold" \ + "r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg," \ + "W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn," \ + "-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel," \ + "[:PmenuKind,]:PmenuKindSel,{:PmenuExtra,}:PmenuExtraSel,x:PmenuSbar,X:PmenuThumb," \ + "*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn," \ + "q:QuickFixLine,0:Whitespace,I:NormalNC" + +// Default values for 'errorformat'. +// The "%f|%l| %m" one is used for when the contents of the quickfix window is +// written to a file. +#ifdef MSWIN +# define DFLT_EFM \ + "%f(%l) \\=: %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f(%l) \\=: %m,%*[^ ] %f %l: %m,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,%f|%l| %m" +#else +# define DFLT_EFM \ + "%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%-Gg%\\?make[%*\\d]: *** [%f:%l:%m,%-Gg%\\?make: *** [%f:%l:%m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%-GIn file included from %f:%l:%c:,%-GIn file included from %f:%l:%c\\,,%-GIn file included from %f:%l:%c,%-GIn file included from %f:%l,%-G%*[ ]from %f:%l:%c,%-G%*[ ]from %f:%l:,%-G%*[ ]from %f:%l\\,,%-G%*[ ]from %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory %*[`']%f',%X%*\\a[%*\\d]: Leaving directory %*[`']%f',%D%*\\a: Entering directory %*[`']%f',%X%*\\a: Leaving directory %*[`']%f',%DMaking %*\\a in %f,%f|%l| %m" +#endif + +#define DFLT_GREPFORMAT "%f:%l:%m,%f:%l%m,%f %l%m" + +// default values for b_p_ff 'fileformat' and p_ffs 'fileformats' +#define FF_DOS "dos" +#define FF_MAC "mac" +#define FF_UNIX "unix" + +#ifdef USE_CRNL +# define DFLT_FF "dos" +# define DFLT_FFS_VIM "dos,unix" +# define DFLT_FFS_VI "dos,unix" // also autodetect in compatible mode +#else +# define DFLT_FF "unix" +# define DFLT_FFS_VIM "unix,dos" +# define DFLT_FFS_VI "" +#endif + +// Possible values for 'encoding' +#define ENC_UCSBOM "ucs-bom" // check for BOM at start of file + +// default value for 'encoding' +#define ENC_DFLT "utf-8" + +// end-of-line style +#define EOL_UNKNOWN (-1) // not defined yet +#define EOL_UNIX 0 // NL +#define EOL_DOS 1 // CR NL +#define EOL_MAC 2 // CR + +// Formatting options for p_fo 'formatoptions' +#define FO_WRAP 't' +#define FO_WRAP_COMS 'c' +#define FO_RET_COMS 'r' +#define FO_OPEN_COMS 'o' +#define FO_NO_OPEN_COMS '/' +#define FO_Q_COMS 'q' +#define FO_Q_NUMBER 'n' +#define FO_Q_SECOND '2' +#define FO_INS_VI 'v' +#define FO_INS_LONG 'l' +#define FO_INS_BLANK 'b' +#define FO_MBYTE_BREAK 'm' // break before/after multi-byte char +#define FO_MBYTE_JOIN 'M' // no space before/after multi-byte char +#define FO_MBYTE_JOIN2 'B' // no space between multi-byte chars +#define FO_ONE_LETTER '1' +#define FO_WHITE_PAR 'w' // trailing white space continues paragr. +#define FO_AUTO 'a' // automatic formatting +#define FO_RIGOROUS_TW ']' // respect textwidth rigorously +#define FO_REMOVE_COMS 'j' // remove comment leaders when joining lines +#define FO_PERIOD_ABBR 'p' // don't break a single space after a period + +#define DFLT_FO_VI "vt" +#define DFLT_FO_VIM "tcqj" +#define FO_ALL "tcro/q2vlb1mMBn,aw]jp" // for do_set() + +// characters for the p_cpo option: +#define CPO_ALTREAD 'a' // ":read" sets alternate file name +#define CPO_ALTWRITE 'A' // ":write" sets alternate file name +#define CPO_BAR 'b' // "\|" ends a mapping +#define CPO_BSLASH 'B' // backslash in mapping is not special +#define CPO_SEARCH 'c' +#define CPO_CONCAT 'C' // Don't concatenate sourced lines +#define CPO_DOTTAG 'd' // "./tags" in 'tags' is in current dir +#define CPO_DIGRAPH 'D' // No digraph after "r", "f", etc. +#define CPO_EXECBUF 'e' +#define CPO_EMPTYREGION 'E' // operating on empty region is an error +#define CPO_FNAMER 'f' // set file name for ":r file" +#define CPO_FNAMEW 'F' // set file name for ":w file" +#define CPO_INTMOD 'i' // interrupt a read makes buffer modified +#define CPO_INDENT 'I' // remove auto-indent more often +#define CPO_ENDOFSENT 'J' // need two spaces to detect end of sentence +#define CPO_KOFFSET 'K' // don't wait for key code in mappings +#define CPO_LITERAL 'l' // take char after backslash in [] literal +#define CPO_LISTWM 'L' // 'list' changes wrapmargin +#define CPO_SHOWMATCH 'm' +#define CPO_MATCHBSL 'M' // "%" ignores use of backslashes +#define CPO_NUMCOL 'n' // 'number' column also used for text +#define CPO_LINEOFF 'o' +#define CPO_OVERNEW 'O' // silently overwrite new file +#define CPO_LISP 'p' // 'lisp' indenting +#define CPO_FNAMEAPP 'P' // set file name for ":w >>file" +#define CPO_JOINCOL 'q' // with "3J" use column after first join +#define CPO_REDO 'r' +#define CPO_REMMARK 'R' // remove marks when filtering +#define CPO_BUFOPT 's' +#define CPO_BUFOPTGLOB 'S' +#define CPO_TAGPAT 't' // tag pattern is used for "n" +#define CPO_UNDO 'u' // "u" undoes itself +#define CPO_BACKSPACE 'v' // "v" keep deleted text +#define CPO_FWRITE 'W' // "w!" doesn't overwrite readonly files +#define CPO_ESC 'x' +#define CPO_REPLCNT 'X' // "R" with a count only deletes chars once +#define CPO_YANK 'y' +#define CPO_KEEPRO 'Z' // don't reset 'readonly' on ":w!" +#define CPO_DOLLAR '$' +#define CPO_FILTER '!' +#define CPO_MATCH '%' +#define CPO_PLUS '+' // ":write file" resets 'modified' +#define CPO_REGAPPEND '>' // insert NL when appending to a register +#define CPO_SCOLON ';' // using "," and ";" will skip over char if + // cursor would not move +#define CPO_CHANGEW '_' // "cw" special-case +// default values for Vim and Vi +#define CPO_VIM "aABceFs_" +#define CPO_VI "aAbBcCdDeEfFiIJKlLmMnoOpPqrRsStuvWxXyZ$!%+>;_" + +// characters for p_ww option: +#define WW_ALL "bshl<>[],~" + +// characters for p_mouse option: +#define MOUSE_NORMAL 'n' // use mouse in Normal mode +#define MOUSE_VISUAL 'v' // use mouse in Visual/Select mode +#define MOUSE_INSERT 'i' // use mouse in Insert mode +#define MOUSE_COMMAND 'c' // use mouse in Command-line mode +#define MOUSE_HELP 'h' // use mouse in help buffers +#define MOUSE_RETURN 'r' // use mouse for hit-return message +#define MOUSE_A "nvich" // used for 'a' flag +#define MOUSE_ALL "anvichr" // all possible characters +#define MOUSE_NONE ' ' // don't use Visual selection +#define MOUSE_NONEF 'x' // forced modeless selection + +// default vertical and horizontal mouse scroll values. +// Note: This should be in sync with the default mousescroll option. +#define MOUSESCROLL_VERT_DFLT 3 +#define MOUSESCROLL_HOR_DFLT 6 + +#define COCU_ALL "nvic" // flags for 'concealcursor' + +/// characters for p_shm option: +enum { + SHM_RO = 'r', ///< Readonly. + SHM_MOD = 'm', ///< Modified. + SHM_LINES = 'l', ///< "L" instead of "lines". + SHM_WRI = 'w', ///< "[w]" instead of "written". + SHM_ABBREVIATIONS = 'a', ///< Use abbreviations from #SHM_ALL_ABBREVIATIONS. + SHM_WRITE = 'W', ///< Don't use "written" at all. + SHM_TRUNC = 't', ///< Truncate file messages. + SHM_TRUNCALL = 'T', ///< Truncate all messages. + SHM_OVER = 'o', ///< Overwrite file messages. + SHM_OVERALL = 'O', ///< Overwrite more messages. + SHM_SEARCH = 's', ///< No search hit bottom messages. + SHM_ATTENTION = 'A', ///< No ATTENTION messages. + SHM_INTRO = 'I', ///< Intro messages. + SHM_COMPLETIONMENU = 'c', ///< Completion menu messages. + SHM_COMPLETIONSCAN = 'C', ///< Completion scanning messages. + SHM_RECORDING = 'q', ///< Short recording message. + SHM_FILEINFO = 'F', ///< No file info messages. + SHM_SEARCHCOUNT = 'S', ///< No search stats: '[1/10]' +}; +/// Represented by 'a' flag. +#define SHM_ALL_ABBREVIATIONS ((char[]) { \ + SHM_RO, SHM_MOD, SHM_LINES, SHM_WRI, \ + 0 }) + +// characters for p_go: +#define GO_ASEL 'a' // autoselect +#define GO_ASELML 'A' // autoselect modeless selection +#define GO_BOT 'b' // use bottom scrollbar +#define GO_CONDIALOG 'c' // use console dialog +#define GO_DARKTHEME 'd' // use dark theme variant +#define GO_TABLINE 'e' // may show tabline +#define GO_FORG 'f' // start GUI in foreground +#define GO_GREY 'g' // use grey menu items +#define GO_HORSCROLL 'h' // flexible horizontal scrolling +#define GO_ICON 'i' // use Vim icon +#define GO_LEFT 'l' // use left scrollbar +#define GO_VLEFT 'L' // left scrollbar with vert split +#define GO_MENUS 'm' // use menu bar +#define GO_NOSYSMENU 'M' // don't source system menu +#define GO_POINTER 'p' // pointer enter/leave callbacks +#define GO_ASELPLUS 'P' // autoselectPlus +#define GO_RIGHT 'r' // use right scrollbar +#define GO_VRIGHT 'R' // right scrollbar with vert split +#define GO_TOOLBAR 'T' // add toolbar +#define GO_FOOTER 'F' // add footer +#define GO_VERTICAL 'v' // arrange dialog buttons vertically +#define GO_KEEPWINSIZE 'k' // keep GUI window size +#define GO_ALL "!aAbcdefFghilLmMpPrRtTvk" // all possible flags for 'go' + +// flags for 'comments' option +#define COM_NEST 'n' // comments strings nest +#define COM_BLANK 'b' // needs blank after string +#define COM_START 's' // start of comment +#define COM_MIDDLE 'm' // middle of comment +#define COM_END 'e' // end of comment +#define COM_AUTO_END 'x' // last char of end closes comment +#define COM_FIRST 'f' // first line comment only +#define COM_LEFT 'l' // left adjusted +#define COM_RIGHT 'r' // right adjusted +#define COM_NOBACK 'O' // don't use for "O" command +#define COM_ALL "nbsmexflrO" // all flags for 'comments' option +#define COM_MAX_LEN 50 // maximum length of a part + +/// 'statusline' option flags +enum { + STL_FILEPATH = 'f', ///< Path of file in buffer. + STL_FULLPATH = 'F', ///< Full path of file in buffer. + STL_FILENAME = 't', ///< Last part (tail) of file path. + STL_COLUMN = 'c', ///< Column og cursor. + STL_VIRTCOL = 'v', ///< Virtual column. + STL_VIRTCOL_ALT = 'V', ///< - with 'if different' display. + STL_LINE = 'l', ///< Line number of cursor. + STL_NUMLINES = 'L', ///< Number of lines in buffer. + STL_BUFNO = 'n', ///< Current buffer number. + STL_KEYMAP = 'k', ///< 'keymap' when active. + STL_OFFSET = 'o', ///< Offset of character under cursor. + STL_OFFSET_X = 'O', ///< - in hexadecimal. + STL_BYTEVAL = 'b', ///< Byte value of character. + STL_BYTEVAL_X = 'B', ///< - in hexadecimal. + STL_ROFLAG = 'r', ///< Readonly flag. + STL_ROFLAG_ALT = 'R', ///< - other display. + STL_HELPFLAG = 'h', ///< Window is showing a help file. + STL_HELPFLAG_ALT = 'H', ///< - other display. + STL_FILETYPE = 'y', ///< 'filetype'. + STL_FILETYPE_ALT = 'Y', ///< - other display. + STL_PREVIEWFLAG = 'w', ///< Window is showing the preview buf. + STL_PREVIEWFLAG_ALT = 'W', ///< - other display. + STL_MODIFIED = 'm', ///< Modified flag. + STL_MODIFIED_ALT = 'M', ///< - other display. + STL_QUICKFIX = 'q', ///< Quickfix window description. + STL_PERCENTAGE = 'p', ///< Percentage through file. + STL_ALTPERCENT = 'P', ///< Percentage as TOP BOT ALL or NN%. + STL_ARGLISTSTAT = 'a', ///< Argument list status as (x of y). + STL_PAGENUM = 'N', ///< Page number (when printing). + STL_SHOWCMD = 'S', ///< 'showcmd' buffer + STL_FOLDCOL = 'C', ///< Fold column for 'statuscolumn' + STL_SIGNCOL = 's', ///< Sign column for 'statuscolumn' + STL_VIM_EXPR = '{', ///< Start of expression to substitute. + STL_SEPARATE = '=', ///< Separation between alignment sections. + STL_TRUNCMARK = '<', ///< Truncation mark if line is too long. + STL_USER_HL = '*', ///< Highlight from (User)1..9 or 0. + STL_HIGHLIGHT = '#', ///< Highlight name. + STL_TABPAGENR = 'T', ///< Tab page label nr. + STL_TABCLOSENR = 'X', ///< Tab page close nr. + STL_CLICK_FUNC = '@', ///< Click region start. +}; +/// C string containing all 'statusline' option flags +#define STL_ALL ((char[]) { \ + STL_FILEPATH, STL_FULLPATH, STL_FILENAME, STL_COLUMN, STL_VIRTCOL, \ + STL_VIRTCOL_ALT, STL_LINE, STL_NUMLINES, STL_BUFNO, STL_KEYMAP, STL_OFFSET, \ + STL_OFFSET_X, STL_BYTEVAL, STL_BYTEVAL_X, STL_ROFLAG, STL_ROFLAG_ALT, \ + STL_HELPFLAG, STL_HELPFLAG_ALT, STL_FILETYPE, STL_FILETYPE_ALT, \ + STL_PREVIEWFLAG, STL_PREVIEWFLAG_ALT, STL_MODIFIED, STL_MODIFIED_ALT, \ + STL_QUICKFIX, STL_PERCENTAGE, STL_ALTPERCENT, STL_ARGLISTSTAT, STL_PAGENUM, \ + STL_SHOWCMD, STL_FOLDCOL, STL_SIGNCOL, STL_VIM_EXPR, STL_SEPARATE, \ + STL_TRUNCMARK, STL_USER_HL, STL_HIGHLIGHT, STL_TABPAGENR, STL_TABCLOSENR, \ + STL_CLICK_FUNC, STL_TABPAGENR, STL_TABCLOSENR, STL_CLICK_FUNC, \ + 0, }) + +// flags used for parsed 'wildmode' +#define WIM_FULL 0x01 +#define WIM_LONGEST 0x02 +#define WIM_LIST 0x04 +#define WIM_BUFLASTUSED 0x08 + +// arguments for can_bs() +// each defined char should be unique over all values +// except for BS_START, that intentionally also matches BS_NOSTOP +// because BS_NOSTOP behaves exactly the same except it +// does not stop at the start of the insert point +#define BS_INDENT 'i' // "Indent" +#define BS_EOL 'l' // "eoL" +#define BS_START 's' // "Start" +#define BS_NOSTOP 'p' // "nostoP + +// flags for the 'culopt' option +#define CULOPT_LINE 0x01 // Highlight complete line +#define CULOPT_SCRLINE 0x02 // Highlight screen line +#define CULOPT_NBR 0x04 // Highlight Number column + +#define LISPWORD_VALUE \ + "defun,define,defmacro,set!,lambda,if,case,let,flet,let*,letrec,do,do*,define-syntax,let-syntax,letrec-syntax,destructuring-bind,defpackage,defparameter,defstruct,deftype,defvar,do-all-symbols,do-external-symbols,do-symbols,dolist,dotimes,ecase,etypecase,eval-when,labels,macrolet,multiple-value-bind,multiple-value-call,multiple-value-prog1,multiple-value-setq,prog1,progv,typecase,unless,unwind-protect,when,with-input-from-string,with-open-file,with-open-stream,with-output-to-string,with-package-iterator,define-condition,handler-bind,handler-case,restart-bind,restart-case,with-simple-restart,store-value,use-value,muffle-warning,abort,continue,with-slots,with-slots*,with-accessors,with-accessors*,defclass,defmethod,print-unreadable-object" + +// The following are actual variables for the options + +EXTERN char *p_ambw; ///< 'ambiwidth' +EXTERN int p_acd; ///< 'autochdir' +EXTERN int p_ai; ///< 'autoindent' +EXTERN int p_bin; ///< 'binary' +EXTERN int p_bomb; ///< 'bomb' +EXTERN int p_bl; ///< 'buflisted' +EXTERN int p_cin; ///< 'cindent' +EXTERN OptInt p_channel; ///< 'channel' +EXTERN char *p_cink; ///< 'cinkeys' +EXTERN char *p_cinsd; ///< 'cinscopedecls' +EXTERN char *p_cinw; ///< 'cinwords' +EXTERN char *p_cfu; ///< 'completefunc' +EXTERN char *p_ofu; ///< 'omnifunc' +EXTERN char *p_tsrfu; ///< 'thesaurusfunc' +EXTERN int p_ci; ///< 'copyindent' +EXTERN int p_ar; ///< 'autoread' +EXTERN int p_aw; ///< 'autowrite' +EXTERN int p_awa; ///< 'autowriteall' +EXTERN char *p_bs; ///< 'backspace' +EXTERN char *p_bg; ///< 'background' +EXTERN int p_bk; ///< 'backup' +EXTERN char *p_bkc; ///< 'backupcopy' +EXTERN unsigned bkc_flags; ///< flags from 'backupcopy' +#define BKC_YES 0x001 +#define BKC_AUTO 0x002 +#define BKC_NO 0x004 +#define BKC_BREAKSYMLINK 0x008 +#define BKC_BREAKHARDLINK 0x010 +EXTERN char *p_bdir; ///< 'backupdir' +EXTERN char *p_bex; ///< 'backupext' +EXTERN char *p_bo; ///< 'belloff' +EXTERN char breakat_flags[256]; ///< which characters are in 'breakat' +EXTERN unsigned bo_flags; + +// values for the 'belloff' option +#define BO_ALL 0x0001 +#define BO_BS 0x0002 +#define BO_CRSR 0x0004 +#define BO_COMPL 0x0008 +#define BO_COPY 0x0010 +#define BO_CTRLG 0x0020 +#define BO_ERROR 0x0040 +#define BO_ESC 0x0080 +#define BO_EX 0x0100 +#define BO_HANGUL 0x0200 +#define BO_IM 0x0400 +#define BO_LANG 0x0800 +#define BO_MESS 0x1000 +#define BO_MATCH 0x2000 +#define BO_OPER 0x4000 +#define BO_REG 0x8000 +#define BO_SH 0x10000 +#define BO_SPELL 0x20000 +#define BO_WILD 0x40000 + +EXTERN char *p_bsk; ///< 'backupskip' +EXTERN char *p_breakat; ///< 'breakat' +EXTERN char *p_bh; ///< 'bufhidden' +EXTERN char *p_bt; ///< 'buftype' +EXTERN char *p_cmp; ///< 'casemap' +EXTERN unsigned cmp_flags; +#define CMP_INTERNAL 0x001 +#define CMP_KEEPASCII 0x002 +EXTERN char *p_enc; ///< 'encoding' +EXTERN int p_deco; ///< 'delcombine' +EXTERN char *p_ccv; ///< 'charconvert' +EXTERN char *p_cino; ///< 'cinoptions' +EXTERN char *p_cedit; ///< 'cedit' +EXTERN char *p_cb; ///< 'clipboard' +EXTERN unsigned cb_flags; +#define CB_UNNAMED 0x001 +#define CB_UNNAMEDPLUS 0x002 +#define CB_UNNAMEDMASK (CB_UNNAMED | CB_UNNAMEDPLUS) +EXTERN OptInt p_cwh; ///< 'cmdwinheight' +EXTERN OptInt p_ch; ///< 'cmdheight' +EXTERN char *p_cms; ///< 'commentstring' +EXTERN char *p_cpt; ///< 'complete' +EXTERN OptInt p_columns; ///< 'columns' +EXTERN int p_confirm; ///< 'confirm' +EXTERN char *p_cot; ///< 'completeopt' +#ifdef BACKSLASH_IN_FILENAME +EXTERN char *p_csl; ///< 'completeslash' +#endif +EXTERN OptInt p_pb; ///< 'pumblend' +EXTERN OptInt p_ph; ///< 'pumheight' +EXTERN OptInt p_pw; ///< 'pumwidth' +EXTERN char *p_com; ///< 'comments' +EXTERN char *p_cpo; ///< 'cpoptions' +EXTERN char *p_debug; ///< 'debug' +EXTERN char *p_def; ///< 'define' +EXTERN char *p_inc; +EXTERN char *p_dip; ///< 'diffopt' +EXTERN char *p_dex; ///< 'diffexpr' +EXTERN char *p_dict; ///< 'dictionary' +EXTERN int p_dg; ///< 'digraph' +EXTERN char *p_dir; ///< 'directory' +EXTERN char *p_dy; ///< 'display' +EXTERN unsigned dy_flags; +#define DY_LASTLINE 0x001 +#define DY_TRUNCATE 0x002 +#define DY_UHEX 0x004 +// legacy flag, not used +#define DY_MSGSEP 0x008 +EXTERN int p_ed; ///< 'edcompatible' +EXTERN char *p_ead; ///< 'eadirection' +EXTERN int p_emoji; ///< 'emoji' +EXTERN int p_ea; ///< 'equalalways' +EXTERN char *p_ep; ///< 'equalprg' +EXTERN int p_eb; ///< 'errorbells' +EXTERN char *p_ef; ///< 'errorfile' +EXTERN char *p_efm; ///< 'errorformat' +EXTERN char *p_gefm; ///< 'grepformat' +EXTERN char *p_gp; ///< 'grepprg' +EXTERN int p_eof; ///< 'endoffile' +EXTERN int p_eol; ///< 'endofline' +EXTERN char *p_ei; ///< 'eventignore' +EXTERN int p_et; ///< 'expandtab' +EXTERN int p_exrc; ///< 'exrc' +EXTERN char *p_fenc; ///< 'fileencoding' +EXTERN char *p_fencs; ///< 'fileencodings' +EXTERN char *p_ff; ///< 'fileformat' +EXTERN char *p_ffs; ///< 'fileformats' +EXTERN int p_fic; ///< 'fileignorecase' +EXTERN char *p_ft; ///< 'filetype' +EXTERN char *p_fcs; ///< 'fillchar' +EXTERN int p_fixeol; ///< 'fixendofline' +EXTERN char *p_fcl; ///< 'foldclose' +EXTERN OptInt p_fdls; ///< 'foldlevelstart' +EXTERN char *p_fdo; ///< 'foldopen' +EXTERN unsigned fdo_flags; +#define FDO_ALL 0x001 +#define FDO_BLOCK 0x002 +#define FDO_HOR 0x004 +#define FDO_MARK 0x008 +#define FDO_PERCENT 0x010 +#define FDO_QUICKFIX 0x020 +#define FDO_SEARCH 0x040 +#define FDO_TAG 0x080 +#define FDO_INSERT 0x100 +#define FDO_UNDO 0x200 +#define FDO_JUMP 0x400 +EXTERN char *p_fex; ///< 'formatexpr' +EXTERN char *p_flp; ///< 'formatlistpat' +EXTERN char *p_fo; ///< 'formatoptions' +EXTERN char *p_fp; ///< 'formatprg' +EXTERN int p_fs; ///< 'fsync' +EXTERN int p_gd; ///< 'gdefault' +EXTERN char *p_guicursor; ///< 'guicursor' +EXTERN char *p_guifont; ///< 'guifont' +EXTERN char *p_guifontwide; ///< 'guifontwide' +EXTERN char *p_hf; ///< 'helpfile' +EXTERN OptInt p_hh; ///< 'helpheight' +EXTERN char *p_hlg; ///< 'helplang' +EXTERN int p_hid; ///< 'hidden' +EXTERN char *p_hl; ///< 'highlight' +EXTERN int p_hls; ///< 'hlsearch' +EXTERN OptInt p_hi; ///< 'history' +EXTERN int p_arshape; ///< 'arabicshape' +EXTERN int p_icon; ///< 'icon' +EXTERN char *p_iconstring; ///< 'iconstring' +EXTERN int p_ic; ///< 'ignorecase' +EXTERN OptInt p_iminsert; ///< 'iminsert' +EXTERN OptInt p_imsearch; ///< 'imsearch' +EXTERN int p_inf; ///< 'infercase' +EXTERN char *p_inex; ///< 'includeexpr' +EXTERN int p_is; ///< 'incsearch' +EXTERN char *p_inde; ///< 'indentexpr' +EXTERN char *p_indk; ///< 'indentkeys' +EXTERN char *p_icm; ///< 'inccommand' +EXTERN char *p_isf; ///< 'isfname' +EXTERN char *p_isi; ///< 'isident' +EXTERN char *p_isk; ///< 'iskeyword' +EXTERN char *p_isp; ///< 'isprint' +EXTERN int p_js; ///< 'joinspaces' +EXTERN char *p_jop; ///< 'jumpooptions' +EXTERN unsigned jop_flags; +#define JOP_STACK 0x01 +#define JOP_VIEW 0x02 +EXTERN char *p_keymap; ///< 'keymap' +EXTERN char *p_kp; ///< 'keywordprg' +EXTERN char *p_km; ///< 'keymodel' +EXTERN char *p_langmap; ///< 'langmap' +EXTERN int p_lnr; ///< 'langnoremap' +EXTERN int p_lrm; ///< 'langremap' +EXTERN char *p_lm; ///< 'langmenu' +EXTERN OptInt p_lines; ///< 'lines' +EXTERN OptInt p_linespace; ///< 'linespace' +EXTERN int p_lisp; ///< 'lisp' +EXTERN char *p_lop; ///< 'lispoptions' +EXTERN char *p_lispwords; ///< 'lispwords' +EXTERN OptInt p_ls; ///< 'laststatus' +EXTERN OptInt p_stal; ///< 'showtabline' +EXTERN char *p_lcs; ///< 'listchars' + +EXTERN int p_lz; ///< 'lazyredraw' +EXTERN int p_lpl; ///< 'loadplugins' +EXTERN int p_magic; ///< 'magic' +EXTERN char *p_menc; ///< 'makeencoding' +EXTERN char *p_mef; ///< 'makeef' +EXTERN char *p_mp; ///< 'makeprg' +EXTERN char *p_mps; ///< 'matchpairs' +EXTERN OptInt p_mat; ///< 'matchtime' +EXTERN OptInt p_mco; ///< 'maxcombine' +EXTERN OptInt p_mfd; ///< 'maxfuncdepth' +EXTERN OptInt p_mmd; ///< 'maxmapdepth' +EXTERN OptInt p_mmp; ///< 'maxmempattern' +EXTERN OptInt p_mis; ///< 'menuitems' +EXTERN char *p_msm; ///< 'mkspellmem' +EXTERN int p_ml; ///< 'modeline' +EXTERN int p_mle; ///< 'modelineexpr' +EXTERN OptInt p_mls; ///< 'modelines' +EXTERN int p_ma; ///< 'modifiable' +EXTERN int p_mod; ///< 'modified' +EXTERN char *p_mouse; ///< 'mouse' +EXTERN char *p_mousem; ///< 'mousemodel' +EXTERN int p_mousemev; ///< 'mousemoveevent' +EXTERN int p_mousef; ///< 'mousefocus' +EXTERN char *p_mousescroll; ///< 'mousescroll' +EXTERN OptInt p_mousescroll_vert INIT(= MOUSESCROLL_VERT_DFLT); +EXTERN OptInt p_mousescroll_hor INIT(= MOUSESCROLL_HOR_DFLT); +EXTERN OptInt p_mouset; ///< 'mousetime' +EXTERN int p_more; ///< 'more' +EXTERN char *p_nf; ///< 'nrformats' +EXTERN char *p_opfunc; ///< 'operatorfunc' +EXTERN char *p_para; ///< 'paragraphs' +EXTERN int p_paste; ///< 'paste' +EXTERN char *p_pex; ///< 'patchexpr' +EXTERN char *p_pm; ///< 'patchmode' +EXTERN char *p_path; ///< 'path' +EXTERN char *p_cdpath; ///< 'cdpath' +EXTERN int p_pi; ///< 'preserveindent' +EXTERN OptInt p_pyx; ///< 'pyxversion' +EXTERN char *p_qe; ///< 'quoteescape' +EXTERN int p_ro; ///< 'readonly' +EXTERN char *p_rdb; ///< 'redrawdebug' +EXTERN unsigned rdb_flags; +#define RDB_COMPOSITOR 0x001 +#define RDB_NOTHROTTLE 0x002 +#define RDB_INVALID 0x004 +#define RDB_NODELTA 0x008 +#define RDB_LINE 0x010 +#define RDB_FLUSH 0x020 +#define RDB_INTERSECT 0x040 + +EXTERN OptInt p_rdt; ///< 'redrawtime' +EXTERN OptInt p_re; ///< 'regexpengine' +EXTERN OptInt p_report; ///< 'report' +EXTERN OptInt p_pvh; ///< 'previewheight' +EXTERN int p_ari; ///< 'allowrevins' +EXTERN int p_ri; ///< 'revins' +EXTERN int p_ru; ///< 'ruler' +EXTERN char *p_ruf; ///< 'rulerformat' +EXTERN char *p_pp; ///< 'packpath' +EXTERN char *p_qftf; ///< 'quickfixtextfunc' +EXTERN char *p_rtp; ///< 'runtimepath' +EXTERN OptInt p_scbk; ///< 'scrollback' +EXTERN OptInt p_sj; ///< 'scrolljump' +EXTERN OptInt p_so; ///< 'scrolloff' +EXTERN char *p_sbo; ///< 'scrollopt' +EXTERN char *p_sections; ///< 'sections' +EXTERN int p_secure; ///< 'secure' +EXTERN char *p_sel; ///< 'selection' +EXTERN char *p_slm; ///< 'selectmode' +EXTERN char *p_ssop; ///< 'sessionoptions' +EXTERN unsigned ssop_flags; + +#define SSOP_BUFFERS 0x001 +#define SSOP_WINPOS 0x002 +#define SSOP_RESIZE 0x004 +#define SSOP_WINSIZE 0x008 +#define SSOP_LOCALOPTIONS 0x010 +#define SSOP_OPTIONS 0x020 +#define SSOP_HELP 0x040 +#define SSOP_BLANK 0x080 +#define SSOP_GLOBALS 0x100 +#define SSOP_SLASH 0x200 // Deprecated, always set. +#define SSOP_UNIX 0x400 // Deprecated, always set. +#define SSOP_SESDIR 0x800 +#define SSOP_CURDIR 0x1000 +#define SSOP_FOLDS 0x2000 +#define SSOP_CURSOR 0x4000 +#define SSOP_TABPAGES 0x8000 +#define SSOP_TERMINAL 0x10000 +#define SSOP_SKIP_RTP 0x20000 + +EXTERN char *p_sh; ///< 'shell' +EXTERN char *p_shcf; ///< 'shellcmdflag' +EXTERN char *p_sp; ///< 'shellpipe' +EXTERN char *p_shq; ///< 'shellquote' +EXTERN char *p_sxq; ///< 'shellxquote' +EXTERN char *p_sxe; ///< 'shellxescape' +EXTERN char *p_srr; ///< 'shellredir' +EXTERN int p_stmp; ///< 'shelltemp' +#ifdef BACKSLASH_IN_FILENAME +EXTERN int p_ssl; ///< 'shellslash' +#endif +EXTERN char *p_stl; ///< 'statusline' +EXTERN char *p_wbr; ///< 'winbar' +EXTERN int p_sr; ///< 'shiftround' +EXTERN OptInt p_sw; ///< 'shiftwidth' +EXTERN char *p_shm; ///< 'shortmess' +EXTERN char *p_sbr; ///< 'showbreak' +EXTERN int p_sc; ///< 'showcmd' +EXTERN char *p_sloc; ///< 'showcmdloc' +EXTERN int p_sft; ///< 'showfulltag' +EXTERN int p_sm; ///< 'showmatch' +EXTERN int p_smd; ///< 'showmode' +EXTERN OptInt p_ss; ///< 'sidescroll' +EXTERN OptInt p_siso; ///< 'sidescrolloff' +EXTERN int p_scs; ///< 'smartcase' +EXTERN int p_si; ///< 'smartindent' +EXTERN int p_sta; ///< 'smarttab' +EXTERN OptInt p_sts; ///< 'softtabstop' +EXTERN int p_sb; ///< 'splitbelow' +EXTERN char *p_sua; ///< 'suffixesadd' +EXTERN int p_swf; ///< 'swapfile' +EXTERN OptInt p_smc; ///< 'synmaxcol' +EXTERN OptInt p_tpm; ///< 'tabpagemax' +EXTERN char *p_tal; ///< 'tabline' +EXTERN char *p_tpf; ///< 'termpastefilter' +EXTERN unsigned tpf_flags; ///< flags from 'termpastefilter' +#define TPF_BS 0x001 +#define TPF_HT 0x002 +#define TPF_FF 0x004 +#define TPF_ESC 0x008 +#define TPF_DEL 0x010 +#define TPF_C0 0x020 +#define TPF_C1 0x040 +EXTERN char *p_tfu; ///< 'tagfunc' +EXTERN char *p_spc; ///< 'spellcapcheck' +EXTERN char *p_spf; ///< 'spellfile' +EXTERN char *p_spk; ///< 'splitkeep' +EXTERN char *p_spl; ///< 'spelllang' +EXTERN char *p_spo; ///< 'spelloptions' +EXTERN unsigned spo_flags; +EXTERN char *p_sps; ///< 'spellsuggest' +EXTERN int p_spr; ///< 'splitright' +EXTERN int p_sol; ///< 'startofline' +EXTERN char *p_su; ///< 'suffixes' +EXTERN char *p_swb; ///< 'switchbuf' +EXTERN unsigned swb_flags; +// Keep in sync with p_swb_values in optionstr.c +#define SWB_USEOPEN 0x001 +#define SWB_USETAB 0x002 +#define SWB_SPLIT 0x004 +#define SWB_NEWTAB 0x008 +#define SWB_VSPLIT 0x010 +#define SWB_USELAST 0x020 +EXTERN char *p_syn; ///< 'syntax' +EXTERN OptInt p_ts; ///< 'tabstop' +EXTERN int p_tbs; ///< 'tagbsearch' +EXTERN char *p_tc; ///< 'tagcase' +EXTERN unsigned tc_flags; ///< flags from 'tagcase' +#define TC_FOLLOWIC 0x01 +#define TC_IGNORE 0x02 +#define TC_MATCH 0x04 +#define TC_FOLLOWSCS 0x08 +#define TC_SMART 0x10 +EXTERN OptInt p_tl; ///< 'taglength' +EXTERN int p_tr; ///< 'tagrelative' +EXTERN char *p_tags; ///< 'tags' +EXTERN int p_tgst; ///< 'tagstack' +EXTERN int p_tbidi; ///< 'termbidi' +EXTERN OptInt p_tw; ///< 'textwidth' +EXTERN int p_to; ///< 'tildeop' +EXTERN int p_timeout; ///< 'timeout' +EXTERN OptInt p_tm; ///< 'timeoutlen' +EXTERN int p_title; ///< 'title' +EXTERN OptInt p_titlelen; ///< 'titlelen' +EXTERN char *p_titleold; ///< 'titleold' +EXTERN char *p_titlestring; ///< 'titlestring' +EXTERN char *p_tsr; ///< 'thesaurus' +EXTERN int p_tgc; ///< 'termguicolors' +EXTERN int p_ttimeout; ///< 'ttimeout' +EXTERN OptInt p_ttm; ///< 'ttimeoutlen' +EXTERN char *p_udir; ///< 'undodir' +EXTERN int p_udf; ///< 'undofile' +EXTERN OptInt p_ul; ///< 'undolevels' +EXTERN OptInt p_ur; ///< 'undoreload' +EXTERN OptInt p_uc; ///< 'updatecount' +EXTERN OptInt p_ut; ///< 'updatetime' +EXTERN char *p_shada; ///< 'shada' +EXTERN char *p_shadafile; ///< 'shadafile' +EXTERN char *p_vsts; ///< 'varsofttabstop' +EXTERN char *p_vts; ///< 'vartabstop' +EXTERN char *p_vdir; ///< 'viewdir' +EXTERN char *p_vop; ///< 'viewoptions' +EXTERN unsigned vop_flags; ///< uses SSOP_ flags +EXTERN int p_vb; ///< 'visualbell' +EXTERN char *p_ve; ///< 'virtualedit' +EXTERN unsigned ve_flags; +#define VE_BLOCK 5U // includes "all" +#define VE_INSERT 6U // includes "all" +#define VE_ALL 4U +#define VE_ONEMORE 8U +#define VE_NONE 16U // "none" +#define VE_NONEU 32U // "NONE" +EXTERN OptInt p_verbose; ///< 'verbose' +#ifdef IN_OPTION_C +char *p_vfile = ""; ///< used before options are initialized +#else +extern char *p_vfile; ///< 'verbosefile' +#endif +EXTERN int p_warn; ///< 'warn' +EXTERN char *p_wop; ///< 'wildoptions' +EXTERN unsigned wop_flags; +#define WOP_TAGFILE 0x01 +#define WOP_PUM 0x02 +#define WOP_FUZZY 0x04 +EXTERN OptInt p_window; ///< 'window' +EXTERN char *p_wak; ///< 'winaltkeys' +EXTERN char *p_wig; ///< 'wildignore' +EXTERN char *p_ww; ///< 'whichwrap' +EXTERN OptInt p_wc; ///< 'wildchar' +EXTERN OptInt p_wcm; ///< 'wildcharm' +EXTERN int p_wic; ///< 'wildignorecase' +EXTERN char *p_wim; ///< 'wildmode' +EXTERN int p_wmnu; ///< 'wildmenu' +EXTERN OptInt p_wh; ///< 'winheight' +EXTERN OptInt p_wmh; ///< 'winminheight' +EXTERN OptInt p_wmw; ///< 'winminwidth' +EXTERN OptInt p_wiw; ///< 'winwidth' +EXTERN OptInt p_wm; ///< 'wrapmargin' +EXTERN int p_ws; ///< 'wrapscan' +EXTERN int p_write; ///< 'write' +EXTERN int p_wa; ///< 'writeany' +EXTERN int p_wb; ///< 'writebackup' +EXTERN OptInt p_wd; ///< 'writedelay' +EXTERN int p_cdh; ///< 'cdhome' + +EXTERN int p_force_on; ///< options that cannot be turned off. +EXTERN int p_force_off; ///< options that cannot be turned on. + +/// "indir" values for buffer-local options. +/// These need to be defined globally, so that the BV_COUNT can be used with +/// b_p_script_stx[]. +enum { + BV_AI = 0, + BV_AR, + BV_BH, + BV_BKC, + BV_BT, + BV_EFM, + BV_GP, + BV_MP, + BV_BIN, + BV_BL, + BV_BOMB, + BV_CHANNEL, + BV_CI, + BV_CIN, + BV_CINK, + BV_CINO, + BV_CINW, + BV_CINSD, + BV_CM, + BV_CMS, + BV_COM, + BV_CPT, + BV_DICT, + BV_TSR, + BV_CSL, + BV_CFU, + BV_DEF, + BV_INC, + BV_EOF, + BV_EOL, + BV_FIXEOL, + BV_EP, + BV_ET, + BV_FENC, + BV_FP, + BV_BEXPR, + BV_FEX, + BV_FF, + BV_FLP, + BV_FO, + BV_FT, + BV_IMI, + BV_IMS, + BV_INDE, + BV_INDK, + BV_INEX, + BV_INF, + BV_ISK, + BV_KMAP, + BV_KP, + BV_LISP, + BV_LOP, + BV_LW, + BV_MENC, + BV_MA, + BV_ML, + BV_MOD, + BV_MPS, + BV_NF, + BV_OFU, + BV_PATH, + BV_PI, + BV_QE, + BV_RO, + BV_SCBK, + BV_SI, + BV_SMC, + BV_SYN, + BV_SPC, + BV_SPF, + BV_SPL, + BV_SPO, + BV_STS, + BV_SUA, + BV_SW, + BV_SWF, + BV_TFU, + BV_TSRFU, + BV_TAGS, + BV_TC, + BV_TS, + BV_TW, + BV_TX, + BV_UDF, + BV_UL, + BV_WM, + BV_VSTS, + BV_VTS, + BV_COUNT, // must be the last one +}; + +/// "indir" values for window-local options. +/// These need to be defined globally, so that the WV_COUNT can be used in the +/// window structure. +enum { + WV_LIST = 0, + WV_ARAB, + WV_COCU, + WV_COLE, + WV_CRBIND, + WV_BRI, + WV_BRIOPT, + WV_DIFF, + WV_FDC, + WV_FEN, + WV_FDI, + WV_FDL, + WV_FDM, + WV_FML, + WV_FDN, + WV_FDE, + WV_FDT, + WV_FMR, + WV_LBR, + WV_NU, + WV_RNU, + WV_VE, + WV_NUW, + WV_PVW, + WV_RL, + WV_RLC, + WV_SCBIND, + WV_SCROLL, + WV_SMS, + WV_SISO, + WV_SO, + WV_SPELL, + WV_CUC, + WV_CUL, + WV_CULOPT, + WV_CC, + WV_SBR, + WV_STC, + WV_STL, + WV_WFH, + WV_WFW, + WV_WRAP, + WV_SCL, + WV_WINHL, + WV_LCS, + WV_FCS, + WV_WINBL, + WV_WBR, + WV_COUNT, // must be the last one +}; + +// Value for b_p_ul indicating the global value must be used. +#define NO_LOCAL_UNDOLEVEL (-123456) + +#define SB_MAX 100000 // Maximum 'scrollback' value. + +#define MAX_NUMBERWIDTH 20 // used for 'numberwidth' and 'statuscolumn' + +#define TABSTOP_MAX 9999 + +#endif // NVIM_OPTION_VARS_H diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 429a70eb38..cd1d760836 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -6546,9 +6546,9 @@ return { cb = 'did_set_scrollbind', defaults = { if_true = false }, desc = [=[ - See also |scroll-binding|. When this option is set, the current - window scrolls as other scrollbind windows (windows that also have - this option set) scroll. This option is useful for viewing the + See also |scroll-binding|. When this option is set, scrolling the + current window also scrolls other scrollbind windows (windows that + also have this option set). This option is useful for viewing the differences between two versions of a file, see 'diff'. See |'scrollopt'| for options that determine how this option should be interpreted. diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index 797c3cb554..750941da07 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -28,29 +28,25 @@ #include "nvim/indent.h" #include "nvim/indent_c.h" #include "nvim/insexpand.h" -#include "nvim/keycodes.h" #include "nvim/macros.h" -#include "nvim/mapping.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/mouse.h" #include "nvim/move.h" -#include "nvim/ops.h" #include "nvim/option.h" #include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/os.h" #include "nvim/pos.h" -#include "nvim/quickfix.h" #include "nvim/runtime.h" #include "nvim/spell.h" #include "nvim/spellfile.h" #include "nvim/spellsuggest.h" -#include "nvim/statusline.h" #include "nvim/strings.h" -#include "nvim/tag.h" +#include "nvim/types.h" #include "nvim/ui.h" #include "nvim/vim.h" #include "nvim/window.h" @@ -523,71 +519,6 @@ static bool valid_filetype(const char *val) return valid_name(val, ".-_"); } -/// Handle setting 'mousescroll'. -/// @return error message, NULL if it's OK. -const char *did_set_mousescroll(optset_T *args FUNC_ATTR_UNUSED) -{ - long vertical = -1; - long horizontal = -1; - - char *string = p_mousescroll; - - while (true) { - char *end = vim_strchr(string, ','); - size_t length = end ? (size_t)(end - string) : strlen(string); - - // Both "ver:" and "hor:" are 4 bytes long. - // They should be followed by at least one digit. - if (length <= 4) { - return e_invarg; - } - - long *direction; - - if (memcmp(string, "ver:", 4) == 0) { - direction = &vertical; - } else if (memcmp(string, "hor:", 4) == 0) { - direction = &horizontal; - } else { - return e_invarg; - } - - // If the direction has already been set, this is a duplicate. - if (*direction != -1) { - return e_invarg; - } - - // Verify that only digits follow the colon. - for (size_t i = 4; i < length; i++) { - if (!ascii_isdigit(string[i])) { - return N_("E5080: Digit expected"); - } - } - - string += 4; - *direction = getdigits_int(&string, false, -1); - - // Num options are generally kept within the signed int range. - // We know this number won't be negative because we've already checked for - // a minus sign. We'll allow 0 as a means of disabling mouse scrolling. - if (*direction == -1) { - return e_invarg; - } - - if (!end) { - break; - } - - string = end + 1; - } - - // If a direction wasn't set, fallback to the default value. - p_mousescroll_vert = (vertical == -1) ? MOUSESCROLL_VERT_DFLT : vertical; - p_mousescroll_hor = (horizontal == -1) ? MOUSESCROLL_HOR_DFLT : horizontal; - - return NULL; -} - /// Handle setting 'signcolumn' for value 'val' /// /// @return OK when the value is valid, FAIL otherwise @@ -699,6 +630,81 @@ static bool check_illegal_path_names(char *val, uint32_t flags) && strpbrk(val, "*?[|;&<>\r\n") != NULL)); } +/// An option that accepts a list of flags is changed. +/// e.g. 'viewoptions', 'switchbuf', 'casemap', etc. +static const char *did_set_opt_flags(char *val, char **values, unsigned *flagp, bool list) +{ + if (opt_strings_flags(val, values, flagp, list) != OK) { + return e_invarg; + } + return NULL; +} + +/// An option that accepts a list of string values is changed. +/// e.g. 'nrformats', 'scrollopt', 'wildoptions', etc. +static const char *did_set_opt_strings(char *val, char **values, bool list) +{ + return did_set_opt_flags(val, values, NULL, list); +} + +/// An option which is a list of flags is set. Valid values are in "flags". +static const char *did_set_option_listflag(char *val, char *flags, char *errbuf, size_t errbuflen) +{ + for (char *s = val; *s; s++) { + if (vim_strchr(flags, (uint8_t)(*s)) == NULL) { + return illegal_char(errbuf, errbuflen, (uint8_t)(*s)); + } + } + + return NULL; +} + +/// The 'ambiwidth' option is changed. +const char *did_set_ambiwidth(optset_T *args FUNC_ATTR_UNUSED) +{ + if (check_opt_strings(p_ambw, p_ambw_values, false) != OK) { + return e_invarg; + } + return check_chars_options(); +} + +/// The 'background' option is changed. +const char *did_set_background(optset_T *args FUNC_ATTR_UNUSED) +{ + if (check_opt_strings(p_bg, p_bg_values, false) != OK) { + return e_invarg; + } + + int dark = (*p_bg == 'd'); + + init_highlight(false, false); + + if (dark != (*p_bg == 'd') && get_var_value("g:colors_name") != NULL) { + // The color scheme must have set 'background' back to another + // value, that's not what we want here. Disable the color + // scheme and set the colors again. + do_unlet(S_LEN("g:colors_name"), true); + free_string_option(p_bg); + p_bg = xstrdup((dark ? "dark" : "light")); + check_string_option(&p_bg); + init_highlight(false, false); + } + return NULL; +} + +/// The 'backspace' option is changed. +const char *did_set_backspace(optset_T *args FUNC_ATTR_UNUSED) +{ + if (ascii_isdigit(*p_bs)) { + if (*p_bs != '2') { + return e_invarg; + } + } else if (check_opt_strings(p_bs, p_bs_values, true) != OK) { + return e_invarg; + } + return NULL; +} + /// The 'backupcopy' option is changed. const char *did_set_backupcopy(optset_T *args) { @@ -750,12 +756,6 @@ const char *did_set_belloff(optset_T *args FUNC_ATTR_UNUSED) return did_set_opt_flags(p_bo, p_bo_values, &bo_flags, true); } -/// The 'termpastefilter' option is changed. -const char *did_set_termpastefilter(optset_T *args FUNC_ATTR_UNUSED) -{ - return did_set_opt_flags(p_tpf, p_tpf_values, &tpf_flags, true); -} - /// The 'breakindentopt' option is changed. const char *did_set_breakindentopt(optset_T *args) { @@ -771,160 +771,236 @@ const char *did_set_breakindentopt(optset_T *args) return NULL; } -/// The 'isident' or the 'iskeyword' or the 'isprint' or the 'isfname' option is -/// changed. -const char *did_set_isopt(optset_T *args) +/// The 'bufhidden' option is changed. +const char *did_set_bufhidden(optset_T *args) { buf_T *buf = (buf_T *)args->os_buf; - // 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[] - // If the new option is invalid, use old value. - // 'lisp' option: refill g_chartab[] for '-' char - if (buf_init_chartab(buf, true) == FAIL) { - args->os_restore_chartab = true; // need to restore it below - return e_invarg; // error in value - } - return NULL; + return did_set_opt_strings(buf->b_p_bh, p_bufhidden_values, false); } -/// The 'helpfile' option is changed. -const char *did_set_helpfile(optset_T *args FUNC_ATTR_UNUSED) +/// The 'buftype' option is changed. +const char *did_set_buftype(optset_T *args) { - // May compute new values for $VIM and $VIMRUNTIME - if (didset_vim) { - vim_unsetenv_ext("VIM"); + buf_T *buf = (buf_T *)args->os_buf; + win_T *win = (win_T *)args->os_win; + // When 'buftype' is set, check for valid value. + if ((buf->terminal && buf->b_p_bt[0] != 't') + || (!buf->terminal && buf->b_p_bt[0] == 't') + || check_opt_strings(buf->b_p_bt, p_buftype_values, false) != OK) { + return e_invarg; } - if (didset_vimruntime) { - vim_unsetenv_ext("VIMRUNTIME"); + if (win->w_status_height || global_stl_height()) { + win->w_redr_status = true; + redraw_later(win, UPD_VALID); } + buf->b_help = (buf->b_p_bt[0] == 'h'); + redraw_titles(); return NULL; } -/// The 'cursorlineopt' option is changed. -const char *did_set_cursorlineopt(optset_T *args) +/// The 'casemap' option is changed. +const char *did_set_casemap(optset_T *args FUNC_ATTR_UNUSED) { - win_T *win = (win_T *)args->os_win; - char **varp = (char **)args->os_varp; + return did_set_opt_flags(p_cmp, p_cmp_values, &cmp_flags, true); +} - if (**varp == NUL || fill_culopt_flags(*varp, win) != OK) { - return e_invarg; +/// The global 'listchars' or 'fillchars' option is changed. +static const char *did_set_global_listfillchars(win_T *win, char *val, bool opt_lcs, int opt_flags) +{ + const char *errmsg = NULL; + char **local_ptr = opt_lcs ? &win->w_p_lcs : &win->w_p_fcs; + + // only apply the global value to "win" when it does not have a + // local value + if (opt_lcs) { + errmsg = set_listchars_option(win, val, **local_ptr == NUL || !(opt_flags & OPT_GLOBAL)); + } else { + errmsg = set_fillchars_option(win, val, **local_ptr == NUL || !(opt_flags & OPT_GLOBAL)); + } + if (errmsg != NULL) { + return errmsg; } - return NULL; -} + // If the current window is set to use the global + // 'listchars'/'fillchars' value, clear the window-local value. + if (!(opt_flags & OPT_GLOBAL)) { + clear_string_option(local_ptr); + } -/// The 'helplang' option is changed. -const char *did_set_helplang(optset_T *args FUNC_ATTR_UNUSED) -{ - // Check for "", "ab", "ab,cd", etc. - for (char *s = p_hlg; *s != NUL; s += 3) { - if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL)) { - return e_invarg; - } - if (s[2] == NUL) { - break; + FOR_ALL_TAB_WINDOWS(tp, wp) { + // If the current window has a local value need to apply it + // again, it was changed when setting the global value. + // If no error was returned above, we don't expect an error + // here, so ignore the return value. + if (opt_lcs) { + if (*wp->w_p_lcs == NUL) { + (void)set_listchars_option(wp, wp->w_p_lcs, true); + } + } else { + if (*wp->w_p_fcs == NUL) { + (void)set_fillchars_option(wp, wp->w_p_fcs, true); + } } } + + redraw_all_later(UPD_NOT_VALID); + return NULL; } -/// The 'highlight' option is changed. -const char *did_set_highlight(optset_T *args) +/// The 'fillchars' option or the 'listchars' option is changed. +const char *did_set_chars_option(optset_T *args) { + win_T *win = (win_T *)args->os_win; char **varp = (char **)args->os_varp; + const char *errmsg = NULL; - if (strcmp(*varp, HIGHLIGHT_INIT) != 0) { - return e_unsupportedoption; + if (varp == &p_lcs // global 'listchars' + || varp == &p_fcs) { // global 'fillchars' + errmsg = did_set_global_listfillchars(win, *varp, varp == &p_lcs, args->os_flags); + } else if (varp == &win->w_p_lcs) { // local 'listchars' + errmsg = set_listchars_option(win, *varp, true); + } else if (varp == &win->w_p_fcs) { // local 'fillchars' + errmsg = set_fillchars_option(win, *varp, true); } - return NULL; + + return errmsg; } -static const char *did_set_opt_flags(char *val, char **values, unsigned *flagp, bool list) +/// The 'cinoptions' option is changed. +const char *did_set_cinoptions(optset_T *args FUNC_ATTR_UNUSED) { - if (opt_strings_flags(val, values, flagp, list) != OK) { - return e_invarg; - } + // TODO(vim): recognize errors + parse_cino(curbuf); + return NULL; } -static const char *did_set_opt_strings(char *val, char **values, bool list) +/// The 'clipboard' option is changed. +const char *did_set_clipboard(optset_T *args FUNC_ATTR_UNUSED) { - return did_set_opt_flags(val, values, NULL, list); + return did_set_opt_flags(p_cb, p_cb_values, &cb_flags, true); } -/// The 'selectmode' option is changed. -const char *did_set_selectmode(optset_T *args FUNC_ATTR_UNUSED) +/// The 'colorcolumn' option is changed. +const char *did_set_colorcolumn(optset_T *args) { - return did_set_opt_strings(p_slm, p_slm_values, true); + win_T *win = (win_T *)args->os_win; + return check_colorcolumn(win); } -/// The 'inccommand' option is changed. -const char *did_set_inccommand(optset_T *args FUNC_ATTR_UNUSED) +/// The 'comments' option is changed. +const char *did_set_comments(optset_T *args) { - return did_set_opt_strings(p_icm, p_icm_values, false); + char **varp = (char **)args->os_varp; + char *errmsg = NULL; + for (char *s = *varp; *s;) { + while (*s && *s != ':') { + if (vim_strchr(COM_ALL, (uint8_t)(*s)) == NULL + && !ascii_isdigit(*s) && *s != '-') { + errmsg = illegal_char(args->os_errbuf, args->os_errbuflen, (uint8_t)(*s)); + break; + } + s++; + } + if (*s++ == NUL) { + errmsg = N_("E524: Missing colon"); + } else if (*s == ',' || *s == NUL) { + errmsg = N_("E525: Zero length string"); + } + if (errmsg != NULL) { + break; + } + while (*s && *s != ',') { + if (*s == '\\' && s[1] != NUL) { + s++; + } + s++; + } + s = skip_to_option_part(s); + } + return errmsg; } -/// The 'sessionoptions' option is changed. -const char *did_set_sessionoptions(optset_T *args) +/// The 'commentstring' option is changed. +const char *did_set_commentstring(optset_T *args) { - if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, true) != OK) { - return e_invarg; - } - if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR)) { - // Don't allow both "sesdir" and "curdir". - const char *oldval = args->os_oldval.string; - (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, true); - return e_invarg; + char **varp = (char **)args->os_varp; + + if (**varp != NUL && strstr(*varp, "%s") == NULL) { + return N_("E537: 'commentstring' must be empty or contain %s"); } return NULL; } -/// The 'ambiwidth' option is changed. -const char *did_set_ambiwidth(optset_T *args FUNC_ATTR_UNUSED) +/// The 'complete' option is changed. +const char *did_set_complete(optset_T *args) { - if (check_opt_strings(p_ambw, p_ambw_values, false) != OK) { - return e_invarg; + char **varp = (char **)args->os_varp; + + // check if it is a valid value for 'complete' -- Acevedo + for (char *s = *varp; *s;) { + while (*s == ',' || *s == ' ') { + s++; + } + if (!*s) { + break; + } + if (vim_strchr(".wbuksid]tU", (uint8_t)(*s)) == NULL) { + return illegal_char(args->os_errbuf, args->os_errbuflen, (uint8_t)(*s)); + } + if (*++s != NUL && *s != ',' && *s != ' ') { + if (s[-1] == 'k' || s[-1] == 's') { + // skip optional filename after 'k' and 's' + while (*s && *s != ',' && *s != ' ') { + if (*s == '\\' && s[1] != NUL) { + s++; + } + s++; + } + } else { + if (args->os_errbuf != NULL) { + vim_snprintf(args->os_errbuf, args->os_errbuflen, + _("E535: Illegal character after <%c>"), + *--s); + return args->os_errbuf; + } + return ""; + } + } } - return check_chars_options(); + return NULL; } -/// The 'background' option is changed. -const char *did_set_background(optset_T *args FUNC_ATTR_UNUSED) +/// The 'completeopt' option is changed. +const char *did_set_completeopt(optset_T *args FUNC_ATTR_UNUSED) { - if (check_opt_strings(p_bg, p_bg_values, false) != OK) { + if (check_opt_strings(p_cot, p_cot_values, true) != OK) { return e_invarg; } - - int dark = (*p_bg == 'd'); - - init_highlight(false, false); - - if (dark != (*p_bg == 'd') && get_var_value("g:colors_name") != NULL) { - // The color scheme must have set 'background' back to another - // value, that's not what we want here. Disable the color - // scheme and set the colors again. - do_unlet(S_LEN("g:colors_name"), true); - free_string_option(p_bg); - p_bg = xstrdup((dark ? "dark" : "light")); - check_string_option(&p_bg); - init_highlight(false, false); - } + completeopt_was_set(); return NULL; } -/// The 'whichwrap' option is changed. -const char *did_set_whichwrap(optset_T *args) +#ifdef BACKSLASH_IN_FILENAME +/// The 'completeslash' option is changed. +const char *did_set_completeslash(optset_T *args) { - char **varp = (char **)args->os_varp; - - return did_set_option_listflag(*varp, WW_ALL, args->os_errbuf, args->os_errbuflen); + buf_T *buf = (buf_T *)args->os_buf; + if (check_opt_strings(p_csl, p_csl_values, false) != OK + || check_opt_strings(buf->b_p_csl, p_csl_values, false) != OK) { + return e_invarg; + } + return NULL; } +#endif -/// The 'shortmess' option is changed. -const char *did_set_shortmess(optset_T *args) +/// The 'concealcursor' option is changed. +const char *did_set_concealcursor(optset_T *args) { char **varp = (char **)args->os_varp; - return did_set_option_listflag(*varp, SHM_ALL, args->os_errbuf, args->os_errbuflen); + return did_set_option_listflag(*varp, COCU_ALL, args->os_errbuf, args->os_errbuflen); } /// The 'cpoptions' option is changed. @@ -935,66 +1011,42 @@ const char *did_set_cpoptions(optset_T *args) return did_set_option_listflag(*varp, CPO_VI, args->os_errbuf, args->os_errbuflen); } -/// The 'clipboard' option is changed. -const char *did_set_clipboard(optset_T *args FUNC_ATTR_UNUSED) -{ - return did_set_opt_flags(p_cb, p_cb_values, &cb_flags, true); -} - -/// The 'foldopen' option is changed. -const char *did_set_foldopen(optset_T *args FUNC_ATTR_UNUSED) -{ - return did_set_opt_flags(p_fdo, p_fdo_values, &fdo_flags, true); -} - -/// The 'formatoptions' option is changed. -const char *did_set_formatoptions(optset_T *args) -{ - char **varp = (char **)args->os_varp; - - return did_set_option_listflag(*varp, FO_ALL, args->os_errbuf, args->os_errbuflen); -} - -/// The 'concealcursor' option is changed. -const char *did_set_concealcursor(optset_T *args) +/// The 'cursorlineopt' option is changed. +const char *did_set_cursorlineopt(optset_T *args) { + win_T *win = (win_T *)args->os_win; char **varp = (char **)args->os_varp; - return did_set_option_listflag(*varp, COCU_ALL, args->os_errbuf, args->os_errbuflen); -} - -/// The 'mouse' option is changed. -const char *did_set_mouse(optset_T *args) -{ - char **varp = (char **)args->os_varp; + if (**varp == NUL || fill_culopt_flags(*varp, win) != OK) { + return e_invarg; + } - return did_set_option_listflag(*varp, MOUSE_ALL, args->os_errbuf, args->os_errbuflen); + return NULL; } -/// The 'wildmode' option is changed. -const char *did_set_wildmode(optset_T *args FUNC_ATTR_UNUSED) +/// The 'debug' option is changed. +const char *did_set_debug(optset_T *args FUNC_ATTR_UNUSED) { - if (check_opt_wim() == FAIL) { - return e_invarg; - } - return NULL; + return did_set_opt_strings(p_debug, p_debug_values, false); } -/// The 'winaltkeys' option is changed. -const char *did_set_winaltkeys(optset_T *args FUNC_ATTR_UNUSED) +/// The 'diffopt' option is changed. +const char *did_set_diffopt(optset_T *args FUNC_ATTR_UNUSED) { - if (*p_wak == NUL || check_opt_strings(p_wak, p_wak_values, false) != OK) { + if (diffopt_changed() == FAIL) { return e_invarg; } return NULL; } -/// The 'eventignore' option is changed. -const char *did_set_eventignore(optset_T *args FUNC_ATTR_UNUSED) +/// The 'display' option is changed. +const char *did_set_display(optset_T *args FUNC_ATTR_UNUSED) { - if (check_ei() == FAIL) { + if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, true) != OK) { return e_invarg; } + (void)init_chartab(); + msg_grid_validate(); return NULL; } @@ -1046,6 +1098,229 @@ const char *did_set_encoding(optset_T *args) return NULL; } +/// The 'eventignore' option is changed. +const char *did_set_eventignore(optset_T *args FUNC_ATTR_UNUSED) +{ + if (check_ei() == FAIL) { + return e_invarg; + } + return NULL; +} + +/// The 'fileformat' option is changed. +const char *did_set_fileformat(optset_T *args) +{ + buf_T *buf = (buf_T *)args->os_buf; + char **varp = (char **)args->os_varp; + const char *oldval = args->os_oldval.string; + int opt_flags = args->os_flags; + if (!MODIFIABLE(buf) && !(opt_flags & OPT_GLOBAL)) { + return e_modifiable; + } else if (check_opt_strings(*varp, p_ff_values, false) != OK) { + return e_invarg; + } + redraw_titles(); + // update flag in swap file + ml_setflags(buf); + // Redraw needed when switching to/from "mac": a CR in the text + // will be displayed differently. + if (get_fileformat(buf) == EOL_MAC || *oldval == 'm') { + redraw_buf_later(buf, UPD_NOT_VALID); + } + return NULL; +} + +/// The 'fileformats' option is changed. +const char *did_set_fileformats(optset_T *args) +{ + return did_set_opt_strings(p_ffs, p_ff_values, true); +} + +/// The 'filetype' or the 'syntax' option is changed. +const char *did_set_filetype_or_syntax(optset_T *args) +{ + char **varp = (char **)args->os_varp; + + if (!valid_filetype(*varp)) { + return e_invarg; + } + + args->os_value_changed = strcmp(args->os_oldval.string, *varp) != 0; + + // Since we check the value, there is no need to set P_INSECURE, + // even when the value comes from a modeline. + args->os_value_checked = true; + + return NULL; +} + +/// The 'foldclose' option is changed. +const char *did_set_foldclose(optset_T *args FUNC_ATTR_UNUSED) +{ + return did_set_opt_strings(p_fcl, p_fcl_values, true); +} + +/// The 'foldcolumn' option is changed. +const char *did_set_foldcolumn(optset_T *args) +{ + char **varp = (char **)args->os_varp; + if (**varp == NUL || check_opt_strings(*varp, p_fdc_values, false) != OK) { + return e_invarg; + } + return NULL; +} + +/// The 'foldexpr' option is changed. +const char *did_set_foldexpr(optset_T *args) +{ + win_T *win = (win_T *)args->os_win; + (void)did_set_optexpr(args); + if (foldmethodIsExpr(win)) { + foldUpdateAll(win); + } + return NULL; +} + +/// The 'foldignore' option is changed. +const char *did_set_foldignore(optset_T *args) +{ + win_T *win = (win_T *)args->os_win; + if (foldmethodIsIndent(win)) { + foldUpdateAll(win); + } + return NULL; +} + +/// The 'foldmarker' option is changed. +const char *did_set_foldmarker(optset_T *args) +{ + win_T *win = (win_T *)args->os_win; + char **varp = (char **)args->os_varp; + char *p = vim_strchr(*varp, ','); + + if (p == NULL) { + return e_comma_required; + } + + if (p == *varp || p[1] == NUL) { + return e_invarg; + } + + if (foldmethodIsMarker(win)) { + foldUpdateAll(win); + } + + return NULL; +} + +/// The 'foldmethod' option is changed. +const char *did_set_foldmethod(optset_T *args) +{ + win_T *win = (win_T *)args->os_win; + char **varp = (char **)args->os_varp; + if (check_opt_strings(*varp, p_fdm_values, false) != OK + || *win->w_p_fdm == NUL) { + return e_invarg; + } + foldUpdateAll(win); + if (foldmethodIsDiff(win)) { + newFoldLevel(); + } + return NULL; +} + +/// The 'foldopen' option is changed. +const char *did_set_foldopen(optset_T *args FUNC_ATTR_UNUSED) +{ + return did_set_opt_flags(p_fdo, p_fdo_values, &fdo_flags, true); +} + +/// The 'formatoptions' option is changed. +const char *did_set_formatoptions(optset_T *args) +{ + char **varp = (char **)args->os_varp; + + return did_set_option_listflag(*varp, FO_ALL, args->os_errbuf, args->os_errbuflen); +} + +/// The 'guicursor' option is changed. +const char *did_set_guicursor(optset_T *args FUNC_ATTR_UNUSED) +{ + return parse_shape_opt(SHAPE_CURSOR); +} + +/// The 'helpfile' option is changed. +const char *did_set_helpfile(optset_T *args FUNC_ATTR_UNUSED) +{ + // May compute new values for $VIM and $VIMRUNTIME + if (didset_vim) { + vim_unsetenv_ext("VIM"); + } + if (didset_vimruntime) { + vim_unsetenv_ext("VIMRUNTIME"); + } + return NULL; +} + +/// The 'helplang' option is changed. +const char *did_set_helplang(optset_T *args FUNC_ATTR_UNUSED) +{ + // Check for "", "ab", "ab,cd", etc. + for (char *s = p_hlg; *s != NUL; s += 3) { + if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL)) { + return e_invarg; + } + if (s[2] == NUL) { + break; + } + } + return NULL; +} + +/// The 'highlight' option is changed. +const char *did_set_highlight(optset_T *args) +{ + char **varp = (char **)args->os_varp; + + if (strcmp(*varp, HIGHLIGHT_INIT) != 0) { + return e_unsupportedoption; + } + return NULL; +} + +/// The 'iconstring' option is changed. +const char *did_set_iconstring(optset_T *args) +{ + return did_set_titleiconstring(args, STL_IN_ICON); +} + +/// The 'inccommand' option is changed. +const char *did_set_inccommand(optset_T *args FUNC_ATTR_UNUSED) +{ + return did_set_opt_strings(p_icm, p_icm_values, false); +} + +/// The 'isident' or the 'iskeyword' or the 'isprint' or the 'isfname' option is +/// changed. +const char *did_set_isopt(optset_T *args) +{ + buf_T *buf = (buf_T *)args->os_buf; + // 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[] + // If the new option is invalid, use old value. + // 'lisp' option: refill g_chartab[] for '-' char + if (buf_init_chartab(buf, true) == FAIL) { + args->os_restore_chartab = true; // need to restore it below + return e_invarg; // error in value + } + return NULL; +} + +/// The 'jumpoptions' option is changed. +const char *did_set_jumpoptions(optset_T *args FUNC_ATTR_UNUSED) +{ + return did_set_opt_flags(p_jop, p_jop_values, &jop_flags, true); +} + /// The 'keymap' option has changed. const char *did_set_keymap(optset_T *args) { @@ -1098,33 +1373,26 @@ const char *did_set_keymap(optset_T *args) return errmsg; } -/// The 'fileformat' option is changed. -const char *did_set_fileformat(optset_T *args) +/// The 'keymodel' option is changed. +const char *did_set_keymodel(optset_T *args FUNC_ATTR_UNUSED) { - buf_T *buf = (buf_T *)args->os_buf; - char **varp = (char **)args->os_varp; - const char *oldval = args->os_oldval.string; - int opt_flags = args->os_flags; - if (!MODIFIABLE(buf) && !(opt_flags & OPT_GLOBAL)) { - return e_modifiable; - } else if (check_opt_strings(*varp, p_ff_values, false) != OK) { + if (check_opt_strings(p_km, p_km_values, true) != OK) { return e_invarg; } - redraw_titles(); - // update flag in swap file - ml_setflags(buf); - // Redraw needed when switching to/from "mac": a CR in the text - // will be displayed differently. - if (get_fileformat(buf) == EOL_MAC || *oldval == 'm') { - redraw_buf_later(buf, UPD_NOT_VALID); - } + km_stopsel = (vim_strchr(p_km, 'o') != NULL); + km_startsel = (vim_strchr(p_km, 'a') != NULL); return NULL; } -/// The 'fileformats' option is changed. -const char *did_set_fileformats(optset_T *args) +/// The 'lispoptions' option is changed. +const char *did_set_lispoptions(optset_T *args) { - return did_set_opt_strings(p_ffs, p_ff_values, true); + char **varp = (char **)args->os_varp; + + if (**varp != NUL && strcmp(*varp, "expr:0") != 0 && strcmp(*varp, "expr:1") != 0) { + return e_invarg; + } + return NULL; } /// The 'matchpairs' option is changed. @@ -1154,150 +1422,183 @@ const char *did_set_matchpairs(optset_T *args) return NULL; } -/// The 'cinoptions' option is changed. -const char *did_set_cinoptions(optset_T *args FUNC_ATTR_UNUSED) +/// The 'mkspellmem' option is changed. +const char *did_set_mkspellmem(optset_T *args FUNC_ATTR_UNUSED) { - // TODO(vim): recognize errors - parse_cino(curbuf); - + if (spell_check_msm() != OK) { + return e_invarg; + } return NULL; } -/// The 'colorcolumn' option is changed. -const char *did_set_colorcolumn(optset_T *args) +/// The 'mouse' option is changed. +const char *did_set_mouse(optset_T *args) { - win_T *win = (win_T *)args->os_win; - return check_colorcolumn(win); + char **varp = (char **)args->os_varp; + + return did_set_option_listflag(*varp, MOUSE_ALL, args->os_errbuf, args->os_errbuflen); } -const char *did_set_comments(optset_T *args) +/// The 'mousemodel' option is changed. +const char *did_set_mousemodel(optset_T *args FUNC_ATTR_UNUSED) { - char **varp = (char **)args->os_varp; - char *errmsg = NULL; - for (char *s = *varp; *s;) { - while (*s && *s != ':') { - if (vim_strchr(COM_ALL, (uint8_t)(*s)) == NULL - && !ascii_isdigit(*s) && *s != '-') { - errmsg = illegal_char(args->os_errbuf, args->os_errbuflen, (uint8_t)(*s)); - break; - } - s++; - } - if (*s++ == NUL) { - errmsg = N_("E524: Missing colon"); - } else if (*s == ',' || *s == NUL) { - errmsg = N_("E525: Zero length string"); - } - if (errmsg != NULL) { - break; - } - while (*s && *s != ',') { - if (*s == '\\' && s[1] != NUL) { - s++; - } - s++; - } - s = skip_to_option_part(s); - } - return errmsg; + return did_set_opt_strings(p_mousem, p_mousem_values, false); } -/// The global 'listchars' or 'fillchars' option is changed. -static const char *did_set_global_listfillchars(win_T *win, char *val, bool opt_lcs, int opt_flags) +/// Handle setting 'mousescroll'. +/// @return error message, NULL if it's OK. +const char *did_set_mousescroll(optset_T *args FUNC_ATTR_UNUSED) { - const char *errmsg = NULL; - char **local_ptr = opt_lcs ? &win->w_p_lcs : &win->w_p_fcs; + OptInt vertical = -1; + OptInt horizontal = -1; - // only apply the global value to "win" when it does not have a - // local value - if (opt_lcs) { - errmsg = set_listchars_option(win, val, **local_ptr == NUL || !(opt_flags & OPT_GLOBAL)); - } else { - errmsg = set_fillchars_option(win, val, **local_ptr == NUL || !(opt_flags & OPT_GLOBAL)); - } - if (errmsg != NULL) { - return errmsg; - } + char *string = p_mousescroll; - // If the current window is set to use the global - // 'listchars'/'fillchars' value, clear the window-local value. - if (!(opt_flags & OPT_GLOBAL)) { - clear_string_option(local_ptr); - } + while (true) { + char *end = vim_strchr(string, ','); + size_t length = end ? (size_t)(end - string) : strlen(string); - FOR_ALL_TAB_WINDOWS(tp, wp) { - // If the current window has a local value need to apply it - // again, it was changed when setting the global value. - // If no error was returned above, we don't expect an error - // here, so ignore the return value. - if (opt_lcs) { - if (*wp->w_p_lcs == NUL) { - (void)set_listchars_option(wp, wp->w_p_lcs, true); - } + // Both "ver:" and "hor:" are 4 bytes long. + // They should be followed by at least one digit. + if (length <= 4) { + return e_invarg; + } + + OptInt *direction; + + if (memcmp(string, "ver:", 4) == 0) { + direction = &vertical; + } else if (memcmp(string, "hor:", 4) == 0) { + direction = &horizontal; } else { - if (*wp->w_p_fcs == NUL) { - (void)set_fillchars_option(wp, wp->w_p_fcs, true); + return e_invarg; + } + + // If the direction has already been set, this is a duplicate. + if (*direction != -1) { + return e_invarg; + } + + // Verify that only digits follow the colon. + for (size_t i = 4; i < length; i++) { + if (!ascii_isdigit(string[i])) { + return N_("E5080: Digit expected"); } } + + string += 4; + *direction = getdigits_int(&string, false, -1); + + // Num options are generally kept within the signed int range. + // We know this number won't be negative because we've already checked for + // a minus sign. We'll allow 0 as a means of disabling mouse scrolling. + if (*direction == -1) { + return e_invarg; + } + + if (!end) { + break; + } + + string = end + 1; } - redraw_all_later(UPD_NOT_VALID); + // If a direction wasn't set, fallback to the default value. + p_mousescroll_vert = (vertical == -1) ? MOUSESCROLL_VERT_DFLT : vertical; + p_mousescroll_hor = (horizontal == -1) ? MOUSESCROLL_HOR_DFLT : horizontal; return NULL; } -/// Handle the new value of 'fillchars'. -const char *set_fillchars_option(win_T *wp, char *val, int apply) +/// The 'nrformats' option is changed. +const char *did_set_nrformats(optset_T *args) { - return set_chars_option(wp, val, false, apply); + char **varp = (char **)args->os_varp; + + return did_set_opt_strings(*varp, p_nf_values, true); } -/// Handle the new value of 'listchars'. -const char *set_listchars_option(win_T *wp, char *val, int apply) +/// One of the '*expr' options is changed:, 'diffexpr', 'foldexpr', 'foldtext', +/// 'formatexpr', 'includeexpr', 'indentexpr', 'patchexpr' and 'charconvert'. +const char *did_set_optexpr(optset_T *args) { - return set_chars_option(wp, val, true, apply); + char **varp = (char **)args->os_varp; + + // If the option value starts with <SID> or s:, then replace that with + // the script identifier. + char *name = get_scriptlocal_funcname(*varp); + if (name != NULL) { + free_string_option(*varp); + *varp = name; + } + return NULL; } -/// The 'fillchars' option or the 'listchars' option is changed. -const char *did_set_chars_option(optset_T *args) +/// The 'redrawdebug' option is changed. +const char *did_set_redrawdebug(optset_T *args FUNC_ATTR_UNUSED) +{ + return did_set_opt_flags(p_rdb, p_rdb_values, &rdb_flags, true); +} + +/// The 'rightleftcmd' option is changed. +const char *did_set_rightleftcmd(optset_T *args) { - win_T *win = (win_T *)args->os_win; char **varp = (char **)args->os_varp; - const char *errmsg = NULL; - if (varp == &p_lcs // global 'listchars' - || varp == &p_fcs) { // global 'fillchars' - errmsg = did_set_global_listfillchars(win, *varp, varp == &p_lcs, args->os_flags); - } else if (varp == &win->w_p_lcs) { // local 'listchars' - errmsg = set_listchars_option(win, *varp, true); - } else if (varp == &win->w_p_fcs) { // local 'fillchars' - errmsg = set_fillchars_option(win, *varp, true); + // Currently only "search" is a supported value. + if (**varp != NUL && strcmp(*varp, "search") != 0) { + return e_invarg; } - return errmsg; + return NULL; } -/// The 'verbosefile' option is changed. -const char *did_set_verbosefile(optset_T *args) +/// The 'rulerformat' option is changed. +const char *did_set_rulerformat(optset_T *args) { - verbose_stop(); - if (*p_vfile != NUL && verbose_open() == FAIL) { - return (char *)e_invarg; + return did_set_statustabline_rulerformat(args, true, false); +} + +/// The 'scrollopt' option is changed. +const char *did_set_scrollopt(optset_T *args FUNC_ATTR_UNUSED) +{ + return did_set_opt_strings(p_sbo, p_scbopt_values, true); +} + +/// The 'selection' option is changed. +const char *did_set_selection(optset_T *args FUNC_ATTR_UNUSED) +{ + if (*p_sel == NUL || check_opt_strings(p_sel, p_sel_values, false) != OK) { + return e_invarg; } return NULL; } -/// The 'viewoptions' option is changed. -const char *did_set_viewoptions(optset_T *args FUNC_ATTR_UNUSED) +/// The 'selectmode' option is changed. +const char *did_set_selectmode(optset_T *args FUNC_ATTR_UNUSED) { - return did_set_opt_flags(p_vop, p_ssop_values, &vop_flags, true); + return did_set_opt_strings(p_slm, p_slm_values, true); } -static int shada_idx = -1; +/// The 'sessionoptions' option is changed. +const char *did_set_sessionoptions(optset_T *args) +{ + if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, true) != OK) { + return e_invarg; + } + if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR)) { + // Don't allow both "sesdir" and "curdir". + const char *oldval = args->os_oldval.string; + (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, true); + return e_invarg; + } + return NULL; +} static const char *did_set_shada(vimoption_T **opt, int *opt_idx, bool *free_oldval, char *errbuf, size_t errbuflen) { + static int shada_idx = -1; // TODO(ZyX-I): Remove this code in the future, alongside with &viminfo // option. *opt_idx = (((*opt)->fullname[0] == 'v') @@ -1352,6 +1653,14 @@ static const char *did_set_shada(vimoption_T **opt, int *opt_idx, bool *free_old return NULL; } +/// The 'shortmess' option is changed. +const char *did_set_shortmess(optset_T *args) +{ + char **varp = (char **)args->os_varp; + + return did_set_option_listflag(*varp, SHM_ALL, args->os_errbuf, args->os_errbuflen); +} + /// The 'showbreak' option is changed. const char *did_set_showbreak(optset_T *args) { @@ -1366,63 +1675,37 @@ const char *did_set_showbreak(optset_T *args) return NULL; } -/// The 'titlestring' or the 'iconstring' option is changed. -static const char *did_set_titleiconstring(optset_T *args, int flagval) -{ - char **varp = (char **)args->os_varp; - - // NULL => statusline syntax - if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL) { - stl_syntax |= flagval; - } else { - stl_syntax &= ~flagval; - } - did_set_title(); - - return NULL; -} - -/// The 'titlestring' option is changed. -const char *did_set_titlestring(optset_T *args) -{ - return did_set_titleiconstring(args, STL_IN_TITLE); -} - -/// The 'iconstring' option is changed. -const char *did_set_iconstring(optset_T *args) +/// The 'showcmdloc' option is changed. +const char *did_set_showcmdloc(optset_T *args FUNC_ATTR_UNUSED) { - return did_set_titleiconstring(args, STL_IN_ICON); + return did_set_opt_strings(p_sloc, p_sloc_values, true); } -/// The 'selection' option is changed. -const char *did_set_selection(optset_T *args FUNC_ATTR_UNUSED) +/// The 'signcolumn' option is changed. +const char *did_set_signcolumn(optset_T *args) { - if (*p_sel == NUL || check_opt_strings(p_sel, p_sel_values, false) != OK) { + win_T *win = (win_T *)args->os_win; + char **varp = (char **)args->os_varp; + const char *oldval = args->os_oldval.string; + if (check_signcolumn(*varp) != OK) { return e_invarg; } - return NULL; -} - -/// The 'keymodel' option is changed. -const char *did_set_keymodel(optset_T *args FUNC_ATTR_UNUSED) -{ - if (check_opt_strings(p_km, p_km_values, true) != OK) { - return e_invarg; + // When changing the 'signcolumn' to or from 'number', recompute the + // width of the number column if 'number' or 'relativenumber' is set. + if (((*oldval == 'n' && *(oldval + 1) == 'u') + || (*win->w_p_scl == 'n' && *(win->w_p_scl + 1) == 'u')) + && (win->w_p_nu || win->w_p_rnu)) { + win->w_nrwidth_line_count = 0; } - km_stopsel = (vim_strchr(p_km, 'o') != NULL); - km_startsel = (vim_strchr(p_km, 'a') != NULL); return NULL; } -/// The 'display' option is changed. -const char *did_set_display(optset_T *args FUNC_ATTR_UNUSED) +/// The 'spellcapcheck' option is changed. +const char *did_set_spellcapcheck(optset_T *args) { - if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, true) != OK) { - return e_invarg; - } - (void)init_chartab(); - msg_grid_validate(); - return NULL; + win_T *win = (win_T *)args->os_win; + // When 'spellcapcheck' is set compile the regexp program. + return compile_cap_prog(win->w_s); } /// The 'spellfile' option is changed. @@ -1438,6 +1721,7 @@ const char *did_set_spellfile(optset_T *args) return did_set_spell_option(true); } +/// The 'spelllang' option is changed. const char *did_set_spelllang(optset_T *args) { char **varp = (char **)args->os_varp; @@ -1450,14 +1734,6 @@ const char *did_set_spelllang(optset_T *args) return did_set_spell_option(false); } -/// The 'spellcapcheck' option is changed. -const char *did_set_spellcapcheck(optset_T *args) -{ - win_T *win = (win_T *)args->os_win; - // When 'spellcapcheck' is set compile the regexp program. - return compile_cap_prog(win->w_s); -} - /// The 'spelloptions' option is changed. const char *did_set_spelloptions(optset_T *args) { @@ -1484,52 +1760,16 @@ const char *did_set_splitkeep(optset_T *args FUNC_ATTR_UNUSED) return did_set_opt_strings(p_spk, p_spk_values, false); } -/// The 'mkspellmem' option is changed. -const char *did_set_mkspellmem(optset_T *args FUNC_ATTR_UNUSED) -{ - if (spell_check_msm() != OK) { - return e_invarg; - } - return NULL; -} - -/// The 'mousemodel' option is changed. -const char *did_set_mousemodel(optset_T *args FUNC_ATTR_UNUSED) -{ - return did_set_opt_strings(p_mousem, p_mousem_values, false); -} - -/// The 'bufhidden' option is changed. -const char *did_set_bufhidden(optset_T *args) -{ - buf_T *buf = (buf_T *)args->os_buf; - return did_set_opt_strings(buf->b_p_bh, p_bufhidden_values, false); -} - -/// The 'buftype' option is changed. -const char *did_set_buftype(optset_T *args) +/// The 'statuscolumn' option is changed. +const char *did_set_statuscolumn(optset_T *args) { - buf_T *buf = (buf_T *)args->os_buf; - win_T *win = (win_T *)args->os_win; - // When 'buftype' is set, check for valid value. - if ((buf->terminal && buf->b_p_bt[0] != 't') - || (!buf->terminal && buf->b_p_bt[0] == 't') - || check_opt_strings(buf->b_p_bt, p_buftype_values, false) != OK) { - return e_invarg; - } - if (win->w_status_height || global_stl_height()) { - win->w_redr_status = true; - redraw_later(win, UPD_VALID); - } - buf->b_help = (buf->b_p_bt[0] == 'h'); - redraw_titles(); - return NULL; + return did_set_statustabline_rulerformat(args, false, true); } -/// The 'casemap' option is changed. -const char *did_set_casemap(optset_T *args FUNC_ATTR_UNUSED) +/// The 'statusline' option is changed. +const char *did_set_statusline(optset_T *args) { - return did_set_opt_flags(p_cmp, p_cmp_values, &cmp_flags, true); + return did_set_statustabline_rulerformat(args, false, false); } /// The 'statusline', 'winbar', 'tabline', 'rulerformat' or 'statuscolumn' option is changed. @@ -1571,10 +1811,10 @@ static const char *did_set_statustabline_rulerformat(optset_T *args, bool rulerf return errmsg; } -/// The 'statusline' option is changed. -const char *did_set_statusline(optset_T *args) +/// The 'switchbuf' option is changed. +const char *did_set_switchbuf(optset_T *args FUNC_ATTR_UNUSED) { - return did_set_statustabline_rulerformat(args, false, false); + return did_set_opt_flags(p_swb, p_swb_values, &swb_flags, true); } /// The 'tabline' option is changed. @@ -1583,146 +1823,6 @@ const char *did_set_tabline(optset_T *args) return did_set_statustabline_rulerformat(args, false, false); } -/// The 'rulerformat' option is changed. -const char *did_set_rulerformat(optset_T *args) -{ - return did_set_statustabline_rulerformat(args, true, false); -} - -/// The 'winbar' option is changed. -const char *did_set_winbar(optset_T *args) -{ - return did_set_statustabline_rulerformat(args, false, false); -} - -/// The 'statuscolumn' option is changed. -const char *did_set_statuscolumn(optset_T *args) -{ - return did_set_statustabline_rulerformat(args, false, true); -} - -/// The 'scrollopt' option is changed. -const char *did_set_scrollopt(optset_T *args FUNC_ATTR_UNUSED) -{ - return did_set_opt_strings(p_sbo, p_scbopt_values, true); -} - -/// The 'complete' option is changed. -const char *did_set_complete(optset_T *args) -{ - char **varp = (char **)args->os_varp; - - // check if it is a valid value for 'complete' -- Acevedo - for (char *s = *varp; *s;) { - while (*s == ',' || *s == ' ') { - s++; - } - if (!*s) { - break; - } - if (vim_strchr(".wbuksid]tU", (uint8_t)(*s)) == NULL) { - return illegal_char(args->os_errbuf, args->os_errbuflen, (uint8_t)(*s)); - } - if (*++s != NUL && *s != ',' && *s != ' ') { - if (s[-1] == 'k' || s[-1] == 's') { - // skip optional filename after 'k' and 's' - while (*s && *s != ',' && *s != ' ') { - if (*s == '\\' && s[1] != NUL) { - s++; - } - s++; - } - } else { - if (args->os_errbuf != NULL) { - vim_snprintf(args->os_errbuf, args->os_errbuflen, - _("E535: Illegal character after <%c>"), - *--s); - return args->os_errbuf; - } - return ""; - } - } - } - return NULL; -} - -/// The 'completeopt' option is changed. -const char *did_set_completeopt(optset_T *args FUNC_ATTR_UNUSED) -{ - if (check_opt_strings(p_cot, p_cot_values, true) != OK) { - return e_invarg; - } - completeopt_was_set(); - return NULL; -} - -#ifdef BACKSLASH_IN_FILENAME -/// The 'completeslash' option is changed. -const char *did_set_completeslash(optset_T *args) -{ - buf_T *buf = (buf_T *)args->os_buf; - if (check_opt_strings(p_csl, p_csl_values, false) != OK - || check_opt_strings(buf->b_p_csl, p_csl_values, false) != OK) { - return e_invarg; - } - return NULL; -} -#endif - -/// The 'showcmdloc' option is changed. -const char *did_set_showcmdloc(optset_T *args FUNC_ATTR_UNUSED) -{ - return did_set_opt_strings(p_sloc, p_sloc_values, true); -} - -/// The 'signcolumn' option is changed. -const char *did_set_signcolumn(optset_T *args) -{ - win_T *win = (win_T *)args->os_win; - char **varp = (char **)args->os_varp; - const char *oldval = args->os_oldval.string; - if (check_signcolumn(*varp) != OK) { - return e_invarg; - } - // When changing the 'signcolumn' to or from 'number', recompute the - // width of the number column if 'number' or 'relativenumber' is set. - if (((*oldval == 'n' && *(oldval + 1) == 'u') - || (*win->w_p_scl == 'n' && *(win->w_p_scl + 1) == 'u')) - && (win->w_p_nu || win->w_p_rnu)) { - win->w_nrwidth_line_count = 0; - } - return NULL; -} - -/// The 'foldcolumn' option is changed. -const char *did_set_foldcolumn(optset_T *args) -{ - char **varp = (char **)args->os_varp; - if (**varp == NUL || check_opt_strings(*varp, p_fdc_values, false) != OK) { - return e_invarg; - } - return NULL; -} - -/// The 'backspace' option is changed. -const char *did_set_backspace(optset_T *args FUNC_ATTR_UNUSED) -{ - if (ascii_isdigit(*p_bs)) { - if (*p_bs != '2') { - return e_invarg; - } - } else if (check_opt_strings(p_bs, p_bs_values, true) != OK) { - return e_invarg; - } - return NULL; -} - -/// The 'switchbuf' option is changed. -const char *did_set_switchbuf(optset_T *args FUNC_ATTR_UNUSED) -{ - return did_set_opt_flags(p_swb, p_swb_values, &swb_flags, true); -} - /// The 'tagcase' option is changed. const char *did_set_tagcase(optset_T *args) { @@ -1750,177 +1850,32 @@ const char *did_set_tagcase(optset_T *args) return NULL; } -/// The 'debug' option is changed. -const char *did_set_debug(optset_T *args FUNC_ATTR_UNUSED) -{ - return did_set_opt_strings(p_debug, p_debug_values, false); -} - -/// The 'diffopt' option is changed. -const char *did_set_diffopt(optset_T *args FUNC_ATTR_UNUSED) -{ - if (diffopt_changed() == FAIL) { - return e_invarg; - } - return NULL; -} - -/// The 'foldmethod' option is changed. -const char *did_set_foldmethod(optset_T *args) -{ - win_T *win = (win_T *)args->os_win; - char **varp = (char **)args->os_varp; - if (check_opt_strings(*varp, p_fdm_values, false) != OK - || *win->w_p_fdm == NUL) { - return e_invarg; - } - foldUpdateAll(win); - if (foldmethodIsDiff(win)) { - newFoldLevel(); - } - return NULL; -} - -/// The 'foldmarker' option is changed. -const char *did_set_foldmarker(optset_T *args) +/// The 'termpastefilter' option is changed. +const char *did_set_termpastefilter(optset_T *args FUNC_ATTR_UNUSED) { - win_T *win = (win_T *)args->os_win; - char **varp = (char **)args->os_varp; - char *p = vim_strchr(*varp, ','); - - if (p == NULL) { - return e_comma_required; - } - - if (p == *varp || p[1] == NUL) { - return e_invarg; - } - - if (foldmethodIsMarker(win)) { - foldUpdateAll(win); - } - - return NULL; + return did_set_opt_flags(p_tpf, p_tpf_values, &tpf_flags, true); } -/// The 'commentstring' option is changed. -const char *did_set_commentstring(optset_T *args) +/// The 'titlestring' or the 'iconstring' option is changed. +static const char *did_set_titleiconstring(optset_T *args, int flagval) { char **varp = (char **)args->os_varp; - if (**varp != NUL && strstr(*varp, "%s") == NULL) { - return N_("E537: 'commentstring' must be empty or contain %s"); - } - return NULL; -} - -/// The 'foldignore' option is changed. -const char *did_set_foldignore(optset_T *args) -{ - win_T *win = (win_T *)args->os_win; - if (foldmethodIsIndent(win)) { - foldUpdateAll(win); - } - return NULL; -} - -/// The 'virtualedit' option is changed. -const char *did_set_virtualedit(optset_T *args) -{ - win_T *win = (win_T *)args->os_win; - - char *ve = p_ve; - unsigned *flags = &ve_flags; - - if (args->os_flags & OPT_LOCAL) { - ve = win->w_p_ve; - flags = &win->w_ve_flags; - } - - if ((args->os_flags & OPT_LOCAL) && *ve == NUL) { - // make the local value empty: use the global value - *flags = 0; + // NULL => statusline syntax + if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL) { + stl_syntax |= flagval; } else { - if (opt_strings_flags(ve, p_ve_values, flags, true) != OK) { - return e_invarg; - } else if (strcmp(ve, args->os_oldval.string) != 0) { - // Recompute cursor position in case the new 've' setting - // changes something. - validate_virtcol_win(win); - // XXX: this only works when win == curwin - coladvance(win->w_virtcol); - } - } - return NULL; -} - -/// The 'jumpoptions' option is changed. -const char *did_set_jumpoptions(optset_T *args FUNC_ATTR_UNUSED) -{ - return did_set_opt_flags(p_jop, p_jop_values, &jop_flags, true); -} - -/// The 'redrawdebug' option is changed. -const char *did_set_redrawdebug(optset_T *args FUNC_ATTR_UNUSED) -{ - return did_set_opt_flags(p_rdb, p_rdb_values, &rdb_flags, true); -} - -/// The 'wildoptions' option is changed. -const char *did_set_wildoptions(optset_T *args FUNC_ATTR_UNUSED) -{ - return did_set_opt_flags(p_wop, p_wop_values, &wop_flags, true); -} - -/// The 'lispoptions' option is changed. -const char *did_set_lispoptions(optset_T *args) -{ - char **varp = (char **)args->os_varp; - - if (**varp != NUL && strcmp(*varp, "expr:0") != 0 && strcmp(*varp, "expr:1") != 0) { - return e_invarg; - } - return NULL; -} - -/// The 'rightleftcmd' option is changed. -const char *did_set_rightleftcmd(optset_T *args) -{ - char **varp = (char **)args->os_varp; - - // Currently only "search" is a supported value. - if (**varp != NUL && strcmp(*varp, "search") != 0) { - return e_invarg; - } - - return NULL; -} - -/// The 'filetype' or the 'syntax' option is changed. -const char *did_set_filetype_or_syntax(optset_T *args) -{ - char **varp = (char **)args->os_varp; - - if (!valid_filetype(*varp)) { - return e_invarg; + stl_syntax &= ~flagval; } - - args->os_value_changed = strcmp(args->os_oldval.string, *varp) != 0; - - // Since we check the value, there is no need to set P_INSECURE, - // even when the value comes from a modeline. - args->os_value_checked = true; + did_set_title(); return NULL; } -const char *did_set_winhl(optset_T *args) +/// The 'titlestring' option is changed. +const char *did_set_titlestring(optset_T *args) { - win_T *win = (win_T *)args->os_win; - if (!parse_winhl_opt(win)) { - return e_invarg; - } - return NULL; + return did_set_titleiconstring(args, STL_IN_TITLE); } /// The 'varsofttabstop' option is changed. @@ -1944,7 +1899,7 @@ const char *did_set_varsofttabstop(optset_T *args) return e_invarg; } - long *oldarray = buf->b_p_vsts_array; + colnr_T *oldarray = buf->b_p_vsts_array; if (tabstop_set(*varp, &(buf->b_p_vsts_array))) { xfree(oldarray); } else { @@ -1975,7 +1930,7 @@ const char *did_set_vartabstop(optset_T *args) return e_invarg; } - long *oldarray = buf->b_p_vts_array; + colnr_T *oldarray = buf->b_p_vts_array; if (tabstop_set(*varp, &(buf->b_p_vts_array))) { xfree(oldarray); if (foldmethodIsIndent(win)) { @@ -1987,62 +1942,97 @@ const char *did_set_vartabstop(optset_T *args) return NULL; } -/// The 'nrformats' option is changed. -const char *did_set_nrformats(optset_T *args) +/// The 'verbosefile' option is changed. +const char *did_set_verbosefile(optset_T *args) { - char **varp = (char **)args->os_varp; + verbose_stop(); + if (*p_vfile != NUL && verbose_open() == FAIL) { + return (char *)e_invarg; + } + return NULL; +} - return did_set_opt_strings(*varp, p_nf_values, true); +/// The 'viewoptions' option is changed. +const char *did_set_viewoptions(optset_T *args FUNC_ATTR_UNUSED) +{ + return did_set_opt_flags(p_vop, p_ssop_values, &vop_flags, true); } -/// One of the '*expr' options is changed:, 'diffexpr', 'foldexpr', 'foldtext', -/// 'formatexpr', 'includeexpr', 'indentexpr', 'patchexpr' and 'charconvert'. -const char *did_set_optexpr(optset_T *args) +/// The 'virtualedit' option is changed. +const char *did_set_virtualedit(optset_T *args) { - char **varp = (char **)args->os_varp; + win_T *win = (win_T *)args->os_win; - // If the option value starts with <SID> or s:, then replace that with - // the script identifier. - char *name = get_scriptlocal_funcname(*varp); - if (name != NULL) { - free_string_option(*varp); - *varp = name; + char *ve = p_ve; + unsigned *flags = &ve_flags; + + if (args->os_flags & OPT_LOCAL) { + ve = win->w_p_ve; + flags = &win->w_ve_flags; + } + + if ((args->os_flags & OPT_LOCAL) && *ve == NUL) { + // make the local value empty: use the global value + *flags = 0; + } else { + if (opt_strings_flags(ve, p_ve_values, flags, true) != OK) { + return e_invarg; + } else if (strcmp(ve, args->os_oldval.string) != 0) { + // Recompute cursor position in case the new 've' setting + // changes something. + validate_virtcol_win(win); + // XXX: this only works when win == curwin + coladvance(win->w_virtcol); + } } return NULL; } -/// The 'foldexpr' option is changed. -const char *did_set_foldexpr(optset_T *args) +/// The 'whichwrap' option is changed. +const char *did_set_whichwrap(optset_T *args) { - win_T *win = (win_T *)args->os_win; - (void)did_set_optexpr(args); - if (foldmethodIsExpr(win)) { - foldUpdateAll(win); + char **varp = (char **)args->os_varp; + + return did_set_option_listflag(*varp, WW_ALL, args->os_errbuf, args->os_errbuflen); +} + +/// The 'wildmode' option is changed. +const char *did_set_wildmode(optset_T *args FUNC_ATTR_UNUSED) +{ + if (check_opt_wim() == FAIL) { + return e_invarg; } return NULL; } -/// The 'foldclose' option is changed. -const char *did_set_foldclose(optset_T *args FUNC_ATTR_UNUSED) +/// The 'wildoptions' option is changed. +const char *did_set_wildoptions(optset_T *args FUNC_ATTR_UNUSED) { - return did_set_opt_strings(p_fcl, p_fcl_values, true); + return did_set_opt_flags(p_wop, p_wop_values, &wop_flags, true); } -/// An option which is a list of flags is set. Valid values are in 'flags'. -static const char *did_set_option_listflag(char *val, char *flags, char *errbuf, size_t errbuflen) +/// The 'winaltkeys' option is changed. +const char *did_set_winaltkeys(optset_T *args FUNC_ATTR_UNUSED) { - for (char *s = val; *s; s++) { - if (vim_strchr(flags, (uint8_t)(*s)) == NULL) { - return illegal_char(errbuf, errbuflen, (uint8_t)(*s)); - } + if (*p_wak == NUL || check_opt_strings(p_wak, p_wak_values, false) != OK) { + return e_invarg; } - return NULL; } -const char *did_set_guicursor(optset_T *args FUNC_ATTR_UNUSED) +/// The 'winbar' option is changed. +const char *did_set_winbar(optset_T *args) { - return parse_shape_opt(SHAPE_CURSOR); + return did_set_statustabline_rulerformat(args, false, false); +} + +const char *did_set_winhl(optset_T *args) +{ + win_T *win = (win_T *)args->os_win; + if (!parse_winhl_opt(win)) { + return e_invarg; + } + return NULL; } // When 'syntax' is set, load the syntax of that name @@ -2303,6 +2293,48 @@ static int get_encoded_char_adv(const char **p) return c; } +struct chars_tab { + int *cp; ///< char value + const char *name; ///< char id + int def; ///< default value + int fallback; ///< default value when "def" isn't single-width +}; + +static fcs_chars_T fcs_chars; +static const struct chars_tab fcs_tab[] = { + { &fcs_chars.stl, "stl", ' ', NUL }, + { &fcs_chars.stlnc, "stlnc", ' ', NUL }, + { &fcs_chars.wbr, "wbr", ' ', NUL }, + { &fcs_chars.horiz, "horiz", 0x2500, '-' }, // ─ + { &fcs_chars.horizup, "horizup", 0x2534, '-' }, // ┴ + { &fcs_chars.horizdown, "horizdown", 0x252c, '-' }, // ┬ + { &fcs_chars.vert, "vert", 0x2502, '|' }, // │ + { &fcs_chars.vertleft, "vertleft", 0x2524, '|' }, // ┤ + { &fcs_chars.vertright, "vertright", 0x251c, '|' }, // ├ + { &fcs_chars.verthoriz, "verthoriz", 0x253c, '+' }, // ┼ + { &fcs_chars.fold, "fold", 0x00b7, '-' }, // · + { &fcs_chars.foldopen, "foldopen", '-', NUL }, + { &fcs_chars.foldclosed, "foldclose", '+', NUL }, + { &fcs_chars.foldsep, "foldsep", 0x2502, '|' }, // │ + { &fcs_chars.diff, "diff", '-', NUL }, + { &fcs_chars.msgsep, "msgsep", ' ', NUL }, + { &fcs_chars.eob, "eob", '~', NUL }, + { &fcs_chars.lastline, "lastline", '@', NUL }, +}; + +static lcs_chars_T lcs_chars; +static const struct chars_tab lcs_tab[] = { + { &lcs_chars.eol, "eol", NUL, NUL }, + { &lcs_chars.ext, "extends", NUL, NUL }, + { &lcs_chars.nbsp, "nbsp", NUL, NUL }, + { &lcs_chars.prec, "precedes", NUL, NUL }, + { &lcs_chars.space, "space", NUL, NUL }, + { &lcs_chars.tab2, "tab", NUL, NUL }, + { &lcs_chars.lead, "lead", NUL, NUL }, + { &lcs_chars.trail, "trail", NUL, NUL }, + { &lcs_chars.conceal, "conceal", NUL, NUL }, +}; + /// Handle setting 'listchars' or 'fillchars'. /// Assume monocell characters /// @@ -2318,47 +2350,7 @@ static const char *set_chars_option(win_T *wp, const char *value, const bool is_ int multispace_len = 0; // Length of lcs-multispace string int lead_multispace_len = 0; // Length of lcs-leadmultispace string - struct chars_tab { - int *cp; ///< char value - char *name; ///< char id - int def; ///< default value - }; - - // XXX: Characters taking 2 columns is forbidden (TUI limitation?). Set old defaults in this case. - struct chars_tab fcs_tab[] = { - { &wp->w_p_fcs_chars.stl, "stl", ' ' }, - { &wp->w_p_fcs_chars.stlnc, "stlnc", ' ' }, - { &wp->w_p_fcs_chars.wbr, "wbr", ' ' }, - { &wp->w_p_fcs_chars.horiz, "horiz", char2cells(0x2500) == 1 ? 0x2500 : '-' }, // ─ - { &wp->w_p_fcs_chars.horizup, "horizup", char2cells(0x2534) == 1 ? 0x2534 : '-' }, // ┴ - { &wp->w_p_fcs_chars.horizdown, "horizdown", char2cells(0x252c) == 1 ? 0x252c : '-' }, // ┬ - { &wp->w_p_fcs_chars.vert, "vert", char2cells(0x2502) == 1 ? 0x2502 : '|' }, // │ - { &wp->w_p_fcs_chars.vertleft, "vertleft", char2cells(0x2524) == 1 ? 0x2524 : '|' }, // ┤ - { &wp->w_p_fcs_chars.vertright, "vertright", char2cells(0x251c) == 1 ? 0x251c : '|' }, // ├ - { &wp->w_p_fcs_chars.verthoriz, "verthoriz", char2cells(0x253c) == 1 ? 0x253c : '+' }, // ┼ - { &wp->w_p_fcs_chars.fold, "fold", char2cells(0x00b7) == 1 ? 0x00b7 : '-' }, // · - { &wp->w_p_fcs_chars.foldopen, "foldopen", '-' }, - { &wp->w_p_fcs_chars.foldclosed, "foldclose", '+' }, - { &wp->w_p_fcs_chars.foldsep, "foldsep", char2cells(0x2502) == 1 ? 0x2502 : '|' }, // │ - { &wp->w_p_fcs_chars.diff, "diff", '-' }, - { &wp->w_p_fcs_chars.msgsep, "msgsep", ' ' }, - { &wp->w_p_fcs_chars.eob, "eob", '~' }, - { &wp->w_p_fcs_chars.lastline, "lastline", '@' }, - }; - - struct chars_tab lcs_tab[] = { - { &wp->w_p_lcs_chars.eol, "eol", NUL }, - { &wp->w_p_lcs_chars.ext, "extends", NUL }, - { &wp->w_p_lcs_chars.nbsp, "nbsp", NUL }, - { &wp->w_p_lcs_chars.prec, "precedes", NUL }, - { &wp->w_p_lcs_chars.space, "space", NUL }, - { &wp->w_p_lcs_chars.tab2, "tab", NUL }, - { &wp->w_p_lcs_chars.lead, "lead", NUL }, - { &wp->w_p_lcs_chars.trail, "trail", NUL }, - { &wp->w_p_lcs_chars.conceal, "conceal", NUL }, - }; - - struct chars_tab *tab; + const struct chars_tab *tab; int entries; if (is_listchars) { tab = lcs_tab; @@ -2380,31 +2372,32 @@ static const char *set_chars_option(win_T *wp, const char *value, const bool is_ // After checking that the value is valid: set defaults for (int i = 0; i < entries; i++) { if (tab[i].cp != NULL) { - *(tab[i].cp) = tab[i].def; + // XXX: Characters taking 2 columns is forbidden (TUI limitation?). + // Set old defaults in this case. + *(tab[i].cp) = char2cells(tab[i].def) == 1 ? tab[i].def : tab[i].fallback; } } + if (is_listchars) { - wp->w_p_lcs_chars.tab1 = NUL; - wp->w_p_lcs_chars.tab3 = NUL; + lcs_chars.tab1 = NUL; + lcs_chars.tab3 = NUL; - xfree(wp->w_p_lcs_chars.multispace); if (multispace_len > 0) { - wp->w_p_lcs_chars.multispace = xmalloc(((size_t)multispace_len + 1) * sizeof(int)); - wp->w_p_lcs_chars.multispace[multispace_len] = NUL; + lcs_chars.multispace = xmalloc(((size_t)multispace_len + 1) * sizeof(int)); + lcs_chars.multispace[multispace_len] = NUL; } else { - wp->w_p_lcs_chars.multispace = NULL; + lcs_chars.multispace = NULL; } - xfree(wp->w_p_lcs_chars.leadmultispace); if (lead_multispace_len > 0) { - wp->w_p_lcs_chars.leadmultispace - = xmalloc(((size_t)lead_multispace_len + 1) * sizeof(int)); - wp->w_p_lcs_chars.leadmultispace[lead_multispace_len] = NUL; + lcs_chars.leadmultispace = xmalloc(((size_t)lead_multispace_len + 1) * sizeof(int)); + lcs_chars.leadmultispace[lead_multispace_len] = NUL; } else { - wp->w_p_lcs_chars.leadmultispace = NULL; + lcs_chars.leadmultispace = NULL; } } } + const char *p = value; while (*p) { int i; @@ -2419,7 +2412,7 @@ static const char *set_chars_option(win_T *wp, const char *value, const bool is_ return e_invarg; } int c2 = 0, c3 = 0; - if (tab[i].cp == &wp->w_p_lcs_chars.tab2) { + if (tab[i].cp == &lcs_chars.tab2) { if (*s == NUL) { return e_invarg; } @@ -2434,12 +2427,13 @@ static const char *set_chars_option(win_T *wp, const char *value, const bool is_ } } } + if (*s == ',' || *s == NUL) { if (round > 0) { - if (tab[i].cp == &wp->w_p_lcs_chars.tab2) { - wp->w_p_lcs_chars.tab1 = c1; - wp->w_p_lcs_chars.tab2 = c2; - wp->w_p_lcs_chars.tab3 = c3; + if (tab[i].cp == &lcs_chars.tab2) { + lcs_chars.tab1 = c1; + lcs_chars.tab2 = c2; + lcs_chars.tab3 = c3; } else if (tab[i].cp != NULL) { *(tab[i].cp) = c1; } @@ -2479,7 +2473,7 @@ static const char *set_chars_option(win_T *wp, const char *value, const bool is_ while (*s != NUL && *s != ',') { int c1 = get_encoded_char_adv(&s); if (p == last_multispace) { - wp->w_p_lcs_chars.multispace[multispace_pos++] = c1; + lcs_chars.multispace[multispace_pos++] = c1; } } p = s; @@ -2510,7 +2504,7 @@ static const char *set_chars_option(win_T *wp, const char *value, const bool is_ while (*s != NUL && *s != ',') { int c1 = get_encoded_char_adv(&s); if (p == last_lmultispace) { - wp->w_p_lcs_chars.leadmultispace[multispace_pos++] = c1; + lcs_chars.leadmultispace[multispace_pos++] = c1; } } p = s; @@ -2526,6 +2520,19 @@ static const char *set_chars_option(win_T *wp, const char *value, const bool is_ } } + if (apply) { + if (is_listchars) { + xfree(wp->w_p_lcs_chars.multispace); + xfree(wp->w_p_lcs_chars.leadmultispace); + wp->w_p_lcs_chars = lcs_chars; + } else { + wp->w_p_fcs_chars = fcs_chars; + } + } else if (is_listchars) { + xfree(lcs_chars.multispace); + xfree(lcs_chars.leadmultispace); + } + return NULL; // no error } @@ -2551,3 +2558,15 @@ const char *check_chars_options(void) } return NULL; } + +/// Handle the new value of 'fillchars'. +const char *set_fillchars_option(win_T *wp, char *val, bool apply) +{ + return set_chars_option(wp, val, false, apply); +} + +/// Handle the new value of 'listchars'. +const char *set_listchars_option(win_T *wp, char *val, bool apply) +{ + return set_chars_option(wp, val, true, apply); +} diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 10fe3cb114..b03509a313 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -25,7 +25,7 @@ #include "nvim/map.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/os/os.h" #include "nvim/path.h" #include "nvim/strings.h" diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 6c3eca8961..77c4766419 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -33,10 +33,9 @@ #include "nvim/globals.h" #include "nvim/log.h" #include "nvim/macros.h" -#include "nvim/main.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/os/fs_defs.h" #include "nvim/os/os.h" #include "nvim/path.h" @@ -76,7 +75,7 @@ int os_chdir(const char *path) { if (p_verbose >= 5) { verbose_enter(); - smsg("chdir(%s)", path); + smsg(0, "chdir(%s)", path); verbose_leave(); } return uv_chdir(path); diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 6310b90f04..03418f4548 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -11,7 +11,6 @@ #include "nvim/api/private/defs.h" #include "nvim/ascii.h" #include "nvim/autocmd.h" -#include "nvim/buffer_defs.h" #include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" #include "nvim/event/rstream.h" @@ -24,8 +23,9 @@ #include "nvim/macros.h" #include "nvim/main.h" #include "nvim/msgpack_rpc/channel.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/os/input.h" +#include "nvim/os/os_defs.h" #include "nvim/os/time.h" #include "nvim/profile.h" #include "nvim/rbuffer.h" diff --git a/src/nvim/os/input.h b/src/nvim/os/input.h index 6f25efdc7b..af17aabd90 100644 --- a/src/nvim/os/input.h +++ b/src/nvim/os/input.h @@ -6,6 +6,7 @@ #include "nvim/api/private/defs.h" #include "nvim/event/multiqueue.h" +#include "nvim/macros.h" EXTERN bool used_stdin INIT(= false); diff --git a/src/nvim/os/lang.c b/src/nvim/os/lang.c index 8ca2aa3a4b..652b851903 100644 --- a/src/nvim/os/lang.c +++ b/src/nvim/os/lang.c @@ -197,7 +197,7 @@ void ex_language(exarg_T *eap) if (p == NULL || *p == NUL) { p = "Unknown"; } - smsg(_("Current %slanguage: \"%s\""), whatstr, p); + smsg(0, _("Current %slanguage: \"%s\""), whatstr, p); } else { # ifndef LC_MESSAGES if (what == VIM_LC_MESSAGES) { diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 81e15bf841..d885c8476f 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -11,7 +11,6 @@ #include "auto/config.h" #include "klib/kvec.h" #include "nvim/ascii.h" -#include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/eval.h" #include "nvim/eval/typval_defs.h" @@ -32,7 +31,7 @@ #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/os/fs.h" #include "nvim/os/os_defs.h" #include "nvim/os/shell.h" @@ -134,6 +133,8 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in #define STYLE_VIMGLOB 2 // use "vimglob", for Posix sh #define STYLE_PRINT 3 // use "print -N", for zsh #define STYLE_BT 4 // `cmd` expansion, execute the pattern directly +#define STYLE_GLOBSTAR 5 // use extended shell glob for bash (this uses extended + // globbing functionality with globstar, needs bash > 4) int shell_style = STYLE_ECHO; int check_spaces; static bool did_find_nul = false; @@ -141,6 +142,9 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in // vimglob() function to define for Posix shell static char *sh_vimglob_func = "vimglob() { while [ $# -ge 1 ]; do echo \"$1\"; shift; done }; vimglob >"; + // vimglob() function with globstar setting enabled, only for bash >= 4.X + static char *sh_globstar_opt = + "[[ ${BASH_VERSINFO[0]} -ge 4 ]] && shopt -s globstar; "; bool is_fish_shell = #if defined(UNIX) @@ -190,6 +194,8 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in // If we use *zsh, "print -N" will work better than "glob". // STYLE_VIMGLOB: NL separated // If we use *sh*, we define "vimglob()". + // STYLE_GLOBSTAR: NL separated + // If we use *bash*, we define "vimglob() and enable globstar option". // STYLE_ECHO: space separated. // A shell we don't know, stay safe and use "echo". if (num_pat == 1 && *pat[0] == '`' @@ -203,9 +209,12 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in shell_style = STYLE_PRINT; } } - if (shell_style == STYLE_ECHO - && strstr(path_tail(p_sh), "sh") != NULL) { - shell_style = STYLE_VIMGLOB; + if (shell_style == STYLE_ECHO) { + if (strstr(path_tail(p_sh), "bash") != NULL) { + shell_style = STYLE_GLOBSTAR; + } else if (strstr(path_tail(p_sh), "sh") != NULL) { + shell_style = STYLE_VIMGLOB; + } } // Compute the length of the command. We need 2 extra bytes: for the @@ -214,6 +223,8 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in len = strlen(tempname) + 29; if (shell_style == STYLE_VIMGLOB) { len += strlen(sh_vimglob_func); + } else if (shell_style == STYLE_GLOBSTAR) { + len += strlen(sh_vimglob_func) + strlen(sh_globstar_opt); } for (i = 0; i < num_pat; i++) { @@ -281,6 +292,9 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in STRCAT(command, "print -N >"); } else if (shell_style == STYLE_VIMGLOB) { STRCAT(command, sh_vimglob_func); + } else if (shell_style == STYLE_GLOBSTAR) { + STRCAT(command, sh_globstar_opt); + STRCAT(command, sh_vimglob_func); } else { STRCAT(command, "echo >"); } @@ -364,7 +378,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in if (!(flags & EW_SILENT)) { msg_putchar('\n'); // clear bottom line quickly cmdline_row = Rows - 1; // continue on last line - msg(_(e_wildexpand)); + msg(_(e_wildexpand), 0); msg_start(); // don't overwrite this message } @@ -381,7 +395,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in if (fd == NULL) { // Something went wrong, perhaps a file name with a special char. if (!(flags & EW_SILENT)) { - msg(_(e_wildexpand)); + msg(_(e_wildexpand), 0); msg_start(); // don't overwrite this message } xfree(tempname); @@ -430,7 +444,9 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in p = skipwhite(p); // skip to next entry } // file names are separated with NL - } else if (shell_style == STYLE_BT || shell_style == STYLE_VIMGLOB) { + } else if (shell_style == STYLE_BT + || shell_style == STYLE_VIMGLOB + || shell_style == STYLE_GLOBSTAR) { buffer[len] = NUL; // make sure the buffer ends in NUL p = buffer; for (i = 0; *p != NUL; i++) { // count number of entries @@ -496,7 +512,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in (*file)[i] = p; // Space or NL separates if (shell_style == STYLE_ECHO || shell_style == STYLE_BT - || shell_style == STYLE_VIMGLOB) { + || shell_style == STYLE_VIMGLOB || shell_style == STYLE_GLOBSTAR) { while (!(shell_style == STYLE_ECHO && *p == ' ') && *p != '\n' && *p != NUL) { p++; @@ -715,7 +731,7 @@ int call_shell(char *cmd, ShellOpts opts, char *extra_shell_arg) if (p_verbose > 3) { verbose_enter(); - smsg(_("Executing command: \"%s\""), cmd == NULL ? p_sh : cmd); + smsg(0, _("Executing command: \"%s\""), cmd == NULL ? p_sh : cmd); msg_putchar('\n'); verbose_leave(); } @@ -876,9 +892,9 @@ static int do_os_system(char **argv, const char *input, size_t len, char **outpu // Failed, probably 'shell' is not executable. if (!silent) { msg_puts(_("\nshell failed to start: ")); - msg_outtrans(os_strerror(status)); + msg_outtrans(os_strerror(status), 0); msg_puts(": "); - msg_outtrans(prog); + msg_outtrans(prog, 0); msg_putchar('\n'); } multiqueue_free(events); @@ -1127,7 +1143,7 @@ static void out_data_append_to_screen(char *output, size_t *count, bool eof) goto end; } - (void)msg_outtrans_len_attr(p, i, 0); + (void)msg_outtrans_len(p, i, 0); p += i; } } diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c index 56fd2125c2..4c4ac9df1e 100644 --- a/src/nvim/os/signal.c +++ b/src/nvim/os/signal.c @@ -9,7 +9,6 @@ #endif #include "nvim/autocmd.h" -#include "nvim/buffer_defs.h" #include "nvim/eval.h" #include "nvim/event/signal.h" #include "nvim/globals.h" diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index 53ddda22fa..fa474b67dd 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -1,11 +1,13 @@ // This is an open source non-commercial project. Dear PVS-Studio, please check // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com +#include <assert.h> #include <stdbool.h> #include <string.h> #include "nvim/ascii.h" #include "nvim/fileio.h" +#include "nvim/globals.h" #include "nvim/memory.h" #include "nvim/os/os.h" #include "nvim/os/stdpaths_defs.h" @@ -69,15 +71,23 @@ const char *get_appname(void) return env_val; } -/// Ensure that APPNAME is valid. In particular, it cannot contain directory separators. +/// Ensure that APPNAME is valid. Must be a name or relative path. bool appname_is_valid(void) { const char *appname = get_appname(); - const size_t appname_len = strlen(appname); - for (size_t i = 0; i < appname_len; i++) { - if (appname[i] == PATHSEP) { - return false; - } + if (path_is_absolute(appname) + // TODO(justinmk): on Windows, path_is_absolute says "/" is NOT absolute. Should it? + || strequal(appname, "/") + || strequal(appname, "\\") + || strequal(appname, ".") + || strequal(appname, "..") +#ifdef BACKSLASH_IN_FILENAME + || strstr(appname, "\\..") != NULL + || strstr(appname, "..\\") != NULL +#endif + || strstr(appname, "/..") != NULL + || strstr(appname, "../") != NULL) { + return false; } return true; } diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c index 0c3b254b9a..ac98f0cf9a 100644 --- a/src/nvim/os/time.c +++ b/src/nvim/os/time.c @@ -4,7 +4,6 @@ #include <inttypes.h> #include <limits.h> #include <stdbool.h> -#include <stdlib.h> #include <string.h> #include <time.h> @@ -15,7 +14,6 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/log.h" -#include "nvim/macros.h" #include "nvim/main.h" #include "nvim/memory.h" #include "nvim/os/input.h" diff --git a/src/nvim/path.c b/src/nvim/path.c index 3b36c2a550..21f0543756 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -2,7 +2,6 @@ // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include <assert.h> -#include <ctype.h> #include <limits.h> #include <stdbool.h> #include <stddef.h> @@ -12,10 +11,10 @@ #include "auto/config.h" #include "nvim/ascii.h" -#include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" #include "nvim/eval.h" +#include "nvim/eval/typval_defs.h" #include "nvim/ex_docmd.h" #include "nvim/file_search.h" #include "nvim/fileio.h" @@ -27,6 +26,7 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/fs_defs.h" #include "nvim/os/input.h" #include "nvim/os/os.h" @@ -35,7 +35,6 @@ #include "nvim/pos.h" #include "nvim/regexp.h" #include "nvim/strings.h" -#include "nvim/types.h" #include "nvim/vim.h" #include "nvim/window.h" diff --git a/src/nvim/plines.c b/src/nvim/plines.c index 99f666ef3f..97782b39bc 100644 --- a/src/nvim/plines.c +++ b/src/nvim/plines.c @@ -3,9 +3,9 @@ // plines.c: calculate the vertical and horizontal size of text in a window -#include <inttypes.h> #include <limits.h> #include <stdbool.h> +#include <stdint.h> #include <string.h> #include "nvim/ascii.h" @@ -21,6 +21,7 @@ #include "nvim/memline.h" #include "nvim/move.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/plines.h" #include "nvim/pos.h" #include "nvim/state.h" @@ -476,7 +477,7 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en char *posptr; // points to char at pos->col int incr; int head; - long *vts = wp->w_buffer->b_p_vts_array; + colnr_T *vts = wp->w_buffer->b_p_vts_array; int ts = (int)wp->w_buffer->b_p_ts; colnr_T vcol = 0; diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c index 488c893bd8..af4ffd7829 100644 --- a/src/nvim/popupmenu.c +++ b/src/nvim/popupmenu.c @@ -6,7 +6,6 @@ /// Popup menu (PUM) #include <assert.h> -#include <limits.h> #include <stdbool.h> #include <string.h> @@ -17,9 +16,9 @@ #include "nvim/charset.h" #include "nvim/drawscreen.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds.h" #include "nvim/getchar.h" +#include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/highlight.h" @@ -32,6 +31,7 @@ #include "nvim/message.h" #include "nvim/move.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/popupmenu.h" #include "nvim/pos.h" #include "nvim/strings.h" @@ -655,7 +655,7 @@ void pum_redraw(void) i >= thumb_pos && i < thumb_pos + thumb_height ? attr_thumb : attr_scroll); } } - grid_line_flush(false); + grid_line_flush(); row++; } } diff --git a/src/nvim/profile.c b/src/nvim/profile.c index d8ba4741bc..3162a446c0 100644 --- a/src/nvim/profile.c +++ b/src/nvim/profile.c @@ -24,7 +24,6 @@ #include "nvim/keycodes.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/option_defs.h" #include "nvim/os/os.h" #include "nvim/os/time.h" #include "nvim/pos.h" diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 70fcf3d276..e6d5831dd3 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -23,7 +23,6 @@ #include "nvim/edit.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/eval/window.h" #include "nvim/ex_cmds.h" #include "nvim/ex_cmds2.h" @@ -33,6 +32,7 @@ #include "nvim/ex_getln.h" #include "nvim/fileio.h" #include "nvim/fold.h" +#include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/help.h" @@ -41,13 +41,14 @@ #include "nvim/macros.h" #include "nvim/mark.h" #include "nvim/mbyte.h" -#include "nvim/memfile_defs.h" #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/move.h" #include "nvim/normal.h" #include "nvim/option.h" +#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/fs_defs.h" #include "nvim/os/input.h" @@ -3132,7 +3133,7 @@ static void qf_list_entry(qfline_T *qfp, int qf_idx, bool cursel) } msg_putchar('\n'); - msg_outtrans_attr(IObuff, cursel ? HL_ATTR(HLF_QFL) : qfFileAttr); + msg_outtrans(IObuff, cursel ? HL_ATTR(HLF_QFL) : qfFileAttr); if (qfp->qf_lnum != 0) { msg_puts_attr(":", qfSepAttr); @@ -3308,7 +3309,7 @@ static void qf_msg(qf_info_T *qi, int which, char *lead) xstrlcat(buf, title, IOSIZE); } trunc_string(buf, buf, Columns - 1, IOSIZE); - msg(buf); + msg(buf, 0); } /// ":colder [count]": Up in the quickfix stack. @@ -3367,7 +3368,7 @@ void qf_history(exarg_T *eap) } if (qf_stack_empty(qi)) { - msg(_("No entries")); + msg(_("No entries"), 0); } else { for (int i = 0; i < qi->qf_listcount; i++) { qf_msg(qi, i, i == qi->qf_curlist ? "> " : " "); @@ -4317,7 +4318,7 @@ static char *make_get_fullcmd(const char *makecmd, const char *fname) } msg_start(); msg_puts(":!"); - msg_outtrans(cmd); // show what we are doing + msg_outtrans(cmd, 0); // show what we are doing return cmd; } @@ -5168,9 +5169,9 @@ static void vgr_display_fname(char *fname) msg_start(); char *p = msg_strtrunc(fname, true); if (p == NULL) { - msg_outtrans(fname); + msg_outtrans(fname, 0); } else { - msg_outtrans(p); + msg_outtrans(p, 0); xfree(p); } msg_clr_eos(); @@ -5187,7 +5188,7 @@ static buf_T *vgr_load_dummy_buf(char *fname, char *dirname_start, char *dirname // indent scripts, a great speed improvement. char *save_ei = au_event_disable(",Filetype"); - long save_mls = p_mls; + OptInt save_mls = p_mls; p_mls = 0; // Load file into a buffer, so that 'fileencoding' is detected, @@ -5458,7 +5459,7 @@ static int vgr_process_files(win_T *wp, qf_info_T *qi, vgr_args_T *cmd_args, boo if (buf == NULL) { if (!got_int) { - smsg(_("Cannot open file \"%s\""), fname); + smsg(0, _("Cannot open file \"%s\""), fname); } } else { // Try for a match in all lines of the buffer. diff --git a/src/nvim/quickfix.h b/src/nvim/quickfix.h index 0da43e436c..70b013be9c 100644 --- a/src/nvim/quickfix.h +++ b/src/nvim/quickfix.h @@ -2,6 +2,7 @@ #define NVIM_QUICKFIX_H #include "nvim/ex_cmds_defs.h" +#include "nvim/option_defs.h" #include "nvim/types.h" // flags for skip_vimgrep_pat() diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 14c7e56e97..3f792cd8d5 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -20,7 +20,6 @@ #include "nvim/charset.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/eval/userfunc.h" #include "nvim/garray.h" #include "nvim/gettext.h" @@ -32,7 +31,7 @@ #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/os/input.h" #include "nvim/plines.h" #include "nvim/pos.h" @@ -40,7 +39,6 @@ #include "nvim/regexp_defs.h" #include "nvim/strings.h" #include "nvim/types.h" -#include "nvim/undo_defs.h" #include "nvim/vim.h" #ifdef REGEXP_DEBUG @@ -2319,7 +2317,7 @@ regprog_T *vim_regcomp(const char *expr_arg, int re_flags) regexp_engine = expr[4] - '0'; expr += 5; #ifdef REGEXP_DEBUG - smsg("New regexp mode selected (%d): %s", + smsg(0, "New regexp mode selected (%d): %s", regexp_engine, regname[newengine]); #endif diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 7d58a87ab7..3e573f1607 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -6840,7 +6840,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm result = false; win_T *wp = rex.reg_win == NULL ? curwin : rex.reg_win; if (op == 1 && col - 1 > t->state->val && col > 100) { - long ts = wp->w_buffer->b_p_ts; + long ts = (long)wp->w_buffer->b_p_ts; // Guess that a character won't use more columns than 'tabstop', // with a minimum of 4. diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index 269c3805a1..12cf08636f 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -9,6 +9,7 @@ #include <errno.h> #include <fcntl.h> #include <inttypes.h> +#include <stddef.h> #include <stdio.h> #include <string.h> #include <uv.h> @@ -17,7 +18,6 @@ #include "nvim/api/private/helpers.h" #include "nvim/ascii.h" #include "nvim/autocmd.h" -#include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" #include "nvim/debugger.h" @@ -31,6 +31,7 @@ #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" +#include "nvim/hashtab.h" #include "nvim/lua/executor.h" #include "nvim/macros.h" #include "nvim/map.h" @@ -39,6 +40,8 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" +#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/os/stdpaths_defs.h" @@ -353,9 +356,9 @@ int do_in_path(const char *path, const char *prefix, char *name, int flags, if (p_verbose > 10 && name != NULL) { verbose_enter(); if (*prefix != NUL) { - smsg(_("Searching for \"%s\" under \"%s\" in \"%s\""), name, prefix, path); + smsg(0, _("Searching for \"%s\" under \"%s\" in \"%s\""), name, prefix, path); } else { - smsg(_("Searching for \"%s\" in \"%s\""), name, path); + smsg(0, _("Searching for \"%s\" in \"%s\""), name, path); } verbose_leave(); } @@ -396,7 +399,7 @@ int do_in_path(const char *path, const char *prefix, char *name, int flags, if (p_verbose > 10) { verbose_enter(); - smsg(_("Searching for \"%s\""), buf); + smsg(0, _("Searching for \"%s\""), buf); verbose_leave(); } @@ -418,7 +421,7 @@ int do_in_path(const char *path, const char *prefix, char *name, int flags, semsg(_(e_dirnotf), basepath, name); } else if (p_verbose > 1) { verbose_enter(); - smsg(_("not found in '%s': \"%s\""), basepath, name); + smsg(0, _("not found in '%s': \"%s\""), basepath, name); verbose_leave(); } } @@ -481,7 +484,7 @@ int do_in_cached_path(char *name, int flags, DoInRuntimepathCB callback, void *c if (p_verbose > 10 && name != NULL) { verbose_enter(); - smsg(_("Searching for \"%s\" in runtime path"), name); + smsg(0, _("Searching for \"%s\" in runtime path"), name); verbose_leave(); } @@ -520,7 +523,7 @@ int do_in_cached_path(char *name, int flags, DoInRuntimepathCB callback, void *c if (p_verbose > 10) { verbose_enter(); - smsg(_("Searching for \"%s\""), buf); + smsg(0, _("Searching for \"%s\""), buf); verbose_leave(); } @@ -540,7 +543,7 @@ int do_in_cached_path(char *name, int flags, DoInRuntimepathCB callback, void *c semsg(_(e_dirnotf), "runtime path", name); } else if (p_verbose > 1) { verbose_enter(); - smsg(_("not found in runtime path: \"%s\""), name); + smsg(0, _("not found in runtime path: \"%s\""), name); verbose_leave(); } } @@ -2047,7 +2050,7 @@ int do_source(char *fname, int check_other, int is_vimrc, int *ret_sid) return retval; } if (os_isdir(fname_exp)) { - smsg(_("Cannot source a directory: \"%s\""), fname); + smsg(0, _("Cannot source a directory: \"%s\""), fname); goto theend; } @@ -2091,9 +2094,9 @@ int do_source(char *fname, int check_other, int is_vimrc, int *ret_sid) if (p_verbose > 1) { verbose_enter(); if (SOURCING_NAME == NULL) { - smsg(_("could not source \"%s\""), fname); + smsg(0, _("could not source \"%s\""), fname); } else { - smsg(_("line %" PRId64 ": could not source \"%s\""), + smsg(0, _("line %" PRId64 ": could not source \"%s\""), (int64_t)SOURCING_LNUM, fname); } verbose_leave(); @@ -2107,9 +2110,9 @@ int do_source(char *fname, int check_other, int is_vimrc, int *ret_sid) if (p_verbose > 1) { verbose_enter(); if (SOURCING_NAME == NULL) { - smsg(_("sourcing \"%s\""), fname); + smsg(0, _("sourcing \"%s\""), fname); } else { - smsg(_("line %" PRId64 ": sourcing \"%s\""), (int64_t)SOURCING_LNUM, fname); + smsg(0, _("line %" PRId64 ": sourcing \"%s\""), (int64_t)SOURCING_LNUM, fname); } verbose_leave(); } @@ -2242,9 +2245,9 @@ int do_source(char *fname, int check_other, int is_vimrc, int *ret_sid) estack_pop(); if (p_verbose > 1) { verbose_enter(); - smsg(_("finished sourcing %s"), fname); + smsg(0, _("finished sourcing %s"), fname); if (SOURCING_NAME != NULL) { - smsg(_("continuing in %s"), SOURCING_NAME); + smsg(0, _("continuing in %s"), SOURCING_NAME); } verbose_leave(); } @@ -2329,7 +2332,7 @@ void ex_scriptnames(exarg_T *eap) vim_snprintf(IObuff, IOSIZE, "%3d: %s", i, NameBuff); if (!message_filtered(IObuff)) { msg_putchar('\n'); - msg_outtrans(IObuff); + msg_outtrans(IObuff, 0); line_breakcheck(); } } diff --git a/src/nvim/runtime.h b/src/nvim/runtime.h index 23a9f468db..7308ef5f75 100644 --- a/src/nvim/runtime.h +++ b/src/nvim/runtime.h @@ -9,6 +9,7 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_eval_defs.h" #include "nvim/garray.h" +#include "nvim/option_defs.h" #include "nvim/pos.h" #include "nvim/types.h" diff --git a/src/nvim/search.c b/src/nvim/search.c index cb6596d211..2d13ad3f0d 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -43,6 +43,7 @@ #include "nvim/move.h" #include "nvim/normal.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/fs.h" #include "nvim/os/input.h" #include "nvim/os/time.h" @@ -1263,7 +1264,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char *pat, int count, in memset(msgbuf + pat_len, ' ', (size_t)(r - msgbuf)); } } - msg_outtrans(msgbuf); + msg_outtrans(msgbuf, 0); msg_clr_eos(); msg_check(); @@ -2293,8 +2294,8 @@ void showmatch(int c) { pos_T *lpos; colnr_T vcol; - long *so = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so; - long *siso = curwin->w_p_siso >= 0 ? &curwin->w_p_siso : &p_siso; + OptInt *so = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so; + OptInt *siso = curwin->w_p_siso >= 0 ? &curwin->w_p_siso : &p_siso; char *p; // Only show match for chars in the 'matchpairs' option. @@ -2338,8 +2339,8 @@ void showmatch(int c) pos_T mpos = *lpos; // save the pos, update_screen() may change it pos_T save_cursor = curwin->w_cursor; - long save_so = *so; - long save_siso = *siso; + OptInt save_so = *so; + OptInt save_siso = *siso; // Handle "$" in 'cpo': If the ')' is typed on top of the "$", // stop displaying the "$". if (dollar_vcol >= 0 && dollar_vcol == curwin->w_virtcol) { @@ -3709,7 +3710,7 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool if (new_fname != NULL) { // using "new_fname" is more reliable, e.g., when // 'includeexpr' is set. - msg_outtrans_attr(new_fname, HL_ATTR(HLF_D)); + msg_outtrans(new_fname, HL_ATTR(HLF_D)); } else { // Isolate the file name. // Include the surrounding "" or <> if present. @@ -3743,7 +3744,7 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool } save_char = p[i]; p[i] = NUL; - msg_outtrans_attr(p, HL_ATTR(HLF_D)); + msg_outtrans(p, HL_ATTR(HLF_D)); p[i] = save_char; } @@ -3791,14 +3792,14 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool files[depth].lnum = 0; files[depth].matched = false; if (action == ACTION_EXPAND) { - msg_hist_off = true; // reset in msg_trunc_attr() + msg_hist_off = true; // reset in msg_trunc() vim_snprintf(IObuff, IOSIZE, _("Scanning included file: %s"), new_fname); - msg_trunc_attr(IObuff, true, HL_ATTR(HLF_R)); + msg_trunc(IObuff, true, HL_ATTR(HLF_R)); } else if (p_verbose >= 5) { verbose_enter(); - smsg(_("Searching included file %s"), new_fname); + smsg(0, _("Searching included file %s"), new_fname); verbose_leave(); } } @@ -4116,9 +4117,9 @@ exit_matched: if (type == CHECK_PATH) { if (!did_show) { if (action != ACTION_SHOW_ALL) { - msg(_("All included files were found")); + msg(_("All included files were found"), 0); } else { - msg(_("No included files")); + msg(_("No included files"), 0); } } } else if (!found diff --git a/src/nvim/shada.c b/src/nvim/shada.c index e302c05b1c..14d35d9b59 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -25,7 +25,6 @@ #include "nvim/eval/decode.h" #include "nvim/eval/encode.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds.h" #include "nvim/ex_docmd.h" #include "nvim/fileio.h" @@ -43,6 +42,7 @@ #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/fileio.h" #include "nvim/os/fs_defs.h" #include "nvim/os/os.h" @@ -795,7 +795,7 @@ static int shada_read_file(const char *const file, const int flags) if (p_verbose > 1) { verbose_enter(); - smsg(_("Reading ShaDa file \"%s\"%s%s%s%s"), + smsg(0, _("Reading ShaDa file \"%s\"%s%s%s%s"), fname, (flags & kShaDaWantInfo) ? _(" info") : "", (flags & kShaDaWantMarks) ? _(" marks") : "", @@ -2506,7 +2506,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, ShaDaReadDef for (HistoryType i = 0; i < HIST_COUNT; i++) { long num_saved = get_shada_parameter(hist_type2char(i)); if (num_saved == -1) { - num_saved = p_hi; + num_saved = (long)p_hi; } if (num_saved > 0) { dump_history = true; @@ -3049,7 +3049,7 @@ shada_write_file_nomerge: {} if (p_verbose > 1) { verbose_enter(); - smsg(_("Writing ShaDa file \"%s\""), fname); + smsg(0, _("Writing ShaDa file \"%s\""), fname); verbose_leave(); } diff --git a/src/nvim/sign.c b/src/nvim/sign.c index 1910e046e6..96af14bfc6 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -7,6 +7,7 @@ #include <inttypes.h> #include <stdbool.h> +#include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -20,7 +21,6 @@ #include "nvim/edit.h" #include "nvim/eval/funcs.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/fold.h" @@ -31,7 +31,6 @@ #include "nvim/highlight_group.h" #include "nvim/macros.h" #include "nvim/mbyte.h" -#include "nvim/memline_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/move.h" @@ -1660,15 +1659,15 @@ static void sign_get_placed(buf_T *buf, linenr_T lnum, int sign_id, const char * /// List one sign. static void sign_list_defined(sign_T *sp) { - smsg("sign %s", sp->sn_name); + smsg(0, "sign %s", sp->sn_name); if (sp->sn_icon != NULL) { msg_puts(" icon="); - msg_outtrans(sp->sn_icon); + msg_outtrans(sp->sn_icon, 0); msg_puts(_(" (not supported)")); } if (sp->sn_text != NULL) { msg_puts(" text="); - msg_outtrans(sp->sn_text); + msg_outtrans(sp->sn_text, 0); } if (sp->sn_line_hl > 0) { msg_puts(" linehl="); diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 38e045a08b..a97b9c6a0a 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -90,6 +90,7 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/fs.h" #include "nvim/os/input.h" #include "nvim/os/os_defs.h" @@ -1626,7 +1627,7 @@ static void spell_load_lang(char *lang) lang); do_cmdline_cmd(autocmd_buf); } else { - smsg(_("Warning: Cannot find word list \"%s.%s.spl\" or \"%s.ascii.spl\""), + smsg(0, _("Warning: Cannot find word list \"%s.%s.spl\" or \"%s.ascii.spl\""), lang, spell_enc(), lang); } } else if (sl.sl_slang != NULL) { @@ -2076,7 +2077,7 @@ char *parse_spelllang(win_T *wp) } else { // This is probably an error. Give a warning and // accept the words anyway. - smsg(_("Warning: region %s not supported"), + smsg(0, _("Warning: region %s not supported"), region); } } else { diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index d7dc7fb672..f1df2e56f3 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -231,12 +231,12 @@ #include <inttypes.h> #include <limits.h> #include <stdbool.h> +#include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> -#include "auto/config.h" #include "nvim/arglist.h" #include "nvim/ascii.h" #include "nvim/buffer.h" @@ -254,6 +254,7 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/os/time.h" @@ -265,7 +266,6 @@ #include "nvim/spell_defs.h" #include "nvim/spellfile.h" #include "nvim/strings.h" -#include "nvim/types.h" #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/vim.h" @@ -612,14 +612,14 @@ slang_T *spell_load_file(char *fname, char *lang, slang_T *old_lp, bool silent) semsg(_(e_notopen), fname); } else if (p_verbose > 2) { verbose_enter(); - smsg(e_notopen, fname); + smsg(0, e_notopen, fname); verbose_leave(); } goto endFAIL; } if (p_verbose > 2) { verbose_enter(); - smsg(_("Reading spell file \"%s\""), fname); + smsg(0, _("Reading spell file \"%s\""), fname); verbose_leave(); } @@ -1955,9 +1955,9 @@ static void spell_print_node(wordnode_T *node, int depth) PRINTSOME(line1, depth, "(%d)", node->wn_nr, 0); PRINTSOME(line2, depth, " ", 0, 0); PRINTSOME(line3, depth, " ", 0, 0); - msg(line1); - msg(line2); - msg(line3); + msg(line1, 0); + msg(line2, 0); + msg(line3, 0); } else { node->wn_u1.index = true; @@ -1981,9 +1981,9 @@ static void spell_print_node(wordnode_T *node, int depth) } if (node->wn_byte == NUL) { - msg(line1); - msg(line2); - msg(line3); + msg(line1, 0); + msg(line2, 0); + msg(line3, 0); } // do the children @@ -2097,7 +2097,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) if (spin->si_conv.vc_type != CONV_NONE) { pc = string_convert(&spin->si_conv, rline, NULL); if (pc == NULL) { - smsg(_("Conversion failure for word in %s line %d: %s"), + smsg(0, _("Conversion failure for word in %s line %d: %s"), fname, lnum, rline); continue; } @@ -2144,7 +2144,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) aff->af_enc = enc_canonize(items[1]); if (!spin->si_ascii && convert_setup(&spin->si_conv, aff->af_enc, p_enc) == FAIL) { - smsg(_("Conversion in %s not supported: from %s to %s"), + smsg(0, _("Conversion in %s not supported: from %s to %s"), fname, aff->af_enc, p_enc); } spin->si_conv.vc_fail = true; @@ -2157,7 +2157,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) } else if (strcmp(items[1], "caplong") == 0) { aff->af_flagtype = AFT_CAPLONG; } else { - smsg(_("Invalid value for FLAG in %s line %d: %s"), + smsg(0, _("Invalid value for FLAG in %s line %d: %s"), fname, lnum, items[1]); } if (aff->af_rare != 0 @@ -2171,7 +2171,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) || compflags != NULL || aff->af_suff.ht_used > 0 || aff->af_pref.ht_used > 0) { - smsg(_("FLAG after using flags in %s line %d: %s"), + smsg(0, _("FLAG after using flags in %s line %d: %s"), fname, lnum, items[1]); } } else if (spell_info_item(items[0]) && itemcnt > 1) { @@ -2223,14 +2223,16 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) && aff->af_compforbid == 0) { aff->af_compforbid = affitem2flag(aff->af_flagtype, items[1], fname, lnum); if (aff->af_pref.ht_used > 0) { - smsg(_("Defining COMPOUNDFORBIDFLAG after PFX item may give wrong results in %s line %d"), + smsg(0, + _("Defining COMPOUNDFORBIDFLAG after PFX item may give wrong results in %s line %d"), fname, lnum); } } else if (is_aff_rule(items, itemcnt, "COMPOUNDPERMITFLAG", 2) && aff->af_comppermit == 0) { aff->af_comppermit = affitem2flag(aff->af_flagtype, items[1], fname, lnum); if (aff->af_pref.ht_used > 0) { - smsg(_("Defining COMPOUNDPERMITFLAG after PFX item may give wrong results in %s line %d"), + smsg(0, + _("Defining COMPOUNDPERMITFLAG after PFX item may give wrong results in %s line %d"), fname, lnum); } } else if (is_aff_rule(items, itemcnt, "COMPOUNDFLAG", 2) @@ -2245,7 +2247,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) // We don't use the count, but do check that it's a number and // not COMPOUNDRULE mistyped. if (atoi(items[1]) == 0) { - smsg(_("Wrong COMPOUNDRULES value in %s line %d: %s"), + smsg(0, _("Wrong COMPOUNDRULES value in %s line %d: %s"), fname, lnum, items[1]); } } else if (is_aff_rule(items, itemcnt, "COMPOUNDRULE", 2)) { @@ -2269,21 +2271,21 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) && compmax == 0) { compmax = atoi(items[1]); if (compmax == 0) { - smsg(_("Wrong COMPOUNDWORDMAX value in %s line %d: %s"), + smsg(0, _("Wrong COMPOUNDWORDMAX value in %s line %d: %s"), fname, lnum, items[1]); } } else if (is_aff_rule(items, itemcnt, "COMPOUNDMIN", 2) && compminlen == 0) { compminlen = atoi(items[1]); if (compminlen == 0) { - smsg(_("Wrong COMPOUNDMIN value in %s line %d: %s"), + smsg(0, _("Wrong COMPOUNDMIN value in %s line %d: %s"), fname, lnum, items[1]); } } else if (is_aff_rule(items, itemcnt, "COMPOUNDSYLMAX", 2) && compsylmax == 0) { compsylmax = atoi(items[1]); if (compsylmax == 0) { - smsg(_("Wrong COMPOUNDSYLMAX value in %s line %d: %s"), + smsg(0, _("Wrong COMPOUNDSYLMAX value in %s line %d: %s"), fname, lnum, items[1]); } } else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDDUP", 1)) { @@ -2296,7 +2298,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) compoptions |= COMP_CHECKTRIPLE; } else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDPATTERN", 2)) { if (atoi(items[1]) == 0) { - smsg(_("Wrong CHECKCOMPOUNDPATTERN value in %s line %d: %s"), + smsg(0, _("Wrong CHECKCOMPOUNDPATTERN value in %s line %d: %s"), fname, lnum, items[1]); } } else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDPATTERN", 3)) { @@ -2352,11 +2354,11 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) if (!HASHITEM_EMPTY(hi)) { cur_aff = HI2AH(hi); if (cur_aff->ah_combine != (*items[2] == 'Y')) { - smsg(_("Different combining flag in continued affix block in %s line %d: %s"), + smsg(0, _("Different combining flag in continued affix block in %s line %d: %s"), fname, lnum, items[1]); } if (!cur_aff->ah_follows) { - smsg(_("Duplicate affix in %s line %d: %s"), + smsg(0, _("Duplicate affix in %s line %d: %s"), fname, lnum, items[1]); } } else { @@ -2374,9 +2376,8 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) || cur_aff->ah_flag == aff->af_nosuggest || cur_aff->ah_flag == aff->af_needcomp || cur_aff->ah_flag == aff->af_comproot) { - smsg(_("Affix also used for " - "BAD/RARE/KEEPCASE/NEEDAFFIX/NEEDCOMPOUND/NOSUGGEST " - "in %s line %d: %s"), + smsg(0, _("Affix also used for BAD/RARE/KEEPCASE/NEEDAFFIX/NEEDCOMPOUND/NOSUGGEST " + "in %s line %d: %s"), fname, lnum, items[1]); } STRCPY(cur_aff->ah_key, items[1]); @@ -2400,11 +2401,11 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) if (itemcnt > lasti && !aff->af_ignoreextra && *items[lasti] != '#') { - smsg(_(e_afftrailing), fname, lnum, items[lasti]); + smsg(0, _(e_afftrailing), fname, lnum, items[lasti]); } if (strcmp(items[2], "Y") != 0 && strcmp(items[2], "N") != 0) { - smsg(_("Expected Y or N in %s line %d: %s"), + smsg(0, _("Expected Y or N in %s line %d: %s"), fname, lnum, items[2]); } @@ -2440,7 +2441,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) if (itemcnt > lasti && *items[lasti] != '#' && (strcmp(items[lasti], "-") != 0 || itemcnt != lasti + 1)) { - smsg(_(e_afftrailing), fname, lnum, items[lasti]); + smsg(0, _(e_afftrailing), fname, lnum, items[lasti]); } // New item for an affix letter. @@ -2475,7 +2476,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) snprintf(buf, sizeof(buf), *items[0] == 'P' ? "^%s" : "%s$", items[4]); aff_entry->ae_prog = vim_regcomp(buf, RE_MAGIC + RE_STRING + RE_STRICT); if (aff_entry->ae_prog == NULL) { - smsg(_("Broken condition in %s line %d: %s"), + smsg(0, _("Broken condition in %s line %d: %s"), fname, lnum, items[4]); } } @@ -2587,7 +2588,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) || is_aff_rule(items, itemcnt, "REPSAL", 2)) { // Ignore REP/REPSAL count if (!isdigit((uint8_t)(*items[1]))) { - smsg(_("Expected REP(SAL) count in %s line %d"), + smsg(0, _("Expected REP(SAL) count in %s line %d"), fname, lnum); } } else if ((strcmp(items[0], "REP") == 0 @@ -2597,7 +2598,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) // Myspell ignores extra arguments, we require it starts with // # to detect mistakes. if (itemcnt > 3 && items[3][0] != '#') { - smsg(_(e_afftrailing), fname, lnum, items[3]); + smsg(0, _(e_afftrailing), fname, lnum, items[3]); } if (items[0][3] == 'S' ? do_repsal : do_rep) { // Replace underscore with space (can't include a space @@ -2622,7 +2623,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) // First line contains the count. found_map = true; if (!isdigit((uint8_t)(*items[1]))) { - smsg(_("Expected MAP count in %s line %d"), + smsg(0, _("Expected MAP count in %s line %d"), fname, lnum); } } else if (do_mapline) { @@ -2633,7 +2634,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) && vim_strchr(spin->si_map.ga_data, c) != NULL) || vim_strchr(p, c) != NULL) { - smsg(_("Duplicate character in MAP in %s line %d"), + smsg(0, _("Duplicate character in MAP in %s line %d"), fname, lnum); } } @@ -2676,7 +2677,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) } } } else { - smsg(_("Unrecognized or duplicate item in %s line %d: %s"), + smsg(0, _("Unrecognized or duplicate item in %s line %d: %s"), fname, lnum, items[0]); } } @@ -2708,7 +2709,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) if (compsylmax != 0) { if (syllable == NULL) { - smsg("%s", _("COMPOUNDSYLMAX used without SYLLABLE")); + smsg(0, "%s", _("COMPOUNDSYLMAX used without SYLLABLE")); } aff_check_number(spin->si_compsylmax, compsylmax, "COMPOUNDSYLMAX"); spin->si_compsylmax = compsylmax; @@ -2726,11 +2727,11 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) // Check that we didn't use too many renumbered flags. if (spin->si_newcompID < spin->si_newprefID) { if (spin->si_newcompID == 127 || spin->si_newcompID == 255) { - msg(_("Too many postponed prefixes")); + msg(_("Too many postponed prefixes"), 0); } else if (spin->si_newprefID == 0 || spin->si_newprefID == 127) { - msg(_("Too many compound flags")); + msg(_("Too many compound flags"), 0); } else { - msg(_("Too many postponed prefixes and/or compound flags")); + msg(_("Too many postponed prefixes and/or compound flags"), 0); } } @@ -2741,10 +2742,10 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname) if (sofofrom != NULL || sofoto != NULL) { if (sofofrom == NULL || sofoto == NULL) { - smsg(_("Missing SOFO%s line in %s"), + smsg(0, _("Missing SOFO%s line in %s"), sofofrom == NULL ? "FROM" : "TO", fname); } else if (!GA_EMPTY(&spin->si_sal)) { - smsg(_("Both SAL and SOFO lines in %s"), fname); + smsg(0, _("Both SAL and SOFO lines in %s"), fname); } else { aff_check_string(spin->si_sofofr, sofofrom, "SOFOFROM"); aff_check_string(spin->si_sofoto, sofoto, "SOFOTO"); @@ -2822,15 +2823,15 @@ static unsigned affitem2flag(int flagtype, char *item, char *fname, int lnum) unsigned res = get_affitem(flagtype, &p); if (res == 0) { if (flagtype == AFT_NUM) { - smsg(_("Flag is not a number in %s line %d: %s"), + smsg(0, _("Flag is not a number in %s line %d: %s"), fname, lnum, item); } else { - smsg(_("Illegal flag in %s line %d: %s"), + smsg(0, _("Illegal flag in %s line %d: %s"), fname, lnum, item); } } if (*p != NUL) { - smsg(_(e_affname), fname, lnum, item); + smsg(0, _(e_affname), fname, lnum, item); return 0; } @@ -2993,7 +2994,7 @@ static bool flag_in_afflist(int flagtype, char *afflist, unsigned flag) static void aff_check_number(int spinval, int affval, char *name) { if (spinval != 0 && spinval != affval) { - smsg(_("%s value differs from what is used in another .aff file"), + smsg(0, _("%s value differs from what is used in another .aff file"), name); } } @@ -3002,7 +3003,7 @@ static void aff_check_number(int spinval, int affval, char *name) static void aff_check_string(char *spinval, char *affval, char *name) { if (spinval != NULL && strcmp(spinval, affval) != 0) { - smsg(_("%s value differs from what is used in another .aff file"), + smsg(0, _("%s value differs from what is used in another .aff file"), name); } } @@ -3139,7 +3140,7 @@ static int spell_read_dic(spellinfo_T *spin, char *fname, afffile_T *affile) if (spin->si_conv.vc_type != CONV_NONE) { pc = string_convert(&spin->si_conv, line, NULL); if (pc == NULL) { - smsg(_("Conversion failure for word in %s line %d: %s"), + smsg(0, _("Conversion failure for word in %s line %d: %s"), fname, lnum, line); continue; } @@ -3179,7 +3180,7 @@ static int spell_read_dic(spellinfo_T *spin, char *fname, afffile_T *affile) _("line %6d, word %6ld - %s"), lnum, spin->si_foldwcount + spin->si_keepwcount, w); msg_start(); - msg_outtrans_long_attr(message, 0); + msg_outtrans_long(message, 0); msg_clr_eos(); msg_didout = false; msg_col = 0; @@ -3199,10 +3200,10 @@ static int spell_read_dic(spellinfo_T *spin, char *fname, afffile_T *affile) hi = hash_lookup(&ht, dw, strlen(dw), hash); if (!HASHITEM_EMPTY(hi)) { if (p_verbose > 0) { - smsg(_("Duplicate word in %s line %d: %s"), + smsg(0, _("Duplicate word in %s line %d: %s"), fname, lnum, dw); } else if (duplicate == 0) { - smsg(_("First duplicate word in %s line %d: %s"), + smsg(0, _("First duplicate word in %s line %d: %s"), fname, lnum, dw); } duplicate++; @@ -3263,10 +3264,10 @@ static int spell_read_dic(spellinfo_T *spin, char *fname, afffile_T *affile) } if (duplicate > 0) { - smsg(_("%d duplicate word(s) in %s"), duplicate, fname); + smsg(0, _("%d duplicate word(s) in %s"), duplicate, fname); } if (spin->si_ascii && non_ascii > 0) { - smsg(_("Ignored %d word(s) with non-ASCII characters in %s"), + smsg(0, _("Ignored %d word(s) with non-ASCII characters in %s"), non_ascii, fname); } hash_clear(&ht); @@ -3681,7 +3682,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char *fname) if (spin->si_conv.vc_type != CONV_NONE) { pc = string_convert(&spin->si_conv, rline, NULL); if (pc == NULL) { - smsg(_("Conversion failure for word in %s line %ld: %s"), + smsg(0, _("Conversion failure for word in %s line %ld: %s"), fname, lnum, rline); continue; } @@ -3695,10 +3696,10 @@ static int spell_read_wordfile(spellinfo_T *spin, char *fname) line++; if (strncmp(line, "encoding=", 9) == 0) { if (spin->si_conv.vc_type != CONV_NONE) { - smsg(_("Duplicate /encoding= line ignored in %s line %ld: %s"), + smsg(0, _("Duplicate /encoding= line ignored in %s line %ld: %s"), fname, lnum, line - 1); } else if (did_word) { - smsg(_("/encoding= line after word ignored in %s line %ld: %s"), + smsg(0, _("/encoding= line after word ignored in %s line %ld: %s"), fname, lnum, line - 1); } else { char *enc; @@ -3708,7 +3709,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char *fname) enc = enc_canonize(line); if (!spin->si_ascii && convert_setup(&spin->si_conv, enc, p_enc) == FAIL) { - smsg(_("Conversion in %s not supported: from %s to %s"), + smsg(0, _("Conversion in %s not supported: from %s to %s"), fname, line, p_enc); } xfree(enc); @@ -3719,12 +3720,12 @@ static int spell_read_wordfile(spellinfo_T *spin, char *fname) if (strncmp(line, "regions=", 8) == 0) { if (spin->si_region_count > 1) { - smsg(_("Duplicate /regions= line ignored in %s line %ld: %s"), + smsg(0, _("Duplicate /regions= line ignored in %s line %ld: %s"), fname, lnum, line); } else { line += 8; if (strlen(line) > MAXREGIONS * 2) { - smsg(_("Too many regions in %s line %ld: %s"), + smsg(0, _("Too many regions in %s line %ld: %s"), fname, lnum, line); } else { spin->si_region_count = (int)strlen(line) / 2; @@ -3737,7 +3738,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char *fname) continue; } - smsg(_("/ line ignored in %s line %ld: %s"), + smsg(0, _("/ line ignored in %s line %ld: %s"), fname, lnum, line - 1); continue; } @@ -3764,13 +3765,13 @@ static int spell_read_wordfile(spellinfo_T *spin, char *fname) l = (uint8_t)(*p) - '0'; if (l == 0 || l > spin->si_region_count) { - smsg(_("Invalid region nr in %s line %ld: %s"), + smsg(0, _("Invalid region nr in %s line %ld: %s"), fname, lnum, p); break; } regionmask |= 1 << (l - 1); } else { - smsg(_("Unrecognized flags in %s line %ld: %s"), + smsg(0, _("Unrecognized flags in %s line %ld: %s"), fname, lnum, p); break; } @@ -4047,7 +4048,7 @@ static int tree_add_word(spellinfo_T *spin, const char *word, wordnode_T *root, node = *prev; } #ifdef SPELL_PRINTTREE - smsg("Added \"%s\"", word); + smsg(0, "Added \"%s\"", word); spell_print_tree(root->wn_sibling); #endif @@ -4924,7 +4925,7 @@ static void spell_make_sugfile(spellinfo_T *spin, char *wfname) goto theend; } - smsg(_("Number of words after soundfolding: %" PRId64), + smsg(0, _("Number of words after soundfolding: %" PRId64), (int64_t)spin->si_spellbuf->b_ml.ml_line_count); // Compress the soundfold trie. @@ -5035,7 +5036,7 @@ static int sug_filltree(spellinfo_T *spin, slang_T *slang) } } - smsg(_("Total number of words: %d"), words_done); + smsg(0, _("Total number of words: %d"), words_done); return OK; } @@ -5398,7 +5399,7 @@ static void mkspell(int fcount, char **fnames, bool ascii, bool over_write, bool } if (spin.si_compflags != NULL && spin.si_nobreak) { - msg(_("Warning: both compounding and NOBREAK specified")); + msg(_("Warning: both compounding and NOBREAK specified"), 0); } if (!error && !got_int) { @@ -5468,7 +5469,7 @@ static void spell_message(const spellinfo_T *spin, char *str) if (!spin->si_verbose) { verbose_enter(); } - msg(str); + msg(str, 0); ui_flush(); if (!spin->si_verbose) { verbose_leave(); @@ -5584,7 +5585,7 @@ void spell_add_word(char *word, int len, SpellAddType what, int idx, bool undo) fputc('#', fd); if (undo) { home_replace(NULL, fname, NameBuff, MAXPATHL, true); - smsg(_("Word '%.*s' removed from %s"), len, word, NameBuff); + smsg(0, _("Word '%.*s' removed from %s"), len, word, NameBuff); } } if (fseek(fd, fpos_next, SEEK_SET) != 0) { @@ -5634,7 +5635,7 @@ void spell_add_word(char *word, int len, SpellAddType what, int idx, bool undo) fclose(fd); home_replace(NULL, fname, NameBuff, MAXPATHL, true); - smsg(_("Word '%.*s' added to %s"), len, word, NameBuff); + smsg(0, _("Word '%.*s' added to %s"), len, word, NameBuff); } } diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c index ba389cc070..2ee93b4934 100644 --- a/src/nvim/spellsuggest.c +++ b/src/nvim/spellsuggest.c @@ -7,6 +7,7 @@ #include <inttypes.h> #include <limits.h> #include <stdbool.h> +#include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -18,7 +19,6 @@ #include "nvim/cursor.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/fileio.h" #include "nvim/garray.h" #include "nvim/getchar.h" @@ -34,6 +34,7 @@ #include "nvim/message.h" #include "nvim/normal.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/fs.h" #include "nvim/os/input.h" #include "nvim/os/os_defs.h" @@ -526,10 +527,10 @@ void spell_suggest(int count) true, need_cap, true); if (GA_EMPTY(&sug.su_ga)) { - msg(_("Sorry, no suggestions")); + msg(_("Sorry, no suggestions"), 0); } else if (count > 0) { if (count > sug.su_ga.ga_len) { - smsg(_("Sorry, only %" PRId64 " suggestions"), + smsg(0, _("Sorry, only %" PRId64 " suggestions"), (int64_t)sug.su_ga.ga_len); } } else { @@ -1480,9 +1481,9 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun int j; // print the stack of changes that brought us here - smsg("------ %s -------", fword); + smsg(0, "------ %s -------", fword); for (j = 0; j < depth; j++) { - smsg("%s", changename[j]); + smsg(0, "%s", changename[j]); } } #endif diff --git a/src/nvim/state.c b/src/nvim/state.c index 9a65e25a90..424fda2ede 100644 --- a/src/nvim/state.c +++ b/src/nvim/state.c @@ -7,13 +7,10 @@ #include "nvim/ascii.h" #include "nvim/autocmd.h" -#include "nvim/buffer_defs.h" #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/event/defs.h" -#include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" #include "nvim/getchar.h" #include "nvim/globals.h" @@ -23,6 +20,7 @@ #include "nvim/macros.h" #include "nvim/main.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/input.h" #include "nvim/state.h" #include "nvim/strings.h" diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 4d318f8c59..1529b63812 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -16,6 +16,7 @@ #include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/digraph.h" +#include "nvim/drawline.h" #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval_defs.h" @@ -30,9 +31,9 @@ #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/move.h" #include "nvim/normal.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/os.h" #include "nvim/path.h" @@ -41,7 +42,6 @@ #include "nvim/sign.h" #include "nvim/statusline.h" #include "nvim/strings.h" -#include "nvim/types.h" #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/vim.h" @@ -62,8 +62,6 @@ typedef enum { /// If inversion is possible we use it. Else '=' characters are used. void win_redr_status(win_T *wp) { - int row; - int col; char *p; int len; int fillchar; @@ -151,16 +149,15 @@ void win_redr_status(win_T *wp) } } - row = is_stl_global ? (Rows - (int)p_ch - 1) : W_ENDROW(wp); - col = is_stl_global ? 0 : wp->w_wincol; - int width = grid_puts(&default_grid, p, -1, row, col, attr); - grid_fill(&default_grid, row, row + 1, width + col, - this_ru_col + col, fillchar, fillchar, attr); + grid_line_start(&default_grid, is_stl_global ? (Rows - (int)p_ch - 1) : W_ENDROW(wp)); + int col = is_stl_global ? 0 : wp->w_wincol; + + int width = grid_line_puts(col, p, -1, attr); + grid_line_fill(width + col, this_ru_col + col, fillchar, attr); if (get_keymap_str(wp, "<%s>", NameBuff, MAXPATHL) && this_ru_col - len > (int)(strlen(NameBuff) + 1)) { - grid_puts(&default_grid, NameBuff, -1, row, - (int)((size_t)this_ru_col - strlen(NameBuff) - 1), attr); + grid_line_puts((int)((size_t)this_ru_col - strlen(NameBuff) - 1), NameBuff, -1, attr); } win_redr_ruler(wp); @@ -170,10 +167,11 @@ void win_redr_status(win_T *wp) const int sc_width = MIN(10, this_ru_col - len - 2); if (sc_width > 0) { - grid_puts(&default_grid, showcmd_buf, sc_width, row, - wp->w_wincol + this_ru_col - sc_width - 1, attr); + grid_line_puts(wp->w_wincol + this_ru_col - sc_width - 1, showcmd_buf, sc_width, attr); } } + + grid_line_flush(); } // May need to draw the character below the vertical separator. @@ -419,7 +417,9 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) int start_col = col; // Draw each snippet with the specified highlighting. - grid_line_start(grid, row); + if (!draw_ruler) { + grid_line_start(grid, row); + } int curattr = attr; char *p = buf; @@ -448,7 +448,9 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) // fill up with "fillchar" grid_line_fill(col, maxcol, fillchar, curattr); - grid_line_flush(false); + if (!draw_ruler) { + grid_line_flush(); + } // Fill the tab_page_click_defs, w_status_click_defs or w_winbar_click_defs array for clicking // in the tab page line, status line or window bar @@ -481,6 +483,7 @@ void win_redr_winbar(win_T *wp) entered = false; } +/// must be called after a grid_line_start() at the intended row void win_redr_ruler(win_T *wp) { bool is_stl_global = global_stl_height() > 0; @@ -516,36 +519,28 @@ void win_redr_ruler(win_T *wp) && *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum) == NUL; int width; - int row; int fillchar; int attr; int off; bool part_of_status = false; if (wp->w_status_height) { - row = W_ENDROW(wp); fillchar = fillchar_status(&attr, wp); off = wp->w_wincol; width = wp->w_width; part_of_status = true; } else if (is_stl_global) { - row = Rows - (int)p_ch - 1; fillchar = fillchar_status(&attr, wp); off = 0; width = Columns; part_of_status = true; } else { - row = Rows - 1; fillchar = ' '; attr = HL_ATTR(HLF_MSG); width = Columns; off = 0; } - if (!part_of_status && p_ch == 0 && !ui_has(kUIMessages)) { - return; - } - // In list mode virtcol needs to be recomputed colnr_T virtcol = wp->w_virtcol; if (wp->w_p_list && wp->w_p_lcs_chars.tab1 == NUL) { @@ -617,11 +612,8 @@ void win_redr_ruler(win_T *wp) } } - ScreenGrid *grid = part_of_status ? &default_grid : &msg_grid_adj; - grid_puts(grid, buffer, -1, row, this_ru_col + off, attr); - grid_fill(grid, row, row + 1, - this_ru_col + off + (int)strlen(buffer), off + width, fillchar, - fillchar, attr); + int w = grid_line_puts(this_ru_col + off, buffer, -1, attr); + grid_line_fill(this_ru_col + off + w, off + width, fillchar, attr); } } @@ -741,6 +733,7 @@ void draw_tabline(void) int c; int len; char *p; + grid_line_start(&default_grid, 0); FOR_ALL_TABS(tp) { tabcount++; } @@ -775,14 +768,14 @@ void draw_tabline(void) attr = win_hl_attr(cwp, HLF_TPS); } if (use_sep_chars && col > 0) { - grid_putchar(&default_grid, '|', 0, col++, attr); + grid_line_put_schar(col++, schar_from_ascii('|'), attr); } if (tp->tp_topframe != topframe) { attr = win_hl_attr(cwp, HLF_TP); } - grid_putchar(&default_grid, ' ', 0, col++, attr); + grid_line_put_schar(col++, schar_from_ascii(' '), attr); int modified = false; @@ -799,14 +792,14 @@ void draw_tabline(void) if (col + len >= Columns - 3) { break; } - grid_puts(&default_grid, NameBuff, len, 0, col, - hl_combine_attr(attr, win_hl_attr(cwp, HLF_T))); + grid_line_puts(col, NameBuff, len, + hl_combine_attr(attr, win_hl_attr(cwp, HLF_T))); col += len; } if (modified) { - grid_puts(&default_grid, "+", 1, 0, col++, attr); + grid_line_put_schar(col++, schar_from_ascii('+'), attr); } - grid_putchar(&default_grid, ' ', 0, col++, attr); + grid_line_put_schar(col++, schar_from_ascii(' '), attr); } int room = scol - col + tabwidth - 1; @@ -824,10 +817,10 @@ void draw_tabline(void) len = Columns - col - 1; } - grid_puts(&default_grid, p, (int)strlen(p), 0, col, attr); + grid_line_puts(col, p, -1, attr); col += len; } - grid_putchar(&default_grid, ' ', 0, col++, attr); + grid_line_put_schar(col++, schar_from_ascii(' '), attr); // Store the tab page number in tab_page_click_defs[], so that // jump_to_mouse() knows where each one is. @@ -846,27 +839,29 @@ void draw_tabline(void) } else { c = ' '; } - grid_fill(&default_grid, 0, 1, col, Columns, c, c, attr_fill); + grid_line_fill(col, Columns, c, attr_fill); // Draw the 'showcmd' information if 'showcmdloc' == "tabline". if (p_sc && *p_sloc == 't') { const int sc_width = MIN(10, (int)Columns - col - (tabcount > 1) * 3); if (sc_width > 0) { - grid_puts(&default_grid, showcmd_buf, sc_width, 0, - Columns - sc_width - (tabcount > 1) * 2, attr_nosel); + grid_line_puts(Columns - sc_width - (tabcount > 1) * 2, + showcmd_buf, sc_width, attr_nosel); } } // Put an "X" for closing the current tab if there are several. if (tabcount > 1) { - grid_putchar(&default_grid, 'X', 0, Columns - 1, attr_nosel); + grid_line_put_schar(Columns - 1, schar_from_ascii('X'), attr_nosel); tab_page_click_defs[Columns - 1] = (StlClickDefinition) { .type = kStlClickTabClose, .tabnr = 999, .func = NULL, }; } + + grid_line_flush(); } // Reset the flag here again, in case evaluating 'tabline' causes it to be diff --git a/src/nvim/strings.c b/src/nvim/strings.c index 661dae7592..0d307a760f 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -21,6 +21,7 @@ #include "nvim/ex_docmd.h" #include "nvim/garray.h" #include "nvim/gettext.h" +#include "nvim/globals.h" #include "nvim/macros.h" #include "nvim/math.h" #include "nvim/mbyte.h" @@ -33,19 +34,19 @@ #include "nvim/vim.h" static const char e_cannot_mix_positional_and_non_positional_str[] - = N_("E1400: Cannot mix positional and non-positional arguments: %s"); + = N_("E1500: Cannot mix positional and non-positional arguments: %s"); static const char e_fmt_arg_nr_unused_str[] - = N_("E1401: format argument %d unused in $-style format: %s"); + = N_("E1501: format argument %d unused in $-style format: %s"); static const char e_positional_num_field_spec_reused_str_str[] - = N_("E1402: Positional argument %d used as field width reused as different type: %s/%s"); + = N_("E1502: Positional argument %d used as field width reused as different type: %s/%s"); static const char e_positional_nr_out_of_bounds_str[] - = N_("E1403: Positional argument %d out of bounds: %s"); + = N_("E1503: Positional argument %d out of bounds: %s"); static const char e_positional_arg_num_type_inconsistent_str_str[] - = N_("E1404: Positional argument %d type used inconsistently: %s/%s"); + = N_("E1504: Positional argument %d type used inconsistently: %s/%s"); static const char e_invalid_format_specifier_str[] - = N_("E1405: Invalid format specifier: %s"); + = N_("E1505: Invalid format specifier: %s"); static const char e_aptypes_is_null_nr_str[] - = "E1408: Internal error: ap_types or ap_types[idx] is NULL: %d: %s"; + = "E1520: Internal error: ap_types or ap_types[idx] is NULL: %d: %s"; static const char typename_unknown[] = N_("unknown"); static const char typename_int[] = N_("int"); diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 7e3ae4a62c..9b238e6ff9 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6,6 +6,7 @@ #include <assert.h> #include <inttypes.h> #include <stdbool.h> +#include <stddef.h> #include <stdlib.h> #include <string.h> @@ -33,7 +34,7 @@ #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/path.h" @@ -2713,7 +2714,7 @@ static int syn_regexec(regmmatch_T *rmp, linenr_T lnum, colnr_T col, syn_time_T } if (timed_out && !syn_win->w_s->b_syn_slow) { syn_win->w_s->b_syn_slow = true; - msg(_("'redrawtime' exceeded, syntax highlighting disabled")); + msg(_("'redrawtime' exceeded, syntax highlighting disabled"), 0); } if (r > 0) { @@ -2816,9 +2817,9 @@ static void syn_cmd_conceal(exarg_T *eap, int syncing) next = skiptowhite(arg); if (*arg == NUL) { if (curwin->w_s->b_syn_conceal) { - msg("syntax conceal on"); + msg("syntax conceal on", 0); } else { - msg("syntax conceal off"); + msg("syntax conceal off", 0); } } else if (STRNICMP(arg, "on", 2) == 0 && next - arg == 2) { curwin->w_s->b_syn_conceal = true; @@ -2843,9 +2844,9 @@ static void syn_cmd_case(exarg_T *eap, int syncing) next = skiptowhite(arg); if (*arg == NUL) { if (curwin->w_s->b_syn_ic) { - msg("syntax case ignore"); + msg("syntax case ignore", 0); } else { - msg("syntax case match"); + msg("syntax case match", 0); } } else if (STRNICMP(arg, "match", 5) == 0 && next - arg == 5) { curwin->w_s->b_syn_ic = false; @@ -2870,9 +2871,9 @@ static void syn_cmd_foldlevel(exarg_T *eap, int syncing) if (*arg == NUL) { switch (curwin->w_s->b_syn_foldlevel) { case SYNFLD_START: - msg("syntax foldlevel start"); break; + msg("syntax foldlevel start", 0); break; case SYNFLD_MINIMUM: - msg("syntax foldlevel minimum"); break; + msg("syntax foldlevel minimum", 0); break; default: break; } @@ -2909,11 +2910,11 @@ static void syn_cmd_spell(exarg_T *eap, int syncing) next = skiptowhite(arg); if (*arg == NUL) { if (curwin->w_s->b_syn_spell == SYNSPL_TOP) { - msg("syntax spell toplevel"); + msg("syntax spell toplevel", 0); } else if (curwin->w_s->b_syn_spell == SYNSPL_NOTOP) { - msg("syntax spell notoplevel"); + msg("syntax spell notoplevel", 0); } else { - msg("syntax spell default"); + msg("syntax spell default", 0); } } else if (STRNICMP(arg, "toplevel", 8) == 0 && next - arg == 8) { curwin->w_s->b_syn_spell = SYNSPL_TOP; @@ -2946,9 +2947,9 @@ static void syn_cmd_iskeyword(exarg_T *eap, int syncing) msg_puts("\n"); if (curwin->w_s->b_syn_isk != empty_option) { msg_puts("syntax iskeyword "); - msg_outtrans(curwin->w_s->b_syn_isk); + msg_outtrans(curwin->w_s->b_syn_isk, 0); } else { - msg_outtrans(_("syntax iskeyword not set")); + msg_outtrans(_("syntax iskeyword not set"), 0); } } else { if (STRNICMP(arg, "clear", 5) == 0) { @@ -3235,7 +3236,7 @@ static void syn_cmd_list(exarg_T *eap, int syncing) } if (!syntax_present(curwin)) { - msg(_(msg_no_items)); + msg(_(msg_no_items), 0); return; } @@ -3427,7 +3428,7 @@ static void syn_list_one(const int id, const bool syncing, const bool link_only) msg_putchar(' '); if (spp->sp_sync_idx >= 0) { msg_outtrans(highlight_group_name(SYN_ITEMS(curwin->w_s) - [spp->sp_sync_idx].sp_syn.id - 1)); + [spp->sp_sync_idx].sp_syn.id - 1), 0); } else { msg_puts("NONE"); } @@ -3440,7 +3441,7 @@ static void syn_list_one(const int id, const bool syncing, const bool link_only) (void)syn_list_header(did_header, 0, id, true); msg_puts_attr("links to", attr); msg_putchar(' '); - msg_outtrans(highlight_group_name(highlight_link_id(id - 1) - 1)); + msg_outtrans(highlight_group_name(highlight_link_id(id - 1) - 1), 0); } } @@ -3461,7 +3462,7 @@ static void syn_list_cluster(int id) // slight hack: roughly duplicate the guts of syn_list_header() msg_putchar('\n'); - msg_outtrans(SYN_CLSTR(curwin->w_s)[id].scl_name); + msg_outtrans(SYN_CLSTR(curwin->w_s)[id].scl_name, 0); if (msg_col >= endcol) { // output at least one space endcol = msg_col + 1; @@ -3498,9 +3499,9 @@ static void put_id_list(const char *const name, const int16_t *const list, const int scl_id = *p - SYNID_CLUSTER; msg_putchar('@'); - msg_outtrans(SYN_CLSTR(curwin->w_s)[scl_id].scl_name); + msg_outtrans(SYN_CLSTR(curwin->w_s)[scl_id].scl_name, 0); } else { - msg_outtrans(highlight_group_name(*p - 1)); + msg_outtrans(highlight_group_name(*p - 1), 0); } if (p[1]) { msg_putchar(','); @@ -3520,9 +3521,9 @@ static void put_pattern(const char *const s, const int c, const synpat_T *const msg_puts_attr("matchgroup", attr); msg_putchar('='); if (last_matchgroup == 0) { - msg_outtrans("NONE"); + msg_outtrans("NONE", 0); } else { - msg_outtrans(highlight_group_name(last_matchgroup - 1)); + msg_outtrans(highlight_group_name(last_matchgroup - 1), 0); } msg_putchar(' '); } @@ -3539,7 +3540,7 @@ static void put_pattern(const char *const s, const int c, const synpat_T *const } } msg_putchar(sepchars[i]); - msg_outtrans(spp->sp_pattern); + msg_outtrans(spp->sp_pattern, 0); msg_putchar(sepchars[i]); // output any pattern options @@ -3649,7 +3650,7 @@ static bool syn_list_keywords(const int id, const hashtab_T *const ht, bool did_ prev_skipempty = (kp->flags & HL_SKIPEMPTY); } } - msg_outtrans(kp->keyword); + msg_outtrans(kp->keyword, 0); } } } @@ -5590,7 +5591,7 @@ static void syntime_clear(void) synpat_T *spp; if (!syntax_present(curwin)) { - msg(_(msg_no_items)); + msg(_(msg_no_items), 0); return; } for (int idx = 0; idx < curwin->w_s->b_syn_patterns.ga_len; idx++) { @@ -5628,7 +5629,7 @@ static int syn_compare_syntime(const void *v1, const void *v2) static void syntime_report(void) { if (!syntax_present(curwin)) { - msg(_(msg_no_items)); + msg(_(msg_no_items), 0); return; } @@ -5682,7 +5683,7 @@ static void syntime_report(void) msg_puts(profile_msg(p->average)); msg_puts(" "); msg_advance(50); - msg_outtrans(highlight_group_name(p->id - 1)); + msg_outtrans(highlight_group_name(p->id - 1), 0); msg_puts(" "); msg_advance(69); @@ -5695,7 +5696,7 @@ static void syntime_report(void) if (len > (int)strlen(p->pattern)) { len = (int)strlen(p->pattern); } - msg_outtrans_len(p->pattern, len); + msg_outtrans_len(p->pattern, len, 0); msg_puts("\n"); } ga_clear(&ga); diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 8bbfb663bd..636d16d4e6 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -20,7 +20,6 @@ #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" @@ -42,6 +41,8 @@ #include "nvim/message.h" #include "nvim/move.h" #include "nvim/option.h" +#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/os/os.h" @@ -719,7 +720,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) // Only when going to try the next match, report that the previous // file didn't exist. Otherwise an emsg() is given below. if (nofile_fname != NULL && error_cur_match != cur_match) { - smsg(_("File \"%s\" does not exist"), nofile_fname); + smsg(0, _("File \"%s\" does not exist"), nofile_fname); } ic = (matches[cur_match][0] & MT_IC_OFF); @@ -736,11 +737,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) } if ((num_matches > prev_num_matches || new_tag) && num_matches > 1) { - if (ic) { - msg_attr(IObuff, HL_ATTR(HLF_W)); - } else { - msg(IObuff); - } + msg(IObuff, ic ? HL_ATTR(HLF_W) : 0); msg_scroll = true; // Don't overwrite this message. } else { give_warning(IObuff, ic); @@ -847,13 +844,10 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char mt_names[matches[i][0] & MT_MASK]); msg_puts(IObuff); if (tagp.tagkind != NULL) { - msg_outtrans_len(tagp.tagkind, - (int)(tagp.tagkind_end - tagp.tagkind)); + msg_outtrans_len(tagp.tagkind, (int)(tagp.tagkind_end - tagp.tagkind), 0); } msg_advance(13); - msg_outtrans_len_attr(tagp.tagname, - (int)(tagp.tagname_end - tagp.tagname), - HL_ATTR(HLF_T)); + msg_outtrans_len(tagp.tagname, (int)(tagp.tagname_end - tagp.tagname), HL_ATTR(HLF_T)); msg_putchar(' '); taglen_advance(taglen); @@ -861,7 +855,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char // it and put "..." in the middle p = tag_full_fname(&tagp); if (p != NULL) { - msg_outtrans_attr(p, HL_ATTR(HLF_D)); + msg_outtrans(p, HL_ATTR(HLF_D)); XFREE_CLEAR(p); } if (msg_col > 0) { @@ -1149,9 +1143,8 @@ void do_tags(exarg_T *eap) tagstack[i].cur_match + 1, tagstack[i].tagname, tagstack[i].fmark.mark.lnum); - msg_outtrans(IObuff); - msg_outtrans_attr(name, tagstack[i].fmark.fnum == curbuf->b_fnum - ? HL_ATTR(HLF_D) : 0); + msg_outtrans(IObuff, 0); + msg_outtrans(name, tagstack[i].fmark.fnum == curbuf->b_fnum ? HL_ATTR(HLF_D) : 0); xfree(name); } } @@ -2219,7 +2212,7 @@ static void findtags_in_file(findtags_state_T *st, int flags, char *buf_ffname) if (p_verbose >= 5) { verbose_enter(); - smsg(_("Searching tags file %s"), st->tag_fname); + smsg(0, _("Searching tags file %s"), st->tag_fname); verbose_leave(); } st->did_open = true; // remember that we found at least one file @@ -3019,7 +3012,7 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help) // Only give a message when really guessed, not when 'ic' // is set and match found while ignoring case. if (found == 2 || !save_p_ic) { - msg(_("E435: Couldn't find tag, just guessing!")); + msg(_("E435: Couldn't find tag, just guessing!"), 0); if (!msg_scrolled && msg_silent == 0) { ui_flush(); os_delay(1010L, true); @@ -3287,7 +3280,7 @@ static int add_tag_field(dict_T *dict, const char *field_name, const char *start if (tv_dict_find(dict, field_name, -1) != NULL) { if (p_verbose > 0) { verbose_enter(); - smsg(_("Duplicate field name: %s"), field_name); + smsg(0, _("Duplicate field name: %s"), field_name); verbose_leave(); } return FAIL; diff --git a/src/nvim/tag.h b/src/nvim/tag.h index e08145f727..90ef0384a1 100644 --- a/src/nvim/tag.h +++ b/src/nvim/tag.h @@ -2,6 +2,7 @@ #define NVIM_TAG_H #include "nvim/ex_cmds_defs.h" +#include "nvim/option_defs.h" #include "nvim/types.h" // Values for do_tag(). diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 5e0ff072fb..169525da20 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -59,8 +59,6 @@ #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" -#include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" #include "nvim/event/time.h" #include "nvim/ex_docmd.h" @@ -81,6 +79,7 @@ #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/pos.h" #include "nvim/state.h" @@ -438,8 +437,8 @@ bool terminal_enter(void) char *save_w_p_culopt = NULL; uint8_t save_w_p_culopt_flags = curwin->w_p_culopt_flags; int save_w_p_cuc = curwin->w_p_cuc; - long save_w_p_so = curwin->w_p_so; - long save_w_p_siso = curwin->w_p_siso; + OptInt save_w_p_so = curwin->w_p_so; + OptInt save_w_p_siso = curwin->w_p_siso; if (curwin->w_p_cul && curwin->w_p_culopt_flags & CULOPT_NBR) { if (strcmp(curwin->w_p_culopt, "number") != 0) { save_w_p_culopt = curwin->w_p_culopt; diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c index 6d82179796..0de62440f9 100644 --- a/src/nvim/textformat.c +++ b/src/nvim/textformat.c @@ -31,13 +31,13 @@ #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/input.h" #include "nvim/pos.h" #include "nvim/search.h" #include "nvim/strings.h" #include "nvim/textformat.h" #include "nvim/textobject.h" -#include "nvim/types.h" #include "nvim/undo.h" #include "nvim/vim.h" #include "nvim/window.h" diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index c40888b85d..18a56c74ca 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -9,7 +9,6 @@ #include <string.h> #include "nvim/ascii.h" -#include "nvim/buffer_defs.h" #include "nvim/cursor.h" #include "nvim/drawscreen.h" #include "nvim/edit.h" @@ -24,7 +23,7 @@ #include "nvim/memory.h" #include "nvim/move.h" #include "nvim/normal.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/pos.h" #include "nvim/search.h" #include "nvim/strings.h" diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index edf8cbe237..487f8b010e 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -5,6 +5,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <uv.h> #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" @@ -16,8 +17,7 @@ #include "nvim/main.h" #include "nvim/map.h" #include "nvim/memory.h" -#include "nvim/option.h" -#include "nvim/os/input.h" +#include "nvim/option_vars.h" #include "nvim/os/os.h" #include "nvim/tui/input.h" #include "nvim/tui/input_defs.h" @@ -763,8 +763,8 @@ static void tinput_read_cb(Stream *stream, RBuffer *buf, size_t count_, void *da if (rbuffer_size(input->read_stream.buffer)) { // If 'ttimeout' is not set, start the timer with a timeout of 0 to process // the next input. - long ms = input->ttimeout ? - (input->ttimeoutlen >= 0 ? input->ttimeoutlen : 0) : 0; + int64_t ms = input->ttimeout ? + (input->ttimeoutlen >= 0 ? input->ttimeoutlen : 0) : 0; // Stop the current timer if already running time_watcher_stop(&input->timer_handle); time_watcher_start(&input->timer_handle, tinput_timer_cb, (uint32_t)ms, 0); diff --git a/src/nvim/tui/input.h b/src/nvim/tui/input.h index da565fbb6f..f631860e74 100644 --- a/src/nvim/tui/input.h +++ b/src/nvim/tui/input.h @@ -12,6 +12,7 @@ #include "nvim/rbuffer.h" #include "nvim/tui/input_defs.h" #include "nvim/tui/tui.h" +#include "nvim/types.h" typedef enum { kExtkeysNone, @@ -27,7 +28,7 @@ typedef struct term_input { int8_t waiting_for_bg_response; int8_t waiting_for_csiu_response; ExtkeysType extkeys_type; - long ttimeoutlen; + OptInt ttimeoutlen; TermKey *tk; TermKey_Terminfo_Getstr_Hook *tk_ti_hook_fn; ///< libtermkey terminfo hook TimeWatcher timer_handle; diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index db15cdb053..944c1d14c2 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -25,7 +25,6 @@ #include "nvim/event/stream.h" #include "nvim/globals.h" #include "nvim/grid.h" -#include "nvim/grid_defs.h" #include "nvim/highlight_defs.h" #include "nvim/log.h" #include "nvim/macros.h" diff --git a/src/nvim/types.h b/src/nvim/types.h index afc1b3f5fe..c2c815a0bc 100644 --- a/src/nvim/types.h +++ b/src/nvim/types.h @@ -52,4 +52,6 @@ typedef struct Decoration Decoration; # endif #endif +typedef int64_t OptInt; + #endif // NVIM_TYPES_H diff --git a/src/nvim/ui.c b/src/nvim/ui.c index ba16ba545f..954d933d9c 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -30,6 +30,7 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/time.h" #include "nvim/strings.h" #include "nvim/ui.h" @@ -332,7 +333,7 @@ void vim_beep(unsigned val) // comes from. if (vim_strchr(p_debug, 'e') != NULL) { msg_source(HL_ATTR(HLF_W)); - msg_attr(_("Beep!"), HL_ATTR(HLF_W)); + msg(_("Beep!"), HL_ATTR(HLF_W)); } } @@ -439,7 +440,7 @@ void ui_line(ScreenGrid *grid, int row, int startcol, int endcol, int clearcol, ui_call_grid_cursor_goto(grid->handle, row, MIN(clearcol, (int)grid->cols - 1)); ui_call_flush(); - uint64_t wd = (uint64_t)labs(p_wd); + uint64_t wd = (uint64_t)llabs(p_wd); os_sleep(wd); pending_cursor_update = true; // restore the cursor later } @@ -522,7 +523,7 @@ void ui_flush(void) ui_call_flush(); if (p_wd && (rdb_flags & RDB_FLUSH)) { - os_sleep((uint64_t)labs(p_wd)); + os_sleep((uint64_t)llabs(p_wd)); } } diff --git a/src/nvim/ui_client.c b/src/nvim/ui_client.c index cc564f4777..8e60af478b 100644 --- a/src/nvim/ui_client.c +++ b/src/nvim/ui_client.c @@ -7,6 +7,8 @@ #include <stdint.h> #include <stdlib.h> +#include "nvim/api/keysets.h" +#include "nvim/api/private/dispatch.h" #include "nvim/api/private/helpers.h" #include "nvim/channel.h" #include "nvim/eval.h" diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c index b88c355f42..0f26e269ae 100644 --- a/src/nvim/ui_compositor.c +++ b/src/nvim/ui_compositor.c @@ -17,7 +17,6 @@ #include "klib/kvec.h" #include "nvim/api/private/defs.h" #include "nvim/ascii.h" -#include "nvim/buffer_defs.h" #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/highlight.h" @@ -26,7 +25,7 @@ #include "nvim/macros.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/os/time.h" #include "nvim/types.h" #include "nvim/ui.h" @@ -461,7 +460,7 @@ static void compose_debug(Integer startrow, Integer endrow, Integer startcol, In static void debug_delay(Integer lines) { ui_call_flush(); - uint64_t wd = (uint64_t)labs(p_wd); + uint64_t wd = (uint64_t)llabs(p_wd); uint64_t factor = (uint64_t)MAX(MIN(lines, 5), 1); os_sleep(factor * wd); } diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 1194eeca35..5396bfcda2 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -95,7 +95,6 @@ #include "nvim/edit.h" #include "nvim/eval/funcs.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" @@ -113,6 +112,7 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/fs_defs.h" #include "nvim/os/input.h" #include "nvim/os/os.h" @@ -183,12 +183,12 @@ static void u_check_tree(u_header_T *uhp, u_header_T *exp_uh_next, u_header_T *e // Check pointers back are correct. if (uhp->uh_next.ptr != exp_uh_next) { emsg("uh_next wrong"); - smsg("expected: 0x%x, actual: 0x%x", + smsg(0, "expected: 0x%x, actual: 0x%x", exp_uh_next, uhp->uh_next.ptr); } if (uhp->uh_alt_prev.ptr != exp_uh_alt_prev) { emsg("uh_alt_prev wrong"); - smsg("expected: 0x%x, actual: 0x%x", + smsg(0, "expected: 0x%x, actual: 0x%x", exp_uh_alt_prev, uhp->uh_alt_prev.ptr); } @@ -225,7 +225,7 @@ static void u_check(int newhead_may_be_NULL) } if (header_count != curbuf->b_u_numhead) { emsg("b_u_numhead invalid"); - smsg("expected: %" PRId64 ", actual: %" PRId64, + smsg(0, "expected: %" PRId64 ", actual: %" PRId64, (int64_t)header_count, (int64_t)curbuf->b_u_numhead); } } @@ -324,7 +324,7 @@ bool undo_allowed(buf_T *buf) } /// Get the 'undolevels' value for the current buffer. -static long get_undolevel(buf_T *buf) +static OptInt get_undolevel(buf_T *buf) { if (buf->b_p_ul == NO_LOCAL_UNDOLEVEL) { return p_ul; @@ -1179,7 +1179,7 @@ void u_write_undo(const char *const name, const bool forceit, buf_T *const buf, if (file_name == NULL) { if (p_verbose > 0) { verbose_enter(); - smsg("%s", _("Cannot write undo file in any directory in 'undodir'")); + smsg(0, "%s", _("Cannot write undo file in any directory in 'undodir'")); verbose_leave(); } return; @@ -1215,7 +1215,7 @@ void u_write_undo(const char *const name, const bool forceit, buf_T *const buf, if (name == NULL) { verbose_enter(); } - smsg(_("Will not overwrite with undo file, cannot read: %s"), + smsg(0, _("Will not overwrite with undo file, cannot read: %s"), file_name); if (name == NULL) { verbose_leave(); @@ -1232,7 +1232,7 @@ void u_write_undo(const char *const name, const bool forceit, buf_T *const buf, if (name == NULL) { verbose_enter(); } - smsg(_("Will not overwrite, this is not an undo file: %s"), + smsg(0, _("Will not overwrite, this is not an undo file: %s"), file_name); if (name == NULL) { verbose_leave(); @@ -1262,7 +1262,7 @@ void u_write_undo(const char *const name, const bool forceit, buf_T *const buf, (void)os_setperm(file_name, perm); if (p_verbose > 0) { verbose_enter(); - smsg(_("Writing undo file: %s"), file_name); + smsg(0, _("Writing undo file: %s"), file_name); verbose_leave(); } @@ -1399,7 +1399,7 @@ void u_read_undo(char *name, const uint8_t *hash, const char *orig_name FUNC_ATT && file_info_undo.stat.st_uid != getuid()) { if (p_verbose > 0) { verbose_enter(); - smsg(_("Not reading undo file, owner differs: %s"), + smsg(0, _("Not reading undo file, owner differs: %s"), file_name); verbose_leave(); } @@ -1412,7 +1412,7 @@ void u_read_undo(char *name, const uint8_t *hash, const char *orig_name FUNC_ATT if (p_verbose > 0) { verbose_enter(); - smsg(_("Reading undo file: %s"), file_name); + smsg(0, _("Reading undo file: %s"), file_name); verbose_leave(); } @@ -1648,7 +1648,7 @@ void u_read_undo(char *name, const uint8_t *hash, const char *orig_name FUNC_ATT #endif if (name != NULL) { - smsg(_("Finished reading undo file %s"), file_name); + smsg(0, _("Finished reading undo file %s"), file_name); } goto theend; @@ -1883,7 +1883,7 @@ static void u_doit(int startcount, bool quiet, bool do_buf_event) curbuf->b_u_curhead = curbuf->b_u_oldhead; beep_flush(); if (count == startcount - 1) { - msg(_("Already at oldest change")); + msg(_("Already at oldest change"), 0); return; } break; @@ -1894,7 +1894,7 @@ static void u_doit(int startcount, bool quiet, bool do_buf_event) if (curbuf->b_u_curhead == NULL || get_undolevel(curbuf) <= 0) { beep_flush(); // nothing to redo if (count == startcount - 1) { - msg(_("Already at newest change")); + msg(_("Already at newest change"), 0); return; } break; @@ -2118,9 +2118,9 @@ void undo_time(long step, bool sec, bool file, bool absolute) if (closest == closest_start) { if (step < 0) { - msg(_("Already at oldest change")); + msg(_("Already at oldest change"), 0); } else { - msg(_("Already at newest change")); + msg(_("Already at newest change"), 0); } return; } @@ -2719,7 +2719,7 @@ void ex_undolist(exarg_T *eap) } if (GA_EMPTY(&ga)) { - msg(_("Nothing to undo")); + msg(_("Nothing to undo"), 0); } else { sort_strings(ga.ga_data, ga.ga_len); diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c index 7ccd13c3a7..131b1ce3ef 100644 --- a/src/nvim/usercmd.c +++ b/src/nvim/usercmd.c @@ -30,7 +30,7 @@ #include "nvim/memory.h" #include "nvim/menu.h" #include "nvim/message.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/os/input.h" #include "nvim/runtime.h" #include "nvim/strings.h" @@ -495,7 +495,7 @@ static void uc_list(char *name, size_t name_len) msg_putchar(' '); } - msg_outtrans_attr(cmd->uc_name, HL_ATTR(HLF_D)); + msg_outtrans(cmd->uc_name, HL_ATTR(HLF_D)); len = strlen(cmd->uc_name) + 4; do { @@ -582,7 +582,7 @@ static void uc_list(char *name, size_t name_len) } while ((int64_t)len < 25 - over); IObuff[len] = '\0'; - msg_outtrans(IObuff); + msg_outtrans(IObuff, 0); if (cmd->uc_luaref != LUA_NOREF) { char *fn = nlua_funcref_str(cmd->uc_luaref); @@ -611,7 +611,7 @@ static void uc_list(char *name, size_t name_len) } if (!found) { - msg(_("No user-defined commands found")); + msg(_("No user-defined commands found"), 0); } } diff --git a/src/nvim/version.c b/src/nvim/version.c index 0744a601bb..20bbcb2f8a 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -9,11 +9,11 @@ #include <assert.h> #include <limits.h> #include <stdbool.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> -#include "auto/config.h" #include "auto/versiondef.h" // version info generated by the build system #include "auto/versiondef_git.h" #include "nvim/api/private/defs.h" @@ -31,8 +31,7 @@ #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/option_defs.h" -#include "nvim/os/os_defs.h" +#include "nvim/option_vars.h" #include "nvim/strings.h" #include "nvim/version.h" #include "nvim/vim.h" @@ -2691,19 +2690,19 @@ void list_lua_version(void) Object ret = nlua_exec(cstr_as_string(code), (Array)ARRAY_DICT_INIT, &err); assert(!ERROR_SET(&err)); assert(ret.type == kObjectTypeString); - msg(ret.data.string.data); + msg(ret.data.string.data, 0); api_free_object(ret); } void list_version(void) { - msg(longVersion); - msg(version_buildtype); + msg(longVersion, 0); + msg(version_buildtype, 0); list_lua_version(); if (p_verbose > 0) { #ifndef NDEBUG - msg(version_cflags); + msg(version_cflags, 0); #endif version_msg("\n\n"); diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index b53508bc6c..0ab58a8b37 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -61,7 +61,6 @@ #include "nvim/ascii.h" #include "nvim/assert.h" #include "nvim/charset.h" -#include "nvim/eval/typval.h" #include "nvim/gettext.h" #include "nvim/keycodes.h" #include "nvim/macros.h" @@ -938,7 +937,6 @@ static const char *intchar2str(const int ch) } #ifdef UNIT_TESTING -# include <stdio.h> REAL_FATTR_UNUSED static inline void viml_pexpr_debug_print_ast_node(const ExprASTNode *const *const eastnode_p, diff --git a/src/nvim/window.c b/src/nvim/window.c index 98fe96af87..41199306fa 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -27,7 +27,6 @@ #include "nvim/edit.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/eval/vars.h" #include "nvim/eval/window.h" #include "nvim/ex_cmds.h" @@ -52,13 +51,14 @@ #include "nvim/mark.h" #include "nvim/match.h" #include "nvim/mbyte.h" -#include "nvim/memline_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/mouse.h" #include "nvim/move.h" #include "nvim/normal.h" #include "nvim/option.h" +#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/os.h" #include "nvim/os/os_defs.h" @@ -380,7 +380,7 @@ newwindow: case 'T': CHECK_CMDWIN; if (one_window(curwin)) { - msg(_(m_onlyone)); + msg(_(m_onlyone), 0); } else { tabpage_T *oldtab = curtab; @@ -3981,7 +3981,7 @@ void close_others(int message, int forceit) if (one_nonfloat() && !lastwin->w_floating) { if (message && !autocmd_busy) { - msg(_(m_onlyone)); + msg(_(m_onlyone), 0); } return; } @@ -5750,7 +5750,7 @@ void win_size_restore(garray_T *gap) { if (win_count() * 2 + 1 == gap->ga_len && ((int *)gap->ga_data)[0] == - (int)ROWS_AVAIL + global_stl_height() - last_stl_height(false)) { + ROWS_AVAIL + global_stl_height() - last_stl_height(false)) { // The order matters, because frames contain other frames, but it's // difficult to get right. The easy way out is to do it twice. for (int j = 0; j < 2; j++) { @@ -6773,7 +6773,7 @@ void win_new_width(win_T *wp, int width) void win_comp_scroll(win_T *wp) { - const long old_w_p_scr = wp->w_p_scr; + const OptInt old_w_p_scr = wp->w_p_scr; wp->w_p_scr = wp->w_height_inner / 2; if (wp->w_p_scr == 0) { |