diff options
| author | Lewis Russell <lewis6991@gmail.com> | 2022-08-13 15:59:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-13 16:59:15 +0200 |
| commit | c1cbe3fb3d2ec1dbcfdc14ee2d9a5e8049d494ae (patch) | |
| tree | a9af8ce3f502a4ed693aaf0cb2aabbf2c5c8cd98 /src | |
| parent | 3cf629022b6289a980c47cfae921f9aec1948585 (diff) | |
| download | rneovim-c1cbe3fb3d2ec1dbcfdc14ee2d9a5e8049d494ae.tar.gz rneovim-c1cbe3fb3d2ec1dbcfdc14ee2d9a5e8049d494ae.tar.bz2 rneovim-c1cbe3fb3d2ec1dbcfdc14ee2d9a5e8049d494ae.zip | |
refactor(screen.c): resolve all clint errors (#19754)
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Christian Clason <c.clason@uni-graz.at>
Diffstat (limited to 'src')
| -rw-r--r-- | src/nvim/buffer_defs.h | 2 | ||||
| -rw-r--r-- | src/nvim/screen.c | 846 |
2 files changed, 362 insertions, 486 deletions
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index c7a300a5a6..89a8a99296 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -431,7 +431,7 @@ typedef struct { typedef struct { hashtab_T b_keywtab; // syntax keywords hash table hashtab_T b_keywtab_ic; // idem, ignore case - int b_syn_error; // TRUE when error occurred in HL + bool b_syn_error; // true when error occurred in HL bool b_syn_slow; // true when 'redrawtime' reached int b_syn_ic; // ignore case for :syn cmds int b_syn_foldlevel; // how to compute foldlevel on a line diff --git a/src/nvim/screen.c b/src/nvim/screen.c index bbbe985dcd..609c2e3017 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -129,8 +129,8 @@ #include "nvim/vim.h" #include "nvim/window.h" -#define MB_FILLER_CHAR '<' /* character used when a double-width character - * doesn't fit. */ +#define MB_FILLER_CHAR '<' // character used when a double-width character + // doesn't fit. static match_T search_hl; // used for 'hlsearch' highlight matching @@ -185,9 +185,7 @@ void redraw_later(win_T *wp, int type) } } -/* - * Mark all windows to be redrawn later. - */ +/// Mark all windows to be redrawn later. void redraw_all_later(int type) { FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { @@ -207,9 +205,7 @@ void screen_invalidate_highlights(void) } } -/* - * Mark all windows that are editing the current buffer to be updated later. - */ +/// Mark all windows that are editing the current buffer to be updated later. void redraw_curbuf_later(int type) { redraw_buf_later(curbuf, type); @@ -250,14 +246,12 @@ void redraw_buf_range_later(buf_T *buf, linenr_T firstline, linenr_T lastline) } } -/* - * Changed something in the current window, at buffer line "lnum", that - * requires that line and possibly other lines to be redrawn. - * Used when entering/leaving Insert mode with the cursor on a folded line. - * Used to remove the "$" from a change command. - * 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. - */ +/// Changed something in the current window, at buffer line "lnum", that +/// requires that line and possibly other lines to be redrawn. +/// Used when entering/leaving Insert mode with the cursor on a folded line. +/// Used to remove the "$" from a change command. +/// 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) FUNC_ATTR_NONNULL_ALL { @@ -347,8 +341,8 @@ int update_screen(int type) type = NOT_VALID; } - /* Postpone the redrawing when it's not needed and when being called - * recursively. */ + // Postpone the redrawing when it's not needed and when being called + // recursively. if (!redrawing() || updating_screen) { must_redraw = type; if (type > INVERTED_ALL) { @@ -489,17 +483,15 @@ int update_screen(int type) check_for_delay(false); } - /* Force redraw when width of 'number' or 'relativenumber' column - * changes. */ + // 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)) { curwin->w_redr_type = NOT_VALID; } - /* - * Only start redrawing if there is really something to do. - */ + // Only start redrawing if there is really something to do. if (type == INVERTED) { update_curswant(); } @@ -514,8 +506,7 @@ int update_screen(int type) && curwin->w_old_cursor_lnum == curwin->w_cursor.lnum && curwin->w_old_visual_mode == VIsual_mode && (curwin->w_valid & VALID_VIRTCOL) - && curwin->w_old_curswant == curwin->w_curswant) - )) { + && curwin->w_old_curswant == curwin->w_curswant))) { curwin->w_redr_type = type; } @@ -530,10 +521,8 @@ int update_screen(int type) draw_tabline(); } - /* - * Correct stored syntax highlighting info for changes in each displayed - * buffer. Each buffer must only be done once. - */ + // Correct stored syntax highlighting info for changes in each displayed + // buffer. Each buffer must only be done once. FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { update_window_hl(wp, type >= NOT_VALID || hl_changed); @@ -552,10 +541,8 @@ int update_screen(int type) } } - /* - * Go from top to bottom through the windows, redrawing the ones that need - * it. - */ + // Go from top to bottom through the windows, redrawing the ones that need + // it. bool did_one = false; search_hl.rm.regprog = NULL; @@ -594,16 +581,16 @@ int update_screen(int type) pum_redraw(); } - /* Reset b_mod_set flags. Going through all windows is probably faster - * than going through all buffers (there could be many buffers). */ + // Reset b_mod_set flags. Going through all windows is probably faster + // than going through all buffers (there could be many buffers). FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { wp->w_buffer->b_mod_set = false; } updating_screen = 0; - /* Clear or redraw the command line. Done last, because scrolling may - * mess up the command line. */ + // Clear or redraw the command line. Done last, because scrolling may + // mess up the command line. if (clear_cmdline || redraw_cmdline) { showmode(); } @@ -669,33 +656,31 @@ bool win_cursorline_standout(const win_T *wp) return wp->w_p_cul || (wp->w_p_cole > 0 && !conceal_cursor_line(wp)); } -/* - * Update a single window. - * - * This may cause the windows below it also to be redrawn (when clearing the - * screen or scrolling lines). - * - * 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. - * This results in three areas that may need updating: - * 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) - */ +/// Update a single window. +/// +/// This may cause the windows below it also to be redrawn (when clearing the +/// screen or scrolling lines). +/// +/// 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. +/// This results in three areas that may need updating: +/// 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) static void win_update(win_T *wp, DecorProviders *providers) { bool called_decor_providers = false; @@ -703,14 +688,14 @@ win_update_start: ; buf_T *buf = wp->w_buffer; int type; - int top_end = 0; /* Below last row of the top area that needs - updating. 0 when no top area updating. */ - int mid_start = 999; /* first row of the mid area that needs - updating. 999 when no mid area updating. */ - int mid_end = 0; /* Below last row of the mid area that needs - updating. 0 when no mid area updating. */ - int bot_start = 999; /* first row of the bot area that needs - updating. 999 when no bot area updating */ + int top_end = 0; // Below last row of the top area that needs + // updating. 0 when no top area updating. + int mid_start = 999; // first row of the mid area that needs + // updating. 999 when no mid area updating. + int mid_end = 0; // Below last row of the mid area that needs + // updating. 0 when no mid area updating. + int bot_start = 999; // first row of the bot area that needs + // updating. 999 when no bot area updating bool scrolled_down = false; // true when scrolled down when w_topline got smaller a bit bool top_to_mod = false; // redraw above mod_top @@ -764,8 +749,8 @@ win_update_start: init_search_hl(wp, &search_hl); - /* Force redraw when width of 'number' or 'relativenumber' column - * changes. */ + // Force redraw when width of 'number' or 'relativenumber' column + // changes. i = (wp->w_p_nu || wp->w_p_rnu) ? number_width(wp) : 0; if (wp->w_nrwidth != i) { type = NOT_VALID; @@ -782,10 +767,8 @@ win_update_start: // everything (only happens when redrawing is off for while). type = NOT_VALID; } else { - /* - * Set mod_top to the first line that needs displaying because of - * changes. Set mod_bot to the first line after the changes. - */ + // Set mod_top to the first line that needs displaying because of + // changes. Set mod_bot to the first line after the changes. mod_top = wp->w_redraw_top; if (wp->w_redraw_bot != 0) { mod_bot = wp->w_redraw_bot + 1; @@ -795,8 +778,8 @@ win_update_start: if (buf->b_mod_set) { if (mod_top == 0 || mod_top > buf->b_mod_top) { mod_top = buf->b_mod_top; - /* Need to redraw lines above the change that may be included - * in a pattern match. */ + // Need to redraw lines above the change that may be included + // in a pattern match. if (syntax_present(wp)) { mod_top -= buf->b_s.b_syn_sync_linebreaks; if (mod_top < 1) { @@ -831,21 +814,19 @@ win_update_start: if (mod_top != 0 && hasAnyFolding(wp)) { linenr_T lnumt, lnumb; - /* - * A change in a line can cause lines above it to become folded or - * unfolded. Find the top most buffer line that may be affected. - * If the line was previously folded and displayed, get the first - * line of that fold. If the line is folded now, get the first - * folded line. Use the minimum of these two. - */ - - /* Find last valid w_lines[] entry above mod_top. Set lnumt to - * the line below it. If there is no valid entry, use w_topline. - * Find the first valid w_lines[] entry below mod_bot. Set lnumb - * to this line. If there is no valid entry, use MAXLNUM. */ + // A change in a line can cause lines above it to become folded or + // unfolded. Find the top most buffer line that may be affected. + // If the line was previously folded and displayed, get the first + // line of that fold. If the line is folded now, get the first + // folded line. Use the minimum of these two. + + // Find last valid w_lines[] entry above mod_top. Set lnumt to + // the line below it. If there is no valid entry, use w_topline. + // Find the first valid w_lines[] entry below mod_bot. Set lnumb + // 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) { lnumt = wp->w_lines[i].wl_lastlnum + 1; @@ -875,10 +856,10 @@ win_update_start: } } - /* When a change starts above w_topline and the end is below - * w_topline, start redrawing at w_topline. - * 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. */ + // When a change starts above w_topline and the end is below + // w_topline, start redrawing at w_topline. + // 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) { mod_top = wp->w_topline; @@ -887,8 +868,8 @@ win_update_start: } } - /* When line numbers are displayed need to redraw all lines below - * inserted/deleted lines. */ + // 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) { mod_bot = MAXLNUM; } @@ -896,13 +877,11 @@ win_update_start: wp->w_redraw_top = 0; // reset for next time wp->w_redraw_bot = 0; - /* - * When only displaying the lines at the top, set top_end. Used when - * window has scrolled down for msg_scrolled. - */ + // When only displaying the lines at the top, set top_end. Used when + // window has scrolled down for msg_scrolled. if (type == REDRAW_TOP) { j = 0; - for (i = 0; i < wp->w_lines_valid; ++i) { + for (i = 0; i < wp->w_lines_valid; i++) { j += wp->w_lines[i].wl_size; if (j >= wp->w_upd_rows) { top_end = (int)j; @@ -918,14 +897,12 @@ win_update_start: } } - /* - * If there are no changes on the screen that require a complete redraw, - * handle three cases: - * 1: we are off the top of the screen by a few lines: scroll down - * 2: wp->w_topline is below wp->w_lines[0].wl_lnum: may scroll up - * 3: wp->w_topline is wp->w_lines[0].wl_lnum: find first entry in - * w_lines[] that needs updating. - */ + // If there are no changes on the screen that require a complete redraw, + // handle three cases: + // 1: we are off the top of the screen by a few lines: scroll down + // 2: wp->w_topline is below wp->w_lines[0].wl_lnum: may scroll up + // 3: wp->w_topline is wp->w_lines[0].wl_lnum: find first entry in + // w_lines[] that needs updating. if ((type == VALID || type == SOME_VALID || type == INVERTED || type == INVERTED_ALL) && !wp->w_botfill && !wp->w_old_botfill) { @@ -938,16 +915,13 @@ win_update_start: } else if (wp->w_lines[0].wl_valid && (wp->w_topline < wp->w_lines[0].wl_lnum || (wp->w_topline == wp->w_lines[0].wl_lnum - && wp->w_topfill > wp->w_old_topfill) - )) { - /* - * New topline is above old topline: May scroll down. - */ + && wp->w_topfill > wp->w_old_topfill))) { + // New topline is above old topline: May scroll down. if (hasAnyFolding(wp)) { linenr_T ln; - /* count the number of lines we are off, counting a sequence - * of folded lines as one */ + // count the number of lines we are off, counting a sequence + // of folded lines as one j = 0; for (ln = wp->w_topline; ln < wp->w_lines[0].wl_lnum; ln++) { j++; @@ -995,11 +969,9 @@ win_update_start: mid_start = 0; // redraw all lines } } else { - /* - * New topline is at or below old topline: May scroll up. - * When topline didn't change, find first entry in w_lines[] that - * needs updating. - */ + // New topline is at or below old topline: May scroll up. + // When topline didn't change, find first entry in w_lines[] that + // needs updating. // try to find wp->w_topline in wp->w_lines[].wl_lnum j = -1; @@ -1013,16 +985,15 @@ win_update_start: row += wp->w_lines[i].wl_size; } if (j == -1) { - /* if wp->w_topline is not in wp->w_lines[].wl_lnum redraw all - * lines */ + // if wp->w_topline is not in wp->w_lines[].wl_lnum redraw all + // lines mid_start = 0; } else { - /* - * Try to delete the correct number of lines. - * wp->w_topline is at wp->w_lines[i].wl_lnum. - */ - /* If the topline didn't change, delete old filler lines, - * otherwise delete filler lines of the new topline... */ + // Try to delete the correct number of lines. + // wp->w_topline is at wp->w_lines[i].wl_lnum. + + // 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) { row += wp->w_old_topfill; } else { @@ -1035,18 +1006,16 @@ win_update_start: bot_start = wp->w_grid.rows - row; } 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 - * upwards, to compensate for the deleted lines. Set - * bot_start to the first row that needs redrawing. - */ + // Skip the lines (below the deleted lines) that are still + // 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. bot_start = 0; idx = 0; for (;;) { wp->w_lines[idx] = wp->w_lines[j]; - /* stop at line that didn't fit, unless it is still - * valid (no lines deleted) */ + // stop at line that didn't fit, unless it is still + // valid (no lines deleted) if (row > 0 && bot_start + row + (int)wp->w_lines[j].wl_size > wp->w_grid.rows) { wp->w_lines_valid = idx + 1; @@ -1119,11 +1088,9 @@ win_update_start: to = wp->w_old_visual_lnum; } } else { - /* - * Find the line numbers that need to be updated: The lines - * between the old cursor position and the current cursor - * position. Also check if the Visual position changed. - */ + // Find the line numbers that need to be updated: The lines + // between the old cursor position and the current cursor + // position. Also check if the Visual position changed. if (curwin->w_cursor.lnum < wp->w_old_cursor_lnum) { from = curwin->w_cursor.lnum; to = wp->w_old_cursor_lnum; @@ -1153,11 +1120,9 @@ win_update_start: } } - /* - * If in block mode and changed column or curwin->w_curswant: - * update all lines. - * First compute the actual start and end column. - */ + // If in block mode and changed column or curwin->w_curswant: + // update all lines. + // First compute the actual start and end column. if (VIsual_mode == Ctrl_V) { colnr_T fromc, toc; unsigned int save_ve_flags = curwin->w_ve_flags; @@ -1219,17 +1184,13 @@ win_update_start: } } - /* - * There is no need to update lines above the top of the window. - */ + // There is no need to update lines above the top of the window. 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 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) { from = wp->w_botline - 1; @@ -1239,15 +1200,13 @@ win_update_start: } } - /* - * Find the minimal part to be updated. - * Watch out for scrolling that made entries in w_lines[] invalid. - * E.g., CTRL-U makes the first half of w_lines[] invalid and sets - * top_end; need to redraw from top_end to the "to" line. - * A middle mouse click with a Visual selection may change the text - * above the Visual area and reset wl_valid, do count these for - * mid_end (in srow). - */ + // Find the minimal part to be updated. + // Watch out for scrolling that made entries in w_lines[] invalid. + // E.g., CTRL-U makes the first half of w_lines[] invalid and sets + // top_end; need to redraw from top_end to the "to" line. + // A middle mouse click with a Visual selection may change the text + // above the Visual area and reset wl_valid, do count these for + // mid_end (in srow). if (mid_start > 0) { lnum = wp->w_topline; idx = 0; @@ -1263,11 +1222,11 @@ win_update_start: } else if (!scrolled_down) { srow += wp->w_lines[idx].wl_size; } - ++idx; + idx++; if (idx < wp->w_lines_valid && wp->w_lines[idx].wl_valid) { lnum = wp->w_lines[idx].wl_lnum; } else { - ++lnum; + lnum++; } } srow += mid_start; @@ -1304,9 +1263,7 @@ win_update_start: proftime_T syntax_tm = profile_setlimit(p_rdt); syn_set_timeout(&syntax_tm); - /* - * Update all the window rows. - */ + // Update all the window rows. idx = 0; // first entry in w_lines[].wl_size row = 0; srow = 0; @@ -1330,8 +1287,8 @@ win_update_start: bool cursorline_standout = win_cursorline_standout(wp); for (;;) { - /* stop updating when reached the end of the window (check for _past_ - * the end of the window is at the end of the loop) */ + // stop updating when reached the end of the window (check for _past_ + // the end of the window is at the end of the loop) if (row == wp->w_grid.rows) { didline = true; break; @@ -1343,8 +1300,8 @@ win_update_start: break; } - /* Remember the starting row of the line that is going to be dealt - * with. It is used further down when the line doesn't fit. */ + // Remember the starting row of the line that is going to be dealt + // with. It is used further down when the line doesn't fit. srow = row; // Update a line when it is in an area that needs updating, when it @@ -1379,13 +1336,11 @@ win_update_start: top_to_mod = false; } - /* - * When at start of changed lines: May scroll following lines - * up or down to minimize redrawing. - * Don't do this when the change continues until the end. - * Don't scroll when dollar_vcol >= 0, keep the "$". - * Don't scroll when redrawing the top, scrolled already above. - */ + // When at start of changed lines: May scroll following lines + // up or down to minimize redrawing. + // Don't do this when the change continues until the end. + // Don't scroll when dollar_vcol >= 0, keep the "$". + // Don't scroll when redrawing the top, scrolled already above. if (lnum == mod_top && mod_bot != MAXLNUM && !(dollar_vcol >= 0 && mod_bot == mod_top + 1) @@ -1395,12 +1350,12 @@ win_update_start: int xtra_rows; linenr_T l; - /* Count the old number of window rows, using w_lines[], which - * should still contain the sizes for the lines as they are - * currently displayed. */ - for (i = idx; i < wp->w_lines_valid; ++i) { - /* Only valid lines have a meaningful wl_lnum. Invalid - * lines are part of the changed area. */ + // Count the old number of window rows, using w_lines[], which + // should still contain the sizes for the lines as they are + // currently displayed. + for (i = idx; i < wp->w_lines_valid; i++) { + // 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) { break; @@ -1408,9 +1363,9 @@ win_update_start: old_rows += wp->w_lines[i].wl_size; if (wp->w_lines[i].wl_valid && wp->w_lines[i].wl_lastlnum + 1 == mod_bot) { - /* Must have found the last valid entry above mod_bot. - * Add following invalid entries. */ - ++i; + // Must have found the last valid entry above mod_bot. + // Add following invalid entries. + i++; while (i < wp->w_lines_valid && !wp->w_lines[i].wl_valid) { old_rows += wp->w_lines[i++].wl_size; @@ -1420,13 +1375,13 @@ win_update_start: } if (i >= wp->w_lines_valid) { - /* We can't find a valid line below the changed lines, - * need to redraw until the end of the window. - * Inserting/deleting lines has no use. */ + // We can't find a valid line below the changed lines, + // need to redraw until the end of the window. + // Inserting/deleting lines has no use. bot_start = 0; } else { - /* Able to count old number of rows: Count new window - * rows, and may insert/delete lines */ + // Able to count old number of rows: Count new window + // rows, and may insert/delete lines j = idx; for (l = lnum; l < mod_bot; l++) { if (hasFoldingWin(wp, l, NULL, &l, true, NULL)) { @@ -1445,10 +1400,10 @@ win_update_start: } xtra_rows = new_rows - old_rows; if (xtra_rows < 0) { - /* May scroll text up. If there is not enough - * remaining text or scrolling fails, must redraw the - * rest. If scrolling works, must redraw the text - * below the scrolled text. */ + // May scroll text up. If there is not enough + // remaining text or scrolling fails, must redraw the + // rest. If scrolling works, must redraw the text + // below the scrolled text. if (row - xtra_rows >= wp->w_grid.rows - 2) { mod_bot = MAXLNUM; } else { @@ -1456,9 +1411,9 @@ win_update_start: bot_start = wp->w_grid.rows + xtra_rows; } } else if (xtra_rows > 0) { - /* May scroll text down. If there is not enough - * remaining text of scrolling fails, must redraw the - * rest. */ + // May scroll text down. If there is not enough + // remaining text of scrolling fails, must redraw the + // rest. if (row + xtra_rows >= wp->w_grid.rows - 2) { mod_bot = MAXLNUM; } else { @@ -1471,8 +1426,8 @@ win_update_start: } } - /* When not updating the rest, may need to move w_lines[] - * entries. */ + // When not updating the rest, may need to move w_lines[] + // entries. if (mod_bot != MAXLNUM && i != j) { if (j < i) { int x = row + new_rows; @@ -1492,7 +1447,7 @@ win_update_start: break; } x += wp->w_lines[j++].wl_size; - ++i; + i++; } if (bot_start > x) { bot_start = x; @@ -1508,23 +1463,21 @@ win_update_start: wp->w_lines[i] = wp->w_lines[i - j]; } - /* The w_lines[] entries for inserted lines are - * now invalid, but wl_size may be used above. - * Reset to zero. */ + // The w_lines[] entries for inserted lines are + // now invalid, but wl_size may be used above. + // Reset to zero. while (i >= idx) { wp->w_lines[i].wl_size = 0; - wp->w_lines[i--].wl_valid = FALSE; + wp->w_lines[i--].wl_valid = false; } } } } } - /* - * When lines are folded, display one line for all of them. - * Otherwise, display normally (can be several display lines when - * 'wrap' is on). - */ + // When lines are folded, display one line for all of them. + // Otherwise, display normally (can be several display lines when + // 'wrap' is on). foldinfo_T foldinfo = fold_info(wp, lnum); if (foldinfo.fi_lines == 0 @@ -1603,9 +1556,7 @@ win_update_start: break; } } - /* - * End of loop over all window lines. - */ + // End of loop over all window lines. // Now that the window has been redrawn with the old and new cursor line, // update w_last_cursorline. @@ -1617,27 +1568,21 @@ win_update_start: wp->w_lines_valid = idx; } - /* - * Let the syntax stuff know we stop parsing here. - */ + // Let the syntax stuff know we stop parsing here. 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 - * line we were working on, then the line didn't fit. - */ + // If we didn't hit the end of the file, and we didn't finish the last + // line we were working on, then the line didn't fit. wp->w_empty_rows = 0; wp->w_filler_rows = 0; if (!eof && !didline) { int at_attr = hl_combine_attr(wp->w_hl_attr_normal, win_hl_attr(wp, HLF_AT)); if (lnum == wp->w_topline) { - /* - * Single line that does not fit! - * Don't overwrite it, it can be edited. - */ + // Single line that does not fit! + // Don't overwrite it, it can be edited. wp->w_botline = lnum + 1; } else if (win_get_fill(wp, lnum) >= wp->w_grid.rows - srow) { // Window ends in filler lines. @@ -1708,18 +1653,16 @@ win_update_start: } if (dollar_vcol == -1) { - /* - * There is a trick with w_botline. If we invalidate it on each - * change that might modify it, this will cause a lot of expensive - * calls to plines_win() in update_topline() each time. Therefore the - * value of w_botline is often approximated, and this value is used to - * compute the value of w_topline. If the value of w_botline was - * wrong, check that the value of w_topline is correct (cursor is on - * the visible part of the text). If it's not, we need to redraw - * again. Mostly this just means scrolling up a few lines, so it - * doesn't look too bad. Only do this for the current window (where - * changes are relevant). - */ + // There is a trick with w_botline. If we invalidate it on each + // change that might modify it, this will cause a lot of expensive + // calls to plines_win() in update_topline() each time. Therefore the + // value of w_botline is often approximated, and this value is used to + // compute the value of w_topline. If the value of w_botline was + // wrong, check that the value of w_topline is correct (cursor is on + // the visible part of the text). If it's not, we need to redraw + // again. Mostly this just means scrolling up a few lines, so it + // doesn't look too bad. Only do this for the current window (where + // changes are relevant). wp->w_valid |= VALID_BOTLINE; wp->w_viewport_invalid = true; if (wp == curwin && wp->w_botline != old_botline && !recursive) { @@ -1828,7 +1771,7 @@ static void win_draw_end(win_T *wp, int c1, int c2, bool draw_margin, int row, i static bool advance_color_col(int vcol, int **color_cols) { while (**color_cols >= 0 && vcol > **color_cols) { - ++*color_cols; + (*color_cols)++; } return **color_cols >= 0; } @@ -2071,7 +2014,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc 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. + bool 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 @@ -2080,13 +2023,13 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc #define SPWORDLEN 150 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 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" - static int checked_col = 0; /* column in "checked_lnum" up to which - * there are no spell errors */ + 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 static linenr_T capcol_lnum = 0; // line number where "cap_col" int cur_checked_col = 0; // checked column for current line @@ -2433,9 +2376,9 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc cap_col = (int)getwhitecols(line); } - /* To be able to spell-check over line boundaries copy the end of the - * current line into nextline[]. Above the start of the next line was - * copied to nextline[SPWORDLEN]. */ + // To be able to spell-check over line boundaries copy the end of the + // 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. nextlinecol = MAXCOL; @@ -2443,8 +2386,8 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc } else { v = (long)STRLEN(line); if (v < SPWORDLEN) { - /* Short line, use it completely and append the start of the - * next line. */ + // Short line, use it completely and append the start of the + // next line. nextlinecol = 0; memmove(nextline, line, (size_t)v); STRMOVE(nextline + v, nextline + SPWORDLEN); @@ -2491,10 +2434,8 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc } } - /* - * 'nowrap' or 'wrap' and a single line that doesn't fit: Advance to the - * first character to be displayed. - */ + // 'nowrap' or 'wrap' and a single line that doesn't fit: Advance to the + // first character to be displayed. |