From ebd2372f928c6f1cfe823d36aabf479f6930232f Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Thu, 2 Feb 2023 23:56:25 +0100 Subject: refactor: use flexible arrays instead of the length-of-one trick (#22072) The "length-of-one" trick, where the last element of a struct is an array of size 1, but extra size is allocated when calling malloc where it uses more than 1 element in the array, cause problems with some compilers. Some compilers set _FORTIFY_SOURCE=2 by default which incorrectly considers it as an overflow. More information: https://github.com/neovim/neovim/issues/223#issuecomment-1413828554 Using flexible array members allows us to to properly convey to the compiler that its size may be larger than 1. This also enables us to remove lengthy workarounds that are unreliable, as they depend on CMAKE_BUILD_TYPE which isn't defined for multi-config generators. Closes: https://github.com/neovim/neovim/issues/223 --- src/nvim/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 3b3dfcd5b6..40453211b4 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -64,7 +64,7 @@ struct msgchunk_S { char sb_eol; // true when line ends after this text int sb_msg_col; // column in which text starts int sb_attr; // text attributes - char sb_text[1]; // text to be displayed, actually longer + char sb_text[]; // text to be displayed }; // Magic chars used in confirm dialog strings -- cgit From 4be6c6cf0ddf5e31d4103cb5df06651ba6f4897b Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Feb 2023 11:05:57 +0100 Subject: refactor: replace char_u with char (#21901) refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/message.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 40453211b4..88f58ef0df 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1085,7 +1085,7 @@ void ex_messages(void *const eap_p) } else if (p->msg && p->msg[0]) { Array content_entry = ARRAY_DICT_INIT; ADD(content_entry, INTEGER_OBJ(p->attr)); - ADD(content_entry, STRING_OBJ(cstr_to_string((char *)(p->msg)))); + ADD(content_entry, STRING_OBJ(cstr_to_string(p->msg))); ADD(content, ARRAY_OBJ(content_entry)); } ADD(entry, ARRAY_OBJ(content)); @@ -1470,9 +1470,9 @@ void msg_putchar_attr(int c, int attr) buf[2] = (char)K_THIRD(c); buf[3] = NUL; } else { - buf[utf_char2bytes(c, (char *)buf)] = NUL; + buf[utf_char2bytes(c, buf)] = NUL; } - msg_puts_attr((const char *)buf, attr); + msg_puts_attr(buf, attr); } void msg_outnum(long n) @@ -2139,7 +2139,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) int t_col = 0; // Screen cells todo, 0 when "t_s" not used. int l; int cw; - const char *sb_str = (char *)str; + const char *sb_str = str; int sb_col = msg_col; int wrap; int did_last_char; @@ -2153,7 +2153,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) } // Concat pieces with the same highlight size_t len = strnlen(str, (size_t)maxlen); // -V781 - ga_concat_len(&msg_ext_last_chunk, (char *)str, len); + ga_concat_len(&msg_ext_last_chunk, str, len); msg_ext_cur_len += len; return; } -- cgit From 27177e581902967dcf4f2f426464da1b636ca420 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Feb 2023 14:14:24 +0100 Subject: refactor: reduce scope of locals as per the style guide (#22211) --- src/nvim/message.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 88f58ef0df..4904bde095 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -369,14 +369,13 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline) char *msg_strtrunc(char *s, int force) { char *buf = NULL; - int len; - int room; // May truncate message to avoid a hit-return prompt if ((!msg_scroll && !need_wait_return && shortmess(SHM_TRUNCALL) && !exmode_active && msg_silent == 0 && !ui_has(kUIMessages)) || force) { - len = vim_strsize(s); + int room; + int len = vim_strsize(s); if (msg_scrolled != 0) { // Use all the columns. room = (Rows - msg_row) * Columns - 1; @@ -1033,7 +1032,6 @@ void ex_messages(void *const eap_p) { const exarg_T *const eap = (const exarg_T *)eap_p; struct msg_hist *p; - int c = 0; if (strcmp(eap->arg, "clear") == 0) { int keep = eap->addr_count == 0 ? 0 : eap->line2; @@ -1052,6 +1050,7 @@ void ex_messages(void *const eap_p) p = first_msg_hist; if (eap->addr_count != 0) { + int c = 0; // Count total messages for (; p != NULL && !got_int; p = p->next) { c++; @@ -1542,7 +1541,6 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr) const char *str = msgstr; const char *plain_start = msgstr; char *s; - int mb_l; int c; int save_got_int = got_int; @@ -1565,7 +1563,7 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr) // Normal characters are printed several at a time. while (--len >= 0 && !got_int) { // Don't include composing chars after the end. - mb_l = utfc_ptr2len_len(str, len + 1); + int mb_l = utfc_ptr2len_len(str, len + 1); if (mb_l > 1) { c = utf_ptr2char(str); if (vim_isprintc(c)) { @@ -2652,12 +2650,11 @@ void msg_sb_eol(void) static msgchunk_T *disp_sb_line(int row, msgchunk_T *smp) { msgchunk_T *mp = smp; - char *p; for (;;) { msg_row = row; msg_col = mp->sb_msg_col; - p = mp->sb_text; + char *p = mp->sb_text; if (*p == '\n') { // don't display the line break p++; } @@ -2767,7 +2764,6 @@ static int do_more_prompt(int typed_char) int oldState = State; int c; int retval = false; - int toscroll; bool to_redraw = false; msgchunk_T *mp_last = NULL; msgchunk_T *mp; @@ -2809,7 +2805,7 @@ static int do_more_prompt(int typed_char) c = get_keystroke(resize_events); } - toscroll = 0; + int toscroll = 0; switch (c) { case BS: // scroll one line back case K_BS: @@ -3507,7 +3503,6 @@ int do_dialog(int type, char *title, char *message, char *buttons, int dfltbutto { int retval = 0; char *hotkeys; - int c; int i; if (silent_mode // No dialogs in silent mode ("ex -s") @@ -3530,7 +3525,7 @@ int do_dialog(int type, char *title, char *message, char *buttons, int dfltbutto for (;;) { // Get a typed character directly from the user. - c = get_keystroke(NULL); + int c = get_keystroke(NULL); switch (c) { case CAR: // User accepts default option case NL: -- cgit From 0326ef2f41a5c18c6cfd2c1b1dda95f7b309a5c4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 17 Feb 2023 07:15:24 +0800 Subject: vim-patch:9.0.1314: :messages behavior depends on 'fileformat' of current buffer (#22286) Problem: :messages behavior depends on 'fileformat' of current buffer. Solution: Pass the buffer pointer to where it is used. (Mirko Ceroni, closes vim/vim#11995) https://github.com/vim/vim/commit/1d87e11a1ef201b26ed87585fba70182ad0c468a Co-authored-by: cero1988 --- src/nvim/message.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 4904bde095..dc88c53392 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -773,7 +773,7 @@ bool emsg(const char *s) void emsg_invreg(int name) { - semsg(_("E354: Invalid register name: '%s'"), transchar(name)); + semsg(_("E354: Invalid register name: '%s'"), transchar_buf(NULL, name)); } /// Print an error message with unknown number of arguments @@ -1531,7 +1531,7 @@ char *msg_outtrans_one(char *p, int attr) msg_outtrans_len_attr(p, l, attr); return p + l; } - msg_puts_attr((const char *)transchar_byte((uint8_t)(*p)), attr); + msg_puts_attr((const char *)transchar_byte_buf(NULL, (uint8_t)(*p)), attr); return p + 1; } @@ -1576,14 +1576,14 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr) msg_puts_attr_len(plain_start, str - plain_start, attr); } plain_start = str + mb_l; - msg_puts_attr((const char *)transchar(c), + msg_puts_attr((const char *)transchar_buf(NULL, c), (attr == 0 ? HL_ATTR(HLF_8) : attr)); retval += char2cells(c); } len -= mb_l - 1; str += mb_l; } else { - s = (char *)transchar_byte((uint8_t)(*str)); + s = (char *)transchar_byte_buf(NULL, (uint8_t)(*str)); if (s[1] != NUL) { // Unprintable char: print the printable chars so far and the // translation of the unprintable char. @@ -1665,7 +1665,7 @@ int msg_outtrans_special(const char *strstart, bool from, int maxlen) } if (text[0] != NUL && text[1] == NUL) { // single-byte character or illegal byte - text = (char *)transchar_byte((uint8_t)text[0]); + text = (char *)transchar_byte_buf(NULL, (uint8_t)text[0]); } const int len = vim_strsize((char *)text); if (maxlen > 0 && retval + len >= maxlen) { @@ -1911,7 +1911,7 @@ void msg_prt_line(char *s, int list) s--; } else if (c != NUL && (n = byte2cells(c)) > 1) { n_extra = n - 1; - p_extra = (char *)transchar_byte(c); + p_extra = (char *)transchar_byte_buf(NULL, c); c_extra = NUL; c_final = NUL; c = (unsigned char)(*p_extra++); -- cgit From d6ecead36406233cc56353dd05f3380f0497630f Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 14 Mar 2023 11:49:46 +0100 Subject: refactor(screen): screen.c delenda est drawscreen.c vs screen.c makes absolutely no sense. The screen exists only to draw upon it, therefore helper functions are distributed randomly between screen.c and the file that does the redrawing. In addition screen.c does a lot of drawing on the screen. It made more sense for vim/vim as our grid.c is their screen.c Not sure if we want to dump all the code for option chars into optionstr.c, so keep these in a optionchar.c for now. --- src/nvim/message.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index dc88c53392..aecb46c6bd 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -49,7 +49,6 @@ #include "nvim/pos.h" #include "nvim/regexp.h" #include "nvim/runtime.h" -#include "nvim/screen.h" #include "nvim/strings.h" #include "nvim/ui.h" #include "nvim/ui_compositor.h" @@ -1340,6 +1339,14 @@ void set_keep_msg(char *s, int attr) keep_msg_attr = attr; } +/// Return true if printing messages should currently be done. +bool messaging(void) +{ + // TODO(bfredl): with general support for "async" messages with p_ch, + // this should be re-enabled. + return !(p_lz && char_avail() && !KeyTyped) && (p_ch > 0 || ui_has(kUIMessages)); +} + void msgmore(long n) { long pn; @@ -3807,3 +3814,21 @@ int vim_dialog_yesnoallcancel(int type, char *title, char *message, int dflt) } return VIM_CANCEL; } + +/// Check if there should be a delay to allow the user to see a message. +/// +/// Used before clearing or redrawing the screen or the command line. +void msg_check_for_delay(bool check_msg_scroll) +{ + if ((emsg_on_display || (check_msg_scroll && msg_scroll)) + && !did_wait_return + && emsg_silent == 0 + && !in_assert_fails) { + ui_flush(); + os_delay(1006L, true); + emsg_on_display = false; + if (check_msg_scroll) { + msg_scroll = false; + } + } +} -- cgit From d5f6176e6dc4b4e12fc5061ca6e87f4af533e46a Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Sat, 1 Apr 2023 02:49:51 +0200 Subject: refactor: add const and remove unnecessary casts (#22841) --- src/nvim/message.c | 59 +++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index aecb46c6bd..98ef6e5cba 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -216,13 +216,13 @@ void msg_grid_validate(void) /// When terminal not initialized (yet) os_errmsg(..) is used. /// /// @return true if wait_return() not called -int msg(char *s) +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(char *s) +int verb_msg(const char *s) { verbose_enter(); int n = msg_attr_keep(s, 0, false, false); @@ -278,8 +278,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((const char *)chunk.text.data, chunk.attr, - true, &need_clear); + msg_multiline_attr(chunk.text.data, chunk.attr, true, &need_clear); } if (history && kv_size(hl_msg)) { add_msg_hist_multiattr(NULL, 0, 0, true, hl_msg); @@ -305,7 +304,7 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline) // Skip messages not match ":filter pattern". // Don't filter when there is an error. - if (!emsg_on_display && message_filtered((char *)s)) { + if (!emsg_on_display && message_filtered(s)) { return true; } @@ -333,7 +332,7 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline) // Truncate the message if needed. msg_start(); - buf = msg_strtrunc((char *)s, false); + buf = msg_strtrunc(s, false); if (buf != NULL) { s = buf; } @@ -349,8 +348,8 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline) } retval = msg_end(); - if (keep && retval && vim_strsize((char *)s) < (Rows - cmdline_row - 1) * Columns + sc_col) { - set_keep_msg((char *)s, 0); + if (keep && retval && vim_strsize(s) < (Rows - cmdline_row - 1) * Columns + sc_col) { + set_keep_msg(s, 0); } need_fileinfo = false; @@ -365,7 +364,7 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline) /// @return an allocated string or NULL when no truncating is done. /// /// @param force always truncate -char *msg_strtrunc(char *s, int force) +char *msg_strtrunc(const char *s, int force) { char *buf = NULL; @@ -395,7 +394,7 @@ char *msg_strtrunc(char *s, int force) /// Truncate a string "s" to "buf" with cell width "room". /// "s" and "buf" may be equal. -void trunc_string(char *s, char *buf, int room_in, int buflen) +void trunc_string(const char *s, char *buf, int room_in, int buflen) { int room = room_in - 3; // "..." takes 3 chars int half; @@ -503,7 +502,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((const char *)IObuff, attr); + return msg_attr(IObuff, attr); } int smsg_attr_keep(int attr, const char *s, ...) @@ -514,7 +513,7 @@ int smsg_attr_keep(int attr, const char *s, ...) va_start(arglist, s); vim_vsnprintf(IObuff, IOSIZE, s, arglist); va_end(arglist); - return msg_attr_keep((const char *)IObuff, attr, true, false); + return msg_attr_keep(IObuff, attr, true, false); } // Remember the last sourcing name/lnum used in an error message, so that it @@ -862,7 +861,7 @@ void siemsg(const char *s, ...) } /// Give an "Internal error" message. -void internal_error(char *where) +void internal_error(const char *where) { siemsg(_(e_intern2), where); } @@ -1327,7 +1326,7 @@ static void hit_return_msg(void) } /// Set "keep_msg" to "s". Free the old value and check for NULL pointer. -void set_keep_msg(char *s, int attr) +void set_keep_msg(const char *s, int attr) { xfree(keep_msg); if (s != NULL && msg_silent == 0) { @@ -1562,7 +1561,7 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr) // If the string starts with a composing character first draw a space on // which the composing char can be drawn. - if (utf_iscomposing(utf_ptr2char((char *)msgstr))) { + if (utf_iscomposing(utf_ptr2char(msgstr))) { msg_puts_attr(" ", attr); } @@ -1598,7 +1597,7 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr) msg_puts_attr_len(plain_start, str - plain_start, attr); } plain_start = str + 1; - msg_puts_attr((const char *)s, attr == 0 ? HL_ATTR(HLF_8) : attr); + msg_puts_attr(s, attr == 0 ? HL_ATTR(HLF_8) : attr); retval += (int)strlen(s); } else { retval++; @@ -1674,7 +1673,7 @@ int msg_outtrans_special(const char *strstart, bool from, int maxlen) // single-byte character or illegal byte text = (char *)transchar_byte_buf(NULL, (uint8_t)text[0]); } - const int len = vim_strsize((char *)text); + const int len = vim_strsize(text); if (maxlen > 0 && retval + len >= maxlen) { break; } @@ -1966,7 +1965,7 @@ void msg_prt_line(char *s, int list) /// Use grid_puts() to output one multi-byte character. /// /// @return the pointer "s" advanced to the next character. -static char *screen_puts_mbyte(char *s, int l, int attr) +static const char *screen_puts_mbyte(const char *s, int l, int attr) { int cw; attr = hl_combine_attr(HL_ATTR(HLF_MSG), attr); @@ -2212,7 +2211,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) } else { l = utfc_ptr2len(s); } - s = screen_puts_mbyte((char *)s, l, attr); + s = screen_puts_mbyte(s, l, attr); did_last_char = true; } else { did_last_char = false; @@ -2229,7 +2228,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) if (p_more) { // Store text for scrolling back. - store_sb_text((char **)&sb_str, (char *)s, attr, &sb_col, true); + store_sb_text(&sb_str, s, attr, &sb_col, true); } inc_msg_scrolled(); @@ -2274,7 +2273,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) if (wrap && p_more && !recurse) { // Store text for scrolling back. - store_sb_text((char **)&sb_str, (char *)s, attr, &sb_col, true); + store_sb_text(&sb_str, s, attr, &sb_col, true); } if (*s == '\n') { // go to next line @@ -2312,7 +2311,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) // characters and draw them all at once later. if (cmdmsg_rl || (cw > 1 && msg_col + t_col >= Columns - 1)) { if (l > 1) { - s = screen_puts_mbyte((char *)s, l, attr) - 1; + s = screen_puts_mbyte(s, l, attr) - 1; } else { msg_screen_putchar(*s, attr); } @@ -2333,7 +2332,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) t_puts(&t_col, t_s, s, attr); } if (p_more && !recurse && !(s == sb_str + 1 && *sb_str == '\n')) { - store_sb_text((char **)&sb_str, (char *)s, attr, &sb_col, false); + store_sb_text(&sb_str, s, attr, &sb_col, false); } msg_check(); @@ -2341,7 +2340,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) /// @return true when ":filter pattern" was used and "msg" does not match /// "pattern". -bool message_filtered(char *msg) +bool message_filtered(const char *msg) { if (cmdmod.cmod_filter_regmatch.regprog == NULL) { return false; @@ -2507,7 +2506,7 @@ static sb_clear_T do_clear_sb_text = SB_CLEAR_NONE; /// @param sb_str start of string /// @param s just after string /// @param finish line ends -static void store_sb_text(char **sb_str, char *s, int attr, int *sb_col, int finish) +static void store_sb_text(const char **sb_str, const char *s, int attr, int *sb_col, int finish) { msgchunk_T *mp; @@ -2681,7 +2680,7 @@ 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); // Output postponed text. msg_didout = true; // Remember that line is not empty. - grid_puts_len(&msg_grid_adj, (char *)t_s, (int)(s - t_s), msg_row, msg_col, attr); + grid_puts_len(&msg_grid_adj, t_s, (int)(s - t_s), msg_row, msg_col, attr); msg_col += *t_col; *t_col = 0; // If the string starts with a composing character don't increment the @@ -3308,7 +3307,7 @@ static void redir_write(const char *const str, const ptrdiff_t maxlen) write_reg_contents(redir_reg, s, (ssize_t)len, true); } if (redir_vname) { - var_redir_str((char *)s, (int)maxlen); + var_redir_str(s, (int)maxlen); } // Write and adjust the current column. @@ -3417,7 +3416,7 @@ int verbose_open(void) /// Give a warning message (for searching). /// Use 'w' highlighting and may repeat the message after redrawing -void give_warning(char *message, bool hl) +void give_warning(const char *message, bool hl) FUNC_ATTR_NONNULL_ARG(1) { // Don't do this for ":silent". @@ -3440,7 +3439,7 @@ void give_warning(char *message, bool hl) msg_ext_set_kind("wmsg"); } - if (msg_attr((const char *)message, keep_msg_attr) && msg_scrolled == 0) { + if (msg_attr(message, keep_msg_attr) && msg_scrolled == 0) { set_keep_msg(message, keep_msg_attr); } msg_didout = false; // Overwrite this message. @@ -3450,7 +3449,7 @@ void give_warning(char *message, bool hl) no_wait_return--; } -void give_warning2(char *const message, char *const a1, bool hl) +void give_warning2(const char *const message, const char *const a1, bool hl) { vim_snprintf(IObuff, IOSIZE, message, a1); give_warning(IObuff, hl); -- cgit From d510bfbc8e447b1a60d5ec7faaa8f440eb4ef56f Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sun, 2 Apr 2023 10:11:42 +0200 Subject: refactor: remove char_u (#22829) Closes https://github.com/neovim/neovim/issues/459 --- src/nvim/message.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 98ef6e5cba..b43bc6ce9b 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1589,7 +1589,7 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr) len -= mb_l - 1; str += mb_l; } else { - s = (char *)transchar_byte_buf(NULL, (uint8_t)(*str)); + s = transchar_byte_buf(NULL, (uint8_t)(*str)); if (s[1] != NUL) { // Unprintable char: print the printable chars so far and the // translation of the unprintable char. @@ -1671,7 +1671,7 @@ int msg_outtrans_special(const char *strstart, bool from, int maxlen) } if (text[0] != NUL && text[1] == NUL) { // single-byte character or illegal byte - text = (char *)transchar_byte_buf(NULL, (uint8_t)text[0]); + text = transchar_byte_buf(NULL, (uint8_t)text[0]); } const int len = vim_strsize(text); if (maxlen > 0 && retval + len >= maxlen) { @@ -1917,7 +1917,7 @@ void msg_prt_line(char *s, int list) s--; } else if (c != NUL && (n = byte2cells(c)) > 1) { n_extra = n - 1; - p_extra = (char *)transchar_byte_buf(NULL, c); + p_extra = transchar_byte_buf(NULL, c); c_extra = NUL; c_final = NUL; c = (unsigned char)(*p_extra++); -- cgit From 1d2a29f75ba7d094c8e7444c9b249a4a7211c93c Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Fri, 7 Apr 2023 19:39:04 +0200 Subject: refactor: make char * parameters const in message.c Add const to char * parameters in message.c functions and remove some redundant casts. --- src/nvim/message.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index b43bc6ce9b..6524ae708e 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1488,17 +1488,17 @@ void msg_outnum(long n) msg_puts(buf); } -void msg_home_replace(char *fname) +void msg_home_replace(const char *fname) { msg_home_replace_attr(fname, 0); } -void msg_home_replace_hl(char *fname) +void msg_home_replace_hl(const char *fname) { msg_home_replace_attr(fname, HL_ATTR(HLF_D)); } -static void msg_home_replace_attr(char *fname, int attr) +static void msg_home_replace_attr(const char *fname, int attr) { char *name = home_replace_save(NULL, fname); msg_outtrans_attr(name, attr); @@ -1510,7 +1510,7 @@ static void msg_home_replace_attr(char *fname, int attr) /// Use attributes 'attr'. /// /// @return the number of characters it takes on the screen. -int msg_outtrans(char *str) +int msg_outtrans(const char *str) { return msg_outtrans_attr(str, 0); } @@ -1529,7 +1529,7 @@ int msg_outtrans_len(const char *str, int len) /// Handles multi-byte characters. /// /// @return pointer to the next character. -char *msg_outtrans_one(char *p, int attr) +const char *msg_outtrans_one(const char *p, int attr) { int l; @@ -1616,11 +1616,11 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr) return retval; } -void msg_make(char *arg) +void msg_make(const char *arg) { int i; - static char *str = "eeffoc"; - static char *rs = "Plon#dqg#vxjduB"; + static const char *str = "eeffoc"; + static const char *rs = "Plon#dqg#vxjduB"; arg = skipwhite(arg); for (i = 5; *arg && i >= 0; i--) { @@ -1806,20 +1806,20 @@ void str2specialbuf(const char *sp, char *buf, size_t len) } /// print line for :print or :list command -void msg_prt_line(char *s, int list) +void msg_prt_line(const char *s, int list) { int c; int col = 0; int n_extra = 0; int c_extra = 0; int c_final = 0; - char *p_extra = NULL; // init to make SASC shut up + const char *p_extra = NULL; // init to make SASC shut up int n; int attr = 0; - char *lead = NULL; + const char *lead = NULL; bool in_multispace = false; int multispace_pos = 0; - char *trail = NULL; + const char *trail = NULL; int l; if (curwin->w_p_list) { @@ -2011,12 +2011,12 @@ 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(char *longstr, int attr) +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(char *longstr, int len, int attr) +void msg_outtrans_long_len_attr(const char *longstr, int len, int attr) { int slen = len; int room; -- cgit From 9408f2dcf7cade2631688300e9b58eed6bc5219a Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Fri, 7 Apr 2023 19:40:57 +0200 Subject: refactor: remove redundant const char * casts --- src/nvim/message.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 6524ae708e..f78980c859 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1537,7 +1537,7 @@ const char *msg_outtrans_one(const char *p, int attr) msg_outtrans_len_attr(p, l, attr); return p + l; } - msg_puts_attr((const char *)transchar_byte_buf(NULL, (uint8_t)(*p)), attr); + msg_puts_attr(transchar_byte_buf(NULL, (uint8_t)(*p)), attr); return p + 1; } @@ -1582,8 +1582,7 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr) msg_puts_attr_len(plain_start, str - plain_start, attr); } plain_start = str + mb_l; - msg_puts_attr((const char *)transchar_buf(NULL, c), - (attr == 0 ? HL_ATTR(HLF_8) : attr)); + msg_puts_attr(transchar_buf(NULL, c), attr == 0 ? HL_ATTR(HLF_8) : attr); retval += char2cells(c); } len -= mb_l - 1; @@ -1777,7 +1776,7 @@ const char *str2special(const char **const sp, const bool replace_spaces, const || c < ' ' || (replace_spaces && c == ' ') || (replace_lt && c == '<')) { - return (const char *)get_special_key_name(c, modifiers); + return get_special_key_name(c, modifiers); } buf[0] = (char)c; buf[1] = NUL; -- cgit From 3b0df1780e2c8526bda5dead18ee7cc45925caba Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Wed, 26 Apr 2023 23:23:44 +0200 Subject: refactor: uncrustify Notable changes: replace all infinite loops to `while(true)` and remove `int` from `unsigned int`. --- src/nvim/message.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index f78980c859..e8e2d57e41 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -438,7 +438,7 @@ void trunc_string(const char *s, char *buf, int room_in, int buflen) // Last part: End of the string. half = i = (int)strlen(s); - for (;;) { + while (true) { do { half = half - utf_head_off(s, s + half - 1) - 1; } while (half > 0 && utf_iscomposing(utf_ptr2char(s + half))); @@ -2656,7 +2656,7 @@ static msgchunk_T *disp_sb_line(int row, msgchunk_T *smp) { msgchunk_T *mp = smp; - for (;;) { + while (true) { msg_row = row; msg_col = mp->sb_msg_col; char *p = mp->sb_text; @@ -2801,7 +2801,7 @@ static int do_more_prompt(int typed_char) if (typed_char == NUL) { msg_moremsg(false); } - for (;;) { + while (true) { // Get a typed character directly from the user. if (used_typed_char != NUL) { c = used_typed_char; // was typed at hit-enter prompt @@ -3528,7 +3528,7 @@ int do_dialog(int type, char *title, char *message, char *buttons, int dfltbutto no_wait_return++; hotkeys = msg_show_console_dialog(message, buttons, dfltbutton); - for (;;) { + while (true) { // Get a typed character directly from the user. int c = get_keystroke(NULL); switch (c) { -- cgit From e8661133c533345e8d83a38b077e45922988fa90 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 6 May 2023 09:34:29 +0800 Subject: vim-patch:9.0.0904: various comment and indent flaws (#23498) Problem: Various comment and indent flaws. Solution: Improve comments and indenting. https://github.com/vim/vim/commit/88456cd3c49a3dd1fda17cf350daa9b8216b1aa6 Omit test_function_lists.vim change as that file is likely not applicable to Nvim due to the existence of Nvim-only functions. Co-authored-by: Bram Moolenaar --- src/nvim/message.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index e8e2d57e41..63bcf3e069 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1250,6 +1250,7 @@ void wait_return(int redraw) || c == K_MOUSEDOWN || c == K_MOUSEUP || c == K_MOUSEMOVE); os_breakcheck(); + // Avoid that the mouse-up event causes visual mode to start. if (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE || c == K_RIGHTMOUSE || c == K_X1MOUSE || c == K_X2MOUSE) { -- cgit From c9f47fca8b896ecb304294cce675fedac9ab926c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 17 May 2023 21:06:27 +0800 Subject: fix(messages): ensure msg_grid is at top at more prompt (#23584) --- src/nvim/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 63bcf3e069..aa97ea15e5 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -181,7 +181,7 @@ void msg_grid_validate(void) msg_grid.dirty_col = xcalloc((size_t)Rows, sizeof(*msg_grid.dirty_col)); // Tricky: allow resize while pager or ex mode is active - int pos = MAX(max_rows - msg_scrolled, 0); + int pos = (State & MODE_ASKMORE) ? 0 : MAX(max_rows - msg_scrolled, 0); msg_grid.throttled = false; // don't throttle in 'cmdheight' area msg_grid_set_pos(pos, msg_scrolled); ui_comp_put_grid(&msg_grid, pos, 0, msg_grid.rows, msg_grid.cols, -- cgit From cfd4fdfea4d0e68ea50ad412b88b5289ded6fd6f Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Tue, 23 May 2023 14:25:10 +0600 Subject: refactor(api): new helper macros Adds new API helper macros `CSTR_AS_OBJ()`, `STATIC_CSTR_AS_OBJ()`, and `STATIC_CSTR_TO_OBJ()`, which cleans up a lot of the current code. These macros will also be used extensively in the upcoming option refactor PRs because then API Objects will be used to get/set options. This PR also modifies pre-existing code to use old API helper macros like `CSTR_TO_OBJ()` to make them cleaner. --- src/nvim/message.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index aa97ea15e5..1cb4a3cbf4 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1069,7 +1069,7 @@ void ex_messages(void *const eap_p) for (; p != NULL; p = p->next) { if (kv_size(p->multiattr) || (p->msg && p->msg[0])) { Array entry = ARRAY_DICT_INIT; - ADD(entry, STRING_OBJ(cstr_to_string(p->kind))); + ADD(entry, CSTR_TO_OBJ(p->kind)); Array content = ARRAY_DICT_INIT; if (kv_size(p->multiattr)) { for (uint32_t i = 0; i < kv_size(p->multiattr); i++) { @@ -1082,7 +1082,7 @@ void ex_messages(void *const eap_p) } else if (p->msg && p->msg[0]) { Array content_entry = ARRAY_DICT_INIT; ADD(content_entry, INTEGER_OBJ(p->attr)); - ADD(content_entry, STRING_OBJ(cstr_to_string(p->msg))); + ADD(content_entry, CSTR_TO_OBJ(p->msg)); ADD(content, ARRAY_OBJ(content_entry)); } ADD(entry, ARRAY_OBJ(content)); -- cgit From cba07dad494558a4a06e25a35521041864697be3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 16 Jun 2023 08:01:43 +0800 Subject: vim-patch:9.0.1634: message is cleared when removing mode message Problem: Message is cleared when removing mode message (Gary Johnson). Solution: Do not clear the command line after displaying a message. https://github.com/vim/vim/commit/800cdbb7caeb5dd4379c6cb071bb12391f20bcf3 Co-authored-by: Bram Moolenaar --- src/nvim/message.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 1cb4a3cbf4..d0b128c568 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1560,6 +1560,13 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr) attr &= ~MSG_HIST; } + // When drawing over the command line no need to clear it later or remove + // the mode message. + if (msg_row == cmdline_row && msg_col == 0) { + clear_cmdline = false; + mode_displayed = false; + } + // If the string starts with a composing character first draw a space on // which the composing char can be drawn. if (utf_iscomposing(utf_ptr2char(msgstr))) { -- cgit From 11060793d6544e893f31d65e8f964453c463407c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 16 Jun 2023 08:13:42 +0800 Subject: vim-patch:9.0.1635: error message is cleared when removing mode message Problem: Error message is cleared when removing mode message. Solution: Also reset flags when the message is further down. https://github.com/vim/vim/commit/da51ad51bf4fbd66619786d0e6a83fb3ca09930b Co-authored-by: Bram Moolenaar --- src/nvim/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index d0b128c568..0064f0358b 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1562,7 +1562,7 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr) // When drawing over the command line no need to clear it later or remove // the mode message. - if (msg_row == cmdline_row && msg_col == 0) { + if (msg_row >= cmdline_row && msg_col == 0) { clear_cmdline = false; mode_displayed = false; } -- cgit From aa362a2af8ce353d7082834a54bcc124ebd2a026 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 29 Jun 2023 15:48:42 +0800 Subject: refactor: remove some casts to char * (#24200) --- src/nvim/message.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 0064f0358b..c60e5c31fd 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -3511,8 +3511,8 @@ void msg_advance(int col) /// @param textfiel IObuff for inputdialog(), NULL otherwise /// @param ex_cmd when true pressing : accepts default and starts Ex command /// @returns 0 if cancelled, otherwise the nth button (1-indexed). -int do_dialog(int type, char *title, char *message, char *buttons, int dfltbutton, char *textfield, - int ex_cmd) +int do_dialog(int type, const char *title, const char *message, const char *buttons, int dfltbutton, + const char *textfield, int ex_cmd) { int retval = 0; char *hotkeys; @@ -3619,7 +3619,7 @@ static int copy_char(const char *from, char *to, bool lowercase) /// corresponding button has a hotkey /// /// @return Pointer to memory allocated for storing hotkeys -static char *console_dialog_alloc(const char *message, char *buttons, bool has_hotkey[]) +static char *console_dialog_alloc(const char *message, const char *buttons, bool has_hotkey[]) { int lenhotkey = HOTK_LEN; // count first button has_hotkey[0] = false; @@ -3627,7 +3627,7 @@ static char *console_dialog_alloc(const char *message, char *buttons, bool has_h // Compute the size of memory to allocate. int len = 0; int idx = 0; - char *r = buttons; + const char *r = buttons; while (*r) { if (*r == DLG_BUTTON_SEP) { len += 3; // '\n' -> ', '; 'x' -> '(x)' @@ -3673,7 +3673,7 @@ static char *console_dialog_alloc(const char *message, char *buttons, bool has_h /// The hotkeys can be multi-byte characters, but without combining chars. /// /// @return an allocated string with hotkeys. -static char *msg_show_console_dialog(char *message, char *buttons, int dfltbutton) +static char *msg_show_console_dialog(const char *message, const char *buttons, int dfltbutton) FUNC_ATTR_NONNULL_RET { bool has_hotkey[HAS_HOTKEY_LEN] = { false }; @@ -3693,7 +3693,7 @@ static char *msg_show_console_dialog(char *message, char *buttons, int dfltbutto /// @param has_hotkey An element in this array is true if corresponding button /// has a hotkey /// @param[out] hotkeys_ptr Pointer to the memory location where hotkeys will be copied -static void copy_hotkeys_and_msg(const char *message, char *buttons, int default_button_idx, +static void copy_hotkeys_and_msg(const char *message, const char *buttons, int default_button_idx, const bool has_hotkey[], char *hotkeys_ptr) { *confirm_msg = '\n'; @@ -3716,7 +3716,7 @@ static void copy_hotkeys_and_msg(const char *message, char *buttons, int default } int idx = 0; - char *r = buttons; + const char *r = buttons; while (*r) { if (*r == DLG_BUTTON_SEP) { *msgp++ = ','; -- cgit From 30a5c28c8740d2e07c20cb58822b7d7aa489b728 Mon Sep 17 00:00:00 2001 From: Thomas Vigouroux Date: Wed, 19 Jul 2023 17:56:25 +0200 Subject: feat(decoration_provider): log errors as error messages --- src/nvim/message.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index c60e5c31fd..1f6790225c 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -885,6 +885,24 @@ void msg_schedule_semsg(const char *const fmt, ...) loop_schedule_deferred(&main_loop, event_create(msg_semsg_event, 1, s)); } +static void msg_semsg_multiline_event(void **argv) +{ + char *s = argv[0]; + (void)emsg_multiline(s, true); + xfree(s); +} + +void msg_schedule_semsg_multiline(const char *const fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vim_vsnprintf((char *)IObuff, IOSIZE, fmt, ap); + va_end(ap); + + char *s = xstrdup((char *)IObuff); + loop_schedule_deferred(&main_loop, event_create(msg_semsg_multiline_event, 1, s)); +} + /// Like msg(), but truncate to a single line if p_shm contains 't', or when /// "force" is true. This truncates in another way as for normal messages. /// Careful: The string may be changed by msg_may_trunc()! -- cgit From 60d320dea3fe7b7d666d5a18ec8b94178c31acf4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 21 Jul 2023 08:21:46 +0800 Subject: fix(decoration_provider): don't leak memory on error (#24410) --- src/nvim/message.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 1f6790225c..81760dd017 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -896,10 +896,10 @@ void msg_schedule_semsg_multiline(const char *const fmt, ...) { va_list ap; va_start(ap, fmt); - vim_vsnprintf((char *)IObuff, IOSIZE, fmt, ap); + vim_vsnprintf(IObuff, IOSIZE, fmt, ap); va_end(ap); - char *s = xstrdup((char *)IObuff); + char *s = xstrdup(IObuff); loop_schedule_deferred(&main_loop, event_create(msg_semsg_multiline_event, 1, s)); } -- cgit From 3a7cb72dcbe4aaaed47999ab5afaf3d1cb8d4df8 Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 20 Sep 2023 13:42:37 +0200 Subject: refactor(grid): properly namespace and separate stateful grid functions This is a step in an ongoing refactor where the "grid_puts" and "grid_put_linebuf" code paths will share more of the implementation (in particular for delta calculation, doublewidth and 'arabicshape' handling). But it also makes sense by its own as a cleanup, and is thus committed separately. Before this change many of the low level grid functions grid_puts, grid_fill etc could both be used in a standalone fashion but also as part of a batched line update which would be finally transmitted as a single grid_line call (via ui_line() ). This was initially useful to quickly refactor pre-existing vim code to use batched logic safely. However, this pattern is not really helpful for maintainable and newly written code, where the "grid" and "row" arguments are just needlessly repeated. This simplifies these calls to just use grid and row as specified in the initial grid_line_start(grid, row) call. This also makes the intent clear whether any grid_puts() call is actually part of a batch or not, which is better in the long run when more things get refactored to use effective (properly batched) updates. --- src/nvim/message.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 81760dd017..98e5a231b8 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2004,7 +2004,7 @@ static const char *screen_puts_mbyte(const char *s, int l, int attr) return s; } - grid_puts_len(&msg_grid_adj, s, l, msg_row, msg_col, attr); + grid_puts(&msg_grid_adj, s, l, msg_row, msg_col, attr); if (cmdmsg_rl) { msg_col -= cw; if (msg_col == 0) { @@ -2705,7 +2705,7 @@ 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); // Output postponed text. msg_didout = true; // Remember that line is not empty. - grid_puts_len(&msg_grid_adj, t_s, (int)(s - t_s), msg_row, msg_col, attr); + grid_puts(&msg_grid_adj, t_s, (int)(s - t_s), msg_row, msg_col, attr); msg_col += *t_col; *t_col = 0; // If the string starts with a composing character don't increment the @@ -3091,9 +3091,9 @@ void msg_moremsg(int full) char *s = _("-- More --"); attr = hl_combine_attr(HL_ATTR(HLF_MSG), HL_ATTR(HLF_M)); - grid_puts(&msg_grid_adj, s, Rows - 1, 0, attr); + grid_puts(&msg_grid_adj, s, -1, Rows - 1, 0, attr); if (full) { - grid_puts(&msg_grid_adj, _(" SPACE/d/j: screen/page/line down, b/u/k: up, q: quit "), + grid_puts(&msg_grid_adj, _(" SPACE/d/j: screen/page/line down, b/u/k: up, q: quit "), -1, Rows - 1, vim_strsize(s), attr); } } -- cgit From 7d4967547b2793a29f9bd602ec6819458be1bd49 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 25 Sep 2023 06:31:52 +0800 Subject: vim-patch:9.0.1938: multispace wrong when scrolling horizontally (#25348) Problem: multispace wrong when scrolling horizontally Solution: Update position in "multispace" or "leadmultispace" also in skipped chars. Reorder conditions to be more consistent. closes: vim/vim#13145 closes: vim/vim#13147 https://github.com/vim/vim/commit/abc808112ee5df58a9f612f2bb5a65389c2c14e1 --- src/nvim/message.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 98e5a231b8..ad78092cac 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1907,10 +1907,13 @@ void msg_prt_line(const char *s, int list) continue; } else { attr = 0; - c = (unsigned char)(*s++); - in_multispace = c == ' ' && ((col > 0 && s[-2] == ' ') || *s == ' '); - if (!in_multispace) { - multispace_pos = 0; + c = (uint8_t)(*s++); + if (list) { + in_multispace = c == ' ' && (*s == ' ' + || (col > 0 && s[-2] == ' ')); + if (!in_multispace) { + multispace_pos = 0; + } } if (c == TAB && (!list || curwin->w_p_lcs_chars.tab1)) { // tab amount depends on current column @@ -1950,7 +1953,7 @@ void msg_prt_line(const char *s, int list) // the same in plain text. attr = HL_ATTR(HLF_0); } else if (c == ' ') { - if (list && lead != NULL && s <= lead && in_multispace + if (lead != NULL && s <= lead && in_multispace && curwin->w_p_lcs_chars.leadmultispace != NULL) { c = curwin->w_p_lcs_chars.leadmultispace[multispace_pos++]; if (curwin->w_p_lcs_chars.leadmultispace[multispace_pos] == NUL) { @@ -1963,7 +1966,7 @@ void msg_prt_line(const char *s, int list) } else if (trail != NULL && s > trail) { c = curwin->w_p_lcs_chars.trail; attr = HL_ATTR(HLF_0); - } else if (list && in_multispace + } else if (in_multispace && curwin->w_p_lcs_chars.multispace != NULL) { c = curwin->w_p_lcs_chars.multispace[multispace_pos++]; if (curwin->w_p_lcs_chars.multispace[multispace_pos] == NUL) { -- cgit From 9e7c4fe5791559ff2c9ffe6329f1d7e2150385ed Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 25 Sep 2023 08:23:24 +0800 Subject: fix(exception): remember whether message is multiline (#25351) --- src/nvim/message.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index ad78092cac..dba4dba600 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -640,7 +640,7 @@ int emsg_not_now(void) return false; } -static bool emsg_multiline(const char *s, bool multiline) +bool emsg_multiline(const char *s, bool multiline) { int attr; bool ignore = false; @@ -663,7 +663,7 @@ static bool emsg_multiline(const char *s, bool multiline) // be found, the message will be displayed later on.) "ignore" is set // when the message should be ignored completely (used for the // interrupt message). - if (cause_errthrow(s, severe, &ignore)) { + if (cause_errthrow(s, multiline, severe, &ignore)) { if (!ignore) { did_emsg++; } -- cgit From f91cd31d7d9d70006e0000592637d5d997eab52c Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 27 Sep 2023 21:46:39 +0200 Subject: refactor(messages): fold msg_outtrans_attr into msg_outtrans problem: there are too many different functions in message.c solution: fold some of the functions into themselves --- src/nvim/message.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index dba4dba600..4c19c0dd5b 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -237,7 +237,7 @@ int msg_attr(const char *s, const int attr) return msg_attr_keep(s, attr, false, false); } -/// Similar to msg_outtrans_attr, but support newlines and tabs. +/// Similar to msg_outtrans, but support newlines and tabs. void msg_multiline_attr(const char *s, int attr, bool check_int, bool *need_clear) FUNC_ATTR_NONNULL_ALL { @@ -251,7 +251,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 +265,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); } } @@ -341,7 +341,7 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline) if (multiline) { msg_multiline_attr(s, attr, false, &need_clear); } else { - msg_outtrans_attr(s, attr); + msg_outtrans(s, attr); } if (need_clear) { msg_clr_eos(); @@ -1520,7 +1520,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 +1529,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) +int msg_outtrans(const char *str, int attr) { - 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) -{ - return msg_outtrans_len_attr(str, len, 0); + return msg_outtrans_len(str, (int)strlen(str), attr); } /// Output one character at "p". @@ -1553,14 +1543,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; @@ -2052,10 +2042,10 @@ void msg_outtrans_long_len_attr(const char *longstr, int len, int attr) 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. -- cgit From b85f1dafc7c0a19704135617454f1c66f41202c1 Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 27 Sep 2023 22:21:17 +0200 Subject: refactor(messages): fold msg_attr into msg problem: there are too many different functions in message.c solution: fold some of the functions into themselves --- src/nvim/message.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 4c19c0dd5b..a9d5fb332b 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -212,15 +212,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,7 +222,11 @@ 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); @@ -491,7 +486,7 @@ int smsg(const char *s, ...) vim_vsnprintf(IObuff, IOSIZE, s, arglist); va_end(arglist); - return msg(IObuff); + return msg(IObuff, 0); } int smsg_attr(int attr, const char *s, ...) @@ -502,7 +497,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 +599,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 } @@ -918,7 +913,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 +1395,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; } @@ -3457,7 +3452,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. -- cgit From 448d4837be7f7bd60ac0b5a3100c0217ac48a495 Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 27 Sep 2023 22:24:50 +0200 Subject: refactor(messages): rename msg_trunc_attr and msg_multiline_attr without attr --- src/nvim/message.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index a9d5fb332b..63d1b44d67 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -233,7 +233,7 @@ int msg(const char *s, const int attr) } /// Similar to msg_outtrans, but support newlines and tabs. -void msg_multiline_attr(const char *s, int attr, bool check_int, bool *need_clear) +void msg_multiline(const char *s, int attr, bool check_int, bool *need_clear) FUNC_ATTR_NONNULL_ALL { const char *next_spec = s; @@ -273,7 +273,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); @@ -334,7 +334,7 @@ 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(s, attr); } @@ -903,7 +903,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; -- cgit From b07fd0e988581f6b9c620bcfc27a068ee61242c1 Mon Sep 17 00:00:00 2001 From: bfredl Date: Fri, 29 Sep 2023 15:52:27 +0200 Subject: refactor(message): msg_outtrans_long_len_attr -> msg_outtrans_long --- src/nvim/message.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 63d1b44d67..18eb049d70 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2024,17 +2024,11 @@ 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(longstr, slen, attr); -- cgit From 8e11c18d4962c5367a0549bdb2288323545852b6 Mon Sep 17 00:00:00 2001 From: bfredl Date: Fri, 29 Sep 2023 16:10:28 +0200 Subject: refactor(message): msg_puts_attr_len -> msg_puts_len --- src/nvim/message.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 18eb049d70..8807524083 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1590,7 +1590,7 @@ int msg_outtrans_len(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); @@ -1604,7 +1604,7 @@ int msg_outtrans_len(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); @@ -1618,7 +1618,7 @@ int msg_outtrans_len(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; @@ -2040,7 +2040,7 @@ void msg_outtrans_long(const char *longstr, int 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 @@ -2048,7 +2048,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); @@ -2124,7 +2124,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) @@ -2141,7 +2141,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) { @@ -2681,7 +2681,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); -- cgit From bc13bc154aa574e0bb58a50f2e0ca4570efa57c3 Mon Sep 17 00:00:00 2001 From: bfredl Date: Fri, 29 Sep 2023 16:10:54 +0200 Subject: refactor(message): smsg_attr -> smsg --- src/nvim/message.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 8807524083..44fcd83af8 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -474,22 +474,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, 0); -} - -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; -- cgit From cf8b2c0e74fd5e723b0c15c2ce84e6900fd322d3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 12:05:28 +0800 Subject: build(iwyu): add a few more _defs.h mappings (#25435) --- src/nvim/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 44fcd83af8..aef8f34947 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" @@ -46,6 +45,7 @@ #include "nvim/option.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" -- cgit From dc6d0d2daf69e2fdadda81feb97906dbc962a239 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 14:41:34 +0800 Subject: refactor: reorganize option header files (#25437) - Move vimoption_T to option.h - option_defs.h is for option-related types - option_vars.h corresponds to Vim's option.h - option_defs.h and option_vars.h don't include each other --- src/nvim/message.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index aef8f34947..68ea49d53b 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -43,6 +43,7 @@ #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" -- cgit From fd791db0ecebf5d5bf8922ba519f8dd4eef3c5e6 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 3 Oct 2023 00:19:30 +0200 Subject: fix: fix ASAN errors on clang 17 (#25469) --- src/nvim/message.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 68ea49d53b..25324e36ae 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1025,10 +1025,9 @@ int delete_first_msg(void) } /// :messages command implementation -void ex_messages(void *const eap_p) +void ex_messages(exarg_T *eap) FUNC_ATTR_NONNULL_ALL { - const exarg_T *const eap = (const exarg_T *)eap_p; struct msg_hist *p; if (strcmp(eap->arg, "clear") == 0) { -- cgit From a9a48d6b5f00241e16e7131c997f0117bc5e9047 Mon Sep 17 00:00:00 2001 From: bfredl Date: Sat, 30 Sep 2023 10:31:55 +0200 Subject: refactor(message): simplify msg_puts_display and use batched grid updates msg_puts_display was more complex than necessary in nvim, as in nvim, it no longer talks directly with a terminal. In particular we don't need to scroll the grid before emiting the last char. The TUI already takes care of things like that, for terminals where it matters. --- src/nvim/message.c | 323 ++++++++++++++++++----------------------------------- 1 file changed, 109 insertions(+), 214 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 25324e36ae..5777463e25 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1961,40 +1961,6 @@ void msg_prt_line(const char *s, int list) msg_clr_eos(); } -/// Use grid_puts() to output one multi-byte character. -/// -/// @return the pointer "s" advanced to the next character. -static const char *screen_puts_mbyte(const char *s, int l, int attr) -{ - int cw; - attr = hl_combine_attr(HL_ATTR(HLF_MSG), attr); - - msg_didout = true; // remember that line is not empty - cw = utf_ptr2cells(s); - if (cw > 1 - && (cmdmsg_rl ? msg_col <= 1 : msg_col == Columns - 1)) { - // Doesn't fit, print a highlighted '>' to fill it up. - msg_screen_putchar('>', HL_ATTR(HLF_AT)); - return s; - } - - grid_puts(&msg_grid_adj, s, l, msg_row, msg_col, attr); - if (cmdmsg_rl) { - msg_col -= cw; - if (msg_col == 0) { - msg_col = Columns; - msg_row++; - } - } else { - msg_col += cw; - if (msg_col >= Columns) { - msg_col = 0; - msg_row++; - } - } - return s + l; -} - /// Output a string to the screen at position msg_row, msg_col. /// Update msg_row and msg_col for the next message. void msg_puts(const char *s) @@ -2132,14 +2098,8 @@ static void msg_ext_emit_chunk(void) static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) { const char *s = str; - const char *t_s = str; // String from "t_s" to "s" is still todo. - int t_col = 0; // Screen cells todo, 0 when "t_s" not used. - int l; - int cw; const char *sb_str = str; int sb_col = msg_col; - int wrap; - int did_last_char; did_wait_return = false; @@ -2155,175 +2115,143 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) return; } + int print_attr = hl_combine_attr(HL_ATTR(HLF_MSG), attr); msg_grid_validate(); cmdline_was_last_drawn = redrawing_cmdline; - while ((maxlen < 0 || (int)(s - str) < maxlen) && *s != NUL) { - // We are at the end of the screen line when: - // - When outputting a newline. - // - When outputting a character in the last column. - if (!recurse && msg_row >= Rows - 1 - && (*s == '\n' || (cmdmsg_rl - ? (msg_col <= 1 - || (*s == TAB && msg_col <= 7) - || (utf_ptr2cells(s) > 1 - && msg_col <= 2)) - : ((*s != '\r' && msg_col + t_col >= Columns - 1) - || (*s == TAB - && msg_col + t_col >= ((Columns - 1) & ~7)) - || (utf_ptr2cells(s) > 1 - && msg_col + t_col >= Columns - 2))))) { - // The screen is scrolled up when at the last row (some terminals - // scroll automatically, some don't. To avoid problems we scroll - // ourselves). - if (t_col > 0) { - // output postponed text - t_puts(&t_col, t_s, s, attr); - } + int msg_row_pending = -1; - // When no more prompt and no more room, truncate here + while (true) { + if (cmdmsg_rl ? msg_col <= 0 : msg_col >= Columns) { + if (p_more && !recurse) { + // Store text for scrolling back. + store_sb_text(&sb_str, s, attr, &sb_col, true); + } if (msg_no_more && lines_left == 0) { break; } - // Scroll the screen up one line. - bool has_last_char = ((uint8_t)(*s) >= ' ' && !cmdmsg_rl); - msg_scroll_up(!has_last_char, false); + msg_col = cmdmsg_rl ? Columns - 1 : 0; + msg_row++; + msg_didout = false; + } - msg_row = Rows - 2; - if (msg_col >= Columns) { // can happen after screen resize - msg_col = Columns - 1; - } + if (msg_row >= Rows) { + msg_row = Rows - 1; - // Display char in last column before showing more-prompt. - if (has_last_char) { - if (maxlen >= 0) { - // Avoid including composing chars after the end. - l = utfc_ptr2len_len(s, (int)((str + maxlen) - s)); - } else { - l = utfc_ptr2len(s); - } - s = screen_puts_mbyte(s, l, attr); - did_last_char = true; - } else { - did_last_char = false; + // When no more prompt and no more room, truncate here + if (msg_no_more && lines_left == 0) { + break; } - // Tricky: if last cell will be written, delay the throttle until - // after the first scroll. Otherwise we would need to keep track of it. - if (has_last_char && msg_do_throttle()) { - if (!msg_grid.throttled) { - msg_grid_scroll_discount++; + if (!recurse) { + if (msg_row_pending >= 0) { + grid_line_flush_if_valid_row(); + msg_row_pending = -1; } - msg_grid.throttled = true; - } - if (p_more) { - // Store text for scrolling back. - store_sb_text(&sb_str, s, attr, &sb_col, true); - } - - inc_msg_scrolled(); - need_wait_return = true; // may need wait_return() in main() - redraw_cmdline = true; - if (cmdline_row > 0 && !exmode_active) { - cmdline_row--; - } + // Scroll the screen up one line. + msg_scroll_up(true, false); - // If screen is completely filled and 'more' is set then wait - // for a character. - if (lines_left > 0) { - lines_left--; - } - if (p_more && lines_left == 0 && State != MODE_HITRETURN - && !msg_no_more && !exmode_active) { - if (do_more_prompt(NUL)) { - s = confirm_msg_tail; + inc_msg_scrolled(); + need_wait_return = true; // may need wait_return() in main() + redraw_cmdline = true; + if (cmdline_row > 0 && !exmode_active) { + cmdline_row--; } - if (quit_more) { - return; + + // If screen is completely filled and 'more' is set then wait + // for a character. + if (lines_left > 0) { + lines_left--; } - } - // When we displayed a char in last column need to check if there - // is still more. - if (did_last_char) { - continue; + if (p_more && lines_left == 0 && State != MODE_HITRETURN + && !msg_no_more && !exmode_active) { + if (do_more_prompt(NUL)) { + s = confirm_msg_tail; + } + if (quit_more) { + return; + } + } } } - wrap = *s == '\n' - || msg_col + t_col >= Columns - || (utf_ptr2cells(s) > 1 - && msg_col + t_col >= Columns - 1) - ; - if (t_col > 0 && (wrap || *s == '\r' || *s == '\b' - || *s == '\t' || *s == BELL)) { - // Output any postponed text. - t_puts(&t_col, t_s, s, attr); + if (!((maxlen < 0 || (int)(s - str) < maxlen) && *s != NUL)) { + break; } - if (wrap && p_more && !recurse) { - // Store text for scrolling back. - store_sb_text(&sb_str, s, attr, &sb_col, true); + if (msg_row != msg_row_pending && ((uint8_t)(*s) >= 0x20 || *s == TAB)) { + // TODO(bfredl): this logic is messier that it has to be. What + // messages really want is its own private linebuf_char buffer. + if (msg_row_pending >= 0) { + grid_line_flush_if_valid_row(); + } + grid_line_start(&msg_grid_adj, msg_row); + msg_row_pending = msg_row; } - if (*s == '\n') { // go to next line - msg_didout = false; // remember that line is empty - if (cmdmsg_rl) { - msg_col = Columns - 1; + if ((uint8_t)(*s) >= 0x20) { // printable char + int cw = utf_ptr2cells(s); + // avoid including composing chars after the end + int l = (maxlen >= 0) ? utfc_ptr2len_len(s, (int)((str + maxlen) - s)) : utfc_ptr2len(s); + + if (cw > 1 && (cmdmsg_rl ? msg_col <= 1 : msg_col == Columns - 1)) { + // Doesn't fit, print a highlighted '>' to fill it up. + grid_line_puts(msg_col, ">", 1, HL_ATTR(HLF_AT)); + cw = 1; } else { - msg_col = 0; - } - if (++msg_row >= Rows) { // safety check - msg_row = Rows - 1; - } - } else if (*s == '\r') { // go to column 0 - msg_col = 0; - } else if (*s == '\b') { // go to previous char - if (msg_col) { - msg_col--; + grid_line_puts(msg_col, s, l, print_attr); + s += l; } - } else if (*s == TAB) { // translate Tab into spaces - do { - msg_screen_putchar(' ', attr); - } while (msg_col & 7); - } else if (*s == BELL) { // beep (from ":sh") - vim_beep(BO_SH); - } else if ((uint8_t)(*s) >= 0x20) { // printable char - cw = utf_ptr2cells(s); - if (maxlen >= 0) { - // avoid including composing chars after the end - l = utfc_ptr2len_len(s, (int)((str + maxlen) - s)); + msg_didout = true; // remember that line is not empty + if (cmdmsg_rl) { + msg_col -= cw; } else { - l = utfc_ptr2len(s); + msg_col += cw; } - // When drawing from right to left or when a double-wide character - // doesn't fit, draw a single character here. Otherwise collect - // characters and draw them all at once later. - if (cmdmsg_rl || (cw > 1 && msg_col + t_col >= Columns - 1)) { - if (l > 1) { - s = screen_puts_mbyte(s, l, attr) - 1; + } else { + char c = *s++; + if (c == '\n') { // go to next line + msg_didout = false; // remember that line is empty + if (cmdmsg_rl) { + msg_col = Columns - 1; } else { - msg_screen_putchar(*s, attr); + msg_col = 0; } - } else { - // postpone this character until later - if (t_col == 0) { - t_s = s; + msg_row++; + if (p_more && !recurse) { + // Store text for scrolling back. + store_sb_text(&sb_str, s, attr, &sb_col, true); } - t_col += cw; - s += l - 1; + } else if (c == '\r') { // go to column 0 + msg_col = 0; + } else if (c == '\b') { // go to previous char + if (msg_col) { + msg_col--; + } + } else if (c == TAB) { // translate Tab into spaces + do { + grid_line_puts(msg_col, " ", 1, print_attr); + msg_col += cmdmsg_rl ? -1 : 1; + + if (msg_col == (cmdmsg_rl ? 0 : Columns)) { + break; + } + } while (msg_col & 7); + } else if (c == BELL) { // beep (from ":sh") + vim_beep(BO_SH); } } - s++; } - // Output any postponed text. - if (t_col > 0) { - t_puts(&t_col, t_s, s, attr); + if (msg_row_pending >= 0) { + grid_line_flush_if_valid_row(); } + msg_cursor_goto(msg_row, msg_col); + if (p_more && !recurse && !(s == sb_str + 1 && *sb_str == '\n')) { store_sb_text(&sb_str, s, attr, &sb_col, false); } @@ -2331,6 +2259,13 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) msg_check(); } +void msg_cursor_goto(int row, int col) +{ + ScreenGrid *grid = &msg_grid_adj; + grid_adjust(&grid, &row, &col); + ui_grid_cursor_goto(grid->handle, row, col); +} + /// @return true when ":filter pattern" was used and "msg" does not match /// "pattern". bool message_filtered(const char *msg) @@ -2507,6 +2442,9 @@ static void store_sb_text(const char **sb_str, const char *s, int attr, int *sb_ || do_clear_sb_text == SB_CLEAR_CMDLINE_DONE) { clear_sb_text(do_clear_sb_text == SB_CLEAR_ALL); msg_sb_eol(); // prevent messages from overlapping + if (do_clear_sb_text == SB_CLEAR_CMDLINE_DONE && s > *sb_str && **sb_str == '\n') { + (*sb_str)++; + } do_clear_sb_text = SB_CLEAR_NONE; } @@ -2654,9 +2592,6 @@ static msgchunk_T *disp_sb_line(int row, msgchunk_T *smp) msg_row = row; msg_col = mp->sb_msg_col; char *p = mp->sb_text; - if (*p == '\n') { // don't display the line break - p++; - } msg_puts_display(p, -1, mp->sb_attr, true); if (mp->sb_eol || mp->sb_next == NULL) { break; @@ -2667,26 +2602,6 @@ static msgchunk_T *disp_sb_line(int row, msgchunk_T *smp) return mp->sb_next; } -/// 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); - // Output postponed text. - msg_didout = true; // Remember that line is not empty. - grid_puts(&msg_grid_adj, t_s, (int)(s - t_s), msg_row, msg_col, attr); - msg_col += *t_col; - *t_col = 0; - // If the string starts with a composing character don't increment the - // column position for it. - if (utf_iscomposing(utf_ptr2char(t_s))) { - msg_col--; - } - if (msg_col >= Columns) { - msg_col = 0; - msg_row++; - } -} - /// @return true when messages should be printed to stdout/stderr: /// - "batch mode" ("silent mode", -es/-Es) /// - no UI and not embedded @@ -3033,26 +2948,6 @@ void os_msg(const char *str) } #endif // MSWIN -/// Put a character on the screen at the current message position and advance -/// to the next position. Only for printable ASCII! -static void msg_screen_putchar(int c, int attr) -{ - attr = hl_combine_attr(HL_ATTR(HLF_MSG), attr); - msg_didout = true; // remember that line is not empty - grid_putchar(&msg_grid_adj, c, msg_row, msg_col, attr); - if (cmdmsg_rl) { - if (--msg_col == 0) { - msg_col = Columns; - msg_row++; - } - } else { - if (++msg_col >= Columns) { - msg_col = 0; - msg_row++; - } - } -} - void msg_moremsg(int full) { int attr; -- cgit From e72b546354cd90bf0cd8ee6dd045538d713009ad Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 29 Sep 2023 14:58:48 +0200 Subject: refactor: the long goodbye long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types. --- src/nvim/message.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 5777463e25..af19d0ab87 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1346,7 +1346,7 @@ bool messaging(void) return !(p_lz && char_avail() && !KeyTyped) && (p_ch > 0 || ui_has(kUIMessages)); } -void msgmore(long n) +void msgmore(int n) { long pn; @@ -1480,11 +1480,11 @@ void msg_putchar_attr(int c, int attr) msg_puts_attr(buf, attr); } -void msg_outnum(long n) +void msg_outnum(int n) { char buf[20]; - snprintf(buf, sizeof(buf), "%ld", n); + snprintf(buf, sizeof(buf), "%d", n); msg_puts(buf); } -- cgit From 29fe883aa9166bdbcae3f935523c75a8aa56fe45 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 4 Oct 2023 06:31:25 -0700 Subject: feat: ignore swapfile for running Nvim processes #25336 Problem: The swapfile "E325: ATTENTION" dialog is displayed when editing a file already open in another (running) Nvim. Usually this behavior is annoying and irrelevant: - "Recover" and the other options ("Open readonly", "Quit", "Abort") are almost never wanted. - swapfiles are less relevant for "multi-Nvim" since 'autoread' is enabled by default. - Even less relevant if user enables 'autowrite'. Solution: Define a default SwapExists handler which does the following: 1. If the swapfile is owned by a running Nvim process, automatically chooses "(E)dit anyway" (caveat: this creates a new, extra swapfile, which is mostly harmless and ignored except by `:recover` or `nvim -r`. 2. Shows a 1-line "ignoring swapfile..." message. 3. Users can disable the default SwapExists handler via `autocmd! nvim_swapfile`. --- src/nvim/message.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index af19d0ab87..97402276b2 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -475,7 +475,14 @@ void trunc_string(const char *s, char *buf, int room_in, int buflen) } } -// Note: Caller of smsg() must check the resulting string is shorter than IOSIZE!!! +/// Shows a printf-style message with attributes. +/// +/// Note: Caller must check the resulting string is shorter than IOSIZE!!! +/// +/// @see semsg +/// @see swmsg +/// +/// @param s printf-style format message int smsg(int attr, const char *s, ...) FUNC_ATTR_PRINTF(2, 3) { @@ -757,6 +764,8 @@ void emsg_invreg(int name) } /// Print an error message with unknown number of arguments +/// +/// @return whether the message was displayed bool semsg(const char *const fmt, ...) FUNC_ATTR_PRINTF(1, 2) { @@ -3337,9 +3346,22 @@ void give_warning(const char *message, bool hl) no_wait_return--; } -void give_warning2(const char *const message, const char *const a1, bool hl) +/// Shows a warning, with optional highlighting. +/// +/// @param hl enable highlighting +/// @param fmt printf-style format message +/// +/// @see smsg +/// @see semsg +void swmsg(bool hl, const char *const fmt, ...) + FUNC_ATTR_PRINTF(2, 3) { - vim_snprintf(IObuff, IOSIZE, message, a1); + va_list args; + + va_start(args, fmt); + vim_vsnprintf(IObuff, IOSIZE, fmt, args); + va_end(args); + give_warning(IObuff, hl); } -- cgit From a58bb215449cee65b965b9094e9e996ddfe78315 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 5 Oct 2023 14:44:13 +0200 Subject: refactor(grid): get rid of unbatched grid_puts and grid_putchar This finalizes the long running refactor from the old TUI-focused grid implementation where text-drawing cursor was not separated from the visible cursor. Still, the pattern of setting cursor position together with updating a line was convenient. Introduce grid_line_cursor_goto() to still allow this but now being explicit about it. Only having batched drawing functions makes code involving drawing a bit longer. But it is better to be explicit, and this highlights cases where multiple small redraws can be grouped together. This was the case for most of the changed places (messages, lastline, and :intro) --- src/nvim/message.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 97402276b2..67266b325c 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2959,15 +2959,15 @@ void os_msg(const char *str) void msg_moremsg(int full) { - int attr; - char *s = _("-- More --"); - - attr = hl_combine_attr(HL_ATTR(HLF_MSG), HL_ATTR(HLF_M)); - grid_puts(&msg_grid_adj, s, -1, Rows - 1, 0, attr); + int attr = hl_combine_attr(HL_ATTR(HLF_MSG), HL_ATTR(HLF_M)); + grid_line_start(&msg_grid_adj, Rows - 1); + int len = grid_line_puts(0, _("-- More --"), -1, attr); if (full) { - grid_puts(&msg_grid_adj, _(" SPACE/d/j: screen/page/line down, b/u/k: up, q: quit "), -1, - Rows - 1, vim_strsize(s), attr); + len += grid_line_puts(len, _(" SPACE/d/j: screen/page/line down, b/u/k: up, q: quit "), + -1, attr); } + grid_line_cursor_goto(len); + grid_line_flush(); } /// Repeat the message for the current mode: MODE_ASKMORE, MODE_EXTERNCMD, -- cgit From 8e932480f61d6101bf8bea1abc07ed93826221fd Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 29 Sep 2023 14:58:48 +0200 Subject: refactor: the long goodbye long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types. --- src/nvim/message.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 67266b325c..c1acef8b0d 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -567,10 +567,10 @@ static char *get_emsg_lnum(void) if (SOURCING_NAME != NULL && (other_sourcing_name() || SOURCING_LNUM != last_sourcing_lnum) && SOURCING_LNUM != 0) { - const char *const p = _("line %4ld:"); + const char *const p = _("line %4" PRIdLINENR ":"); const size_t buf_len = 20 + strlen(p); char *const buf = xmalloc(buf_len); - snprintf(buf, buf_len, p, (long)SOURCING_LNUM); + snprintf(buf, buf_len, p, SOURCING_LNUM); return buf; } return NULL; @@ -693,8 +693,8 @@ bool emsg_multiline(const char *s, bool multiline) // Log (silent) errors as debug messages. if (SOURCING_NAME != NULL && SOURCING_LNUM != 0) { - DLOG("(:silent) %s (%s (line %ld))", - s, SOURCING_NAME, (long)SOURCING_LNUM); + DLOG("(:silent) %s (%s (line %" PRIdLINENR "))", + s, SOURCING_NAME, SOURCING_LNUM); } else { DLOG("(:silent) %s", s); } @@ -704,7 +704,7 @@ bool emsg_multiline(const char *s, bool multiline) // Log editor errors as INFO. if (SOURCING_NAME != NULL && SOURCING_LNUM != 0) { - ILOG("%s (%s (line %ld))", s, SOURCING_NAME, (long)SOURCING_LNUM); + ILOG("%s (%s (line %" PRIdLINENR "))", s, SOURCING_NAME, SOURCING_LNUM); } else { ILOG("%s", s); } @@ -1357,7 +1357,7 @@ bool messaging(void) void msgmore(int n) { - long pn; + int pn; if (global_busy // no messages now, wait until global is finished || !messaging()) { // 'lazyredraw' set, don't do messages now @@ -1380,11 +1380,11 @@ void msgmore(int n) if (pn > p_report) { if (n > 0) { vim_snprintf(msg_buf, MSG_BUF_LEN, - NGETTEXT("%ld more line", "%ld more lines", pn), + NGETTEXT("%d more line", "%d more lines", pn), pn); } else { vim_snprintf(msg_buf, MSG_BUF_LEN, - NGETTEXT("%ld line less", "%ld fewer lines", pn), + NGETTEXT("%d line less", "%d fewer lines", pn), pn); } if (got_int) { -- cgit From 44f0480a22af8f87f8784dac430416cb9913adea Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 31 Oct 2023 21:33:00 +0100 Subject: refactor(grid): implement rightleftcmd as a post-processing step Previously, 'rightleftcmd' was implemented by having all code which would affect msg_col or output screen cells be conditional on `cmdmsg_rl`. This change removes all that and instead implements rightleft as a mirroring post-processing step. --- src/nvim/message.c | 75 ++++++++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 45 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index c1acef8b0d..3b33559906 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1231,9 +1231,7 @@ void wait_return(int redraw) } else { msg_didout = false; c = K_IGNORE; - msg_col = - cmdmsg_rl ? Columns - 1 : - 0; + msg_col = 0; } if (quit_more) { c = CAR; // just pretend CR was hit @@ -1435,7 +1433,7 @@ void msg_start(void) if (!msg_scroll && full_screen) { // overwrite last message msg_row = cmdline_row; - msg_col = cmdmsg_rl ? Columns - 1 : 0; + msg_col = 0; } else if (msg_didout || (p_ch == 0 && !ui_has(kUIMessages))) { // start message on next line msg_putchar('\n'); did_return = true; @@ -2132,7 +2130,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) int msg_row_pending = -1; while (true) { - if (cmdmsg_rl ? msg_col <= 0 : msg_col >= Columns) { + if (msg_col >= Columns) { if (p_more && !recurse) { // Store text for scrolling back. store_sb_text(&sb_str, s, attr, &sb_col, true); @@ -2141,7 +2139,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) break; } - msg_col = cmdmsg_rl ? Columns - 1 : 0; + msg_col = 0; msg_row++; msg_didout = false; } @@ -2156,7 +2154,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) if (!recurse) { if (msg_row_pending >= 0) { - grid_line_flush_if_valid_row(); + msg_line_flush(); msg_row_pending = -1; } @@ -2196,7 +2194,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) // TODO(bfredl): this logic is messier that it has to be. What // messages really want is its own private linebuf_char buffer. if (msg_row_pending >= 0) { - grid_line_flush_if_valid_row(); + msg_line_flush(); } grid_line_start(&msg_grid_adj, msg_row); msg_row_pending = msg_row; @@ -2207,7 +2205,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) // avoid including composing chars after the end int l = (maxlen >= 0) ? utfc_ptr2len_len(s, (int)((str + maxlen) - s)) : utfc_ptr2len(s); - if (cw > 1 && (cmdmsg_rl ? msg_col <= 1 : msg_col == Columns - 1)) { + if (cw > 1 && (msg_col == Columns - 1)) { // Doesn't fit, print a highlighted '>' to fill it up. grid_line_puts(msg_col, ">", 1, HL_ATTR(HLF_AT)); cw = 1; @@ -2216,20 +2214,12 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) s += l; } msg_didout = true; // remember that line is not empty - if (cmdmsg_rl) { - msg_col -= cw; - } else { - msg_col += cw; - } + msg_col += cw; } else { char c = *s++; if (c == '\n') { // go to next line msg_didout = false; // remember that line is empty - if (cmdmsg_rl) { - msg_col = Columns - 1; - } else { - msg_col = 0; - } + msg_col = 0; msg_row++; if (p_more && !recurse) { // Store text for scrolling back. @@ -2244,9 +2234,9 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) } else if (c == TAB) { // translate Tab into spaces do { grid_line_puts(msg_col, " ", 1, print_attr); - msg_col += cmdmsg_rl ? -1 : 1; + msg_col += 1; - if (msg_col == (cmdmsg_rl ? 0 : Columns)) { + if (msg_col == Columns) { break; } } while (msg_col & 7); @@ -2257,7 +2247,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) } if (msg_row_pending >= 0) { - grid_line_flush_if_valid_row(); + msg_line_flush(); } msg_cursor_goto(msg_row, msg_col); @@ -2268,9 +2258,20 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) msg_check(); } +void msg_line_flush(void) +{ + if (cmdmsg_rl) { + grid_line_mirror(); + } + grid_line_flush_if_valid_row(); +} + void msg_cursor_goto(int row, int col) { ScreenGrid *grid = &msg_grid_adj; + if (cmdmsg_rl) { + col = Columns - 1 - col; + } grid_adjust(&grid, &row, &col); ui_grid_cursor_goto(grid->handle, row, col); } @@ -2656,18 +2657,10 @@ static void msg_puts_printf(const char *str, const ptrdiff_t maxlen) int cw = utf_char2cells(utf_ptr2char(s)); // primitive way to compute the current column - if (cmdmsg_rl) { - if (*s == '\r' || *s == '\n') { - msg_col = Columns - 1; - } else { - msg_col -= cw; - } + if (*s == '\r' || *s == '\n') { + msg_col = 0; } else { - if (*s == '\r' || *s == '\n') { - msg_col = 0; - } else { - msg_col += cw; - } + msg_col += cw; } s += len; } @@ -2915,8 +2908,6 @@ static int do_more_prompt(int typed_char) if (quit_more) { msg_row = Rows - 1; msg_col = 0; - } else if (cmdmsg_rl) { - msg_col = Columns - 1; } entered = false; @@ -3014,7 +3005,7 @@ void msg_clr_eos_force(void) return; } int msg_startcol = (cmdmsg_rl) ? 0 : msg_col; - int msg_endcol = (cmdmsg_rl) ? msg_col + 1 : Columns; + int msg_endcol = (cmdmsg_rl) ? Columns - msg_col : Columns; if (msg_grid.chars && msg_row < msg_grid_pos) { // TODO(bfredl): ugly, this state should already been validated at this @@ -3028,7 +3019,7 @@ void msg_clr_eos_force(void) ' ', ' ', HL_ATTR(HLF_MSG)); redraw_cmdline = true; // overwritten the command line - if (msg_row < Rows - 1 || msg_col == (cmdmsg_rl ? Columns : 0)) { + if (msg_row < Rows - 1 || msg_col == 0) { clear_cmdline = false; // command line has been cleared mode_displayed = false; // mode cleared or overwritten } @@ -3383,14 +3374,8 @@ void msg_advance(int col) if (col >= Columns) { // not enough room col = Columns - 1; } - if (cmdmsg_rl) { - while (msg_col > Columns - col) { - msg_putchar(' '); - } - } else { - while (msg_col < col) { - msg_putchar(' '); - } + while (msg_col < col) { + msg_putchar(' '); } } -- cgit From acc646ad8fc3ef11fcc63b69f3d8484e4a91accd Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 29 Sep 2023 14:58:48 +0200 Subject: refactor: the long goodbye long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types. --- src/nvim/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 3b33559906..2c8c2eb52d 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -3719,7 +3719,7 @@ void msg_check_for_delay(bool check_msg_scroll) && emsg_silent == 0 && !in_assert_fails) { ui_flush(); - os_delay(1006L, true); + os_delay(1006, true); emsg_on_display = false; if (check_msg_scroll) { msg_scroll = false; -- cgit From 8e58d37f2e15ac8540377148e55ed08a039aadb6 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 11 Nov 2023 11:20:08 +0100 Subject: refactor: remove redundant casts --- src/nvim/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 2c8c2eb52d..916b6f2464 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2284,7 +2284,7 @@ bool message_filtered(const char *msg) return false; } - bool match = vim_regexec(&cmdmod.cmod_filter_regmatch, msg, (colnr_T)0); + bool match = vim_regexec(&cmdmod.cmod_filter_regmatch, msg, 0); return cmdmod.cmod_filter_force ? match : !match; } -- cgit From 353a4be7e84fdc101318215bdcc8a7e780d737fe Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 12 Nov 2023 13:13:58 +0100 Subject: build: remove PVS We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable. --- src/nvim/message.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 916b6f2464..dbef962551 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1,6 +1,3 @@ -// 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 - // message.c: functions for displaying messages on the command line #include @@ -2116,7 +2113,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) msg_ext_last_attr = attr; } // Concat pieces with the same highlight - size_t len = strnlen(str, (size_t)maxlen); // -V781 + size_t len = strnlen(str, (size_t)maxlen); ga_concat_len(&msg_ext_last_chunk, str, len); msg_ext_cur_len += len; return; -- cgit From 28f4f3c48498086307ed825d1761edb5789ca0e8 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 12 Nov 2023 15:54:54 +0100 Subject: refactor: follow style guide - reduce variable scope - prefer initialization over declaration and assignment - use bool to represent boolean values --- src/nvim/message.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index dbef962551..8be8581537 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2680,7 +2680,6 @@ static int do_more_prompt(int typed_char) bool to_redraw = false; msgchunk_T *mp_last = NULL; msgchunk_T *mp; - int i; // If headless mode is enabled and no input is required, this variable // will be true. However If server mode is enabled, the message "--more--" @@ -2698,7 +2697,7 @@ static int do_more_prompt(int typed_char) if (typed_char == 'G') { // "g<": Find first line on the last page. mp_last = msg_sb_start(last_msgchunk); - for (i = 0; i < Rows - 2 && mp_last != NULL + for (int i = 0; i < Rows - 2 && mp_last != NULL && mp_last->sb_prev != NULL; i++) { mp_last = msg_sb_start(mp_last->sb_prev); } @@ -2816,13 +2815,13 @@ static int do_more_prompt(int typed_char) } // go to start of line at top of the screen - for (i = 0; i < Rows - 2 && mp != NULL && mp->sb_prev != NULL; i++) { + for (int i = 0; i < Rows - 2 && mp != NULL && mp->sb_prev != NULL; i++) { mp = msg_sb_start(mp->sb_prev); } if (mp != NULL && (mp->sb_prev != NULL || to_redraw)) { // Find line to be displayed at top - for (i = 0; i > toscroll; i--) { + for (int i = 0; i > toscroll; i--) { if (mp == NULL || mp->sb_prev == NULL) { break; } @@ -2846,7 +2845,7 @@ static int do_more_prompt(int typed_char) // event fragmentization, not unnecessary scroll events). grid_fill(&msg_grid_adj, 0, Rows, 0, Columns, ' ', ' ', HL_ATTR(HLF_MSG)); - for (i = 0; mp != NULL && i < Rows - 1; i++) { + for (int i = 0; mp != NULL && i < Rows - 1; i++) { mp = disp_sb_line(i, mp); msg_scrolled++; } -- cgit From 3ab0e296c674a6846512df24a0a70199bba8c59a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 17 Nov 2023 09:33:54 +0800 Subject: vim-patch:9.0.1969: [security] buffer-overflow in trunc_string() Problem: buffer-overflow in trunc_string() Solution: Add NULL at end of buffer Currently trunc_string() assumes that when the string is too long, buf[e-1] will always be writeable. But that assumption may not always be true. The condition currently looks like this else if (e + 3 < buflen) [...] else { // can't fit in the "...", just truncate it buf[e - 1] = NUL; } but this means, we may run into the last else clause with e still being larger than buflen. So a buffer overflow occurs. So instead of using `buf[e - 1]`, let's just always truncate at `buf[buflen - 1]` which should always be writable. https://github.com/vim/vim/commit/3bd7fa12e146c6051490d048a4acbfba974eeb04 vim-patch:9.0.2004: Missing test file Problem: Missing test file Solution: git-add the file to the repo closes: vim/vim#13305 https://github.com/vim/vim/commit/d4afbdd0715c722cfc73d3a8ab9e578667615faa Co-authored-by: Christian Brabandt --- src/nvim/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 8be8581537..ee1a9e60b0 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -468,7 +468,7 @@ void trunc_string(const char *s, char *buf, int room_in, int buflen) buf[e + 3 + len - 1] = NUL; } else { // can't fit in the "...", just truncate it - buf[e - 1] = NUL; + buf[buflen - 1] = NUL; } } -- cgit From b522cb1ac3fbdf6e68eed5d0b6e1cbeaf3ac2254 Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 6 Nov 2023 14:52:27 +0100 Subject: refactor(grid): make screen rendering more multibyte than ever before Problem: buffer text with composing chars are converted from UTF-8 to an array of up to seven UTF-32 values and then converted back to UTF-8 strings. Solution: Convert buffer text directly to UTF-8 based schar_T values. The limit of the text size is now in schar_T bytes, which is currently 31+1 but easily could be raised as it no longer multiplies the size of the entire screen grid when not used, the full size is only required for temporary scratch buffers. Also does some general cleanup to win_line text handling, which was unnecessarily complicated due to multibyte rendering being an "opt-in" feature long ago. Nowadays, a char is just a char, regardless if it consists of one ASCII byte or multiple bytes. --- src/nvim/message.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index ee1a9e60b0..9e9aa1fcd6 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -139,7 +139,7 @@ static int msg_grid_pos_at_flush = 0; static void ui_ext_msg_set_pos(int row, bool scrolled) { - char buf[MAX_MCO + 1]; + char buf[MB_MAXCHAR + 1]; size_t size = (size_t)utf_char2bytes(curwin->w_p_fcs_chars.msgsep, buf); buf[size] = '\0'; ui_call_msg_set_pos(msg_grid.handle, row, scrolled, @@ -1471,7 +1471,7 @@ void msg_putchar(int c) void msg_putchar_attr(int c, int attr) { - char buf[MB_MAXBYTES + 1]; + char buf[MB_MAXCHAR + 1]; if (IS_SPECIAL(c)) { buf[0] = (char)K_SPECIAL; @@ -1560,12 +1560,6 @@ int msg_outtrans_len(const char *msgstr, int len, int attr) mode_displayed = false; } - // If the string starts with a composing character first draw a space on - // which the composing char can be drawn. - if (utf_iscomposing(utf_ptr2char(msgstr))) { - msg_puts_attr(" ", attr); - } - // Go over the string. Special characters are translated and printed. // Normal characters are printed several at a time. while (--len >= 0 && !got_int) { -- cgit From ac1113ded5f8f09dd99a9894d7a7e795626fb728 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 13 Nov 2023 23:40:37 +0100 Subject: refactor: follow style guide - reduce variable scope - prefer initialization over declaration and assignment --- src/nvim/message.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 9e9aa1fcd6..d9f9c26243 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -285,7 +285,6 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline) FUNC_ATTR_NONNULL_ALL { static int entered = 0; - int retval; char *buf = NULL; if (keep && multiline) { @@ -339,7 +338,7 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline) if (need_clear) { msg_clr_eos(); } - retval = msg_end(); + int retval = msg_end(); if (keep && retval && vim_strsize(s) < (Rows - cmdline_row - 1) * Columns + sc_col) { set_keep_msg(s, 0); @@ -390,7 +389,6 @@ char *msg_strtrunc(const char *s, int force) void trunc_string(const char *s, char *buf, int room_in, int buflen) { int room = room_in - 3; // "..." takes 3 chars - int half; int len = 0; int e; int i; @@ -406,7 +404,7 @@ void trunc_string(const char *s, char *buf, int room_in, int buflen) if (room_in < 3) { room = 0; } - half = room / 2; + int half = room / 2; // First part: Start of the string. for (e = 0; len < half && e < buflen; e++) { @@ -628,7 +626,6 @@ int emsg_not_now(void) bool emsg_multiline(const char *s, bool multiline) { - int attr; bool ignore = false; // Skip this if not giving error messages at the moment. @@ -725,7 +722,7 @@ bool emsg_multiline(const char *s, bool multiline) } emsg_on_display = true; // remember there is an error message - attr = HL_ATTR(HLF_E); // set highlight mode for error messages + int attr = HL_ATTR(HLF_E); // set highlight mode for error messages if (msg_scrolled != 0) { need_wait_return = true; // needed in case emsg() is called after } // wait_return() has reset need_wait_return @@ -898,15 +895,13 @@ void msg_schedule_semsg_multiline(const char *const fmt, ...) /// @return a pointer to the printed message, if wait_return() not called. char *msg_trunc(char *s, bool force, int attr) { - int n; - // Add message to history before truncating. add_msg_hist(s, -1, attr, false); char *ts = msg_may_trunc(force, s); msg_hist_off = true; - n = msg(ts, attr); + int n = msg(ts, attr); msg_hist_off = false; if (n) { @@ -1012,12 +1007,10 @@ static void add_msg_hist_multiattr(const char *s, int len, int attr, bool multil /// @return FAIL if there are no messages. int delete_first_msg(void) { - struct msg_hist *p; - if (msg_hist_len <= 0) { return FAIL; } - p = first_msg_hist; + struct msg_hist *p = first_msg_hist; first_msg_hist = p->next; if (first_msg_hist == NULL) { // history is becoming empty assert(msg_hist_len == 1); @@ -1034,8 +1027,6 @@ int delete_first_msg(void) void ex_messages(exarg_T *eap) FUNC_ATTR_NONNULL_ALL { - struct msg_hist *p; - if (strcmp(eap->arg, "clear") == 0) { int keep = eap->addr_count == 0 ? 0 : eap->line2; @@ -1050,7 +1041,7 @@ void ex_messages(exarg_T *eap) return; } - p = first_msg_hist; + struct msg_hist *p = first_msg_hist; if (eap->addr_count != 0) { int c = 0; @@ -1132,8 +1123,6 @@ void msg_end_prompt(void) void wait_return(int redraw) { int c; - int oldState; - int tmpState; int had_got_int; FILE *save_scriptout; @@ -1167,7 +1156,7 @@ void wait_return(int redraw) } redir_off = true; // don't redirect this message - oldState = State; + int oldState = State; if (quit_more) { c = CAR; // just pretend CR was hit quit_more = false; @@ -1282,7 +1271,7 @@ void wait_return(int redraw) // If the screen size changed screen_resize() will redraw the screen. // Otherwise the screen is only redrawn if 'redraw' is set and no ':' // typed. - tmpState = State; + int tmpState = State; State = oldState; // restore State before screen_resize() setmouse(); msg_check(); -- cgit From 951034614110cf2e4388645ee17ed4a315d0d382 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 24 Nov 2023 06:13:24 +0800 Subject: vim-patch:9.0.2125: File info disappears when 'cmdheight' has decreased (#26180) Problem: File info disappears immediately when 'cmdheight' has just decreased due to switching tabpage and 'shortmess' doesn't contain 'o' or 'O'. Solution: Make sure msg_row isn't smaller than cmdline_row. fixes: vim/vim#13560 closes: vim/vim#13561 https://github.com/vim/vim/commit/40ed6711bd385051021691980e8ce16375b4b510 --- src/nvim/message.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index d9f9c26243..2ff0172ac4 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1395,7 +1395,11 @@ void msg_ext_set_kind(const char *msg_kind) /// Prepare for outputting characters in the command line. void msg_start(void) { - int did_return = false; + bool did_return = false; + + if (msg_row < cmdline_row) { + msg_row = cmdline_row; + } if (!msg_silent) { XFREE_CLEAR(keep_msg); // don't display old message now -- cgit From 55dbf5c3798cde8f9bfd36cd17dce636f6f6ea08 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 24 Nov 2023 10:44:19 +0800 Subject: fix(messages): validate msg_grid before using msg_grid_pos (#26189) --- src/nvim/message.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 2ff0172ac4..2ba6355528 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2990,10 +2990,13 @@ void msg_clr_eos_force(void) int msg_startcol = (cmdmsg_rl) ? 0 : msg_col; int msg_endcol = (cmdmsg_rl) ? Columns - msg_col : Columns; + // TODO(bfredl): ugly, this state should already been validated at this + // point. But msg_clr_eos() is called in a lot of places. if (msg_grid.chars && msg_row < msg_grid_pos) { - // TODO(bfredl): ugly, this state should already been validated at this - // point. But msg_clr_eos() is called in a lot of places. - msg_row = msg_grid_pos; + msg_grid_validate(); + if (msg_row < msg_grid_pos) { + msg_row = msg_grid_pos; + } } grid_fill(&msg_grid_adj, msg_row, msg_row + 1, msg_startcol, msg_endcol, -- cgit From 38a20dd89f91c45ec8589bf1c50d50732882d38a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Nov 2023 20:58:37 +0800 Subject: build(IWYU): replace most private mappings with pragmas (#26247) --- src/nvim/message.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 2ba6355528..032f079f46 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -41,6 +41,7 @@ #include "nvim/ops.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" #include "nvim/os/time.h" -- cgit From 40139738eb479d0913ec6ce751ca5adfa50ad8c3 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 26 Nov 2023 21:36:02 +0100 Subject: build: enable IWYU on mac --- src/nvim/message.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 032f079f46..641ceff2e8 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "nvim/api/private/helpers.h" #include "nvim/ascii.h" -- cgit From 8b428ca8b79ebb7b36c3e403ff3bcb6924a635a6 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 16:00:21 +0100 Subject: build(IWYU): fix includes for func_attr.h --- src/nvim/message.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 641ceff2e8..01ca361d5e 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -24,6 +24,7 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_eval.h" #include "nvim/fileio.h" +#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/gettext.h" -- cgit From f4aedbae4cb1f206f5b7c6142697b71dd473059b Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 18:39:38 +0100 Subject: build(IWYU): fix includes for undo_defs.h --- src/nvim/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 01ca361d5e..06badf85a1 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -47,7 +47,7 @@ #include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/os/time.h" -#include "nvim/pos.h" +#include "nvim/pos_defs.h" #include "nvim/regexp.h" #include "nvim/runtime.h" #include "nvim/strings.h" -- cgit From c9f53d0e40815644bbf7c57a0792f2c793c954aa Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Nov 2023 19:00:14 +0800 Subject: refactor: iwyu (#26269) --- src/nvim/message.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 06badf85a1..fcfaf636e6 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -51,6 +51,7 @@ #include "nvim/regexp.h" #include "nvim/runtime.h" #include "nvim/strings.h" +#include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/ui_compositor.h" #include "nvim/vim.h" -- cgit From 79b6ff28ad1204fbb4199b9092f5c578d88cb28e Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 28 Nov 2023 20:31:00 +0100 Subject: refactor: fix headers with IWYU --- src/nvim/message.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index fcfaf636e6..4bf099d1fa 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -11,7 +11,7 @@ #include #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/channel.h" #include "nvim/charset.h" @@ -54,7 +54,7 @@ #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/ui_compositor.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" // To be able to scroll back at the "more" and "hit-enter" prompts we need to // store the displayed text and remember where screen lines start. -- cgit From a6cba103cebce535279db197f9efeb34e9d1171f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 29 Nov 2023 20:32:40 +0800 Subject: refactor: move some constants out of vim_defs.h (#26298) --- src/nvim/message.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 4bf099d1fa..3268ff389a 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -50,6 +50,7 @@ #include "nvim/pos_defs.h" #include "nvim/regexp.h" #include "nvim/runtime.h" +#include "nvim/state_defs.h" #include "nvim/strings.h" #include "nvim/types_defs.h" #include "nvim/ui.h" -- cgit