aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/screen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/screen.c')
-rw-r--r--src/nvim/screen.c1055
1 files changed, 558 insertions, 497 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 208ae3488f..5a995b9a40 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -65,46 +65,50 @@
#include <stdbool.h>
#include <string.h>
-#include "nvim/log.h"
-#include "nvim/vim.h"
-#include "nvim/ascii.h"
+#include "nvim/api/private/helpers.h"
+#include "nvim/api/vim.h"
#include "nvim/arabic.h"
-#include "nvim/screen.h"
+#include "nvim/ascii.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/cursor_shape.h"
+#include "nvim/decoration.h"
#include "nvim/diff.h"
+#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_getln.h"
-#include "nvim/edit.h"
+#include "nvim/extmark.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
-#include "nvim/indent.h"
+#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/highlight.h"
+#include "nvim/indent.h"
+#include "nvim/lib/kvec.h"
+#include "nvim/log.h"
+#include "nvim/lua/executor.h"
#include "nvim/main.h"
#include "nvim/mark.h"
-#include "nvim/extmark.h"
-#include "nvim/decoration.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/menu.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
-#include "nvim/garray.h"
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/option.h"
+#include "nvim/os/time.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/plines.h"
#include "nvim/popupmnu.h"
#include "nvim/quickfix.h"
#include "nvim/regexp.h"
+#include "nvim/screen.h"
#include "nvim/search.h"
#include "nvim/sign.h"
#include "nvim/spell.h"
@@ -116,12 +120,8 @@
#include "nvim/ui_compositor.h"
#include "nvim/undo.h"
#include "nvim/version.h"
+#include "nvim/vim.h"
#include "nvim/window.h"
-#include "nvim/os/time.h"
-#include "nvim/api/private/helpers.h"
-#include "nvim/api/vim.h"
-#include "nvim/lua/executor.h"
-#include "nvim/lib/kvec.h"
#define MB_FILLER_CHAR '<' /* character used when a double-width character
* doesn't fit. */
@@ -135,7 +135,7 @@ static size_t linebuf_size = 0;
static schar_T *linebuf_char = NULL;
static sattr_T *linebuf_attr = NULL;
-static match_T search_hl; /* used for 'hlsearch' highlight matching */
+static match_T search_hl; // used for 'hlsearch' highlight matching
StlClickDefinition *tab_page_click_defs = NULL;
@@ -168,8 +168,7 @@ static bool resizing = false;
static char * provider_err = NULL;
-static bool provider_invoke(NS ns_id, const char *name, LuaRef ref,
- Array args, bool default_true)
+static bool provider_invoke(NS ns_id, const char *name, LuaRef ref, Array args, bool default_true)
{
Error err = ERROR_INIT;
@@ -208,10 +207,12 @@ void redraw_later(win_T *wp, int type)
{
if (!exiting && wp->w_redr_type < type) {
wp->w_redr_type = type;
- if (type >= NOT_VALID)
+ if (type >= NOT_VALID) {
wp->w_lines_valid = 0;
- if (must_redraw < type) /* must_redraw is the maximum of all windows */
+ }
+ if (must_redraw < type) { // must_redraw is the maximum of all windows
must_redraw = type;
+ }
}
}
@@ -270,10 +271,10 @@ void redraw_buf_range_later(buf_T *buf, linenr_T firstline, linenr_T lastline)
if (wp->w_buffer == buf
&& lastline >= wp->w_topline && firstline < wp->w_botline) {
if (wp->w_redraw_top == 0 || wp->w_redraw_top > firstline) {
- wp->w_redraw_top = firstline;
+ wp->w_redraw_top = firstline;
}
if (wp->w_redraw_bot == 0 || wp->w_redraw_bot < lastline) {
- wp->w_redraw_bot = lastline;
+ wp->w_redraw_bot = lastline;
}
redraw_later(wp, VALID);
}
@@ -288,20 +289,16 @@ void redraw_buf_range_later(buf_T *buf, linenr_T firstline, linenr_T lastline)
* Note that when also inserting/deleting lines w_redraw_top and w_redraw_bot
* may become invalid and the whole window will have to be redrawn.
*/
-void
-redrawWinline(
- win_T *wp,
- linenr_T lnum
-)
+void redrawWinline(win_T *wp, linenr_T lnum)
FUNC_ATTR_NONNULL_ALL
{
if (lnum >= wp->w_topline
&& lnum < wp->w_botline) {
if (wp->w_redraw_top == 0 || wp->w_redraw_top > lnum) {
- wp->w_redraw_top = lnum;
+ wp->w_redraw_top = lnum;
}
if (wp->w_redraw_bot == 0 || wp->w_redraw_bot < lnum) {
- wp->w_redraw_bot = lnum;
+ wp->w_redraw_bot = lnum;
}
redraw_later(wp, VALID);
}
@@ -339,8 +336,9 @@ int update_screen(int type)
}
if (must_redraw) {
- if (type < must_redraw) /* use maximal type */
+ if (type < must_redraw) { // use maximal type
type = must_redraw;
+ }
/* must_redraw is reset here, so that when we run into some weird
* reason to redraw while busy redrawing (e.g., asynchronous
@@ -349,9 +347,10 @@ int update_screen(int type)
must_redraw = 0;
}
- /* Need to update w_lines[]. */
- if (curwin->w_lines_valid == 0 && type < NOT_VALID)
+ // Need to update w_lines[].
+ if (curwin->w_lines_valid == 0 && type < NOT_VALID) {
type = NOT_VALID;
+ }
/* Postpone the redrawing when it's not needed and when being called
* recursively. */
@@ -448,12 +447,13 @@ int update_screen(int type)
win_ui_flush();
msg_ext_check_clear();
- /* reset cmdline_row now (may have been changed temporarily) */
+ // reset cmdline_row now (may have been changed temporarily)
compute_cmdrow();
- /* Check for changed highlighting */
- if (need_highlight_changed)
+ // Check for changed highlighting
+ if (need_highlight_changed) {
highlight_changed();
+ }
if (type == CLEAR) { // first clear screen
screenclear(); // will reset clear_cmdline
@@ -503,21 +503,24 @@ int update_screen(int type)
redraw_tabline = true;
}
- if (clear_cmdline) /* going to clear cmdline (done below) */
+ if (clear_cmdline) { // going to clear cmdline (done below)
check_for_delay(FALSE);
+ }
/* Force redraw when width of 'number' or 'relativenumber' column
* changes. */
if (curwin->w_redr_type < NOT_VALID
&& curwin->w_nrwidth != ((curwin->w_p_nu || curwin->w_p_rnu)
- ? number_width(curwin) : 0))
+ ? number_width(curwin) : 0)) {
curwin->w_redr_type = NOT_VALID;
+ }
/*
* Only start redrawing if there is really something to do.
*/
- if (type == INVERTED)
+ if (type == INVERTED) {
update_curswant();
+ }
if (curwin->w_redr_type < type
&& !((type == VALID
&& curwin->w_lines[0].wl_valid
@@ -530,8 +533,9 @@ int update_screen(int type)
&& curwin->w_old_visual_mode == VIsual_mode
&& (curwin->w_valid & VALID_VIRTCOL)
&& curwin->w_old_curswant == curwin->w_curswant)
- ))
+ )) {
curwin->w_redr_type = type;
+ }
// Redraw the tab pages line if needed.
if (redraw_tabline || type >= NOT_VALID) {
@@ -602,7 +606,7 @@ int update_screen(int type)
win_update(wp, &providers);
}
- /* redraw status line after the window to minimize cursor movement */
+ // redraw status line after the window to minimize cursor movement
if (wp->w_redr_status) {
win_redr_status(wp);
}
@@ -631,9 +635,10 @@ int update_screen(int type)
showmode();
}
- /* May put up an introductory message when not editing a file */
- if (!did_intro)
+ // May put up an introductory message when not editing a file
+ if (!did_intro) {
maybe_intro_message();
+ }
did_intro = true;
for (size_t i = 0; i < kv_size(providers); i++) {
@@ -704,7 +709,7 @@ bool win_cursorline_standout(const win_T *wp)
FUNC_ATTR_NONNULL_ALL
{
return wp->w_p_cul
- || (wp->w_p_cole > 0 && (VIsual_active || !conceal_cursor_line(wp)));
+ || (wp->w_p_cole > 0 && (VIsual_active || !conceal_cursor_line(wp)));
}
/*
@@ -715,22 +720,22 @@ bool win_cursorline_standout(const win_T *wp)
*
* How the window is redrawn depends on wp->w_redr_type. Each type also
* implies the one below it.
- * NOT_VALID redraw the whole window
- * SOME_VALID redraw the whole window but do scroll when possible
- * REDRAW_TOP redraw the top w_upd_rows window lines, otherwise like VALID
- * INVERTED redraw the changed part of the Visual area
- * INVERTED_ALL redraw the whole Visual area
- * VALID 1. scroll up/down to adjust for a changed w_topline
- * 2. update lines at the top when scrolled down
- * 3. redraw changed text:
- * - if wp->w_buffer->b_mod_set set, update lines between
- * b_mod_top and b_mod_bot.
- * - if wp->w_redraw_top non-zero, redraw lines between
- * wp->w_redraw_top and wp->w_redr_bot.
- * - continue redrawing when syntax status is invalid.
- * 4. if scrolled up, update lines at the bottom.
+ * NOT_VALID redraw the whole window
+ * SOME_VALID redraw the whole window but do scroll when possible
+ * REDRAW_TOP redraw the top w_upd_rows window lines, otherwise like VALID
+ * INVERTED redraw the changed part of the Visual area
+ * INVERTED_ALL redraw the whole Visual area
+ * VALID 1. scroll up/down to adjust for a changed w_topline
+ * 2. update lines at the top when scrolled down
+ * 3. redraw changed text:
+ * - if wp->w_buffer->b_mod_set set, update lines between
+ * b_mod_top and b_mod_bot.
+ * - if wp->w_redraw_top non-zero, redraw lines between
+ * wp->w_redraw_top and wp->w_redr_bot.
+ * - continue redrawing when syntax status is invalid.
+ * 4. if scrolled up, update lines at the bottom.
* This results in three areas that may need updating:
- * top: from first row to top_end (when scrolled down)
+ * top: from first row to top_end (when scrolled down)
* mid: from mid_start to mid_end (update inversion or changed text)
* bot: from bot_start to last row (when scrolled up)
*/
@@ -749,10 +754,10 @@ static void win_update(win_T *wp, Providers *providers)
bool scrolled_down = false; // true when scrolled down when w_topline got smaller a bit
bool top_to_mod = false; // redraw above mod_top
- int row; /* current window row to display */
- linenr_T lnum; /* current buffer lnum to display */
- int idx; /* current index in w_lines[] */
- int srow; /* starting row of the current line */
+ int row; // current window row to display
+ linenr_T lnum; // current buffer lnum to display
+ int idx; // current index in w_lines[]
+ int srow; // starting row of the current line
bool eof = false; // if true, we hit the end of the file
bool didline = false; // if true, we finished the last line
@@ -767,7 +772,7 @@ static void win_update(win_T *wp, Providers *providers)
#define DID_LINE 2 // updated a normal line
#define DID_FOLD 3 // updated a folded line
int did_update = DID_NONE;
- linenr_T syntax_last_parsed = 0; /* last parsed text line */
+ linenr_T syntax_last_parsed = 0; // last parsed text line
linenr_T mod_top = 0;
linenr_T mod_bot = 0;
int save_got_int;
@@ -824,10 +829,11 @@ static void win_update(win_T *wp, Providers *providers)
* changes. Set mod_bot to the first line after the changes.
*/
mod_top = wp->w_redraw_top;
- if (wp->w_redraw_bot != 0)
+ if (wp->w_redraw_bot != 0) {
mod_bot = wp->w_redraw_bot + 1;
- else
+ } else {
mod_bot = 0;
+ }
if (buf->b_mod_set) {
if (mod_top == 0 || mod_top > buf->b_mod_top) {
mod_top = buf->b_mod_top;
@@ -835,12 +841,14 @@ static void win_update(win_T *wp, Providers *providers)
* in a pattern match. */
if (syntax_present(wp)) {
mod_top -= buf->b_s.b_syn_sync_linebreaks;
- if (mod_top < 1)
+ if (mod_top < 1) {
mod_top = 1;
+ }
}
}
- if (mod_bot == 0 || mod_bot < buf->b_mod_bot)
+ if (mod_bot == 0 || mod_bot < buf->b_mod_bot) {
mod_bot = buf->b_mod_bot;
+ }
// When 'hlsearch' is on and using a multi-line search pattern, a
// change in one line may make the Search highlighting in a
@@ -879,10 +887,11 @@ static void win_update(win_T *wp, Providers *providers)
* to this line. If there is no valid entry, use MAXLNUM. */
lnumt = wp->w_topline;
lnumb = MAXLNUM;
- for (i = 0; i < wp->w_lines_valid; ++i)
+ for (i = 0; i < wp->w_lines_valid; ++i) {
if (wp->w_lines[i].wl_valid) {
- if (wp->w_lines[i].wl_lastlnum < mod_top)
+ if (wp->w_lines[i].wl_lastlnum < mod_top) {
lnumt = wp->w_lines[i].wl_lastlnum + 1;
+ }
if (lnumb == MAXLNUM && wp->w_lines[i].wl_lnum >= mod_bot) {
lnumb = wp->w_lines[i].wl_lnum;
// When there is a fold column it might need updating
@@ -892,6 +901,7 @@ static void win_update(win_T *wp, Providers *providers)
}
}
}
+ }
(void)hasFoldingWin(wp, mod_top, &mod_top, NULL, true, NULL);
if (mod_top > lnumt) {
@@ -912,16 +922,18 @@ static void win_update(win_T *wp, Providers *providers)
* If the end of the change is above w_topline: do like no change was
* made, but redraw the first line to find changes in syntax. */
if (mod_top != 0 && mod_top < wp->w_topline) {
- if (mod_bot > wp->w_topline)
+ if (mod_bot > wp->w_topline) {
mod_top = wp->w_topline;
- else if (syntax_present(wp))
+ } else if (syntax_present(wp)) {
top_end = 1;
+ }
}
/* When line numbers are displayed need to redraw all lines below
* inserted/deleted lines. */
- if (mod_top != 0 && buf->b_mod_xlines != 0 && wp->w_p_nu)
+ if (mod_top != 0 && buf->b_mod_xlines != 0 && wp->w_p_nu) {
mod_bot = MAXLNUM;
+ }
}
wp->w_redraw_top = 0; // reset for next time
wp->w_redraw_bot = 0;
@@ -939,12 +951,13 @@ static void win_update(win_T *wp, Providers *providers)
break;
}
}
- if (top_end == 0)
- /* not found (cannot happen?): redraw everything */
+ if (top_end == 0) {
+ // not found (cannot happen?): redraw everything
type = NOT_VALID;
- else
- /* top area defined, the rest is VALID */
+ } else {
+ // top area defined, the rest is VALID
type = VALID;
+ }
}
/*
@@ -957,8 +970,7 @@ static void win_update(win_T *wp, Providers *providers)
*/
if ((type == VALID || type == SOME_VALID
|| type == INVERTED || type == INVERTED_ALL)
- && !wp->w_botfill && !wp->w_old_botfill
- ) {
+ && !wp->w_botfill && !wp->w_old_botfill) {
if (mod_top != 0
&& wp->w_topline == mod_top
&& (!wp->w_lines[0].wl_valid
@@ -986,14 +998,16 @@ static void win_update(win_T *wp, Providers *providers)
}
(void)hasFoldingWin(wp, ln, NULL, &ln, true, NULL);
}
- } else
+ } else {
j = wp->w_lines[0].wl_lnum - wp->w_topline;
+ }
if (j < wp->w_grid.Rows - 2) { // not too far off
i = plines_m_win(wp, wp->w_topline, wp->w_lines[0].wl_lnum - 1);
- /* insert extra lines for previously invisible filler lines */
- if (wp->w_lines[0].wl_lnum != wp->w_topline)
+ // insert extra lines for previously invisible filler lines
+ if (wp->w_lines[0].wl_lnum != wp->w_topline) {
i += diff_check_fill(wp, wp->w_lines[0].wl_lnum)
- wp->w_old_topfill;
+ }
if (i != 0 && i < wp->w_grid.Rows - 2) { // less than a screen off
// Try to insert the correct number of lines.
// If not the last window, delete the lines at the bottom.
@@ -1030,7 +1044,7 @@ static void win_update(win_T *wp, Providers *providers)
* needs updating.
*/
- /* try to find wp->w_topline in wp->w_lines[].wl_lnum */
+ // try to find wp->w_topline in wp->w_lines[].wl_lnum
j = -1;
row = 0;
for (i = 0; i < wp->w_lines_valid; i++) {
@@ -1052,11 +1066,12 @@ static void win_update(win_T *wp, Providers *providers)
*/
/* If the topline didn't change, delete old filler lines,
* otherwise delete filler lines of the new topline... */
- if (wp->w_lines[0].wl_lnum == wp->w_topline)
+ if (wp->w_lines[0].wl_lnum == wp->w_topline) {
row += wp->w_old_topfill;
- else
+ } else {
row += diff_check_fill(wp, wp->w_topline);
- /* ... but don't delete new filler lines. */
+ }
+ // ... but don't delete new filler lines.
row -= wp->w_topfill;
if (row > 0) {
win_scroll_lines(wp, 0, -row);
@@ -1065,7 +1080,7 @@ static void win_update(win_T *wp, Providers *providers)
if ((row == 0 || bot_start < 999) && wp->w_lines_valid != 0) {
/*
* Skip the lines (below the deleted lines) that are still
- * valid and don't need redrawing. Copy their info
+ * valid and don't need redrawing. Copy their info
* upwards, to compensate for the deleted lines. Set
* bot_start to the first row that needs redrawing.
*/
@@ -1082,7 +1097,7 @@ static void win_update(win_T *wp, Providers *providers)
}
bot_start += wp->w_lines[idx++].wl_size;
- /* stop at the last valid entry in w_lines[].wl_size */
+ // stop at the last valid entry in w_lines[].wl_size
if (++j >= wp->w_lines_valid) {
wp->w_lines_valid = idx;
break;
@@ -1090,10 +1105,11 @@ static void win_update(win_T *wp, Providers *providers)
}
/* Correct the first entry for filler lines at the top
* when it won't get updated below. */
- if (wp->w_p_diff && bot_start > 0)
+ if (wp->w_p_diff && bot_start > 0) {
wp->w_lines[0].wl_size =
plines_win_nofill(wp, wp->w_topline, true)
+ wp->w_topfill;
+ }
}
}
}
@@ -1103,19 +1119,19 @@ static void win_update(win_T *wp, Providers *providers)
mid_end = wp->w_grid.Rows;
}
} else {
- /* Not VALID or INVERTED: redraw all lines. */
+ // Not VALID or INVERTED: redraw all lines.
mid_start = 0;
mid_end = wp->w_grid.Rows;
}
if (type == SOME_VALID) {
- /* SOME_VALID: redraw all lines. */
+ // SOME_VALID: redraw all lines.
mid_start = 0;
mid_end = wp->w_grid.Rows;
type = NOT_VALID;
}
- /* check if we are updating or removing the inverted part */
+ // check if we are updating or removing the inverted part
if ((VIsual_active && buf == curwin->w_buffer)
|| (wp->w_old_cursor_lnum != 0 && type != NOT_VALID)) {
linenr_T from, to;
@@ -1132,15 +1148,19 @@ static void win_update(win_T *wp, Providers *providers)
from = VIsual.lnum;
to = curwin->w_cursor.lnum;
}
- /* redraw more when the cursor moved as well */
- if (wp->w_old_cursor_lnum < from)
+ // redraw more when the cursor moved as well
+ if (wp->w_old_cursor_lnum < from) {
from = wp->w_old_cursor_lnum;
- if (wp->w_old_cursor_lnum > to)
+ }
+ if (wp->w_old_cursor_lnum > to) {
to = wp->w_old_cursor_lnum;
- if (wp->w_old_visual_lnum < from)
+ }
+ if (wp->w_old_visual_lnum < from) {
from = wp->w_old_visual_lnum;
- if (wp->w_old_visual_lnum > to)
+ }
+ if (wp->w_old_visual_lnum > to) {
to = wp->w_old_visual_lnum;
+ }
} else {
/*
* Find the line numbers that need to be updated: The lines
@@ -1153,21 +1173,26 @@ static void win_update(win_T *wp, Providers *providers)
} else {
from = wp->w_old_cursor_lnum;
to = curwin->w_cursor.lnum;
- if (from == 0) /* Visual mode just started */
+ if (from == 0) { // Visual mode just started
from = to;
+ }
}
if (VIsual.lnum != wp->w_old_visual_lnum
|| VIsual.col != wp->w_old_visual_col) {
if (wp->w_old_visual_lnum < from
- && wp->w_old_visual_lnum != 0)
+ && wp->w_old_visual_lnum != 0) {
from = wp->w_old_visual_lnum;
- if (wp->w_old_visual_lnum > to)
+ }
+ if (wp->w_old_visual_lnum > to) {
to = wp->w_old_visual_lnum;
- if (VIsual.lnum < from)
+ }
+ if (VIsual.lnum < from) {
from = VIsual.lnum;
- if (VIsual.lnum > to)
+ }
+ if (VIsual.lnum > to) {
to = VIsual.lnum;
+ }
}
}
@@ -1180,8 +1205,9 @@ static void win_update(win_T *wp, Providers *providers)
colnr_T fromc, toc;
int save_ve_flags = ve_flags;
- if (curwin->w_p_lbr)
+ if (curwin->w_p_lbr) {
ve_flags = VE_ALL;
+ }
getvcols(wp, &VIsual, &curwin->w_cursor, &fromc, &toc);
ve_flags = save_ve_flags;
@@ -1194,16 +1220,18 @@ static void win_update(win_T *wp, Providers *providers)
if (fromc != wp->w_old_cursor_fcol
|| toc != wp->w_old_cursor_lcol) {
- if (from > VIsual.lnum)
+ if (from > VIsual.lnum) {
from = VIsual.lnum;
- if (to < VIsual.lnum)
+ }
+ if (to < VIsual.lnum) {
to = VIsual.lnum;
+ }
}
wp->w_old_cursor_fcol = fromc;
wp->w_old_cursor_lcol = toc;
}
} else {
- /* Use the line numbers of the old Visual area. */
+ // Use the line numbers of the old Visual area.
if (wp->w_old_cursor_lnum < wp->w_old_visual_lnum) {
from = wp->w_old_cursor_lnum;
to = wp->w_old_visual_lnum;
@@ -1216,18 +1244,21 @@ static void win_update(win_T *wp, Providers *providers)
/*
* There is no need to update lines above the top of the window.
*/
- if (from < wp->w_topline)
+ if (from < wp->w_topline) {
from = wp->w_topline;
+ }
/*
* If we know the value of w_botline, use it to restrict the update to
* the lines that are visible in the window.
*/
if (wp->w_valid & VALID_BOTLINE) {
- if (from >= wp->w_botline)
+ if (from >= wp->w_botline) {
from = wp->w_botline - 1;
- if (to >= wp->w_botline)
+ }
+ if (to >= wp->w_botline) {
to = wp->w_botline - 1;
+ }
}
/*
@@ -1243,27 +1274,30 @@ static void win_update(win_T *wp, Providers *providers)
lnum = wp->w_topline;
idx = 0;
srow = 0;
- if (scrolled_down)
+ if (scrolled_down) {
mid_start = top_end;
- else
+ } else {
mid_start = 0;
- while (lnum < from && idx < wp->w_lines_valid) { /* find start */
- if (wp->w_lines[idx].wl_valid)
+ }
+ while (lnum < from && idx < wp->w_lines_valid) { // find start
+ if (wp->w_lines[idx].wl_valid) {
mid_start += wp->w_lines[idx].wl_size;
- else if (!scrolled_down)
+ } else if (!scrolled_down) {
srow += wp->w_lines[idx].wl_size;
+ }
++idx;
- if (idx < wp->w_lines_valid && wp->w_lines[idx].wl_valid)
+ if (idx < wp->w_lines_valid && wp->w_lines[idx].wl_valid) {
lnum = wp->w_lines[idx].wl_lnum;
- else
+ } else {
++lnum;
+ }
}
srow += mid_start;
mid_end = wp->w_grid.Rows;
for (; idx < wp->w_lines_valid; idx++) { // find end
if (wp->w_lines[idx].wl_valid
&& wp->w_lines[idx].wl_lnum >= to + 1) {
- /* Only update until first row of this line */
+ // Only update until first row of this line
mid_end = srow;
break;
}
@@ -1285,7 +1319,7 @@ static void win_update(win_T *wp, Providers *providers)
wp->w_old_visual_col = 0;
}
- /* reset got_int, otherwise regexp won't work */
+ // reset got_int, otherwise regexp won't work
save_got_int = got_int;
got_int = 0;
// Set the time limit to 'redrawtime'.
@@ -1295,7 +1329,7 @@ static void win_update(win_T *wp, Providers *providers)
/*
* Update all the window rows.
*/
- idx = 0; /* first entry in w_lines[].wl_size */
+ idx = 0; // first entry in w_lines[].wl_size
row = 0;
srow = 0;
lnum = wp->w_topline; // first line shown in window
@@ -1335,7 +1369,7 @@ static void win_update(win_T *wp, Providers *providers)
break;
}
- /* stop updating when hit the end of the file */
+ // stop updating when hit the end of the file
if (lnum > buf->b_ml.ml_line_count) {
eof = true;
break;
@@ -1400,8 +1434,9 @@ static void win_update(win_T *wp, Providers *providers)
/* Only valid lines have a meaningful wl_lnum. Invalid
* lines are part of the changed area. */
if (wp->w_lines[i].wl_valid
- && wp->w_lines[i].wl_lnum == mod_bot)
+ && wp->w_lines[i].wl_lnum == mod_bot) {
break;
+ }
old_rows += wp->w_lines[i].wl_size;
if (wp->w_lines[i].wl_valid
&& wp->w_lines[i].wl_lastlnum + 1 == mod_bot) {
@@ -1409,8 +1444,9 @@ static void win_update(win_T *wp, Providers *providers)
* Add following invalid entries. */
++i;
while (i < wp->w_lines_valid
- && !wp->w_lines[i].wl_valid)
+ && !wp->w_lines[i].wl_valid) {
old_rows += wp->w_lines[i++].wl_size;
+ }
break;
}
}
@@ -1473,15 +1509,15 @@ static void win_update(win_T *wp, Providers *providers)
if (j < i) {
int x = row + new_rows;
- /* move entries in w_lines[] upwards */
+ // move entries in w_lines[] upwards
for (;; ) {
- /* stop at last valid entry in w_lines[] */
+ // stop at last valid entry in w_lines[]
if (i >= wp->w_lines_valid) {
wp->w_lines_valid = j;
break;
}
wp->w_lines[j] = wp->w_lines[i];
- /* stop at a line that won't fit */
+ // stop at a line that won't fit
if (x + (int)wp->w_lines[j].wl_size
> wp->w_grid.Rows) {
wp->w_lines_valid = j + 1;
@@ -1490,10 +1526,11 @@ static void win_update(win_T *wp, Providers *providers)
x += wp->w_lines[j++].wl_size;
++i;
}
- if (bot_start > x)
+ if (bot_start > x) {
bot_start = x;
- } else { /* j > i */
- /* move entries in w_lines[] downwards */
+ }
+ } else { // j > i
+ // move entries in w_lines[] downwards
j -= i;
wp->w_lines_valid += j;
if (wp->w_lines_valid > wp->w_grid.Rows) {
@@ -1529,17 +1566,17 @@ static void win_update(win_T *wp, Providers *providers)
&& lnum > wp->w_topline
&& !(dy_flags & (DY_LASTLINE | DY_TRUNCATE))
&& srow + wp->w_lines[idx].wl_size > wp->w_grid.Rows
- && diff_check_fill(wp, lnum) == 0
- ) {
+ && diff_check_fill(wp, lnum) == 0) {
// This line is not going to fit. Don't draw anything here,
// will draw "@ " lines below.
row = wp->w_grid.Rows + 1;
} else {
prepare_search_hl(wp, lnum);
- /* Let the syntax stuff know we skipped a few lines. */
+ // Let the syntax stuff know we skipped a few lines.
if (syntax_last_parsed != 0 && syntax_last_parsed + 1 < lnum
- && syntax_present(wp))
+ && syntax_present(wp)) {
syntax_end_parsing(syntax_last_parsed + 1);
+ }
// Display one line
row = win_line(wp, lnum, srow,
@@ -1603,14 +1640,16 @@ static void win_update(win_T *wp, Providers *providers)
*/
- if (idx > wp->w_lines_valid)
+ if (idx > wp->w_lines_valid) {
wp->w_lines_valid = idx;
+ }
/*
* Let the syntax stuff know we stop parsing here.
*/
- if (syntax_last_parsed != 0 && syntax_present(wp))
+ if (syntax_last_parsed != 0 && syntax_present(wp)) {
syntax_end_parsing(syntax_last_parsed + 1);
+ }
/*
* If we didn't hit the end of the file, and we didn't finish the last
@@ -1656,20 +1695,15 @@ static void win_update(win_T *wp, Providers *providers)
wp->w_botline = buf->b_ml.ml_line_count + 1;
j = diff_check_fill(wp, wp->w_botline);
if (j > 0 && !wp->w_botfill) {
- // display filler lines at the end of the file
- if (char2cells(wp->w_p_fcs_chars.diff) > 1) {
- i = '-';
- } else {
- i = wp->w_p_fcs_chars.diff;
- }
- if (row + j > wp->w_grid.Rows) {
- j = wp->w_grid.Rows - row;
- }
- win_draw_end(wp, i, i, true, row, row + (int)j, HLF_DED);
- row += j;
+ // Display filler text below last line. win_line() will check
+ // for ml_line_count+1 and only draw filler lines
+ foldinfo_T info = FOLDINFO_INIT;
+ row = win_line(wp, wp->w_botline, row, wp->w_grid.Rows,
+ false, false, info, &line_providers);
}
- } else if (dollar_vcol == -1)
+ } else if (dollar_vcol == -1) {
wp->w_botline = lnum;
+ }
// make sure the rest of the screen is blank
// write the 'eob' character to rows that aren't part of the file.
@@ -1684,7 +1718,7 @@ static void win_update(win_T *wp, Providers *providers)
}
syn_set_timeout(NULL);
- /* Reset the type of redrawing required, the window has been updated. */
+ // Reset the type of redrawing required, the window has been updated.
wp->w_redr_type = 0;
wp->w_old_topfill = wp->w_topfill;
wp->w_old_botfill = wp->w_botfill;
@@ -1754,9 +1788,10 @@ static void win_update(win_T *wp, Providers *providers)
}
- /* restore got_int, unless CTRL-C was hit while redrawing */
- if (!got_int)
+ // restore got_int, unless CTRL-C was hit while redrawing
+ if (!got_int) {
got_int = save_got_int;
+ }
} // NOLINT(readability/fn_size)
/// Returns width of the signcolumn that should be used for the whole window
@@ -1776,8 +1811,8 @@ int win_signcol_width(win_T *wp)
/// Call grid_fill() with columns adjusted for 'rightleft' if needed.
/// Return the new offset.
-static int win_fill_end(win_T *wp, int c1, int c2, int off, int width, int row,
- int endrow, int attr)
+static int win_fill_end(win_T *wp, int c1, int c2, int off, int width, int row, int endrow,
+ int attr)
{
int nn = off + width;
@@ -1798,8 +1833,7 @@ static int win_fill_end(win_T *wp, int c1, int c2, int off, int width, int row,
/// Clear lines near the end of the window and mark the unused lines with "c1".
/// Use "c2" as filler character.
/// When "draw_margin" is true, then draw the sign/fold/number columns.
-static void win_draw_end(win_T *wp, int c1, int c2, bool draw_margin, int row,
- int endrow, hlf_T hl)
+static void win_draw_end(win_T *wp, int c1, int c2, bool draw_margin, int row, int endrow, hlf_T hl)
{
assert(hl >= 0 && hl < HLF_COUNT);
int n = 0;
@@ -1844,8 +1878,9 @@ static void win_draw_end(win_T *wp, int c1, int c2, bool draw_margin, int row,
/// @return true when there are columns to draw.
static bool advance_color_col(int vcol, int **color_cols)
{
- while (**color_cols >= 0 && vcol > **color_cols)
+ while (**color_cols >= 0 && vcol > **color_cols) {
++*color_cols;
+ }
return **color_cols >= 0;
}
@@ -1923,13 +1958,7 @@ static int line_putchar(LineState *s, schar_T *dest, int maxcells, bool rl)
///
/// Assume monocell characters
/// @return number of chars added to \param p
-static size_t
-fill_foldcolumn(
- char_u *p,
- win_T *wp,
- foldinfo_T foldinfo,
- linenr_T lnum
-)
+static size_t fill_foldcolumn(char_u *p, win_T *wp, foldinfo_T foldinfo, linenr_T lnum)
{
int i = 0;
int level;
@@ -1998,9 +2027,8 @@ fill_foldcolumn(
/// or explicitly return `false`.
///
/// @return the number of last row the line occupies.
-static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
- bool nochange, bool number_only, foldinfo_T foldinfo,
- Providers *providers)
+static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
+ bool number_only, foldinfo_T foldinfo, Providers *providers)
{
int c = 0; // init for GCC
long vcol = 0; // virtual column (for tabs)
@@ -2033,12 +2061,12 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
int saved_c_final = 0;
int saved_char_attr = 0;
- int n_attr = 0; /* chars with special attr */
- int saved_attr2 = 0; /* char_attr saved for n_attr */
- int n_attr3 = 0; /* chars with overruling special attr */
- int saved_attr3 = 0; /* char_attr saved for n_attr3 */
+ int n_attr = 0; // chars with special attr
+ int saved_attr2 = 0; // char_attr saved for n_attr
+ int n_attr3 = 0; // chars with overruling special attr
+ int saved_attr3 = 0; // char_attr saved for n_attr3
- int n_skip = 0; /* nr of chars to skip for 'nowrap' */
+ int n_skip = 0; // nr of chars to skip for 'nowrap'
int fromcol = -10; // start of inverting
int tocol = MAXCOL; // end of inverting
@@ -2048,29 +2076,29 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
pos_T pos;
long v;
- int char_attr = 0; /* attributes for next character */
- int attr_pri = FALSE; /* char_attr has priority */
+ int char_attr = 0; // attributes for next character
+ int attr_pri = FALSE; // char_attr has priority
int area_highlighting = FALSE; /* Visual or incsearch highlighting
in this line */
- int attr = 0; /* attributes for area highlighting */
- int area_attr = 0; /* attributes desired by highlighting */
- int search_attr = 0; /* attributes desired by 'hlsearch' */
- int vcol_save_attr = 0; /* saved attr for 'cursorcolumn' */
- int syntax_attr = 0; /* attributes desired by syntax */
- int has_syntax = FALSE; /* this buffer has syntax highl. */
+ int attr = 0; // attributes for area highlighting
+ int area_attr = 0; // attributes desired by highlighting
+ int search_attr = 0; // attributes desired by 'hlsearch'
+ int vcol_save_attr = 0; // saved attr for 'cursorcolumn'
+ int syntax_attr = 0; // attributes desired by syntax
+ int has_syntax = FALSE; // this buffer has syntax highl.
int save_did_emsg;
int eol_hl_off = 0; // 1 if highlighted char after EOL
bool draw_color_col = false; // highlight colorcolumn
int *color_cols = NULL; // pointer to according columns array
bool has_spell = false; // this buffer has spell checking
# define SPWORDLEN 150
- char_u nextline[SPWORDLEN * 2]; /* text with start of the next line */
- int nextlinecol = 0; /* column where nextline[] starts */
+ char_u nextline[SPWORDLEN * 2]; // text with start of the next line
+ int nextlinecol = 0; // column where nextline[] starts
int nextline_idx = 0; /* index in nextline[] where next line
starts */
- int spell_attr = 0; /* attributes desired by spelling */
- int word_end = 0; /* last byte with same spell_attr */
- static linenr_T checked_lnum = 0; /* line number for "checked_col" */
+ int spell_attr = 0; // attributes desired by spelling
+ int word_end = 0; // last byte with same spell_attr
+ static linenr_T checked_lnum = 0; // line number for "checked_col"
static int checked_col = 0; /* column in "checked_lnum" up to which
* there are no spell errors */
static int cap_col = -1; // column to check for Cap word
@@ -2122,16 +2150,16 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
int left_curline_col = 0;
int right_curline_col = 0;
- /* draw_state: items that are drawn in sequence: */
-#define WL_START 0 /* nothing done yet */
-# define WL_CMDLINE WL_START + 1 /* cmdline window column */
-# define WL_FOLD WL_CMDLINE + 1 /* 'foldcolumn' */
-# define WL_SIGN WL_FOLD + 1 /* column for signs */
-#define WL_NR WL_SIGN + 1 /* line number */
-# define WL_BRI WL_NR + 1 /* 'breakindent' */
-# define WL_SBR WL_BRI + 1 /* 'showbreak' or 'diff' */
-#define WL_LINE WL_SBR + 1 /* text in the line */
- int draw_state = WL_START; /* what to draw next */
+ // draw_state: items that are drawn in sequence:
+#define WL_START 0 // nothing done yet
+# define WL_CMDLINE WL_START + 1 // cmdline window column
+# define WL_FOLD WL_CMDLINE + 1 // 'foldcolumn'
+# define WL_SIGN WL_FOLD + 1 // column for signs
+#define WL_NR WL_SIGN + 1 // line number
+# define WL_BRI WL_NR + 1 // 'breakindent'
+# define WL_SBR WL_BRI + 1 // 'showbreak' or 'diff'
+#define WL_LINE WL_SBR + 1 // text in the line
+ int draw_state = WL_START; // what to draw next
int syntax_flags = 0;
int syntax_seqnr = 0;
@@ -2155,12 +2183,14 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
boguscols = 0; \
}
- if (startrow > endrow) /* past the end already! */
+ if (startrow > endrow) { // past the end already!
return startrow;
+ }
row = startrow;
buf_T *buf = wp->w_buffer;
+ bool end_fill = (lnum == buf->b_ml.ml_line_count+1);
if (!number_only) {
// To speed up the loop below, set extra_check when there is linebreak,
@@ -2228,6 +2258,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
if (wp->w_p_spell
&& !has_fold
+ && !end_fill
&& *wp->w_s->b_p_spl != NUL
&& !GA_EMPTY(&wp->w_s->b_langp)
&& *(char **)(wp->w_s->b_langp.ga_data) != NULL) {
@@ -2327,7 +2358,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
area_highlighting = true;
attr = win_hl_attr(wp, HLF_V);
}
- // handle 'incsearch' and ":s///c" highlighting
+ // handle 'incsearch' and ":s///c" highlighting
} else if (highlight_match
&& wp == curwin
&& !has_fold
@@ -2356,19 +2387,22 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
filler_lines = diff_check(wp, lnum);
if (filler_lines < 0) {
if (filler_lines == -1) {
- if (diff_find_change(wp, lnum, &change_start, &change_end))
- diff_hlf = HLF_ADD; /* added line */
- else if (change_start == 0)
- diff_hlf = HLF_TXD; /* changed text */
- else
- diff_hlf = HLF_CHD; /* changed line */
- } else
- diff_hlf = HLF_ADD; /* added line */
+ if (diff_find_change(wp, lnum, &change_start, &change_end)) {
+ diff_hlf = HLF_ADD; // added line
+ } else if (change_start == 0) {
+ diff_hlf = HLF_TXD; // changed text
+ } else {
+ diff_hlf = HLF_CHD; // changed line
+ }
+ } else {
+ diff_hlf = HLF_ADD; // added line
+ }
filler_lines = 0;
area_highlighting = TRUE;
}
- if (lnum == wp->w_topline)
+ if (lnum == wp->w_topline) {
filler_lines = wp->w_topfill;
+ }
filler_todo = filler_lines;
// Cursor line highlighting for 'cursorline' in the current window.
@@ -2428,7 +2462,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
line_attr_lowprio_save = line_attr_lowprio;
}
- line = ml_get_buf(wp->w_buffer, lnum, false);
+ line = end_fill ? (char_u *)"" : ml_get_buf(wp->w_buffer, lnum, false);
ptr = line;
if (has_spell && !number_only) {
@@ -2441,7 +2475,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
* current line into nextline[]. Above the start of the next line was
* copied to nextline[SPWORDLEN]. */
if (nextline[SPWORDLEN] == NUL) {
- /* No next line or it is empty. */
+ // No next line or it is empty.
nextlinecol = MAXCOL;
nextline_idx = 0;
} else {
@@ -2454,7 +2488,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
STRMOVE(nextline + v, nextline + SPWORDLEN);
nextline_idx = v + 1;
} else {
- /* Long line, use only the last SPWORDLEN bytes. */
+ // Long line, use only the last SPWORDLEN bytes.
nextlinecol = v - SPWORDLEN;
memmove(nextline, line + nextlinecol, SPWORDLEN); // -V512
nextline_idx = SPWORDLEN + 1;
@@ -2462,7 +2496,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
}
}
- if (wp->w_p_list && !has_fold) {
+ if (wp->w_p_list && !has_fold && !end_fill) {
if (wp->w_p_lcs_chars.space
|| wp->w_p_lcs_chars.trail
|| wp->w_p_lcs_chars.lead
@@ -2475,7 +2509,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
while (trailcol > (colnr_T)0 && ascii_iswhite(ptr[trailcol - 1])) {
trailcol--;
}
- trailcol += (colnr_T) (ptr - line);
+ trailcol += (colnr_T)(ptr - line);
}
// find end of leading whitespace
if (wp->w_p_lcs_chars.lead) {
@@ -2497,10 +2531,11 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
* 'nowrap' or 'wrap' and a single line that doesn't fit: Advance to the
* first character to be displayed.
*/
- if (wp->w_p_wrap)
+ if (wp->w_p_wrap) {
v = wp->w_skipcol;
- else
+ } else {
v = wp->w_leftcol;
+ }
if (v > 0 && !number_only) {
char_u *prev_ptr = ptr;
while (vcol < v && *ptr != NUL) {
@@ -2539,10 +2574,11 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
* Adjust for when the inverted text is before the screen,
* and when the start of the inverted text is before the screen.
*/
- if (tocol <= vcol)
+ if (tocol <= vcol) {
fromcol = 0;
- else if (fromcol >= 0 && fromcol < vcol)
+ } else if (fromcol >= 0 && fromcol < vcol) {
fromcol = vcol;
+ }
// When w_skipcol is non-zero, first line needs 'showbreak'
if (wp->w_p_wrap) {
@@ -2570,13 +2606,14 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
spell_hlf = HLF_COUNT;
word_end = (int)(spell_to_word_end(ptr, wp) - line + 1);
} else {
- /* bad word found, use attributes until end of word */
+ // bad word found, use attributes until end of word
assert(len <= INT_MAX);
word_end = wp->w_cursor.col + (int)len + 1;
- /* Turn index into actual attributes. */
- if (spell_hlf != HLF_COUNT)
+ // Turn index into actual attributes.
+ if (spell_hlf != HLF_COUNT) {
spell_attr = highlight_attr[spell_hlf];
+ }
}
wp->w_cursor = pos;
@@ -2598,12 +2635,14 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
* cursor */
fromcol_prev = fromcol;
fromcol = -1;
- } else if ((colnr_T)fromcol < wp->w_virtcol)
- /* restart highlighting after the cursor */
+ } else if ((colnr_T)fromcol < wp->w_virtcol) {
+ // restart highlighting after the cursor
fromcol_prev = wp->w_virtcol;
+ }
}
- if (fromcol >= tocol)
+ if (fromcol >= tocol) {
fromcol = -1;
+ }
}
/*
@@ -2613,8 +2652,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
cur = wp->w_match_head;
shl_flag = false;
while ((cur != NULL || !shl_flag) && !number_only
- && !has_fold
- ) {
+ && !has_fold && !end_fill) {
if (!shl_flag) {
shl = &search_hl;
shl_flag = true;
@@ -2647,18 +2685,18 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
shl->startcol = 0;
}
if (lnum == shl->lnum + shl->rm.endpos[0].lnum
- - shl->rm.startpos[0].lnum) {
- shl->endcol = shl->rm.endpos[0].col;
+ - shl->rm.startpos[0].lnum) {
+ shl->endcol = shl->rm.endpos[0].col;
} else {
- shl->endcol = MAXCOL;
+ shl->endcol = MAXCOL;
}
// Highlight one character for an empty match.
if (shl->startcol == shl->endcol) {
- if (line[shl->endcol] != NUL) {
- shl->endcol += (*mb_ptr2len)(line + shl->endcol);
- } else {
- ++shl->endcol;
- }
+ if (line[shl->endcol] != NUL) {
+ shl->endcol += (*mb_ptr2len)(line + shl->endcol);
+ } else {
+ ++shl->endcol;
+ }
}
if ((long)shl->startcol < v) { // match at leftcol
shl->attr_cur = shl->attr;
@@ -2667,8 +2705,9 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
}
area_highlighting = true;
}
- if (shl != &search_hl && cur != NULL)
+ if (shl != &search_hl && cur != NULL) {
cur = cur->next;
+ }
}
unsigned off = 0; // Offset relative start of line
@@ -2705,7 +2744,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
if (draw_state == WL_CMDLINE - 1 && n_extra == 0) {
draw_state = WL_CMDLINE;
if (cmdwin_type != 0 && wp == curwin) {
- /* Draw the cmdline character. */
+ // Draw the cmdline character.
n_extra = 1;
c_extra = cmdwin_type;
c_final = NUL;
@@ -2733,18 +2772,17 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
// sign column, this is hit until sign_idx reaches count
if (draw_state == WL_SIGN - 1 && n_extra == 0) {
- draw_state = WL_SIGN;
- /* Show the sign column when there are any signs in this
- * buffer or when using Netbeans. */
- int count = win_signcol_count(wp);
- if (count > 0) {
- get_sign_display_info(
- false, wp, sattrs, row,
- startrow, filler_lines, filler_todo, count,
- &c_extra, &c_final, extra, sizeof(extra),
- &p_extra, &n_extra,
- &char_attr, &draw_state, &sign_idx);
- }
+ draw_state = WL_SIGN;
+ /* Show the sign column when there are any signs in this
+ * buffer or when using Netbeans. */
+ int count = win_signcol_count(wp);
+ if (count > 0) {
+ get_sign_display_info(false, wp, sattrs, row,
+ startrow, filler_lines, filler_todo, count,
+ &c_extra, &c_final, extra, sizeof(extra),
+ &p_extra, &n_extra,
+ &char_attr, &draw_state, &sign_idx);
+ }
}
if (draw_state == WL_NR - 1 && n_extra == 0) {
@@ -2760,12 +2798,11 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
if (*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u'
&& num_signs > 0) {
int count = win_signcol_count(wp);
- get_sign_display_info(
- true, wp, sattrs, row,
- startrow, filler_lines, filler_todo, count,
- &c_extra, &c_final, extra, sizeof(extra),
- &p_extra, &n_extra,
- &char_attr, &draw_state, &sign_idx);
+ get_sign_display_info(true, wp, sattrs, row,
+ startrow, filler_lines, filler_todo, count,
+ &c_extra, &c_final, extra, sizeof(extra),
+ &p_extra, &n_extra,
+ &char_attr, &draw_state, &sign_idx);
} else {
if (row == startrow + filler_lines) {
// Draw the line number (empty space after wrapping). */
@@ -2812,6 +2849,15 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
n_extra = number_width(wp) + 1;
char_attr = win_hl_attr(wp, HLF_N);
+ if (wp->w_p_rnu && lnum < wp->w_cursor.lnum) {
+ // Use LineNrAbove
+ char_attr = win_hl_attr(wp, HLF_LNA);
+ }
+ if (wp->w_p_rnu && lnum > wp->w_cursor.lnum) {
+ // Use LineNrBelow
+ char_attr = win_hl_attr(wp, HLF_LNB);
+ }
+
sign_attrs_T *num_sattr = sign_get_attr(SIGN_NUMHL, sattrs, 0, 1);
if (num_sattr != NULL) {
// :sign defined with "numhl" highlight.
@@ -2899,7 +2945,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
char_attr = win_hl_attr(wp, HLF_DED);
}
if (*p_sbr != NUL && need_showbreak) {
- /* Draw 'showbreak' at the start of each broken line. */
+ // Draw 'showbreak' at the start of each broken line.
p_extra = p_sbr;
c_extra = NUL;
c_final = NUL;
@@ -2911,8 +2957,9 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
vcol_sbr = vcol + MB_CHARLEN(p_sbr);
/* Correct end of highlighted area for 'showbreak',
* required when 'linebreak' is also set. */
- if (tocol == vcol)
+ if (tocol == vcol) {
tocol += n_extra;
+ }
// Combine 'showbreak' with 'cursorline', prioritizing 'showbreak'.
if (cul_attr) {
char_attr = hl_combine_attr(cul_attr, char_attr);
@@ -2930,7 +2977,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
}
if (saved_n_extra) {
- /* Continue item from end of wrapped line. */
+ // Continue item from end of wrapped line.
n_extra = saved_n_extra;
c_extra = saved_c_extra;
c_final = saved_c_final;
@@ -2984,20 +3031,20 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
&& vcol == 0
&& n_extra == 0
&& row == startrow) {
- char_attr = win_hl_attr(wp, HLF_FL);
+ char_attr = win_hl_attr(wp, HLF_FL);
- linenr_T lnume = lnum + foldinfo.fi_lines - 1;
- memset(buf_fold, ' ', FOLD_TEXT_LEN);
- p_extra = get_foldtext(wp, lnum, lnume, foldinfo, buf_fold);
- n_extra = STRLEN(p_extra);
+ linenr_T lnume = lnum + foldinfo.fi_lines - 1;
+ memset(buf_fold, ' ', FOLD_TEXT_LEN);
+ p_extra = get_foldtext(wp, lnum, lnume, foldinfo, buf_fold);
+ n_extra = STRLEN(p_extra);
- if (p_extra != buf_fold) {
- xfree(p_extra_free);
- p_extra_free = p_extra;
- }
- c_extra = NUL;
- c_final = NUL;
- p_extra[n_extra] = NUL;
+ if (p_extra != buf_fold) {
+ xfree(p_extra_free);
+ p_extra_free = p_extra;
+ }
+ c_extra = NUL;
+ c_final = NUL;
+ p_extra[n_extra] = NUL;
}
if (draw_state == WL_LINE
@@ -3038,7 +3085,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
&& (colnr_T)vcol == wp->w_virtcol))) {
area_attr = 0; // stop highlighting
area_active = false;
- }
+ }
if (!n_extra) {
/*
@@ -3063,10 +3110,10 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
if (cur != NULL) {
cur->pos.cur = 0;
}
- bool pos_inprogress = true; // mark that a position match search is
- // in progress
+ bool pos_inprogress = true; // mark that a position match search is
+ // in progress
while (shl->rm.regprog != NULL
- || (cur != NULL && pos_inprogress)) {
+ || (cur != NULL && pos_inprogress)) {
if (shl->startcol != MAXCOL
&& v >= (long)shl->startcol
&& v < (long)shl->endcol) {
@@ -3100,10 +3147,11 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
if (shl->lnum == lnum) {
shl->startcol = shl->rm.startpos[0].col;
- if (shl->rm.endpos[0].lnum == 0)
+ if (shl->rm.endpos[0].lnum == 0) {
shl->endcol = shl->rm.endpos[0].col;
- else
+ } else {
shl->endcol = MAXCOL;
+ }
if (shl->startcol == shl->endcol) {
// highlight empty match, try again after it
@@ -3117,8 +3165,9 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
}
break;
}
- if (shl != &search_hl && cur != NULL)
+ if (shl != &search_hl && cur != NULL) {
cur = cur->next;
+ }
}
/* Use attributes from match with highest priority among
@@ -3139,8 +3188,9 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
search_attr = shl->attr_cur;
search_attr_from_match = shl != &search_hl;
}
- if (shl != &search_hl && cur != NULL)
+ if (shl != &search_hl && cur != NULL) {
cur = cur->next;
+ }
}
// Only highlight one character after the last column.
if (*ptr == NUL
@@ -3403,8 +3453,9 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
if (did_emsg) {
wp->w_s->b_syn_error = TRUE;
has_syntax = FALSE;
- } else
+ } else {
did_emsg = save_did_emsg;
+ }
// Need to get the line again, a multi-line regexp may
// have made it invalid.
@@ -3484,9 +3535,10 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
checked_col = (int)((p - nextline) + len - nextline_idx);
}
- /* Turn index into actual attributes. */
- if (spell_hlf != HLF_COUNT)
+ // Turn index into actual attributes.
+ if (spell_hlf != HLF_COUNT) {
spell_attr = highlight_attr[spell_hlf];
+ }
if (cap_col > 0) {
if (p != prev_ptr
@@ -3496,17 +3548,19 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
capcol_lnum = lnum + 1;
cap_col = (int)((p - nextline) + cap_col
- nextline_idx);
- } else
- /* Compute the actual column. */
+ } else {
+ // Compute the actual column.
cap_col += (int)(prev_ptr - line);
+ }
}
}
}
if (spell_attr != 0) {
- if (!attr_pri)
+ if (!attr_pri) {
char_attr = hl_combine_attr(char_attr, spell_attr);
- else
+ } else {
char_attr = hl_combine_attr(spell_attr, char_attr);
+ }
}
if (wp->w_buffer->terminal) {
@@ -3541,9 +3595,10 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
c_extra = mb_off > 0 ? MB_FILLER_CHAR : ' ';
c_final = NUL;
if (ascii_iswhite(c)) {
- if (c == TAB)
- /* See "Tab alignment" below. */
+ if (c == TAB) {
+ // See "Tab alignment" below.
FIX_FOR_BOGUSCOLS;
+ }
if (!wp->w_p_list) {
c = ' ';
}
@@ -3690,7 +3745,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
? wp->w_p_lcs_chars.tab3
: wp->w_p_lcs_chars.tab1;
if (wp->w_p_lbr) {
- c_extra = NUL; /* using p_extra from above */
+ c_extra = NUL; // using p_extra from above
} else {
c_extra = wp->w_p_lcs_chars.tab2;
}
@@ -3756,10 +3811,11 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
} else if (c != NUL) {
p_extra = transchar_buf(wp->w_buffer, c);
if (n_extra == 0) {
- n_extra = byte2cells(c) - 1;
+ n_extra = byte2cells(c) - 1;
+ }
+ if ((dy_flags & DY_UHEX) && wp->w_p_rl) {
+ rl_mirror(p_extra); // reverse "<12>"
}
- if ((dy_flags & DY_UHEX) && wp->w_p_rl)
- rl_mirror(p_extra); /* reverse "<12>" */
c_extra = NUL;
c_final = NUL;
if (wp->w_p_lbr) {
@@ -3817,8 +3873,9 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
prev_syntax_id = syntax_seqnr;
- if (n_extra > 0)
+ if (n_extra > 0) {
vcol_off += n_extra;
+ }
vcol += n_extra;
if (wp->w_p_wrap && n_extra > 0) {
if (wp->w_p_rl) {
@@ -3944,8 +4001,9 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
int n = 0;
if (wp->w_p_rl) {
- if (col < 0)
+ if (col < 0) {
n = 1;
+ }
} else {
if (col >= grid->Columns) {
n = -1;
@@ -4006,16 +4064,18 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
v = wp->w_leftcol;
}
- /* check if line ends before left margin */
- if (vcol < v + col - win_col_off(wp))
+ // check if line ends before left margin
+ if (vcol < v + col - win_col_off(wp)) {
vcol = v + col - win_col_off(wp);
+ }
// Get rid of the boguscols now, we want to draw until the right
// edge for 'cursorcolumn'.
col -= boguscols;
// boguscols = 0; // Disabled because value never read after this
- if (draw_color_col)
+ if (draw_color_col) {
draw_color_col = advance_color_col(VCOL_HLC, &color_cols);
+ }
bool has_virttext = false;
// Make sure alignment is the same regardless
@@ -4226,7 +4286,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
tocol++;
}
if (wp->w_p_rl) {
- /* now it's time to backup one cell */
+ // now it's time to backup one cell
--off;
--col;
}
@@ -4241,8 +4301,9 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
} else if (wp->w_p_cole > 0 && is_concealing) {
--n_skip;
++vcol_off;
- if (n_extra > 0)
+ if (n_extra > 0) {
vcol_off += n_extra;
+ }
if (wp->w_p_wrap) {
/*
* Special voodoo required if 'wrap' is on.
@@ -4296,27 +4357,30 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
n_attr = 0;
}
}
-
- } else
+ } else {
--n_skip;
+ }
/* Only advance the "vcol" when after the 'number' or 'relativenumber'
* column. */
if (draw_state > WL_NR
- && filler_todo <= 0
- )
+ && filler_todo <= 0) {
++vcol;
+ }
- if (vcol_save_attr >= 0)
+ if (vcol_save_attr >= 0) {
char_attr = vcol_save_attr;
+ }
- /* restore attributes after "predeces" in 'listchars' */
- if (draw_state > WL_NR && n_attr3 > 0 && --n_attr3 == 0)
+ // restore attributes after "predeces" in 'listchars'
+ if (draw_state > WL_NR && n_attr3 > 0 && --n_attr3 == 0) {
char_attr = saved_attr3;
+ }
- /* restore attributes after last 'listchars' or 'number' char */
- if (n_attr > 0 && draw_state == WL_LINE && --n_attr == 0)
+ // restore attributes after last 'listchars' or 'number' char
+ if (n_attr > 0 && draw_state == WL_LINE && --n_attr == 0) {
char_attr = saved_attr2;
+ }
/*
* At end of screen line and there is more to come: Display the line
@@ -4328,15 +4392,15 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
|| filler_todo > 0
|| (wp->w_p_list && wp->w_p_lcs_chars.eol != NUL
&& p_extra != at_end_str)
- || (n_extra != 0 && (c_extra != NUL || *p_extra != NUL)))
- ) {
+ || (n_extra != 0 &&
+ (c_extra != NUL || *p_extra != NUL)))) {
bool wrap = wp->w_p_wrap // Wrapping enabled.
- && filler_todo <= 0 // Not drawing diff filler lines.
- && lcs_eol_one != -1 // Haven't printed the lcs_eol character.
- && row != endrow - 1 // Not the last line being displayed.
- && (grid->Columns == Columns // Window spans the width of the screen,
- || ui_has(kUIMultigrid)) // or has dedicated grid.
- && !wp->w_p_rl; // Not right-to-left.
+ && filler_todo <= 0 // Not drawing diff filler lines.
+ && lcs_eol_one != -1 // Haven't printed the lcs_eol character.
+ && row != endrow - 1 // Not the last line being displayed.
+ && (grid->Columns == Columns // Window spans the width of the screen,
+ || ui_has(kUIMultigrid)) // or has dedicated grid.
+ && !wp->w_p_rl; // Not right-to-left.
int draw_col = col - boguscols;
draw_virt_text(buf, win_col_offset, &draw_col, grid->Columns);
@@ -4361,8 +4425,9 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
* '$' and highlighting until last column, break here. */
if ((!wp->w_p_wrap
&& filler_todo <= 0
- ) || lcs_eol_one == -1)
+ ) || lcs_eol_one == -1) {
break;
+ }
// When the window is too narrow draw all "@" lines.
if (draw_state != WL_LINE && filler_todo <= 0) {
@@ -4370,7 +4435,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
row = endrow;
}
- /* When line got too long for screen break here. */
+ // When line got too long for screen break here.
if (row == endrow) {
++row;
break;
@@ -4383,7 +4448,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
off += col;
}
- /* reset the drawing state for the start of a wrapped line */
+ // reset the drawing state for the start of a wrapped line
draw_state = WL_START;
saved_n_extra = n_extra;
saved_p_extra = p_extra;
@@ -4398,14 +4463,13 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
filler_todo--;
// When the filler lines are actually below the last line of the
// file, don't draw the line itself, break here.
- if (filler_todo == 0 && wp->w_botfill) {
+ if (filler_todo == 0 && (wp->w_botfill || end_fill)) {
break;
}
}
+ } // for every character in the line
- } /* for every character in the line */
-
- /* After an empty line check first word for capital. */
+ // After an empty line check first word for capital.
if (*skipwhite(line) == NUL) {
capcol_lnum = lnum + 1;
cap_col = 0;
@@ -4511,25 +4575,11 @@ void screen_adjust_grid(ScreenGrid **grid, int *row_off, int *col_off)
// @param count max number of signs
// @param[out] n_extrap number of characters from pp_extra to display
// @param[in, out] sign_idxp Index of the displayed sign
-static void get_sign_display_info(
- bool nrcol,
- win_T *wp,
- sign_attrs_T sattrs[],
- int row,
- int startrow,
- int filler_lines,
- int filler_todo,
- int count,
- int *c_extrap,
- int *c_finalp,
- char_u *extra,
- size_t extra_size,
- char_u **pp_extra,
- int *n_extrap,
- int *char_attrp,
- int *draw_statep,
- int *sign_idxp
-)
+static void get_sign_display_info(bool nrcol, win_T *wp, sign_attrs_T sattrs[], int row,
+ int startrow, int filler_lines, int filler_todo, int count,
+ int *c_extrap, int *c_finalp, char_u *extra, size_t extra_size,
+ char_u **pp_extra, int *n_extrap, int *char_attrp,
+ int *draw_statep, int *sign_idxp)
{
// Draw cells with the sign value or blank.
*c_extrap = ' ';
@@ -4567,7 +4617,7 @@ static void get_sign_display_info(
assert((size_t)win_signcol_width(wp) >= mb_string2cells(*pp_extra));
// symbol(s) bytes + (filling spaces) (one byte each)
*n_extrap = symbol_blen +
- (win_signcol_width(wp) - mb_string2cells(*pp_extra));
+ (win_signcol_width(wp) - mb_string2cells(*pp_extra));
assert(extra_size > (size_t)symbol_blen);
memset(extra, ' ', extra_size);
@@ -4597,8 +4647,7 @@ static void get_sign_display_info(
* - the character is multi-byte and the next byte is different
* - the character is two cells wide and the second cell differs.
*/
-static int grid_char_needs_redraw(ScreenGrid *grid, int off_from, int off_to,
- int cols)
+static int grid_char_needs_redraw(ScreenGrid *grid, int off_from, int off_to, int cols)
{
return (cols > 0
&& ((schar_cmp(linebuf_char[off_from], grid->chars[off_to])
@@ -4620,9 +4669,8 @@ static int grid_char_needs_redraw(ScreenGrid *grid, int off_from, int off_to,
/// When FALSE and "clear_width" > 0, clear columns "endcol" to "clear_width"
/// If "wrap" is true, then hint to the UI that "row" contains a line
/// which has wrapped into the next row.
-static void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol,
- int clear_width, int rlflag, win_T *wp,
- int bg_attr, bool wrap)
+static void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int clear_width,
+ int rlflag, win_T *wp, int bg_attr, bool wrap)
{
unsigned off_from;
unsigned off_to;
@@ -4659,12 +4707,11 @@ static void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol,
max_off_to = grid->line_offset[row] + grid->Columns;
if (rlflag) {
- /* Clear rest first, because it's left of the text. */
+ // Clear rest first, because it's left of the text.
if (clear_width > 0) {
while (col <= endcol && grid->chars[off_to][0] == ' '
&& grid->chars[off_to][1] == NUL
- && grid->attrs[off_to] == bg_attr
- ) {
+ && grid->attrs[off_to] == bg_attr) {
++off_to;
++col;
}
@@ -4805,7 +4852,6 @@ void rl_mirror(char_u *str)
*/
void status_redraw_all(void)
{
-
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
if (wp->w_status_height) {
wp->w_redr_status = true;
@@ -4841,8 +4887,9 @@ void redraw_statuslines(void)
win_redr_status(wp);
}
}
- if (redraw_tabline)
+ if (redraw_tabline) {
draw_tabline();
+ }
}
/*
@@ -4894,9 +4941,10 @@ static int status_match_len(expand_T *xp, char_u *s)
int emenu = (xp->xp_context == EXPAND_MENUS
|| xp->xp_context == EXPAND_MENUNAMES);
- /* Check for menu separators - replace with '|'. */
- if (emenu && menu_is_separator(s))
+ // Check for menu separators - replace with '|'.
+ if (emenu && menu_is_separator(s)) {
return 1;
+ }
while (*s != NUL) {
s += skip_status_match_char(xp, s);
@@ -4916,11 +4964,12 @@ static int skip_status_match_char(expand_T *xp, char_u *s)
if ((rem_backslash(s) && xp->xp_context != EXPAND_HELP)
|| ((xp->xp_context == EXPAND_MENUS
|| xp->xp_context == EXPAND_MENUNAMES)
- && (s[0] == '\t' || (s[0] == '\\' && s[1] != NUL)))
- ) {
+ && (s[0] == '\t' ||
+ (s[0] == '\\' && s[1] != NUL)))) {
#ifndef BACKSLASH_IN_FILENAME
- if (xp->xp_shell && csh_like_shell() && s[1] == '\\' && s[2] == '!')
+ if (xp->xp_shell && csh_like_shell() && s[1] == '\\' && s[2] == '!') {
return 2;
+ }
#endif
return 1;
}
@@ -4934,20 +4983,14 @@ static int skip_status_match_char(expand_T *xp, char_u *s)
*
* If inversion is possible we use it. Else '=' characters are used.
*/
-void
-win_redr_status_matches (
- expand_T *xp,
- int num_matches,
- char_u **matches, /* list of matches */
- int match,
- int showtail
-)
+void win_redr_status_matches(expand_T *xp, int num_matches, char_u **matches, // list of matches
+ int match, int showtail)
{
#define L_MATCH(m) (showtail ? sm_gettail(matches[m], false) : matches[m])
int row;
char_u *buf;
int len;
- int clen; /* length in screen cells */
+ int clen; // length in screen cells
int fillchar;
int attr;
int i;
@@ -4961,33 +5004,36 @@ win_redr_status_matches (
int emenu;
int l;
- if (matches == NULL) /* interrupted completion? */
+ if (matches == NULL) { // interrupted completion?
return;
+ }
buf = xmalloc(Columns * MB_MAXBYTES + 1);
- if (match == -1) { /* don't show match but original text */
+ if (match == -1) { // don't show match but original text
match = 0;
highlight = false;
}
- /* count 1 for the ending ">" */
+ // count 1 for the ending ">"
clen = status_match_len(xp, L_MATCH(match)) + 3;
- if (match == 0)
+ if (match == 0) {
first_match = 0;
- else if (match < first_match) {
- /* jumping left, as far as we can go */
+ } else if (match < first_match) {
+ // jumping left, as far as we can go
first_match = match;
add_left = true;
} else {
- /* check if match fits on the screen */
- for (i = first_match; i < match; ++i)
+ // check if match fits on the screen
+ for (i = first_match; i < match; ++i) {
clen += status_match_len(xp, L_MATCH(i)) + 2;
- if (first_match > 0)
+ }
+ if (first_match > 0) {
clen += 2;
+ }
// jumping right, put match at the left
if ((long)clen > Columns) {
first_match = match;
- /* if showing the last match, we can add some on the left */
+ // if showing the last match, we can add some on the left
clen = 2;
for (i = match; i < num_matches; ++i) {
clen += status_match_len(xp, L_MATCH(i)) + 2;
@@ -5000,7 +5046,7 @@ win_redr_status_matches (
}
}
}
- if (add_left)
+ if (add_left) {
while (first_match > 0) {
clen += status_match_len(xp, L_MATCH(first_match - 1)) + 2;
if ((long)clen >= Columns) {
@@ -5008,6 +5054,7 @@ win_redr_status_matches (
}
first_match--;
}
+ }
fillchar = fillchar_status(&attr, curwin);
@@ -5028,7 +5075,7 @@ win_redr_status_matches (
}
s = L_MATCH(i);
- /* Check for menu separators - replace with '|' */
+ // Check for menu separators - replace with '|'
emenu = (xp->xp_context == EXPAND_MENUS
|| xp->xp_context == EXPAND_MENUNAMES);
if (emenu && menu_is_separator(s)) {
@@ -5036,7 +5083,7 @@ win_redr_status_matches (
l = (int)STRLEN(buf + len);
len += l;
clen += l;
- } else
+ } else {
for (; *s != NUL; ++s) {
s += skip_status_match_char(xp, s);
clen += ptr2cells(s);
@@ -5049,14 +5096,17 @@ win_redr_status_matches (
len += (int)STRLEN(buf + len);
}
}
- if (i == match)
+ }
+ if (i == match) {
selend = buf + len;
+ }
*(buf + len++) = ' ';
*(buf + len++) = ' ';
clen += 2;
- if (++i == num_matches)
+ if (++i == num_matches) {
break;
+ }
}
if (i != num_matches) {
@@ -5145,7 +5195,7 @@ static void win_redr_status(win_T *wp)
// popup menu is visible and may be drawn over it
wp->w_redr_status = true;
} else if (*p_stl != NUL || *wp->w_p_stl != NUL) {
- /* redraw custom status line */
+ // redraw custom status line
redraw_custom_statusline(wp);
} else {
fillchar = fillchar_status(&attr, wp);
@@ -5210,9 +5260,10 @@ static void win_redr_status(win_T *wp)
this_ru_col + wp->w_wincol, fillchar, fillchar, attr);
if (get_keymap_str(wp, (char_u *)"<%s>", NameBuff, MAXPATHL)
- && this_ru_col - len > (int)(STRLEN(NameBuff) + 1))
+ && this_ru_col - len > (int)(STRLEN(NameBuff) + 1)) {
grid_puts(&default_grid, NameBuff, row,
(int)(this_ru_col - STRLEN(NameBuff) - 1), attr);
+ }
win_redr_ruler(wp, true);
}
@@ -5242,8 +5293,9 @@ static void redraw_custom_statusline(win_T *wp)
/* When called recursively return. This can happen when the statusline
* contains an expression that triggers a redraw. */
- if (entered)
+ if (entered) {
return;
+ }
entered = true;
did_emsg = false;
@@ -5271,8 +5323,9 @@ bool stl_connected(win_T *wp)
fr = wp->w_frame;
while (fr->fr_parent != NULL) {
if (fr->fr_parent->fr_layout == FR_COL) {
- if (fr->fr_next != NULL)
+ if (fr->fr_next != NULL) {
break;
+ }
} else {
if (fr->fr_next != NULL) {
return true;
@@ -5304,7 +5357,7 @@ bool get_keymap_str(win_T *wp, char_u *fmt, char_u *buf, int len)
curbuf = wp->w_buffer;
curwin = wp;
- STRCPY(buf, "b:keymap_name"); /* must be writable */
+ STRCPY(buf, "b:keymap_name"); // must be writable
++emsg_skip;
s = p = eval_to_string(buf, NULL, FALSE);
--emsg_skip;
@@ -5329,11 +5382,7 @@ bool get_keymap_str(win_T *wp, char_u *fmt, char_u *buf, int len)
* Redraw the status line or ruler of window "wp".
* When "wp" is NULL redraw the tab pages line from 'tabline'.
*/
-static void
-win_redr_custom (
- win_T *wp,
- bool draw_ruler
-)
+static void win_redr_custom(win_T *wp, bool draw_ruler)
{
static bool entered = false;
int attr;
@@ -5359,13 +5408,14 @@ win_redr_custom (
/* There is a tiny chance that this gets called recursively: When
* redrawing a status line triggers redrawing the ruler or tabline.
* Avoid trouble by not allowing recursion. */
- if (entered)
+ if (entered) {
return;
+ }
entered = true;
- /* setup environment for the task at hand */
+ // setup environment for the task at hand
if (wp == NULL) {
- /* Use 'tabline'. Always at the first line of the screen. */
+ // Use 'tabline'. Always at the first line of the screen.
stl = p_tal;
row = 0;
fillchar = ' ';
@@ -5379,15 +5429,19 @@ win_redr_custom (
if (draw_ruler) {
stl = p_ruf;
- /* advance past any leading group spec - implicit in ru_col */
+ // advance past any leading group spec - implicit in ru_col
if (*stl == '%') {
- if (*++stl == '-')
+ if (*++stl == '-') {
stl++;
- if (atoi((char *)stl))
- while (ascii_isdigit(*stl))
+ }
+ if (atoi((char *)stl)) {
+ while (ascii_isdigit(*stl)) {
stl++;
- if (*stl++ != '(')
+ }
+ }
+ if (*stl++ != '(') {
stl = p_ruf;
+ }
}
col = ru_col - (Columns - wp->w_width);
if (col < (wp->w_width + 1) / 2) {
@@ -5404,19 +5458,21 @@ win_redr_custom (
use_sandbox = was_set_insecurely(wp, (char_u *)"rulerformat", 0);
} else {
- if (*wp->w_p_stl != NUL)
+ if (*wp->w_p_stl != NUL) {
stl = wp->w_p_stl;
- else
+ } else {
stl = p_stl;
- use_sandbox = was_set_insecurely(
- wp, (char_u *)"statusline", *wp->w_p_stl == NUL ? 0 : OPT_LOCAL);
+ }
+ use_sandbox = was_set_insecurely(wp, (char_u *)"statusline",
+ *wp->w_p_stl == NUL ? 0 : OPT_LOCAL);
}
col += wp->w_wincol;
}
- if (maxwidth <= 0)
+ if (maxwidth <= 0) {
goto theend;
+ }
/* Temporarily reset 'cursorbind', we don't want a side effect from moving
* the cursor away and back. */
@@ -5439,7 +5495,7 @@ win_redr_custom (
len = (size_t)len < sizeof(buf) ? len : (int)sizeof(buf) - 1;
xfree(p);
- /* fill up with "fillchar" */
+ // fill up with "fillchar"
while (width < maxwidth && len < (int)sizeof(buf) - 1) {
len += utf_char2bytes(fillchar, buf + len);
width++;
@@ -5459,14 +5515,15 @@ win_redr_custom (
col += vim_strnsize(p, textlen);
p = hltab[n].start;
- if (hltab[n].userhl == 0)
+ if (hltab[n].userhl == 0) {
curattr = attr;
- else if (hltab[n].userhl < 0)
+ } else if (hltab[n].userhl < 0) {
curattr = syn_id2attr(-hltab[n].userhl);
- else if (wp != NULL && wp != curwin && wp->w_status_height != 0)
+ } else if (wp != NULL && wp != curwin && wp->w_status_height != 0) {
curattr = highlight_stlnc[hltab[n].userhl - 1];
- else
+ } else {
curattr = highlight_user[hltab[n].userhl - 1];
+ }
}
// Make sure to use an empty string instead of p, if p is beyond buf + len.
grid_puts(grid, p >= buf + len ? (char_u *)"" : p, row, col,
@@ -5483,11 +5540,11 @@ win_redr_custom (
.type = kStlClickDisabled,
};
for (n = 0; tabtab[n].start != NULL; n++) {
- len += vim_strnsize(p, (int)(tabtab[n].start - (char *) p));
+ len += vim_strnsize(p, (int)(tabtab[n].start - (char *)p));
while (col < len) {
tab_page_click_defs[col++] = cur_click_def;
}
- p = (char_u *) tabtab[n].start;
+ p = (char_u *)tabtab[n].start;
cur_click_def = tabtab[n].def;
}
while (col < Columns) {
@@ -5651,8 +5708,7 @@ void grid_putchar(ScreenGrid *grid, int c, int row, int col, int attr)
/// get a single character directly from grid.chars into "bytes[]".
/// Also return its attribute in *attrp;
-void grid_getbytes(ScreenGrid *grid, int row, int col, char_u *bytes,
- int *attrp)
+void grid_getbytes(ScreenGrid *grid, int row, int col, char_u *bytes, int *attrp)
{
unsigned off;
@@ -5699,19 +5755,18 @@ void grid_put_schar(ScreenGrid *grid, int row, int col, char_u *schar, int attr)
assert(put_dirty_row == row);
unsigned int off = grid->line_offset[row] + col;
if (grid->attrs[off] != attr || schar_cmp(grid->chars[off], schar)) {
- schar_copy(grid->chars[off], schar);
- grid->attrs[off] = attr;
+ schar_copy(grid->chars[off], schar);
+ grid->attrs[off] = attr;
- put_dirty_first = MIN(put_dirty_first, col);
- // TODO(bfredl): Y U NO DOUBLEWIDTH?
- put_dirty_last = MAX(put_dirty_last, col+1);
+ put_dirty_first = MIN(put_dirty_first, col);
+ // TODO(bfredl): Y U NO DOUBLEWIDTH?
+ put_dirty_last = MAX(put_dirty_last, col+1);
}
}
/// like grid_puts(), but output "text[len]". When "len" is -1 output up to
/// a NUL.
-void grid_puts_len(ScreenGrid *grid, char_u *text, int textlen, int row,
- int col, int attr)
+void grid_puts_len(ScreenGrid *grid, char_u *text, int textlen, int row, int col, int attr)
{
unsigned off;
char_u *ptr = text;
@@ -5723,7 +5778,7 @@ void grid_puts_len(ScreenGrid *grid, char_u *text, int textlen, int row,
int u8c = 0;
int u8cc[MAX_MCO];
int clear_next_cell = FALSE;
- int prev_c = 0; /* previous Arabic character */
+ int prev_c = 0; // previous Arabic character
int pc, nc, nc1;
int pcc[MAX_MCO];
int need_redraw;
@@ -5816,7 +5871,7 @@ void grid_puts_len(ScreenGrid *grid, char_u *text, int textlen, int row,
if (clear_next_cell) {
clear_next_cell = false;
} else if ((len < 0 ? ptr[mbyte_blen] == NUL
- : ptr + mbyte_blen >= text + len)
+ : ptr + mbyte_blen >= text + len)
&& ((mbyte_cells == 1
&& grid_off2cells(grid, off, max_off) > 1)
|| (mbyte_cells == 2
@@ -5915,10 +5970,11 @@ static void init_search_hl(win_T *wp)
matchitem_T *cur = wp->w_match_head;
while (cur != NULL) {
cur->hl.rm = cur->match;
- if (cur->hlg_id == 0)
+ if (cur->hlg_id == 0) {
cur->hl.attr = 0;
- else
+ } else {
cur->hl.attr = syn_id2attr(cur->hlg_id);
+ }
cur->hl.buf = wp->w_buffer;
cur->hl.lnum = 0;
cur->hl.first_lnum = 0;
@@ -5972,8 +6028,8 @@ static void prepare_search_hl(win_T *wp, linenr_T lnum)
if (cur != NULL) {
cur->pos.cur = 0;
}
- bool pos_inprogress = true; // mark that a position match search is
- // in progress
+ bool pos_inprogress = true; // mark that a position match search is
+ // in progress
int n = 0;
while (shl->first_lnum < lnum && (shl->rm.regprog != NULL
|| (cur != NULL && pos_inprogress))) {
@@ -5991,8 +6047,9 @@ static void prepare_search_hl(win_T *wp, linenr_T lnum)
}
}
}
- if (shl != &search_hl && cur != NULL)
+ if (shl != &search_hl && cur != NULL) {
cur = cur->next;
+ }
}
}
@@ -6004,14 +6061,10 @@ static void prepare_search_hl(win_T *wp, linenr_T lnum)
* shl->lnum is zero.
* Careful: Any pointers for buffer lines will become invalid.
*/
-static void
-next_search_hl (
- win_T *win,
- match_T *shl, /* points to search_hl or a match */
- linenr_T lnum,
- colnr_T mincol, /* minimal column for a match */
- matchitem_T *cur /* to retrieve match positions if any */
-)
+static void next_search_hl(win_T *win, match_T *shl, // points to search_hl or a match
+ linenr_T lnum, colnr_T mincol, // minimal column for a match
+ matchitem_T *cur // to retrieve match positions if any
+ )
FUNC_ATTR_NONNULL_ARG(2)
{
linenr_T l;
@@ -6031,10 +6084,11 @@ next_search_hl (
// 2. If the previous match includes "mincol", use it.
// 3. Continue after the previous match.
l = shl->lnum + shl->rm.endpos[0].lnum - shl->rm.startpos[0].lnum;
- if (lnum > l)
+ if (lnum > l) {
shl->lnum = 0;
- else if (lnum < l || shl->rm.endpos[0].col > mincol)
+ } else if (lnum < l || shl->rm.endpos[0].col > mincol) {
return;
+ }
}
/*
@@ -6045,7 +6099,7 @@ next_search_hl (
for (;; ) {
// Stop searching after passing the time limit.
if (profile_passed_limit(shl->tm)) {
- shl->lnum = 0; /* no match found in time */
+ shl->lnum = 0; // no match found in time
break;
}
// Three situations:
@@ -6097,7 +6151,7 @@ next_search_hl (
}
shl->rm.regprog = NULL;
shl->lnum = 0;
- got_int = FALSE; // avoid the "Type :quit to exit Vim" message
+ got_int = FALSE; // avoid the "Type :quit to exit Vim" message
break;
}
} else if (cur != NULL) {
@@ -6122,13 +6176,10 @@ next_search_hl (
/// If there is a match fill "shl" and return one.
/// Return zero otherwise.
-static int
-next_search_hl_pos(
- match_T *shl, // points to a match
- linenr_T lnum,
- posmatch_T *posmatch, // match positions
- colnr_T mincol // minimal column for a match
-)
+static int next_search_hl_pos(match_T *shl, // points to a match
+ linenr_T lnum, posmatch_T *posmatch, // match positions
+ colnr_T mincol // minimal column for a match
+ )
FUNC_ATTR_NONNULL_ALL
{
int i;
@@ -6182,8 +6233,8 @@ next_search_hl_pos(
/// Fill the grid from 'start_row' to 'end_row', from 'start_col' to 'end_col'
/// with character 'c1' in first column followed by 'c2' in the other columns.
/// Use attributes 'attr'.
-void grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col,
- int end_col, int c1, int c2, int attr)
+void grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col, int end_col, int c1,
+ int c2, int attr)
{
schar_T sc;
@@ -6421,9 +6472,9 @@ retry:
msg_grid_invalid = true;
}
- win_new_shellsize(); /* fit the windows in the new sized shell */
+ win_new_shellsize(); // fit the windows in the new sized shell
- comp_col(); /* recompute columns for shown command and ruler */
+ comp_col(); // recompute columns for shown command and ruler
// We're changing the size of the screen.
// - Allocate new arrays for default_grid
@@ -6436,8 +6487,8 @@ retry:
// size is wrong.
grid_alloc(&default_grid, Rows, Columns, true, true);
- StlClickDefinition *new_tab_page_click_defs = xcalloc(
- (size_t)Columns, sizeof(*new_tab_page_click_defs));
+ StlClickDefinition *new_tab_page_click_defs =
+ xcalloc((size_t)Columns, sizeof(*new_tab_page_click_defs));
clear_tab_page_click_defs(tab_page_click_defs, tab_page_click_defs_size);
xfree(tab_page_click_defs);
@@ -6545,8 +6596,7 @@ void screen_free_all_mem(void)
///
/// @param[out] tpcd Table to clear.
/// @param[in] tpcd_size Size of the table.
-void clear_tab_page_click_defs(StlClickDefinition *const tpcd,
- const long tpcd_size)
+void clear_tab_page_click_defs(StlClickDefinition *const tpcd, const long tpcd_size)
{
if (tpcd != NULL) {
for (long i = 0; i < tpcd_size; i++) {
@@ -6554,7 +6604,7 @@ void clear_tab_page_click_defs(StlClickDefinition *const tpcd,
xfree(tpcd[i].func);
}
}
- memset(tpcd, 0, (size_t) tpcd_size * sizeof(tpcd[0]));
+ memset(tpcd, 0, (size_t)tpcd_size * sizeof(tpcd[0]));
}
}
@@ -6659,8 +6709,8 @@ void setcursor(void)
// With 'rightleft' set and the cursor on a double-wide character,
// position it on the leftmost column.
col = curwin->w_width_inner - curwin->w_wcol
- - ((utf_ptr2cells(get_cursor_pos_ptr()) == 2
- && vim_isprintc(gchar_cursor())) ? 2 : 1);
+ - ((utf_ptr2cells(get_cursor_pos_ptr()) == 2
+ && vim_isprintc(gchar_cursor())) ? 2 : 1);
}
screen_adjust_grid(&grid, &row, &col);
@@ -6709,8 +6759,7 @@ void win_scroll_lines(win_T *wp, int row, int line_count)
/// 'col' is the column from with we start inserting.
//
/// 'row', 'col' and 'end' are relative to the start of the region.
-void grid_ins_lines(ScreenGrid *grid, int row, int line_count, int end, int col,
- int width)
+void grid_ins_lines(ScreenGrid *grid, int row, int line_count, int end, int col, int width)
{
int i;
int j;
@@ -6761,8 +6810,7 @@ void grid_ins_lines(ScreenGrid *grid, int row, int line_count, int end, int col,
/// 'end' is the line after the scrolled part. Normally it is Rows.
/// When scrolling region used 'off' is the offset from the top for the region.
/// 'row' and 'end' are relative to the start of the region.
-void grid_del_lines(ScreenGrid *grid, int row, int line_count, int end, int col,
- int width)
+void grid_del_lines(ScreenGrid *grid, int row, int line_count, int end, int col, int width)
{
int j;
int i;
@@ -6850,16 +6898,16 @@ int showmode(void)
bool nwr_save = need_wait_return;
- /* wait a bit before overwriting an important message */
+ // wait a bit before overwriting an important message
check_for_delay(FALSE);
- /* if the cmdline is more than one line high, erase top lines */
+ // if the cmdline is more than one line high, erase top lines
need_clear = clear_cmdline;
if (clear_cmdline && cmdline_row < Rows - 1) {
msg_clr_cmdline(); // will reset clear_cmdline
}
- /* Position on the last line in the window, column 0 */
+ // Position on the last line in the window, column 0
msg_pos_mode();
attr = HL_ATTR(HLF_CM); // Highlight mode
@@ -6885,8 +6933,9 @@ int showmode(void)
length -= vim_strsize(edit_submode_extra);
}
if (length > 0) {
- if (edit_submode_pre != NULL)
+ if (edit_submode_pre != NULL) {
length -= vim_strsize(edit_submode_pre);
+ }
if (length - vim_strsize(edit_submode) > 0) {
if (edit_submode_pre != NULL) {
msg_puts_attr((const char *)edit_submode_pre, attr);
@@ -6906,13 +6955,14 @@ int showmode(void)
} else {
if (State & TERM_FOCUS) {
MSG_PUTS_ATTR(_(" TERMINAL"), attr);
- } else if (State & VREPLACE_FLAG)
+ } else if (State & VREPLACE_FLAG) {
MSG_PUTS_ATTR(_(" VREPLACE"), attr);
- else if (State & REPLACE_FLAG)
+ } else if (State & REPLACE_FLAG) {
MSG_PUTS_ATTR(_(" REPLACE"), attr);
- else if (State & INSERT) {
- if (p_ri)
+ } else if (State & INSERT) {
+ if (p_ri) {
MSG_PUTS_ATTR(_(" REVERSE"), attr);
+ }
MSG_PUTS_ATTR(_(" INSERT"), attr);
} else if (restart_edit == 'I' || restart_edit == 'i'
|| restart_edit == 'a') {
@@ -6933,8 +6983,9 @@ int showmode(void)
MSG_PUTS_ATTR(NameBuff, attr);
}
}
- if ((State & INSERT) && p_paste)
+ if ((State & INSERT) && p_paste) {
MSG_PUTS_ATTR(_(" (paste)"), attr);
+ }
if (VIsual_active) {
char *p;
@@ -6983,9 +7034,10 @@ int showmode(void)
// NB: also handles clearing the showmode if it was empty or disabled
msg_ext_flush_showmode();
- /* In Visual mode the size of the selected area must be redrawn. */
- if (VIsual_active)
+ // In Visual mode the size of the selected area must be redrawn.
+ if (VIsual_active) {
clear_showcmd();
+ }
// If the last window has no status line, the ruler is after the mode
// message and must be redrawn
@@ -7082,15 +7134,16 @@ void draw_tabline(void)
return;
}
- if (tabline_height() < 1)
+ if (tabline_height() < 1) {
return;
+ }
// Init TabPageIdxs[] to zero: Clicking outside of tabs has no effect.
assert(Columns == tab_page_click_defs_size);
clear_tab_page_click_defs(tab_page_click_defs, tab_page_click_defs_size);
- /* Use the 'tabline' option if it's set. */
+ // Use the 'tabline' option if it's set.
if (*p_tal != NUL) {
int saved_did_emsg = did_emsg;
@@ -7176,7 +7229,7 @@ void draw_tabline(void)
room = scol - col + tabwidth - 1;
if (room > 0) {
- /* Get buffer name in NameBuff[] */
+ // Get buffer name in NameBuff[]
get_trans_bufname(cwp->w_buffer);
(void)shorten_dir(NameBuff);
len = vim_strsize(NameBuff);
@@ -7206,13 +7259,14 @@ void draw_tabline(void)
}
}
- if (use_sep_chars)
+ if (use_sep_chars) {
c = '_';
- else
+ } else {
c = ' ';
+ }
grid_fill(&default_grid, 0, 1, col, Columns, c, c, attr_fill);
- /* Put an "X" for closing the current tab if there are several. */
+ // Put an "X" for closing the current tab if there are several.
if (first_tabpage->tp_next != NULL) {
grid_putchar(&default_grid, 'X', 0, Columns - 1, attr_nosel);
tab_page_click_defs[Columns - 1] = (StlClickDefinition) {
@@ -7267,10 +7321,11 @@ void ui_ext_tabline_update(void)
*/
void get_trans_bufname(buf_T *buf)
{
- if (buf_spname(buf) != NULL)
+ if (buf_spname(buf) != NULL) {
STRLCPY(NameBuff, buf_spname(buf), MAXPATHL);
- else
+ } else {
home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE);
+ }
trans_characters(NameBuff, MAXPATHL);
}
@@ -7334,8 +7389,9 @@ int messaging(void)
/// @param always if false, only show ruler if position has changed.
void showruler(bool always)
{
- if (!always && !redrawing())
+ if (!always && !redrawing()) {
return;
+ }
if ((*p_stl != NUL || *curwin->w_p_stl != NUL) && curwin->w_status_height) {
redraw_custom_statusline(curwin);
} else {
@@ -7344,12 +7400,13 @@ void showruler(bool always)
if (need_maketitle
|| (p_icon && (stl_syntax & STL_IN_ICON))
- || (p_title && (stl_syntax & STL_IN_TITLE))
- )
+ || (p_title && (stl_syntax & STL_IN_TITLE))) {
maketitle();
- /* Redraw the tab pages line if needed. */
- if (redraw_tabline)
+ }
+ // Redraw the tab pages line if needed.
+ if (redraw_tabline) {
draw_tabline();
+ }
}
static void win_redr_ruler(win_T *wp, bool always)
@@ -7365,8 +7422,9 @@ static void win_redr_ruler(win_T *wp, bool always)
* Check if cursor.lnum is valid, since win_redr_ruler() may be called
* after deleting lines, before cursor.lnum is corrected.
*/
- if (wp->w_cursor.lnum > wp->w_buffer->b_ml.ml_line_count)
+ if (wp->w_cursor.lnum > wp->w_buffer->b_ml.ml_line_count) {
return;
+ }
// Don't draw the ruler while doing insert-completion, it might overwrite
// the (long) mode message.
@@ -7394,24 +7452,24 @@ static void win_redr_ruler(win_T *wp, bool always)
*/
int empty_line = FALSE;
if (!(State & INSERT)
- && *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, FALSE) == NUL)
+ && *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, FALSE) == NUL) {
empty_line = TRUE;
+ }
/*
* 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) {
-
+ 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;
@@ -7449,12 +7507,12 @@ static void win_redr_ruler(win_T *wp, bool always)
* To avoid portability problems we use strlen() here.
*/
vim_snprintf((char *)buffer, RULER_BUF_LEN, "%" PRId64 ",",
- (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) ? (int64_t)0L
- : (int64_t)wp->w_cursor.lnum);
+ (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);
+ empty_line ? 0 : (int)wp->w_cursor.col + 1,
+ (int)virtcol + 1);
/*
* Add a "50%" if there is room for it.
@@ -7542,8 +7600,9 @@ int number_width(win_T *wp)
lnum = wp->w_buffer->b_ml.ml_line_count;
}
- if (lnum == wp->w_nrwidth_line_count)
+ if (lnum == wp->w_nrwidth_line_count) {
return wp->w_nrwidth_width;
+ }
wp->w_nrwidth_line_count = lnum;
n = 0;
@@ -7622,11 +7681,12 @@ void screen_resize(int width, int height)
return;
}
- if (width < 0 || height < 0) /* just checking... */
+ if (width < 0 || height < 0) { // just checking...
return;
+ }
if (State == HITRETURN || State == SETWSIZE) {
- /* postpone the resizing */
+ // postpone the resizing
State = SETWSIZE;
return;
}
@@ -7635,8 +7695,9 @@ void screen_resize(int width, int height)
* buffer has already been closed and removing a scrollbar causes a resize
* event. Don't resize then, it will happen after entering another buffer.
*/
- if (curwin->w_buffer == NULL)
+ if (curwin->w_buffer == NULL) {
return;
+ }
recursive = true;