From 60ab22dfa6c9888fe8e261f185bfe4b0ab72956e Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Sat, 4 Feb 2023 10:43:20 +0100 Subject: refactor(column): remove unused build_statuscol_str() arguments Problem: `build_statuscol_str()` still has arguments that were necessary for building a status column string in `number_width()`, which was abandoned in #22094. Solution: Remove unused arguments. --- src/nvim/statusline.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 6ad1f31143..a1523f6574 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -885,11 +885,8 @@ void draw_tabline(void) /// Build the 'statuscolumn' string for line "lnum". When "relnum" == -1, /// the v:lnum and v:relnum variables don't have to be updated. /// -/// @param hlrec HL attributes (can be NULL) -/// @param stcp Status column attributes (can be NULL) /// @return The width of the built status column string for line "lnum" -int build_statuscol_str(win_T *wp, linenr_T lnum, long relnum, int maxwidth, int fillchar, - char *buf, stl_hlrec_t **hlrec, statuscol_T *stcp) +int build_statuscol_str(win_T *wp, linenr_T lnum, long relnum, statuscol_T *stcp) { bool fillclick = relnum >= 0 && lnum == wp->w_topline; @@ -900,8 +897,8 @@ int build_statuscol_str(win_T *wp, linenr_T lnum, long relnum, int maxwidth, int StlClickRecord *clickrec; char *stc = xstrdup(wp->w_p_stc); - int width = build_stl_str_hl(wp, buf, MAXPATHL, stc, "statuscolumn", OPT_LOCAL, fillchar, - maxwidth, hlrec, fillclick ? &clickrec : NULL, stcp); + int width = build_stl_str_hl(wp, stcp->text, MAXPATHL, stc, "statuscolumn", OPT_LOCAL, ' ', + stcp->width, &stcp->hlrec, fillclick ? &clickrec : NULL, stcp); xfree(stc); // Only update click definitions once per window per redraw @@ -909,7 +906,7 @@ int build_statuscol_str(win_T *wp, linenr_T lnum, long relnum, int maxwidth, int stl_clear_click_defs(wp->w_statuscol_click_defs, wp->w_statuscol_click_defs_size); wp->w_statuscol_click_defs = stl_alloc_click_defs(wp->w_statuscol_click_defs, width, &wp->w_statuscol_click_defs_size); - stl_fill_click_defs(wp->w_statuscol_click_defs, clickrec, buf, width, false); + stl_fill_click_defs(wp->w_statuscol_click_defs, clickrec, stcp->text, width, false); } return width; -- cgit From 08fb3b5309dee79585f3eec2450636966cbb01b4 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Tue, 31 Jan 2023 00:52:34 +0100 Subject: perf(column): only build fold/sign column when present in 'statuscolumn' Problem: The fold and sign column is built and stored regardless of whether the corresponding item is present in 'statuscolumn'. Solution: Since the 'statuscolumn' parses itself, we can defer building the columns until the corresponding item is actually encountered. --- src/nvim/statusline.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 6ad1f31143..1882cbbacc 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -38,7 +38,7 @@ #include "nvim/path.h" #include "nvim/pos.h" #include "nvim/screen.h" -#include "nvim/sign_defs.h" +#include "nvim/sign.h" #include "nvim/statusline.h" #include "nvim/strings.h" #include "nvim/types.h" @@ -1648,20 +1648,40 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n if (stcp == NULL) { break; } - bool fold = opt == STL_FOLDCOL; + int width = fold ? (compute_foldcolumn(wp, 0) > 0) : wp->w_scwidth; + + if (width == 0) { + break; + } + + char *p; + if (fold) { + size_t n = fill_foldcolumn(out_p, wp, stcp->foldinfo, (linenr_T)get_vim_var_nr(VV_LNUM)); + stl_items[curitem].minwid = win_hl_attr(wp, stcp->use_cul ? HLF_CLF : HLF_FC); + p = out_p; + p[n] = NUL; + } + *buf_tmp = NUL; - for (int i = 0; i <= SIGN_SHOW_MAX; i++) { - char *p = fold ? stcp->fold_text : stcp->sign_text[i]; - if ((!p || !*p) && *buf_tmp == NUL) { - break; + varnumber_T virtnum = get_vim_var_nr(VV_VIRTNUM); + for (int i = 0; i <= width; i++) { + if (i == width) { + if (*buf_tmp == NUL) { + break; + } + stl_items[curitem].minwid = 0; + } else if (!fold) { + SignTextAttrs *sattr = virtnum ? NULL : sign_get_attr(i, stcp->sattrs, wp->w_scwidth); + p = sattr && sattr->text ? sattr->text : " "; + stl_items[curitem].minwid = sattr ? stcp->sign_cul_attr ? stcp->sign_cul_attr + : sattr->hl_attr_id + : win_hl_attr(wp, stcp->use_cul ? HLF_CLS : HLF_SC); } stl_items[curitem].type = Highlight; stl_items[curitem].start = out_p + strlen(buf_tmp); - stl_items[curitem].minwid = !p || (fold && i) ? 0 : fold ? stcp->fold_attr - : stcp->sign_attr[i]; curitem++; - if (!p || (fold && i)) { + if (i == width) { str = buf_tmp; break; } -- cgit From 7224c889e0d5d70b99ae377036baa6377c33a568 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Feb 2023 10:25:24 +0100 Subject: build: enable MSVC level 3 warnings (#21934) MSVC has 4 different warning levels: 1 (severe), 2 (significant), 3 (production quality) and 4 (informational). Enabling level 3 warnings mostly revealed conversion problems, similar to GCC/clang -Wconversion flag. --- src/nvim/statusline.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 6ad1f31143..9552f3f42b 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -1,6 +1,5 @@ // This is an open source non-commercial project. Dear PVS-Studio, please check // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com -// #include #include @@ -1390,7 +1389,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n NumberBase base = kNumBaseDecimal; bool itemisflag = false; bool fillable = true; - long num = -1; + int num = -1; char *str = NULL; switch (opt) { case STL_FILEPATH: @@ -1520,10 +1519,10 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // Overload %l with v:lnum for 'statuscolumn' if (opt_name != NULL && strcmp(opt_name, "statuscolumn") == 0) { if (wp->w_p_nu && !get_vim_var_nr(VV_VIRTNUM)) { - num = get_vim_var_nr(VV_LNUM); + num = (int)get_vim_var_nr(VV_LNUM); } } else { - num = (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) ? 0L : (long)(wp->w_cursor.lnum); + num = (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) ? 0L : wp->w_cursor.lnum; } break; @@ -1544,7 +1543,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n ? 0 : (int)wp->w_cursor.col + 1))) { break; } - num = (long)virtcol; + num = virtcol; break; } @@ -1604,8 +1603,8 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n long l = ml_find_line_or_offset(wp->w_buffer, wp->w_cursor.lnum, NULL, false); num = (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) || l < 0 ? - 0L : l + 1 + ((State & MODE_INSERT) == 0 && empty_line ? - 0 : (int)wp->w_cursor.col); + 0L : (int)l + 1 + ((State & MODE_INSERT) == 0 && empty_line ? + 0 : (int)wp->w_cursor.col); break; } case STL_BYTEVAL_X: @@ -1625,7 +1624,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // Overload %r with v:relnum for 'statuscolumn' if (opt_name != NULL && strcmp(opt_name, "statuscolumn") == 0) { if (wp->w_p_rnu && !get_vim_var_nr(VV_VIRTNUM)) { - num = get_vim_var_nr(VV_RELNUM); + num = (int)get_vim_var_nr(VV_RELNUM); } } else { itemisflag = true; @@ -1889,7 +1888,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // { Reduce the number by base^n while (num_chars-- > maxwid) { - num /= (long)base; + num /= (int)base; } // } -- 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/statusline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 9552f3f42b..a094a5f945 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -582,7 +582,7 @@ void win_redr_ruler(win_T *wp, bool always) MAXSIZE_TEMP_ARRAY(content, 1); MAXSIZE_TEMP_ARRAY(chunk, 2); ADD_C(chunk, INTEGER_OBJ(attr)); - ADD_C(chunk, STRING_OBJ(cstr_as_string((char *)buffer))); + ADD_C(chunk, STRING_OBJ(cstr_as_string(buffer))); ADD_C(content, ARRAY_OBJ(chunk)); ui_call_msg_ruler(content); did_show_ext_ruler = true; -- cgit From 374955bcc571dff05f068ec18d0f578d1f334c5f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 11 Feb 2023 20:00:31 +0800 Subject: vim-patch:9.0.1300: 'statusline' only supports one "%=" item (#22218) Problem: 'statusline' only supports one "%=" item. Solution: Add support for multiple "%=" items. (TJ DeVries, Yegappan Lakshmanan, closes vim/vim#11970, closes vim/vim#11965) https://github.com/vim/vim/commit/3ec78f973fdaec2cea8e036ed38037b2fe40670b Co-authored-by: Yegappan Lakshmanan --- src/nvim/statusline.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index a094a5f945..6e0dc2e8f7 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -1094,7 +1094,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n continue; } - // STL_SEPARATE: Separation place between left and right aligned items. + // STL_SEPARATE: Separation between items, filled with white space. if (*fmt_p == STL_SEPARATE) { fmt_p++; // Ignored when we are inside of a grouping @@ -2066,8 +2066,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n int num_separators = 0; for (int i = 0; i < itemcnt; i++) { if (stl_items[i].type == Separate) { - // Create an array of the start location for each - // separator mark. + // Create an array of the start location for each separator mark. stl_separator_locations[num_separators] = i; num_separators++; } @@ -2079,17 +2078,17 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n int final_spaces = (maxwidth - width) - standard_spaces * (num_separators - 1); - for (int i = 0; i < num_separators; i++) { - int dislocation = (i == (num_separators - 1)) ? final_spaces : standard_spaces; + for (int l = 0; l < num_separators; l++) { + int dislocation = (l == (num_separators - 1)) ? final_spaces : standard_spaces; dislocation *= utf_char2len(fillchar); - char *start = stl_items[stl_separator_locations[i]].start; + char *start = stl_items[stl_separator_locations[l]].start; char *seploc = start + dislocation; STRMOVE(seploc, start); for (char *s = start; s < seploc;) { MB_CHAR2BYTES(fillchar, s); } - for (int item_idx = stl_separator_locations[i] + 1; + for (int item_idx = stl_separator_locations[l] + 1; item_idx < itemcnt; item_idx++) { stl_items[item_idx].start += dislocation; -- cgit From 5f72ab77bff1f1224be5cbbf9423bdddbc25635c Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sun, 12 Feb 2023 18:48:49 +0100 Subject: refactor: reduce scope of locals as per the style guide 3 (#22221) refactor: reduce scope of locals as per the style guide --- src/nvim/statusline.c | 48 +++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 6e0dc2e8f7..6414b2bb74 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -260,23 +260,17 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) { static bool entered = false; int attr; - int curattr; int row; int col = 0; int maxwidth; - int width; int n; - int len; int fillchar; char buf[MAXPATHL]; char *stl; - char *p; char *opt_name; int opt_scope = 0; stl_hlrec_t *hltab; StlClickRecord *tabtab; - win_T *ewp; - int p_crb_save; bool is_stl_global = global_stl_height() > 0; ScreenGrid *grid = &default_grid; @@ -369,22 +363,22 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) // Temporarily reset 'cursorbind', we don't want a side effect from moving // the cursor away and back. - ewp = wp == NULL ? curwin : wp; - p_crb_save = ewp->w_p_crb; + win_T *ewp = wp == NULL ? curwin : wp; + int p_crb_save = ewp->w_p_crb; ewp->w_p_crb = false; // Make a copy, because the statusline may include a function call that // might change the option value and free the memory. stl = xstrdup(stl); - width = build_stl_str_hl(ewp, buf, sizeof(buf), stl, opt_name, opt_scope, - fillchar, maxwidth, &hltab, &tabtab, NULL); + int width = build_stl_str_hl(ewp, buf, sizeof(buf), stl, opt_name, opt_scope, + fillchar, maxwidth, &hltab, &tabtab, NULL); xfree(stl); ewp->w_p_crb = p_crb_save; // Make all characters printable. - p = transstr(buf, true); - len = (int)xstrlcpy(buf, p, sizeof(buf)); + char *p = transstr(buf, true); + int len = (int)xstrlcpy(buf, p, sizeof(buf)); len = (size_t)len < sizeof(buf) ? len : (int)sizeof(buf) - 1; xfree(p); @@ -398,7 +392,7 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) // Draw each snippet with the specified highlighting. grid_puts_line_start(grid, row); - curattr = attr; + int curattr = attr; p = buf; for (n = 0; hltab[n].start != NULL; n++) { int textlen = (int)(hltab[n].start - p); @@ -709,21 +703,9 @@ static void ui_ext_tabline_update(void) /// Draw the tab pages line at the top of the Vim window. void draw_tabline(void) { - int tabcount = 0; - int tabwidth = 0; - int col = 0; - int scol = 0; - int attr; win_T *wp; - win_T *cwp; - int wincount; - int modified; - int c; - int len; int attr_nosel = HL_ATTR(HLF_TP); int attr_fill = HL_ATTR(HLF_TPF); - char *p; - int room; int use_sep_chars = (t_colors < 8); if (default_grid.chars == NULL) { @@ -748,6 +730,14 @@ void draw_tabline(void) if (*p_tal != NUL) { win_redr_custom(NULL, false, false); } else { + int tabcount = 0; + int tabwidth = 0; + int col = 0; + win_T *cwp; + int wincount; + int c; + int len; + char *p; FOR_ALL_TABS(tp) { tabcount++; } @@ -760,7 +750,7 @@ void draw_tabline(void) tabwidth = 6; } - attr = attr_nosel; + int attr = attr_nosel; tabcount = 0; FOR_ALL_TABS(tp) { @@ -768,7 +758,7 @@ void draw_tabline(void) break; } - scol = col; + int scol = col; if (tp == curtab) { cwp = curwin; @@ -791,7 +781,7 @@ void draw_tabline(void) grid_putchar(&default_grid, ' ', 0, col++, attr); - modified = false; + int modified = false; for (wincount = 0; wp != NULL; wp = wp->w_next, wincount++) { if (bufIsChanged(wp->w_buffer)) { @@ -816,7 +806,7 @@ void draw_tabline(void) grid_putchar(&default_grid, ' ', 0, col++, attr); } - room = scol - col + tabwidth - 1; + int room = scol - col + tabwidth - 1; if (room > 0) { // Get buffer name in NameBuff[] get_trans_bufname(cwp->w_buffer); -- cgit From 39f8aaeb815c2e31cffec12ef36ad4f25df91602 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Fri, 24 Jan 2020 09:48:58 +0100 Subject: fix(status): handle unprintable chars in the statusline --- src/nvim/statusline.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 6414b2bb74..c880de5060 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -152,8 +152,8 @@ void win_redr_status(win_T *wp) row = is_stl_global ? (Rows - (int)p_ch - 1) : W_ENDROW(wp); col = is_stl_global ? 0 : wp->w_wincol; - grid_puts(&default_grid, p, row, col, attr); - grid_fill(&default_grid, row, row + 1, len + col, + int width = grid_puts(&default_grid, p, row, col, attr); + grid_fill(&default_grid, row, row + 1, width + col, this_ru_col + col, fillchar, fillchar, attr); if (get_keymap_str(wp, "<%s>", NameBuff, MAXPATHL) @@ -266,6 +266,7 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) int n; int fillchar; char buf[MAXPATHL]; + char transbuf[MAXPATHL]; char *stl; char *opt_name; int opt_scope = 0; @@ -370,34 +371,25 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) // Make a copy, because the statusline may include a function call that // might change the option value and free the memory. stl = xstrdup(stl); - int width = build_stl_str_hl(ewp, buf, sizeof(buf), stl, opt_name, opt_scope, - fillchar, maxwidth, &hltab, &tabtab, NULL); + build_stl_str_hl(ewp, buf, sizeof(buf), stl, opt_name, opt_scope, + fillchar, maxwidth, &hltab, &tabtab, NULL); xfree(stl); ewp->w_p_crb = p_crb_save; - // Make all characters printable. - char *p = transstr(buf, true); - int len = (int)xstrlcpy(buf, p, sizeof(buf)); - len = (size_t)len < sizeof(buf) ? len : (int)sizeof(buf) - 1; - xfree(p); - - // fill up with "fillchar" - while (width < maxwidth && len < (int)sizeof(buf) - 1) { - len += utf_char2bytes(fillchar, buf + len); - width++; - } - buf[len] = NUL; + int len = (int)strlen(buf); + int start_col = col; // Draw each snippet with the specified highlighting. grid_puts_line_start(grid, row); int curattr = attr; - p = buf; + char *p = buf; for (n = 0; hltab[n].start != NULL; n++) { int textlen = (int)(hltab[n].start - p); - grid_puts_len(grid, p, textlen, row, col, curattr); - col += vim_strnsize(p, textlen); + // Make all characters printable. + size_t tsize = transstr_buf(p, textlen, transbuf, sizeof transbuf, true); + col += grid_puts_len(grid, transbuf, (int)tsize, row, col, curattr); p = hltab[n].start; if (hltab[n].userhl == 0) { @@ -411,7 +403,12 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) } } // Make sure to use an empty string instead of p, if p is beyond buf + len. - grid_puts(grid, p >= buf + len ? "" : p, row, col, curattr); + size_t tsize = transstr_buf(p >= buf + len ? "" : p, -1, transbuf, sizeof transbuf, true); + col += grid_puts_len(grid, transbuf, (int)tsize, row, col, curattr); + int maxcol = start_col + maxwidth; + + // fill up with "fillchar" + grid_fill(grid, row, row + 1, col, maxcol, fillchar, fillchar, curattr); grid_puts_line_flush(false); -- cgit From fe11079721084b3638ae3d8e5266f95d52028fb7 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 8 Mar 2023 12:36:03 +0100 Subject: perf(statusline): UI elements are always redrawn on K_EVENT Problem: 'statusline'-format UI elements are redrawn on each K_EVENT. Solution: Only redraw UI elements when something relevant has changed. --- src/nvim/statusline.c | 224 +++++++++++++++++++++++--------------------------- 1 file changed, 101 insertions(+), 123 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index de91bf334c..ff03017e6c 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -162,7 +162,7 @@ void win_redr_status(win_T *wp) (int)((size_t)this_ru_col - strlen(NameBuff) - 1), attr); } - win_redr_ruler(wp, true); + win_redr_ruler(wp); // Draw the 'showcmd' information if 'showcmdloc' == "statusline". if (p_sc && *p_sloc == 's') { @@ -443,7 +443,7 @@ void win_redr_winbar(win_T *wp) entered = false; } -void win_redr_ruler(win_T *wp, bool always) +void win_redr_ruler(win_T *wp) { bool is_stl_global = global_stl_height() > 0; static bool did_show_ext_ruler = false; @@ -473,138 +473,116 @@ void win_redr_ruler(win_T *wp, bool always) } // Check if not in Insert mode and the line is empty (will show "0-1"). - int empty_line = false; - if ((State & MODE_INSERT) == 0 && *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, false) == NUL) { - empty_line = true; - } + int empty_line = (State & MODE_INSERT) == 0 + && *ml_get_buf(curwin->w_buffer, curwin->w_cursor.lnum, false) == NUL; - // Only draw the ruler when something changed. - validate_virtcol_win(wp); - if (redraw_cmdline - || always - || wp->w_cursor.lnum != wp->w_ru_cursor.lnum - || wp->w_cursor.col != wp->w_ru_cursor.col - || wp->w_virtcol != wp->w_ru_virtcol - || wp->w_cursor.coladd != wp->w_ru_cursor.coladd - || wp->w_topline != wp->w_ru_topline - || wp->w_buffer->b_ml.ml_line_count != wp->w_ru_line_count - || wp->w_topfill != wp->w_ru_topfill - || empty_line != wp->w_ru_empty) { - int width; - int row; - int fillchar; - int attr; - int off; - bool part_of_status = false; - - if (wp->w_status_height) { - row = W_ENDROW(wp); - fillchar = fillchar_status(&attr, wp); - off = wp->w_wincol; - width = wp->w_width; - part_of_status = true; - } else if (is_stl_global) { - row = Rows - (int)p_ch - 1; - fillchar = fillchar_status(&attr, wp); - off = 0; - width = Columns; - part_of_status = true; - } else { - row = Rows - 1; - fillchar = ' '; - attr = HL_ATTR(HLF_MSG); - width = Columns; - off = 0; - } + int width; + int row; + int fillchar; + int attr; + int off; + bool part_of_status = false; - if (!part_of_status && p_ch == 0 && !ui_has(kUIMessages)) { - return; - } + if (wp->w_status_height) { + row = W_ENDROW(wp); + fillchar = fillchar_status(&attr, wp); + off = wp->w_wincol; + width = wp->w_width; + part_of_status = true; + } else if (is_stl_global) { + row = Rows - (int)p_ch - 1; + fillchar = fillchar_status(&attr, wp); + off = 0; + width = Columns; + part_of_status = true; + } else { + row = Rows - 1; + fillchar = ' '; + attr = HL_ATTR(HLF_MSG); + width = Columns; + off = 0; + } - // In list mode virtcol needs to be recomputed - colnr_T virtcol = wp->w_virtcol; - if (wp->w_p_list && wp->w_p_lcs_chars.tab1 == NUL) { - wp->w_p_list = false; - getvvcol(wp, &wp->w_cursor, NULL, &virtcol, NULL); - wp->w_p_list = true; - } + if (!part_of_status && p_ch == 0 && !ui_has(kUIMessages)) { + return; + } + + // In list mode virtcol needs to be recomputed + colnr_T virtcol = wp->w_virtcol; + if (wp->w_p_list && wp->w_p_lcs_chars.tab1 == NUL) { + wp->w_p_list = false; + getvvcol(wp, &wp->w_cursor, NULL, &virtcol, NULL); + wp->w_p_list = true; + } #define RULER_BUF_LEN 70 - char buffer[RULER_BUF_LEN]; - - // Some sprintfs return the length, some return a pointer. - // To avoid portability problems we use strlen() here. - vim_snprintf(buffer, RULER_BUF_LEN, "%" PRId64 ",", - (wp->w_buffer->b_ml.ml_flags & - ML_EMPTY) ? (int64_t)0L : (int64_t)wp->w_cursor.lnum); - size_t len = strlen(buffer); - col_print(buffer + len, RULER_BUF_LEN - len, - empty_line ? 0 : (int)wp->w_cursor.col + 1, - (int)virtcol + 1); - - // Add a "50%" if there is room for it. - // On the last line, don't print in the last column (scrolls the - // screen up on some terminals). - int i = (int)strlen(buffer); - get_rel_pos(wp, buffer + i + 1, RULER_BUF_LEN - i - 1); - int o = i + vim_strsize(buffer + i + 1); - if (wp->w_status_height == 0 && !is_stl_global) { // can't use last char of screen + char buffer[RULER_BUF_LEN]; + + // Some sprintfs return the length, some return a pointer. + // To avoid portability problems we use strlen() here. + vim_snprintf(buffer, RULER_BUF_LEN, "%" PRId64 ",", + (wp->w_buffer->b_ml.ml_flags & + ML_EMPTY) ? (int64_t)0L : (int64_t)wp->w_cursor.lnum); + size_t len = strlen(buffer); + col_print(buffer + len, RULER_BUF_LEN - len, + empty_line ? 0 : (int)wp->w_cursor.col + 1, + (int)virtcol + 1); + + // Add a "50%" if there is room for it. + // On the last line, don't print in the last column (scrolls the + // screen up on some terminals). + int i = (int)strlen(buffer); + get_rel_pos(wp, buffer + i + 1, RULER_BUF_LEN - i - 1); + int o = i + vim_strsize(buffer + i + 1); + if (wp->w_status_height == 0 && !is_stl_global) { // can't use last char of screen + o++; + } + int this_ru_col = ru_col - (Columns - width); + if (this_ru_col < 0) { + this_ru_col = 0; + } + // Never use more than half the window/screen width, leave the other half + // for the filename. + if (this_ru_col < (width + 1) / 2) { + this_ru_col = (width + 1) / 2; + } + if (this_ru_col + o < width) { + // Need at least 3 chars left for get_rel_pos() + NUL. + while (this_ru_col + o < width && RULER_BUF_LEN > i + 4) { + i += utf_char2bytes(fillchar, buffer + i); o++; } - int this_ru_col = ru_col - (Columns - width); - if (this_ru_col < 0) { - this_ru_col = 0; - } - // Never use more than half the window/screen width, leave the other half - // for the filename. - if (this_ru_col < (width + 1) / 2) { - this_ru_col = (width + 1) / 2; - } - if (this_ru_col + o < width) { - // Need at least 3 chars left for get_rel_pos() + NUL. - while (this_ru_col + o < width && RULER_BUF_LEN > i + 4) { - i += utf_char2bytes(fillchar, buffer + i); - o++; - } - get_rel_pos(wp, buffer + i, RULER_BUF_LEN - i); - } + get_rel_pos(wp, buffer + i, RULER_BUF_LEN - i); + } - if (ui_has(kUIMessages) && !part_of_status) { - MAXSIZE_TEMP_ARRAY(content, 1); - MAXSIZE_TEMP_ARRAY(chunk, 2); - ADD_C(chunk, INTEGER_OBJ(attr)); - ADD_C(chunk, STRING_OBJ(cstr_as_string(buffer))); - ADD_C(content, ARRAY_OBJ(chunk)); - ui_call_msg_ruler(content); - did_show_ext_ruler = true; - } else { - if (did_show_ext_ruler) { - ui_call_msg_ruler((Array)ARRAY_DICT_INIT); - did_show_ext_ruler = false; - } - // Truncate at window boundary. - o = 0; - for (i = 0; buffer[i] != NUL; i += utfc_ptr2len(buffer + i)) { - o += utf_ptr2cells(buffer + i); - if (this_ru_col + o > width) { - buffer[i] = NUL; - break; - } + if (ui_has(kUIMessages) && !part_of_status) { + MAXSIZE_TEMP_ARRAY(content, 1); + MAXSIZE_TEMP_ARRAY(chunk, 2); + ADD_C(chunk, INTEGER_OBJ(attr)); + ADD_C(chunk, STRING_OBJ(cstr_as_string(buffer))); + ADD_C(content, ARRAY_OBJ(chunk)); + ui_call_msg_ruler(content); + did_show_ext_ruler = true; + } else { + if (did_show_ext_ruler) { + ui_call_msg_ruler((Array)ARRAY_DICT_INIT); + did_show_ext_ruler = false; + } + // Truncate at window boundary. + o = 0; + for (i = 0; buffer[i] != NUL; i += utfc_ptr2len(buffer + i)) { + o += utf_ptr2cells(buffer + i); + if (this_ru_col + o > width) { + buffer[i] = NUL; + break; } - - ScreenGrid *grid = part_of_status ? &default_grid : &msg_grid_adj; - grid_puts(grid, buffer, row, this_ru_col + off, attr); - grid_fill(grid, row, row + 1, - this_ru_col + off + (int)strlen(buffer), off + width, fillchar, - fillchar, attr); } - wp->w_ru_cursor = wp->w_cursor; - wp->w_ru_virtcol = wp->w_virtcol; - wp->w_ru_empty = (char)empty_line; - wp->w_ru_topline = wp->w_topline; - wp->w_ru_line_count = wp->w_buffer->b_ml.ml_line_count; - wp->w_ru_topfill = wp->w_topfill; + ScreenGrid *grid = part_of_status ? &default_grid : &msg_grid_adj; + grid_puts(grid, buffer, row, this_ru_col + off, attr); + grid_fill(grid, row, row + 1, + this_ru_col + off + (int)strlen(buffer), off + width, fillchar, + fillchar, attr); } } -- 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/statusline.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index ff03017e6c..ca92953b05 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -15,6 +15,7 @@ #include "nvim/buffer.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" +#include "nvim/digraph.h" #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval_defs.h" @@ -36,7 +37,6 @@ #include "nvim/os/os.h" #include "nvim/path.h" #include "nvim/pos.h" -#include "nvim/screen.h" #include "nvim/sign.h" #include "nvim/statusline.h" #include "nvim/strings.h" @@ -180,13 +180,46 @@ void win_redr_status(win_T *wp) if (stl_connected(wp)) { fillchar = fillchar_status(&attr, wp); } else { - fillchar = fillchar_vsep(wp, &attr); + attr = win_hl_attr(wp, HLF_C); + fillchar = wp->w_p_fcs_chars.vert; } grid_putchar(&default_grid, fillchar, W_ENDROW(wp), W_ENDCOL(wp), attr); } busy = false; } +void get_trans_bufname(buf_T *buf) +{ + if (buf_spname(buf) != NULL) { + xstrlcpy(NameBuff, buf_spname(buf), MAXPATHL); + } else { + home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, true); + } + trans_characters(NameBuff, MAXPATHL); +} + +/// Only call if (wp->w_vsep_width != 0). +/// +/// @return true if the status line of window "wp" is connected to the status +/// line of the window right of it. If not, then it's a vertical separator. +bool stl_connected(win_T *wp) +{ + frame_T *fr = wp->w_frame; + while (fr->fr_parent != NULL) { + if (fr->fr_parent->fr_layout == FR_COL) { + if (fr->fr_next != NULL) { + break; + } + } else { + if (fr->fr_next != NULL) { + return true; + } + } + fr = fr->fr_parent; + } + return false; +} + /// Clear status line, window bar or tab page line click definition table /// /// @param[out] tpcd Table to clear. -- cgit From 204a8b17c8ebab1619cc47a920a06dcc348d75f7 Mon Sep 17 00:00:00 2001 From: luukvbaal <31730729+luukvbaal@users.noreply.github.com> Date: Sat, 18 Mar 2023 12:44:44 +0100 Subject: fix(column): rebuild status column when sign column is invalidated (#22690) * fix(column): rebuild status column when sign column is invalidated Problem: When implementing a custom sign column through `'statuscolumn'`, the status column is not properly rebuilt when the sign column width changes. Solution: Force a rebuild of the status column when the sign column width is invalidated. * test(column): 'statuscolumn' has correct width when (un)placing signs --- src/nvim/statusline.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index ca92953b05..a54618205e 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -909,6 +909,25 @@ int build_statuscol_str(win_T *wp, linenr_T lnum, long relnum, statuscol_T *stcp return width; } +/// Force a reset and re-estimation of the status column width. +/// +/// @param wp The window for which to reset the status column (can be NULL if "buf" is not) +/// @param buf The buffer for which to reset the status column (can be NULL) +void invalidate_statuscol(win_T *wp, buf_T *buf) +{ + if (buf != NULL) { + FOR_ALL_WINDOWS_IN_TAB(win, curtab) { + if (*win->w_p_stc != NUL && win->w_buffer == buf) { + win->w_nrwidth_line_count = 0; + win->w_statuscol_line_count = 0; + } + } + } else if (*wp->w_p_stc != NUL) { + wp->w_nrwidth_line_count = 0; // make sure width is reset + wp->w_statuscol_line_count = 0; // make sure width is re-estimated + } +} + /// Build a string from the status line items in "fmt". /// Return length of string in screen cells. /// -- cgit From eeac80de0cf45951dd696f82e5a823c6de20728c Mon Sep 17 00:00:00 2001 From: luukvbaal <31730729+luukvbaal@users.noreply.github.com> Date: Sun, 19 Mar 2023 10:21:49 +0100 Subject: fix(column): invalidate statuscolumn width when UPD_NOT_VALID (#22723) --- src/nvim/statusline.c | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index a54618205e..ca92953b05 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -909,25 +909,6 @@ int build_statuscol_str(win_T *wp, linenr_T lnum, long relnum, statuscol_T *stcp return width; } -/// Force a reset and re-estimation of the status column width. -/// -/// @param wp The window for which to reset the status column (can be NULL if "buf" is not) -/// @param buf The buffer for which to reset the status column (can be NULL) -void invalidate_statuscol(win_T *wp, buf_T *buf) -{ - if (buf != NULL) { - FOR_ALL_WINDOWS_IN_TAB(win, curtab) { - if (*win->w_p_stc != NUL && win->w_buffer == buf) { - win->w_nrwidth_line_count = 0; - win->w_statuscol_line_count = 0; - } - } - } else if (*wp->w_p_stc != NUL) { - wp->w_nrwidth_line_count = 0; // make sure width is reset - wp->w_statuscol_line_count = 0; // make sure width is re-estimated - } -} - /// Build a string from the status line items in "fmt". /// Return length of string in screen cells. /// -- cgit From f0ac91c58b42ed4f38dea7352d89fd39a88142f4 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Sat, 1 Apr 2023 14:58:52 +0200 Subject: feat(api): evaluate 'statuscolumn' with nvim_eval_statusline() --- src/nvim/statusline.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index ca92953b05..b36b703309 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -1512,7 +1512,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n case STL_LINE: // Overload %l with v:lnum for 'statuscolumn' - if (opt_name != NULL && strcmp(opt_name, "statuscolumn") == 0) { + if (stcp != NULL) { if (wp->w_p_nu && !get_vim_var_nr(VV_VIRTNUM)) { num = (int)get_vim_var_nr(VV_LNUM); } @@ -1617,7 +1617,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n case STL_ROFLAG: case STL_ROFLAG_ALT: // Overload %r with v:relnum for 'statuscolumn' - if (opt_name != NULL && strcmp(opt_name, "statuscolumn") == 0) { + if (stcp != NULL) { if (wp->w_p_rnu && !get_vim_var_nr(VV_VIRTNUM)) { num = (int)get_vim_var_nr(VV_RELNUM); } @@ -1652,7 +1652,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n char *p; if (fold) { size_t n = fill_foldcolumn(out_p, wp, stcp->foldinfo, (linenr_T)get_vim_var_nr(VV_LNUM)); - stl_items[curitem].minwid = win_hl_attr(wp, stcp->use_cul ? HLF_CLF : HLF_FC); + stl_items[curitem].minwid = -((stcp->use_cul ? HLF_CLF : HLF_FC) + 1); p = out_p; p[n] = NUL; } @@ -1668,9 +1668,8 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n } else if (!fold) { SignTextAttrs *sattr = virtnum ? NULL : sign_get_attr(i, stcp->sattrs, wp->w_scwidth); p = sattr && sattr->text ? sattr->text : " "; - stl_items[curitem].minwid = sattr ? stcp->sign_cul_attr ? stcp->sign_cul_attr - : sattr->hl_attr_id - : win_hl_attr(wp, stcp->use_cul ? HLF_CLS : HLF_SC); + stl_items[curitem].minwid = -(sattr ? stcp->sign_cul_id ? stcp->sign_cul_id + : sattr->hl_id : (stcp->use_cul ? HLF_CLS : HLF_SC) + 1); } stl_items[curitem].type = Highlight; stl_items[curitem].start = out_p + strlen(buf_tmp); -- 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/statusline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index b36b703309..3c603ed033 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -1482,7 +1482,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // If the output of the expression needs to be evaluated // replace the %{} block with the result of evaluation if (reevaluate && str != NULL && *str != 0 - && strchr((const char *)str, '%') != NULL + && strchr(str, '%') != NULL && evaldepth < MAX_STL_EVAL_DEPTH) { size_t parsed_usefmt = (size_t)(block_start - usefmt); size_t str_length = strlen(str); -- cgit From 2d78e656b715119ca11d131a1a932f22f1b4ad36 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Fri, 7 Apr 2023 21:43:00 +0200 Subject: refactor: remove redundant casts --- src/nvim/statusline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 3c603ed033..6c698f45be 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -1443,8 +1443,8 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // Store the current buffer number as a string variable vim_snprintf(buf_tmp, sizeof(buf_tmp), "%d", curbuf->b_fnum); set_internal_string_var("g:actual_curbuf", buf_tmp); - vim_snprintf((char *)win_tmp, sizeof(win_tmp), "%d", curwin->handle); - set_internal_string_var("g:actual_curwin", (char *)win_tmp); + vim_snprintf(win_tmp, sizeof(win_tmp), "%d", curwin->handle); + set_internal_string_var("g:actual_curwin", win_tmp); buf_T *const save_curbuf = curbuf; win_T *const save_curwin = curwin; -- cgit From 8e2903d2fe810cfa3be41fc1e7a4d8394c84cf11 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 14 Apr 2023 09:11:37 +0800 Subject: vim-patch:8.2.1049: Vim9: leaking memory when using continuation line Problem: Vim9: leaking memory when using continuation line. Solution: Keep a pointer to the continuation line in evalarg_T. Centralize checking for a next command. https://github.com/vim/vim/commit/b171fb179053fa631fec74911b5fb9374cb6a8a1 Omit eval_next_line(): Vim9 script only. vim-patch:8.2.1050: missing change in struct Problem: Missing change in struct. Solution: Add missing change. https://github.com/vim/vim/commit/65a8ed37f7bc61fbe5c612a7b0eb0dfc16ad3e11 Co-authored-by: Bram Moolenaar --- src/nvim/statusline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 6c698f45be..05649e9b7f 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -985,7 +985,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n }; set_var(S_LEN("g:statusline_winid"), &tv, false); - usefmt = eval_to_string_safe(fmt + 2, NULL, use_sandbox); + usefmt = eval_to_string_safe(fmt + 2, use_sandbox); if (usefmt == NULL) { usefmt = fmt; } @@ -1457,7 +1457,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n } // Note: The result stored in `t` is unused. - str = eval_to_string_safe(out_p, &t, use_sandbox); + str = eval_to_string_safe(out_p, use_sandbox); curwin = save_curwin; curbuf = save_curbuf; -- cgit From 88c3d8900112b1798fa5084dd02de6a6fd06f365 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 16 Apr 2023 19:21:06 +0800 Subject: vim-patch:9.0.1143: invalid memory access with bad 'statusline' value (#23133) Problem: Invalid memory access with bad 'statusline' value. Solution: Avoid going over the NUL at the end. https://github.com/vim/vim/commit/7b17eb4b063a234376c1ec909ee293e42cff290c Co-authored-by: Bram Moolenaar --- src/nvim/statusline.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 05649e9b7f..feb67ad6fa 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -1373,6 +1373,9 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // An invalid item was specified. // Continue processing on the next character of the format string. if (vim_strchr(STL_ALL, (uint8_t)(*fmt_p)) == NULL) { + if (*fmt_p == NUL) { // can happen with "%0" + break; + } fmt_p++; continue; } -- cgit From 7095f8ff9d9ce3519abe34a3da4c8f4bdc3fc865 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 17 Apr 2023 17:32:32 +0100 Subject: vim-patch:9.0.1461: ruler not drawn correctly when using 'rulerformat' Problem: Ruler not drawn correctly when using 'rulerformat'. Solution: Adjust formatting depending on whether the ruler is drawn in the statusline or the command line. (Sean Dewar, closes vim/vim#12246) https://github.com/vim/vim/commit/fc8a601c3251c0388a88c1235b18c529385f7196 This issue was made apparent after neovim/neovim@0f1e2b6, as `showmode()` calls `win_redr_ruler()` with `curwin` now if it's floating, rather than the last window if there's no statusline (which usually already shares its right side with that of the editor). Co-authored-by: Sean Dewar --- src/nvim/statusline.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index feb67ad6fa..5a1f7e3a7f 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -348,7 +348,8 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) } else { row = is_stl_global ? (Rows - (int)p_ch - 1) : W_ENDROW(wp); fillchar = fillchar_status(&attr, wp); - maxwidth = is_stl_global ? Columns : wp->w_width; + const bool in_status_line = wp->w_status_height != 0 || is_stl_global; + maxwidth = in_status_line && !is_stl_global ? wp->w_width : Columns; stl_clear_click_defs(wp->w_status_click_defs, wp->w_status_click_defs_size); wp->w_status_click_defs = stl_alloc_click_defs(wp->w_status_click_defs, maxwidth, &wp->w_status_click_defs_size); @@ -374,8 +375,8 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) if (col < (maxwidth + 1) / 2) { col = (maxwidth + 1) / 2; } - maxwidth = maxwidth - col; - if (!wp->w_status_height && !is_stl_global) { + maxwidth -= col; + if (!in_status_line) { grid = &msg_grid_adj; row = Rows - 1; maxwidth--; // writing in last column may cause scrolling @@ -388,7 +389,9 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) opt_scope = ((*wp->w_p_stl != NUL) ? OPT_LOCAL : 0); } - col += is_stl_global ? 0 : wp->w_wincol; + if (in_status_line && !is_stl_global) { + col += wp->w_wincol; + } } if (maxwidth <= 0) { -- cgit From 65dd3c1180cef5ec15a46bd278ab3a0cb1c3460d Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 10 Apr 2023 21:40:35 +0100 Subject: fix(ruler): show ruler of curwin with no statusline in cmdline Problem: After neovim/neovim@846a056, only the ruler for current floating or last window without a statusline is drawn in the cmdline. This means that if the current window is not one of these, but has no statusline, its ruler will not be drawn anymore. Solution: Make `showmode()` draw the ruler of the current window or the last window in the cmdline if it has no statusline. This also maintains the previously restored floating window case (`float->w_status_height` should be 0). This behaviour should again match Vim, but without the overdraw it seems to do to achieve the same effect; it calls `showmode()` to draw the ruler for the last window without a statusline, then may draw over it in `showruler()` (which is now `show_cursor_info_later()` in Nvim) to show the ruler for the current window..? It's very confusing. Also update the logic in `win_redr_ruler()` to mirror the check done in `showmode()`, so that the ruler doesn't potentially draw over the long ins-completion mode message in some cases. --- src/nvim/statusline.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 5a1f7e3a7f..e809922be3 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -497,7 +497,8 @@ void win_redr_ruler(win_T *wp) // Don't draw the ruler while doing insert-completion, it might overwrite // the (long) mode message. - if (wp == lastwin && lastwin->w_status_height == 0 && !is_stl_global) { + win_T *ruler_win = curwin->w_status_height == 0 ? curwin : lastwin_nofloating(); + if (wp == ruler_win && ruler_win->w_status_height == 0 && !is_stl_global) { if (edit_submode != NULL) { return; } @@ -510,7 +511,7 @@ void win_redr_ruler(win_T *wp) // Check if not in Insert mode and the line is empty (will show "0-1"). int empty_line = (State & MODE_INSERT) == 0 - && *ml_get_buf(curwin->w_buffer, curwin->w_cursor.lnum, false) == NUL; + && *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, false) == NUL; int width; int row; -- cgit From 54f5602038975b28570f4ab183b3388842347f57 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 21 Apr 2023 11:22:14 +0200 Subject: fix(statusline): fix uninitialized variable and possible overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In file included from /usr/include/string.h:535, from gsrc/nvim/statusline.c:10: In function ‘strcat’, inlined from ‘build_stl_str_hl’ at gsrc/nvim/statusline.c:1688:9: /usr/include/bits/string_fortified.h:130:10: warning: ‘p’ may be used uninitialized [-Wmaybe-uninitialized] 130 | return __builtin___strcat_chk (__dest, __src, __glibc_objsize (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- src/nvim/statusline.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index e809922be3..db99bae03c 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -1656,7 +1656,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n break; } - char *p; + char *p = NULL; if (fold) { size_t n = fill_foldcolumn(out_p, wp, stcp->foldinfo, (linenr_T)get_vim_var_nr(VV_LNUM)); stl_items[curitem].minwid = -((stcp->use_cul ? HLF_CLF : HLF_FC) + 1); @@ -1678,14 +1678,17 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n stl_items[curitem].minwid = -(sattr ? stcp->sign_cul_id ? stcp->sign_cul_id : sattr->hl_id : (stcp->use_cul ? HLF_CLS : HLF_SC) + 1); } + size_t buflen = strlen(buf_tmp); stl_items[curitem].type = Highlight; - stl_items[curitem].start = out_p + strlen(buf_tmp); + stl_items[curitem].start = out_p + buflen; curitem++; if (i == width) { str = buf_tmp; break; } - STRCAT(buf_tmp, p); + int rc = snprintf(buf_tmp + buflen, sizeof(buf_tmp) - buflen, "%s", p); + (void)rc; // Avoid unused warning on release build + assert(rc > 0); } break; } -- 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/statusline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index db99bae03c..a6fd1d677b 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -2000,7 +2000,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // string to find the last character that will fit. trunc_p = out; width = 0; - for (;;) { + while (true) { width += ptr2cells(trunc_p); if (width >= maxwidth) { break; -- cgit From 4ecf6fdfd857b52c0bab9a8dbfc760364ac2677b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 8 May 2023 16:25:03 +0800 Subject: fix(statusline): bail out properly on negative row (#23535) --- src/nvim/statusline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index a6fd1d677b..5a14d57538 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -336,7 +336,7 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) grid_adjust(&grid, &row, &col); if (row < 0) { - return; + goto theend; } fillchar = wp->w_p_fcs_chars.wbr; -- 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/statusline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 5a14d57538..015c578396 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -596,7 +596,7 @@ void win_redr_ruler(win_T *wp) MAXSIZE_TEMP_ARRAY(content, 1); MAXSIZE_TEMP_ARRAY(chunk, 2); ADD_C(chunk, INTEGER_OBJ(attr)); - ADD_C(chunk, STRING_OBJ(cstr_as_string(buffer))); + ADD_C(chunk, CSTR_AS_OBJ(buffer)); ADD_C(content, ARRAY_OBJ(chunk)); ui_call_msg_ruler(content); did_show_ext_ruler = true; -- cgit From 70da793c5eda9f3e533a137ac0c0e31db1df0324 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Tue, 30 May 2023 14:56:12 +0200 Subject: fix(statusline): corrupted screen with minwid sign item in 'statuscolumn' (#23823) --- src/nvim/statusline.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 015c578396..b89d346fbf 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -1031,6 +1031,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n int evaldepth = 0; int curitem = 0; + int foldsignitem = -1; bool prevchar_isflag = true; bool prevchar_isitem = false; @@ -1655,6 +1656,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n if (width == 0) { break; } + foldsignitem = curitem; char *p = NULL; if (fold) { @@ -1664,32 +1666,22 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n p[n] = NUL; } - *buf_tmp = NUL; + size_t buflen = 0; varnumber_T virtnum = get_vim_var_nr(VV_VIRTNUM); - for (int i = 0; i <= width; i++) { - if (i == width) { - if (*buf_tmp == NUL) { - break; - } - stl_items[curitem].minwid = 0; - } else if (!fold) { + for (int i = 0; i < width; i++) { + if (!fold) { SignTextAttrs *sattr = virtnum ? NULL : sign_get_attr(i, stcp->sattrs, wp->w_scwidth); p = sattr && sattr->text ? sattr->text : " "; stl_items[curitem].minwid = -(sattr ? stcp->sign_cul_id ? stcp->sign_cul_id : sattr->hl_id : (stcp->use_cul ? HLF_CLS : HLF_SC) + 1); } - size_t buflen = strlen(buf_tmp); stl_items[curitem].type = Highlight; stl_items[curitem].start = out_p + buflen; + xstrlcpy(buf_tmp + buflen, p, TMPLEN - buflen); + buflen += strlen(p); curitem++; - if (i == width) { - str = buf_tmp; - break; - } - int rc = snprintf(buf_tmp + buflen, sizeof(buf_tmp) - buflen, "%s", p); - (void)rc; // Avoid unused warning on release build - assert(rc > 0); } + str = buf_tmp; break; } @@ -1832,6 +1824,13 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n } } minwid = 0; + // For a 'statuscolumn' sign or fold item, shift the added items + if (foldsignitem >= 0) { + ptrdiff_t offset = out_p - stl_items[foldsignitem].start; + for (int i = foldsignitem; i < curitem; i++) { + stl_items[i].start += offset; + } + } } else { // Note: The negative value denotes a left aligned item. // Here we switch the minimum width back to a positive value. @@ -1851,6 +1850,14 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n } // } + // For a 'statuscolumn' sign or fold item, add an item to reset the highlight group + if (foldsignitem >= 0) { + foldsignitem = -1; + stl_items[curitem].type = Highlight; + stl_items[curitem].start = out_p; + stl_items[curitem].minwid = 0; + } + // For left-aligned items, fill any remaining space with the fillchar for (; l < minwid && out_p < out_end_p; l++) { MB_CHAR2BYTES(fillchar, out_p); -- cgit From a878e02d5de7e7a842bf7a8e3a0fd19b3a2a2f6e Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Wed, 28 Jun 2023 23:16:03 +0200 Subject: fix(column): use maxwidth to allocate/fill 'statuscolumn' click defs #24190 Use the actual width of the 'statuscolumn' to allocate and fill its click definition array. The returned width of the built statuscolumn string may be shorter (and is padded later). --- src/nvim/statusline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index b89d346fbf..60523925e9 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -905,9 +905,9 @@ int build_statuscol_str(win_T *wp, linenr_T lnum, long relnum, statuscol_T *stcp // Only update click definitions once per window per redraw if (fillclick) { stl_clear_click_defs(wp->w_statuscol_click_defs, wp->w_statuscol_click_defs_size); - wp->w_statuscol_click_defs = stl_alloc_click_defs(wp->w_statuscol_click_defs, width, + wp->w_statuscol_click_defs = stl_alloc_click_defs(wp->w_statuscol_click_defs, stcp->width, &wp->w_statuscol_click_defs_size); - stl_fill_click_defs(wp->w_statuscol_click_defs, clickrec, stcp->text, width, false); + stl_fill_click_defs(wp->w_statuscol_click_defs, clickrec, stcp->text, stcp->width, false); } return width; -- 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/statusline.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 60523925e9..dd602ddf87 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -248,8 +248,8 @@ StlClickDefinition *stl_alloc_click_defs(StlClickDefinition *cdp, long width, si } /// Fill the click definitions array if needed. -void stl_fill_click_defs(StlClickDefinition *click_defs, StlClickRecord *click_recs, char *buf, - int width, bool tabline) +void stl_fill_click_defs(StlClickDefinition *click_defs, StlClickRecord *click_recs, + const char *buf, int width, bool tabline) { if (click_defs == NULL) { return; @@ -270,7 +270,7 @@ void stl_fill_click_defs(StlClickDefinition *click_defs, StlClickRecord *click_r } else { xfree(cur_click_def.func); } - buf = (char *)click_recs[i].start; + buf = click_recs[i].start; cur_click_def = click_recs[i].def; if (!tabline && !(cur_click_def.type == kStlClickDisabled || cur_click_def.type == kStlClickFuncRun)) { @@ -2077,9 +2077,9 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // to be moved backwards. if (stl_items[i].start >= trunc_end_p) { stl_items[i].start -= item_offset; + } else { // Anything inside the truncated area is set to start // at the `<` truncation character. - } else { stl_items[i].start = trunc_p; } } -- cgit From d7bb19e0138c7363ed40c142972c07e4e1912785 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 30 Jun 2023 08:36:09 +0800 Subject: fix(statusline): fill for double-width char after moving items (#24207) --- src/nvim/statusline.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index dd602ddf87..f2502fe1e3 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -263,6 +263,7 @@ void stl_fill_click_defs(StlClickDefinition *click_defs, StlClickRecord *click_r }; for (int i = 0; click_recs[i].start != NULL; i++) { len += vim_strnsize(buf, (int)(click_recs[i].start - buf)); + assert(len <= width); if (col < len) { while (col < len) { click_defs[col++] = cur_click_def; @@ -2052,17 +2053,6 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // Put a `<` to mark where we truncated at *trunc_p = '<'; - - if (width + 1 < maxwidth) { - // Advance the pointer to the end of the string - trunc_p = trunc_p + strlen(trunc_p); - } - - // Fill up for half a double-wide character. - while (++width < maxwidth) { - MB_CHAR2BYTES(fillchar, trunc_p); - *trunc_p = NUL; - } // } // { Change the start point for items based on @@ -2084,6 +2074,17 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n } } // } + + if (width + 1 < maxwidth) { + // Advance the pointer to the end of the string + trunc_p = trunc_p + strlen(trunc_p); + } + + // Fill up for half a double-wide character. + while (++width < maxwidth) { + MB_CHAR2BYTES(fillchar, trunc_p); + *trunc_p = NUL; + } } width = maxwidth; -- cgit From fcf3519c65a2d6736de437f686e788684a6c8564 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 17 Apr 2023 22:18:58 +0200 Subject: refactor: remove long long is 32-bits even on 64-bit windows which makes the type suboptimal for a codebase meant to be cross-platform. --- src/nvim/statusline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index f2502fe1e3..b01febc18c 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -237,7 +237,7 @@ void stl_clear_click_defs(StlClickDefinition *const click_defs, const size_t cli } /// Allocate or resize the click definitions array if needed. -StlClickDefinition *stl_alloc_click_defs(StlClickDefinition *cdp, long width, size_t *size) +StlClickDefinition *stl_alloc_click_defs(StlClickDefinition *cdp, int width, size_t *size) { if (*size < (size_t)width) { xfree(cdp); -- cgit From 01e273c340b5e51b593900c8feb894ba9a46c366 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 24 Jul 2023 15:18:24 +0800 Subject: fix(statuscolumn): don't update clicks if current width is 0 (#24459) --- src/nvim/statusline.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index b01febc18c..b1c7cbb8dc 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -890,7 +890,9 @@ void draw_tabline(void) /// @return The width of the built status column string for line "lnum" int build_statuscol_str(win_T *wp, linenr_T lnum, long relnum, statuscol_T *stcp) { - bool fillclick = relnum >= 0 && lnum == wp->w_topline; + // Only update click definitions once per window per redraw. + // Don't update when current width is 0, since it will be redrawn again if not empty. + const bool fillclick = relnum >= 0 && stcp->width > 0 && lnum == wp->w_topline; if (relnum >= 0) { set_vim_var_nr(VV_LNUM, lnum); @@ -903,7 +905,6 @@ int build_statuscol_str(win_T *wp, linenr_T lnum, long relnum, statuscol_T *stcp stcp->width, &stcp->hlrec, fillclick ? &clickrec : NULL, stcp); xfree(stc); - // Only update click definitions once per window per redraw if (fillclick) { stl_clear_click_defs(wp->w_statuscol_click_defs, wp->w_statuscol_click_defs_size); wp->w_statuscol_click_defs = stl_alloc_click_defs(wp->w_statuscol_click_defs, stcp->width, @@ -1973,8 +1974,8 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n int width = vim_strsize(out); // Return truncated width for 'statuscolumn' - if (stcp != NULL && width > maxwidth) { - stcp->truncate = width - maxwidth; + if (stcp != NULL && width > stcp->width) { + stcp->truncate = width - stcp->width; } if (maxwidth > 0 && width > maxwidth) { // Result is too long, must truncate somewhere. -- cgit From cefd774fac76b91f5368833555818c80c992c3b1 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 24 Aug 2023 15:14:23 +0200 Subject: refactor(memline): distinguish mutating uses of ml_get_buf() ml_get_buf() takes a third parameters to indicate whether the caller wants to mutate the memline data in place. However the vast majority of the call sites is using this function just to specify a buffer but without any mutation. This makes it harder to grep for the places which actually perform mutation. Solution: Remove the bool param from ml_get_buf(). it now works like ml_get() except for a non-current buffer. Add a new ml_get_buf_mut() function for the mutating use-case, which can be grepped along with the other ml_replace() etc functions which can modify the memline. --- src/nvim/statusline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index b1c7cbb8dc..b708ccb4a3 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -512,7 +512,7 @@ void win_redr_ruler(win_T *wp) // Check if not in Insert mode and the line is empty (will show "0-1"). int empty_line = (State & MODE_INSERT) == 0 - && *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, false) == NUL; + && *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum) == NUL; int width; int row; @@ -1012,7 +1012,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n } // Get line & check if empty (cursorpos will show "0-1"). - const char *line_ptr = ml_get_buf(wp->w_buffer, lnum, false); + const char *line_ptr = ml_get_buf(wp->w_buffer, lnum); bool empty_line = (*line_ptr == NUL); // Get the byte value now, in case we need it below. This is more -- cgit From 93af6d9ed0af984be7fc383f25ca20b595961c46 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 25 Aug 2023 19:36:43 +0800 Subject: refactor: move virtcol functions to plines.c Problem: Functions for virtcol and chartabsize are similar (both compute horizontal size), but appear in two different source files. Solution: Move virtcol functions to plines.c. --- src/nvim/statusline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index b708ccb4a3..30c98a2f1e 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -36,6 +36,7 @@ #include "nvim/optionstr.h" #include "nvim/os/os.h" #include "nvim/path.h" +#include "nvim/plines.h" #include "nvim/pos.h" #include "nvim/sign.h" #include "nvim/statusline.h" -- cgit From 8da986ea877b07a5eb117446f410f2a7fc8cd9cb Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 13 Sep 2023 13:39:18 +0200 Subject: refactor(grid): change schar_T representation to be more compact Previously, a screen cell would occupy 28+4=32 bytes per cell as we always made space for up to MAX_MCO+1 codepoints in a cell. As an example, even a pretty modest 50*80 screen would consume 50*80*2*32 = 256000, i e a quarter megabyte With the factor of two due to the TUI side buffer, and even more when using msg_grid and/or ext_multigrid. This instead stores a 4-byte union of either: - a valid UTF-8 sequence up to 4 bytes - an escape char which is invalid UTF-8 (0xFF) plus a 24-bit index to a glyph cache This avoids allocating space for huge composed glyphs _upfront_, while still keeping rendering such glyphs reasonably fast (1 hash table lookup + one plain index lookup). If the same large glyphs are using repeatedly on the screen, this is still a net reduction of memory/cache consumption. The only case which really gets worse is if you blast the screen full with crazy emojis and zalgo text and even this case only leads to 4 extra bytes per char. When only <= 4-byte glyphs are used, plus the 4-byte attribute code, i e 8 bytes in total there is a factor of four reduction of memory use. Memory which will be quite hot in cache as the screen buffer is scanned over in win_line() buffer text drawing A slight complication is that the representation depends on host byte order. I've tested this manually by compling and running this in qemu-s390x and it works fine. We might add a qemu based solution to CI at some point. --- src/nvim/statusline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 30c98a2f1e..4e000b8d29 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -1663,7 +1663,8 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n char *p = NULL; if (fold) { - size_t n = fill_foldcolumn(out_p, wp, stcp->foldinfo, (linenr_T)get_vim_var_nr(VV_LNUM)); + size_t n = fill_foldcolumn(out_p, wp, stcp->foldinfo, + (linenr_T)get_vim_var_nr(VV_LNUM), NULL); stl_items[curitem].minwid = -((stcp->use_cul ? HLF_CLF : HLF_FC) + 1); p = out_p; p[n] = NUL; -- 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/statusline.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 4e000b8d29..b882d663a1 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -153,13 +153,13 @@ void win_redr_status(win_T *wp) row = is_stl_global ? (Rows - (int)p_ch - 1) : W_ENDROW(wp); col = is_stl_global ? 0 : wp->w_wincol; - int width = grid_puts(&default_grid, p, row, col, attr); + int width = grid_puts(&default_grid, p, -1, row, col, attr); grid_fill(&default_grid, row, row + 1, width + col, this_ru_col + col, fillchar, fillchar, attr); if (get_keymap_str(wp, "<%s>", NameBuff, MAXPATHL) && this_ru_col - len > (int)(strlen(NameBuff) + 1)) { - grid_puts(&default_grid, NameBuff, row, + grid_puts(&default_grid, NameBuff, -1, row, (int)((size_t)this_ru_col - strlen(NameBuff) - 1), attr); } @@ -170,8 +170,8 @@ void win_redr_status(win_T *wp) const int sc_width = MIN(10, this_ru_col - len - 2); if (sc_width > 0) { - grid_puts_len(&default_grid, showcmd_buf, sc_width, row, - wp->w_wincol + this_ru_col - sc_width - 1, attr); + grid_puts(&default_grid, showcmd_buf, sc_width, row, + wp->w_wincol + this_ru_col - sc_width - 1, attr); } } } @@ -419,7 +419,7 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) int start_col = col; // Draw each snippet with the specified highlighting. - grid_puts_line_start(grid, row); + grid_line_start(grid, row); int curattr = attr; char *p = buf; @@ -427,7 +427,7 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) int textlen = (int)(hltab[n].start - p); // Make all characters printable. size_t tsize = transstr_buf(p, textlen, transbuf, sizeof transbuf, true); - col += grid_puts_len(grid, transbuf, (int)tsize, row, col, curattr); + col += grid_line_puts(col, transbuf, (int)tsize, curattr); p = hltab[n].start; if (hltab[n].userhl == 0) { @@ -442,13 +442,13 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) } // Make sure to use an empty string instead of p, if p is beyond buf + len. size_t tsize = transstr_buf(p >= buf + len ? "" : p, -1, transbuf, sizeof transbuf, true); - col += grid_puts_len(grid, transbuf, (int)tsize, row, col, curattr); + col += grid_line_puts(col, transbuf, (int)tsize, curattr); int maxcol = start_col + maxwidth; // fill up with "fillchar" - grid_fill(grid, row, row + 1, col, maxcol, fillchar, fillchar, curattr); + grid_line_fill(col, maxcol, fillchar, curattr); - grid_puts_line_flush(false); + grid_line_flush(false); // Fill the tab_page_click_defs, w_status_click_defs or w_winbar_click_defs array for clicking // in the tab page line, status line or window bar @@ -618,7 +618,7 @@ void win_redr_ruler(win_T *wp) } ScreenGrid *grid = part_of_status ? &default_grid : &msg_grid_adj; - grid_puts(grid, buffer, row, this_ru_col + off, attr); + grid_puts(grid, buffer, -1, row, this_ru_col + off, attr); grid_fill(grid, row, row + 1, this_ru_col + off + (int)strlen(buffer), off + width, fillchar, fillchar, attr); @@ -810,12 +810,12 @@ void draw_tabline(void) if (col + len >= Columns - 3) { break; } - grid_puts_len(&default_grid, NameBuff, len, 0, col, - hl_combine_attr(attr, win_hl_attr(cwp, HLF_T))); + grid_puts(&default_grid, NameBuff, len, 0, col, + hl_combine_attr(attr, win_hl_attr(cwp, HLF_T))); col += len; } if (modified) { - grid_puts_len(&default_grid, "+", 1, 0, col++, attr); + grid_puts(&default_grid, "+", 1, 0, col++, attr); } grid_putchar(&default_grid, ' ', 0, col++, attr); } @@ -835,7 +835,7 @@ void draw_tabline(void) len = Columns - col - 1; } - grid_puts_len(&default_grid, p, (int)strlen(p), 0, col, attr); + grid_puts(&default_grid, p, (int)strlen(p), 0, col, attr); col += len; } grid_putchar(&default_grid, ' ', 0, col++, attr); @@ -864,8 +864,8 @@ void draw_tabline(void) const int sc_width = MIN(10, (int)Columns - col - (tabcount > 1) * 3); if (sc_width > 0) { - grid_puts_len(&default_grid, showcmd_buf, sc_width, 0, - Columns - sc_width - (tabcount > 1) * 2, attr_nosel); + grid_puts(&default_grid, showcmd_buf, sc_width, 0, + Columns - sc_width - (tabcount > 1) * 2, attr_nosel); } } -- cgit From f7da4722570617bd8927e7aa533fa9a608c45bba Mon Sep 17 00:00:00 2001 From: bfredl Date: Sat, 23 Sep 2023 16:42:47 +0200 Subject: refactor(options)!: graduate shortmess+=f flag Not everything needs to be crazy overconfigurable. Also fixes a warning in latest clang which didn't approve of the funky math switch statement in append_arg_number --- src/nvim/statusline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 4e000b8d29..89aa635335 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -1583,7 +1583,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // Note: The call will only return true if it actually // appended data to the `buf_tmp` buffer. - if (append_arg_number(wp, buf_tmp, (int)sizeof(buf_tmp), false)) { + if (append_arg_number(wp, buf_tmp, (int)sizeof(buf_tmp))) { str = buf_tmp; } break; -- cgit From 046c9a83f7ed2694c19d915a63ef0dfed9d29dc5 Mon Sep 17 00:00:00 2001 From: tj-moody <92702993+tj-moody@users.noreply.github.com> Date: Sat, 23 Sep 2023 22:49:47 -0400 Subject: fix(ui): always use stl/stlnc fillchars when drawing statusline (#25267) --- src/nvim/statusline.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index a6f1da8761..4d318f8c59 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -637,18 +637,7 @@ int fillchar_status(int *attr, win_T *wp) *attr = win_hl_attr(wp, HLF_SNC); fill = wp->w_p_fcs_chars.stlnc; } - // Use fill when there is highlighting, and highlighting of current - // window differs, or the fillchars differ, or this is not the - // current window - if (*attr != 0 && ((win_hl_attr(wp, HLF_S) != win_hl_attr(wp, HLF_SNC) - || !is_curwin || ONE_WINDOW) - || (wp->w_p_fcs_chars.stl != wp->w_p_fcs_chars.stlnc))) { - return fill; - } - if (is_curwin) { - return '^'; - } - return '='; + return fill; } /// Redraw the status line according to 'statusline' and take care of any -- cgit From 0b2667ed36d26f29683cae8c8a595b5633a7b77f Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 26 Sep 2023 14:03:44 +0200 Subject: refactor(grid): use batched updates for builtin tabline --- src/nvim/statusline.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 4d318f8c59..0d309f7c16 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -741,6 +741,7 @@ void draw_tabline(void) int c; int len; char *p; + grid_line_start(&default_grid, 0); FOR_ALL_TABS(tp) { tabcount++; } @@ -775,14 +776,14 @@ void draw_tabline(void) attr = win_hl_attr(cwp, HLF_TPS); } if (use_sep_chars && col > 0) { - grid_putchar(&default_grid, '|', 0, col++, attr); + grid_line_put_schar(col++, schar_from_ascii('|'), attr); } if (tp->tp_topframe != topframe) { attr = win_hl_attr(cwp, HLF_TP); } - grid_putchar(&default_grid, ' ', 0, col++, attr); + grid_line_put_schar(col++, schar_from_ascii(' '), attr); int modified = false; @@ -799,14 +800,14 @@ void draw_tabline(void) if (col + len >= Columns - 3) { break; } - grid_puts(&default_grid, NameBuff, len, 0, col, - hl_combine_attr(attr, win_hl_attr(cwp, HLF_T))); + grid_line_puts(col, NameBuff, len, + hl_combine_attr(attr, win_hl_attr(cwp, HLF_T))); col += len; } if (modified) { - grid_puts(&default_grid, "+", 1, 0, col++, attr); + grid_line_put_schar(col++, schar_from_ascii('+'), attr); } - grid_putchar(&default_grid, ' ', 0, col++, attr); + grid_line_put_schar(col++, schar_from_ascii(' '), attr); } int room = scol - col + tabwidth - 1; @@ -824,10 +825,10 @@ void draw_tabline(void) len = Columns - col - 1; } - grid_puts(&default_grid, p, (int)strlen(p), 0, col, attr); + grid_line_puts(col, p, -1, attr); col += len; } - grid_putchar(&default_grid, ' ', 0, col++, attr); + grid_line_put_schar(col++, schar_from_ascii(' '), attr); // Store the tab page number in tab_page_click_defs[], so that // jump_to_mouse() knows where each one is. @@ -846,27 +847,29 @@ void draw_tabline(void) } else { c = ' '; } - grid_fill(&default_grid, 0, 1, col, Columns, c, c, attr_fill); + grid_line_fill(col, Columns, c, attr_fill); // Draw the 'showcmd' information if 'showcmdloc' == "tabline". if (p_sc && *p_sloc == 't') { const int sc_width = MIN(10, (int)Columns - col - (tabcount > 1) * 3); if (sc_width > 0) { - grid_puts(&default_grid, showcmd_buf, sc_width, 0, - Columns - sc_width - (tabcount > 1) * 2, attr_nosel); + grid_line_puts(Columns - sc_width - (tabcount > 1) * 2, + showcmd_buf, sc_width, attr_nosel); } } // Put an "X" for closing the current tab if there are several. if (tabcount > 1) { - grid_putchar(&default_grid, 'X', 0, Columns - 1, attr_nosel); + grid_line_put_schar(Columns - 1, schar_from_ascii('X'), attr_nosel); tab_page_click_defs[Columns - 1] = (StlClickDefinition) { .type = kStlClickTabClose, .tabnr = 999, .func = NULL, }; } + + grid_line_flush(false); } // Reset the flag here again, in case evaluating 'tabline' causes it to be -- cgit From 10cabf787724871173a294f2fc1a5dbc62f2ee91 Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 26 Sep 2023 14:28:58 +0200 Subject: refactor(grid): use batched updates for statusline and ruler --- src/nvim/statusline.c | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 0d309f7c16..bdc2e4a57e 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -62,8 +62,6 @@ typedef enum { /// If inversion is possible we use it. Else '=' characters are used. void win_redr_status(win_T *wp) { - int row; - int col; char *p; int len; int fillchar; @@ -151,16 +149,15 @@ void win_redr_status(win_T *wp) } } - row = is_stl_global ? (Rows - (int)p_ch - 1) : W_ENDROW(wp); - col = is_stl_global ? 0 : wp->w_wincol; - int width = grid_puts(&default_grid, p, -1, row, col, attr); - grid_fill(&default_grid, row, row + 1, width + col, - this_ru_col + col, fillchar, fillchar, attr); + grid_line_start(&default_grid, is_stl_global ? (Rows - (int)p_ch - 1) : W_ENDROW(wp)); + int col = is_stl_global ? 0 : wp->w_wincol; + + int width = grid_line_puts(col, p, -1, attr); + grid_line_fill(width + col, this_ru_col + col, fillchar, attr); if (get_keymap_str(wp, "<%s>", NameBuff, MAXPATHL) && this_ru_col - len > (int)(strlen(NameBuff) + 1)) { - grid_puts(&default_grid, NameBuff, -1, row, - (int)((size_t)this_ru_col - strlen(NameBuff) - 1), attr); + grid_line_puts((int)((size_t)this_ru_col - strlen(NameBuff) - 1), NameBuff, -1, attr); } win_redr_ruler(wp); @@ -170,10 +167,11 @@ void win_redr_status(win_T *wp) const int sc_width = MIN(10, this_ru_col - len - 2); if (sc_width > 0) { - grid_puts(&default_grid, showcmd_buf, sc_width, row, - wp->w_wincol + this_ru_col - sc_width - 1, attr); + grid_line_puts(wp->w_wincol + this_ru_col - sc_width - 1, showcmd_buf, sc_width, attr); } } + + grid_line_flush(false); } // May need to draw the character below the vertical separator. @@ -419,7 +417,9 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) int start_col = col; // Draw each snippet with the specified highlighting. - grid_line_start(grid, row); + if (!draw_ruler) { + grid_line_start(grid, row); + } int curattr = attr; char *p = buf; @@ -448,7 +448,9 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) // fill up with "fillchar" grid_line_fill(col, maxcol, fillchar, curattr); - grid_line_flush(false); + if (!draw_ruler) { + grid_line_flush(false); + } // Fill the tab_page_click_defs, w_status_click_defs or w_winbar_click_defs array for clicking // in the tab page line, status line or window bar @@ -481,6 +483,7 @@ void win_redr_winbar(win_T *wp) entered = false; } +/// must be called after a grid_line_start() at the intended row void win_redr_ruler(win_T *wp) { bool is_stl_global = global_stl_height() > 0; @@ -516,36 +519,28 @@ void win_redr_ruler(win_T *wp) && *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum) == NUL; int width; - int row; int fillchar; int attr; int off; bool part_of_status = false; if (wp->w_status_height) { - row = W_ENDROW(wp); fillchar = fillchar_status(&attr, wp); off = wp->w_wincol; width = wp->w_width; part_of_status = true; } else if (is_stl_global) { - row = Rows - (int)p_ch - 1; fillchar = fillchar_status(&attr, wp); off = 0; width = Columns; part_of_status = true; } else { - row = Rows - 1; fillchar = ' '; attr = HL_ATTR(HLF_MSG); width = Columns; off = 0; } - if (!part_of_status && p_ch == 0 && !ui_has(kUIMessages)) { - return; - } - // In list mode virtcol needs to be recomputed colnr_T virtcol = wp->w_virtcol; if (wp->w_p_list && wp->w_p_lcs_chars.tab1 == NUL) { @@ -617,11 +612,8 @@ void win_redr_ruler(win_T *wp) } } - ScreenGrid *grid = part_of_status ? &default_grid : &msg_grid_adj; - grid_puts(grid, buffer, -1, row, this_ru_col + off, attr); - grid_fill(grid, row, row + 1, - this_ru_col + off + (int)strlen(buffer), off + width, fillchar, - fillchar, attr); + int w = grid_line_puts(this_ru_col + off, buffer, -1, attr); + grid_line_fill(this_ru_col + off + w, off + width, fillchar, attr); } } -- cgit From e33269578b5bea2528cc48afc5b009eb8d4ad1d6 Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 20 Sep 2023 10:08:05 +0200 Subject: refactor(grid): unify the two put-text-on-the-screen code paths The screen grid refactors will continue until morale improves. Jokes aside, this is quite a central installment in the series. Before this refactor, there were two fundamentally distinct codepaths for getting some text on the screen: - the win_line() -> grid_put_linebuf() -> ui_line() call chain used for buffer text, with linebuf_char as a temporary scratch buffer - the grid_line_start/grid_line_puts/grid_line_flush() -> ui_line() path used for every thing else: statuslines, messages and the command line. Here the grid->chars[] array itself doubles as a scratch buffer. With this refactor, the later family of functions still exist, however they now as well render to linebuf_char just like win_line() did, and grid_put_linebuf() is called in the end to calculate delta changes. This means we don't need any duplicate logic for delta calculations anymore. Later down the line, it will be possible to share more logic operating on this scratch buffer, like doing 'rightleft' reversal and arabic shaping as a post-processing step. --- src/nvim/statusline.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index bdc2e4a57e..407bf71417 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -171,7 +171,7 @@ void win_redr_status(win_T *wp) } } - grid_line_flush(false); + grid_line_flush(); } // May need to draw the character below the vertical separator. @@ -449,7 +449,7 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) grid_line_fill(col, maxcol, fillchar, curattr); if (!draw_ruler) { - grid_line_flush(false); + grid_line_flush(); } // Fill the tab_page_click_defs, w_status_click_defs or w_winbar_click_defs array for clicking @@ -861,7 +861,7 @@ void draw_tabline(void) }; } - grid_line_flush(false); + grid_line_flush(); } // Reset the flag here again, in case evaluating 'tabline' causes it to be -- 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/statusline.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 407bf71417..b062131287 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -16,6 +16,7 @@ #include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/digraph.h" +#include "nvim/drawline.h" #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval_defs.h" @@ -30,7 +31,6 @@ #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/move.h" #include "nvim/normal.h" #include "nvim/option.h" #include "nvim/optionstr.h" @@ -41,7 +41,6 @@ #include "nvim/sign.h" #include "nvim/statusline.h" #include "nvim/strings.h" -#include "nvim/types.h" #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/vim.h" -- 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/statusline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index b062131287..1529b63812 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -33,6 +33,7 @@ #include "nvim/message.h" #include "nvim/normal.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/os.h" #include "nvim/path.h" -- 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/statusline.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 1529b63812..fb467093ad 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -182,7 +182,9 @@ void win_redr_status(win_T *wp) attr = win_hl_attr(wp, HLF_C); fillchar = wp->w_p_fcs_chars.vert; } - grid_putchar(&default_grid, fillchar, W_ENDROW(wp), W_ENDCOL(wp), attr); + grid_line_start(&default_grid, W_ENDROW(wp)); + grid_line_put_schar(W_ENDCOL(wp), schar_from_char(fillchar), attr); + grid_line_flush(); } busy = false; } -- 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/statusline.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index fb467093ad..9af1bd862f 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -875,7 +875,7 @@ void draw_tabline(void) /// the v:lnum and v:relnum variables don't have to be updated. /// /// @return The width of the built status column string for line "lnum" -int build_statuscol_str(win_T *wp, linenr_T lnum, long relnum, statuscol_T *stcp) +int build_statuscol_str(win_T *wp, linenr_T lnum, linenr_T relnum, statuscol_T *stcp) { // Only update click definitions once per window per redraw. // Don't update when current width is 0, since it will be redrawn again if not empty. @@ -1170,7 +1170,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // { Determine the number of bytes to remove // Find the first character that should be included. - long n = 0; + int n = 0; while (group_len >= stl_items[stl_groupitems[groupdepth]].maxwid) { group_len -= ptr2cells(t + n); n += utfc_ptr2len(t + n); @@ -1295,7 +1295,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n if (*fmt_p == STL_TABCLOSENR) { if (minwid == 0) { // %X ends the close label, go back to the previous tab label nr. - for (long n = curitem - 1; n >= 0; n--) { + for (int n = curitem - 1; n >= 0; n--) { if (stl_items[n].type == TabPage && stl_items[n].minwid >= 0) { minwid = stl_items[n].minwid; break; @@ -1540,8 +1540,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n } case STL_PERCENTAGE: - num = (int)(((long)wp->w_cursor.lnum * 100L) / - (long)wp->w_buffer->b_ml.ml_line_count); + num = ((wp->w_cursor.lnum * 100) / wp->w_buffer->b_ml.ml_line_count); break; case STL_ALTPERCENT: @@ -1592,11 +1591,11 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n base = kNumBaseHexadecimal; FALLTHROUGH; case STL_OFFSET: { - long l = ml_find_line_or_offset(wp->w_buffer, wp->w_cursor.lnum, NULL, - false); + int l = ml_find_line_or_offset(wp->w_buffer, wp->w_cursor.lnum, NULL, + false); num = (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) || l < 0 ? - 0L : (int)l + 1 + ((State & MODE_INSERT) == 0 && empty_line ? - 0 : (int)wp->w_cursor.col); + 0L : l + 1 + ((State & MODE_INSERT) == 0 && empty_line ? + 0 : (int)wp->w_cursor.col); break; } case STL_BYTEVAL_X: @@ -1778,7 +1777,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n } // } - long l = vim_strsize(t); + int l = vim_strsize(t); // If this item is non-empty, record that the last thing // we put in the output buffer was an item @@ -1881,8 +1880,8 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // { Determine how many characters the number will take up when printed // Note: We have to cast the base because the compiler uses // unsigned ints for the enum values. - long num_chars = 1; - for (long n = num; n >= (int)base; n /= (int)base) { + int num_chars = 1; + for (int n = num; n >= (int)base; n /= (int)base) { num_chars++; } @@ -1905,7 +1904,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n num_chars += 2; // How many extra characters there are - long n = num_chars - maxwid; + int n = num_chars - maxwid; // { Reduce the number by base^n while (num_chars-- > maxwid) { @@ -2029,7 +2028,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // Truncate at the truncation point we found } else { // { Determine how many bytes to remove - long trunc_len = 0; + int trunc_len = 0; while (width >= maxwidth) { width -= ptr2cells(trunc_p + trunc_len); trunc_len += utfc_ptr2len(trunc_p + trunc_len); @@ -2049,7 +2048,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // Note: The offset is one less than the truncation length because // the truncation marker `<` is not counted. - long item_offset = trunc_len - 1; + int item_offset = trunc_len - 1; for (int i = item_idx; i < itemcnt; i++) { // Items starting at or after the end of the truncated section need @@ -2124,7 +2123,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n if (hltab != NULL) { *hltab = stl_hltab; stl_hlrec_t *sp = stl_hltab; - for (long l = 0; l < itemcnt; l++) { + for (int l = 0; l < itemcnt; l++) { if (stl_items[l].type == Highlight) { sp->start = stl_items[l].start; sp->userhl = stl_items[l].minwid; @@ -2139,7 +2138,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n if (tabtab != NULL) { *tabtab = stl_tabtab; StlClickRecord *cur_tab_rec = stl_tabtab; - for (long l = 0; l < itemcnt; l++) { + for (int l = 0; l < itemcnt; l++) { if (stl_items[l].type == TabPage) { cur_tab_rec->start = stl_items[l].start; if (stl_items[l].minwid == 0) { -- cgit From 5f03a1eaabfc8de2b3a9c666fcd604763f41e152 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 20 Oct 2023 15:10:33 +0200 Subject: build(lint): remove unnecessary clint.py rules Uncrustify is the source of truth where possible. Remove any redundant checks from clint.py. --- src/nvim/statusline.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 9af1bd862f..f0715220c3 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -958,7 +958,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // Allocate one more, because the last element is used to indicate the // end of the list. - stl_hltab = xmalloc(sizeof(stl_hlrec_t) * (stl_items_len + 1)); + stl_hltab = xmalloc(sizeof(stl_hlrec_t) * (stl_items_len + 1)); stl_tabtab = xmalloc(sizeof(StlClickRecord) * (stl_items_len + 1)); stl_separator_locations = xmalloc(sizeof(int) * stl_items_len); @@ -1017,7 +1017,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n } int groupdepth = 0; - int evaldepth = 0; + int evaldepth = 0; int curitem = 0; int foldsignitem = -1; @@ -2030,7 +2030,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // { Determine how many bytes to remove int trunc_len = 0; while (width >= maxwidth) { - width -= ptr2cells(trunc_p + trunc_len); + width -= ptr2cells(trunc_p + trunc_len); trunc_len += utfc_ptr2len(trunc_p + trunc_len); } // } -- 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/statusline.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index f0715220c3..200478231a 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -558,7 +558,7 @@ void win_redr_ruler(win_T *wp) // To avoid portability problems we use strlen() here. vim_snprintf(buffer, RULER_BUF_LEN, "%" PRId64 ",", (wp->w_buffer->b_ml.ml_flags & - ML_EMPTY) ? (int64_t)0L : (int64_t)wp->w_cursor.lnum); + ML_EMPTY) ? 0 : (int64_t)wp->w_cursor.lnum); size_t len = strlen(buffer); col_print(buffer + len, RULER_BUF_LEN - len, empty_line ? 0 : (int)wp->w_cursor.col + 1, @@ -1514,7 +1514,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n num = (int)get_vim_var_nr(VV_LNUM); } } else { - num = (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) ? 0L : wp->w_cursor.lnum; + num = (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) ? 0 : wp->w_cursor.lnum; } break; @@ -1594,8 +1594,8 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n int l = ml_find_line_or_offset(wp->w_buffer, wp->w_cursor.lnum, NULL, false); num = (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) || l < 0 ? - 0L : l + 1 + ((State & MODE_INSERT) == 0 && empty_line ? - 0 : (int)wp->w_cursor.col); + 0 : l + 1 + ((State & MODE_INSERT) == 0 && empty_line ? + 0 : (int)wp->w_cursor.col); break; } case STL_BYTEVAL_X: -- 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/statusline.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 200478231a..2f989491d0 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.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 - #include #include #include -- cgit From c4afb9788c4f139eb2e3b7aa4d6a6a20b67ba156 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Sat, 11 Nov 2023 00:52:50 +0100 Subject: refactor(sign): move legacy signs to extmarks Problem: The legacy signlist data structures and associated functions are redundant since the introduction of extmark signs. Solution: Store signs defined through the legacy commands in a hashmap, placed signs in the extmark tree. Replace signlist associated functions. Usage of the legacy sign commands should yield no change in behavior with the exception of: - "orphaned signs" are now always removed when the line it is placed on is deleted. This used to depend on the value of 'signcolumn'. - It is no longer possible to place multiple signs with the same identifier in a single group on multiple lines. This will now move the sign instead. Moreover, both signs placed through the legacy sign commands and through |nvim_buf_set_extmark()|: - Will show up in both |sign-place| and |nvim_buf_get_extmarks()|. - Are displayed by increasing sign identifier, left to right. Extmark signs used to be ordered decreasingly as opposed to legacy signs. --- src/nvim/statusline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 2f989491d0..a99313cc4e 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -1656,9 +1656,9 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n varnumber_T virtnum = get_vim_var_nr(VV_VIRTNUM); for (int i = 0; i < width; i++) { if (!fold) { - SignTextAttrs *sattr = virtnum ? NULL : sign_get_attr(i, stcp->sattrs, wp->w_scwidth); + SignTextAttrs *sattr = virtnum ? NULL : &stcp->sattrs[i]; p = sattr && sattr->text ? sattr->text : " "; - stl_items[curitem].minwid = -(sattr ? stcp->sign_cul_id ? stcp->sign_cul_id + stl_items[curitem].minwid = -(sattr && sattr->text ? stcp->sign_cul_id ? stcp->sign_cul_id : sattr->hl_id : (stcp->use_cul ? HLF_CLS : HLF_SC) + 1); } stl_items[curitem].type = Highlight; -- 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/statusline.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index a99313cc4e..aa23d581e1 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -59,11 +59,8 @@ typedef enum { /// If inversion is possible we use it. Else '=' characters are used. void win_redr_status(win_T *wp) { - char *p; - int len; int fillchar; int attr; - int this_ru_col; bool is_stl_global = global_stl_height() > 0; static bool busy = false; @@ -92,8 +89,8 @@ void win_redr_status(win_T *wp) const int stl_width = is_stl_global ? Columns : wp->w_width; get_trans_bufname(wp->w_buffer); - p = NameBuff; - len = (int)strlen(p); + char *p = NameBuff; + int len = (int)strlen(p); if ((bt_help(wp->w_buffer) || wp->w_p_pvw @@ -119,7 +116,7 @@ void win_redr_status(win_T *wp) // len += (int)strlen(p + len); // dead assignment } - this_ru_col = ru_col - (Columns - stl_width); + int this_ru_col = ru_col - (Columns - stl_width); if (this_ru_col < (stl_width + 1) / 2) { this_ru_col = (stl_width + 1) / 2; } @@ -127,10 +124,10 @@ void win_redr_status(win_T *wp) p = "<"; // No room for file name! len = 1; } else { - int clen = 0, i; + int i; // Count total number of display cells. - clen = (int)mb_string2cells(p); + int clen = (int)mb_string2cells(p); // Find first character that will fit. // Going from start to end is much faster for DBCS. @@ -295,7 +292,6 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) int row; int col = 0; int maxwidth; - int n; int fillchar; char buf[MAXPATHL]; char transbuf[MAXPATHL]; @@ -422,7 +418,7 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) int curattr = attr; char *p = buf; - for (n = 0; hltab[n].start != NULL; n++) { + for (int n = 0; hltab[n].start != NULL; n++) { int textlen = (int)(hltab[n].start - p); // Make all characters printable. size_t tsize = transstr_buf(p, textlen, transbuf, sizeof transbuf, true); -- cgit From a6e3d93421ba13c407a96fac9cc01fa41ec7ad98 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Thu, 16 Nov 2023 10:59:11 +0100 Subject: refactor: enable formatting for ternaries This requires removing the "Inner expression should be aligned" rule from clint as it prevents essentially any formatting regarding ternary operators. --- src/nvim/statusline.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index aa23d581e1..774bd1d00c 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -1387,7 +1387,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n xstrlcpy(NameBuff, buf_spname(wp->w_buffer), MAXPATHL); } else { char *t = (opt == STL_FULLPATH) ? wp->w_buffer->b_ffname - : wp->w_buffer->b_fname; + : wp->w_buffer->b_fname; home_replace(wp->w_buffer, t, NameBuff, MAXPATHL, true); } trans_characters(NameBuff, MAXPATHL); @@ -1586,9 +1586,9 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n case STL_OFFSET: { int l = ml_find_line_or_offset(wp->w_buffer, wp->w_cursor.lnum, NULL, false); - num = (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) || l < 0 ? - 0 : l + 1 + ((State & MODE_INSERT) == 0 && empty_line ? - 0 : (int)wp->w_cursor.col); + num = (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) || l < 0 + ? 0 : l + 1 + ((State & MODE_INSERT) == 0 && empty_line + ? 0 : (int)wp->w_cursor.col); break; } case STL_BYTEVAL_X: @@ -1654,8 +1654,9 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n if (!fold) { SignTextAttrs *sattr = virtnum ? NULL : &stcp->sattrs[i]; p = sattr && sattr->text ? sattr->text : " "; - stl_items[curitem].minwid = -(sattr && sattr->text ? stcp->sign_cul_id ? stcp->sign_cul_id - : sattr->hl_id : (stcp->use_cul ? HLF_CLS : HLF_SC) + 1); + stl_items[curitem].minwid = -(sattr && sattr->text + ? (stcp->sign_cul_id ? stcp->sign_cul_id : sattr->hl_id) + : (stcp->use_cul ? HLF_CLS : HLF_SC) + 1); } stl_items[curitem].type = Highlight; stl_items[curitem].start = out_p + buflen; -- 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/statusline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 774bd1d00c..6acc328be3 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -35,7 +35,7 @@ #include "nvim/os/os.h" #include "nvim/path.h" #include "nvim/plines.h" -#include "nvim/pos.h" +#include "nvim/pos_defs.h" #include "nvim/sign.h" #include "nvim/statusline.h" #include "nvim/strings.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/statusline.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 6acc328be3..d42a180948 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -8,7 +8,7 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" @@ -23,7 +23,7 @@ #include "nvim/grid.h" #include "nvim/highlight.h" #include "nvim/highlight_group.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" @@ -41,7 +41,7 @@ #include "nvim/strings.h" #include "nvim/ui.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" // Determines how deeply nested %{} blocks will be evaluated in statusline. -- 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/statusline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index d42a180948..604ec3dfae 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -37,6 +37,7 @@ #include "nvim/plines.h" #include "nvim/pos_defs.h" #include "nvim/sign.h" +#include "nvim/state_defs.h" #include "nvim/statusline.h" #include "nvim/strings.h" #include "nvim/ui.h" -- cgit From 86cc791debba09c8ed1aa0d863be844108866a38 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 29 Nov 2023 23:10:21 +0800 Subject: refactor: move function macros out of vim_defs.h (#26300) --- src/nvim/statusline.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/statusline.c') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 604ec3dfae..4dac1b1451 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -42,7 +42,6 @@ #include "nvim/strings.h" #include "nvim/ui.h" #include "nvim/undo.h" -#include "nvim/vim_defs.h" #include "nvim/window.h" // Determines how deeply nested %{} blocks will be evaluated in statusline. -- cgit