multigrid: Fix lint errors

This commit is contained in:
Utkarsh Maheshwari
2018-09-21 18:14:32 +05:30
committed by Björn Linse
parent 8b47b56fc6
commit ba6f9f60ad
20 changed files with 328 additions and 277 deletions

View File

@@ -248,8 +248,8 @@ static void ui_set_option(UI *ui, bool init, String name, Object value,
/// Sets the inner "width" and "height" of the window grid identified by /// Sets the inner "width" and "height" of the window grid identified by
/// "grid" handle. If the grid does not exist, set error. /// "grid" handle. If the grid does not exist, set error.
void nvim_ui_try_resize_grid(uint64_t channel_id, Integer grid, Integer width, void nvim_ui_try_resize_grid(uint64_t channel_id, Integer grid, Integer width,
Integer height, Error *error) Integer height, Error *error)
FUNC_API_SINCE(4) FUNC_API_REMOTE_ONLY FUNC_API_SINCE(5) FUNC_API_REMOTE_ONLY
{ {
if (!pmap_has(uint64_t)(connected_uis, channel_id)) { if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
api_set_error(error, kErrorTypeException, api_set_error(error, kErrorTypeException,

View File

@@ -1104,7 +1104,8 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *he
if (size + sbrlen + numberwidth > (colnr_T)wp->w_grid.Columns) { if (size + sbrlen + numberwidth > (colnr_T)wp->w_grid.Columns) {
// Calculate effective window width. // Calculate effective window width.
int width = (colnr_T)wp->w_grid.Columns - sbrlen - numberwidth; int width = (colnr_T)wp->w_grid.Columns - sbrlen - numberwidth;
int prev_width = col ? ((colnr_T)wp->w_grid.Columns - (sbrlen + col)) : 0; int prev_width = col ? ((colnr_T)wp->w_grid.Columns - (sbrlen + col))
: 0;
if (width == 0) { if (width == 0) {
width = (colnr_T)wp->w_grid.Columns; width = (colnr_T)wp->w_grid.Columns;
} }

View File

@@ -223,9 +223,10 @@ static int coladvance2(
} else { } else {
int b = (int)wcol - (int)col; int b = (int)wcol - (int)col;
/* The difference between wcol and col is used to set coladd. */ // The difference between wcol and col is used to set coladd.
if (b > 0 && b < (MAXCOL - 2 * curwin->w_grid.Columns)) if (b > 0 && b < (MAXCOL - 2 * curwin->w_grid.Columns)) {
pos->coladd = b; pos->coladd = b;
}
col += b; col += b;
} }

View File

@@ -1495,7 +1495,7 @@ void edit_putchar(int c, int highlight)
int attr; int attr;
if (default_grid.ScreenLines != NULL) { if (default_grid.ScreenLines != NULL) {
update_topline(); /* just in case w_topline isn't valid */ update_topline(); // just in case w_topline isn't valid
validate_cursor(); validate_cursor();
if (highlight) { if (highlight) {
attr = HL_ATTR(HLF_8); attr = HL_ATTR(HLF_8);
@@ -1518,8 +1518,9 @@ void edit_putchar(int c, int highlight)
} }
} else { } else {
pc_col += curwin->w_wcol; pc_col += curwin->w_wcol;
if (grid_lefthalve(&curwin->w_grid, pc_row, pc_col)) if (grid_lefthalve(&curwin->w_grid, pc_row, pc_col)) {
pc_status = PC_STATUS_LEFT; pc_status = PC_STATUS_LEFT;
}
} }
/* save the character to be able to put it back */ /* save the character to be able to put it back */
@@ -1568,7 +1569,7 @@ void display_dollar(colnr_T col)
curwin->w_cursor.col -= utf_head_off(p, p + col); curwin->w_cursor.col -= utf_head_off(p, p + col);
curs_columns(false); // Recompute w_wrow and w_wcol curs_columns(false); // Recompute w_wrow and w_wcol
if (curwin->w_wcol < curwin->w_grid.Columns) { if (curwin->w_wcol < curwin->w_grid.Columns) {
edit_putchar('$', FALSE); edit_putchar('$', false);
dollar_vcol = curwin->w_virtcol; dollar_vcol = curwin->w_virtcol;
} }
curwin->w_cursor.col = save_col; curwin->w_cursor.col = save_col;
@@ -5842,8 +5843,9 @@ comp_textwidth (
/* The width is the window width minus 'wrapmargin' minus all the /* The width is the window width minus 'wrapmargin' minus all the
* things that add to the margin. */ * things that add to the margin. */
textwidth = curwin->w_grid.Columns - curbuf->b_p_wm; textwidth = curwin->w_grid.Columns - curbuf->b_p_wm;
if (cmdwin_type != 0) if (cmdwin_type != 0) {
textwidth -= 1; textwidth -= 1;
}
textwidth -= curwin->w_p_fdc; textwidth -= curwin->w_p_fdc;
if (signcolumn_on(curwin)) { if (signcolumn_on(curwin)) {
@@ -5857,8 +5859,9 @@ comp_textwidth (
textwidth = 0; textwidth = 0;
if (ff && textwidth == 0) { if (ff && textwidth == 0) {
textwidth = curwin->w_grid.Columns - 1; textwidth = curwin->w_grid.Columns - 1;
if (textwidth > 79) if (textwidth > 79) {
textwidth = 79; textwidth = 79;
}
} }
return textwidth; return textwidth;
} }

View File

@@ -256,10 +256,12 @@ void ex_align(exarg_T *eap)
*/ */
if (width <= 0) if (width <= 0)
width = curbuf->b_p_tw; width = curbuf->b_p_tw;
if (width == 0 && curbuf->b_p_wm > 0) if (width == 0 && curbuf->b_p_wm > 0) {
width = curwin->w_grid.Columns - curbuf->b_p_wm; width = curwin->w_grid.Columns - curbuf->b_p_wm;
if (width <= 0) }
if (width <= 0) {
width = 80; width = 80;
}
} }
if (u_save((linenr_T)(eap->line1 - 1), (linenr_T)(eap->line2 + 1)) == FAIL) if (u_save((linenr_T)(eap->line1 - 1), (linenr_T)(eap->line2 + 1)) == FAIL)

View File

@@ -9194,10 +9194,10 @@ static int ses_winsizes(FILE *fd, int restore_size, win_T *tab_firstwin)
/* restore height when not full height */ /* restore height when not full height */
if (wp->w_height + wp->w_status_height < topframe->fr_height if (wp->w_height + wp->w_status_height < topframe->fr_height
&& (fprintf(fd, && (fprintf(fd,
"exe '%dresize ' . ((&lines * %" PRId64 "exe '%dresize ' . ((&lines * %" PRId64
" + %" PRId64 ") / %" PRId64 ")", " + %" PRId64 ") / %" PRId64 ")",
n, (int64_t)wp->w_grid.Rows, n, (int64_t)wp->w_grid.Rows,
(int64_t)(Rows / 2), (int64_t)Rows) < 0 (int64_t)(Rows / 2), (int64_t)Rows) < 0
|| put_eol(fd) == FAIL)) || put_eol(fd) == FAIL))
return FAIL; return FAIL;

View File

@@ -2129,7 +2129,7 @@ static int vgetorpeek(int advance)
col = curwin->w_cursor.col - 1; col = curwin->w_cursor.col - 1;
} }
} else if (curwin->w_p_wrap && curwin->w_wrow) { } else if (curwin->w_p_wrap && curwin->w_wrow) {
--curwin->w_wrow; curwin->w_wrow--;
curwin->w_wcol = curwin->w_grid.Columns - 1; curwin->w_wcol = curwin->w_grid.Columns - 1;
col = curwin->w_cursor.col - 1; col = curwin->w_cursor.col - 1;
} }

View File

@@ -159,7 +159,7 @@ typedef off_t off_T;
EXTERN ScreenGrid default_grid INIT(= { 0, NULL, NULL, NULL, NULL, 0, 0, 0, 0, EXTERN ScreenGrid default_grid INIT(= { 0, NULL, NULL, NULL, NULL, 0, 0, 0, 0,
0, 0, 0 }); 0, 0, 0 });
#define DEFAULT_GRID_HANDLE 1 /* handle for the default_grid */ #define DEFAULT_GRID_HANDLE 1 // handle for the default_grid
/* /*
* When vgetc() is called, it sets mod_mask to the set of modifiers that are * When vgetc() is called, it sets mod_mask to the set of modifiers that are

View File

@@ -582,7 +582,8 @@ static void prt_header(prt_settings_T *const psettings, const int pagenum,
*/ */
static void prt_message(char_u *s) static void prt_message(char_u *s)
{ {
grid_fill(&default_grid, (int)Rows - 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0); grid_fill(&default_grid, (int)Rows - 1, (int)Rows, 0, (int)Columns, ' ', ' ',
0);
grid_puts(&default_grid, s, (int)Rows - 1, 0, HL_ATTR(HLF_R)); grid_puts(&default_grid, s, (int)Rows - 1, 0, HL_ATTR(HLF_R));
ui_flush(); ui_flush();
} }

View File

@@ -463,7 +463,7 @@ int get_breakindent_win(win_T *wp, char_u *line)
static char_u *prev_line = NULL; // cached pointer to line. static char_u *prev_line = NULL; // cached pointer to line.
static varnumber_T prev_tick = 0; // Changedtick of cached value. static varnumber_T prev_tick = 0; // Changedtick of cached value.
int bri = 0; int bri = 0;
/* window width minus window margin space, i.e. what rests for text */ // window width minus window margin space, i.e. what rests for text
const int eff_wwidth = wp->w_grid.Columns const int eff_wwidth = wp->w_grid.Columns
- ((wp->w_p_nu || wp->w_p_rnu) - ((wp->w_p_nu || wp->w_p_rnu)
&& (vim_strchr(p_cpo, CPO_NUMCOL) == NULL) && (vim_strchr(p_cpo, CPO_NUMCOL) == NULL)

View File

@@ -1546,10 +1546,8 @@ void msg_prt_line(char_u *s, int list)
msg_clr_eos(); msg_clr_eos();
} }
/* // Use grid_puts() to output one multi-byte character.
* Use grid_puts() to output one multi-byte character. // Return the pointer "s" advanced to the next character.
* Return the pointer "s" advanced to the next character.
*/
static char_u *screen_puts_mbyte(char_u *s, int l, int attr) static char_u *screen_puts_mbyte(char_u *s, int l, int attr)
{ {
int cw; int cw;
@@ -2097,7 +2095,8 @@ static void t_puts(int *t_col, const char_u *t_s, const char_u *s, int attr)
{ {
// Output postponed text. // Output postponed text.
msg_didout = true; // Remember that line is not empty. msg_didout = true; // Remember that line is not empty.
grid_puts_len(&default_grid, (char_u *)t_s, (int)(s - t_s), msg_row, msg_col, attr); grid_puts_len(&default_grid, (char_u *)t_s, (int)(s - t_s), msg_row, msg_col,
attr);
msg_col += *t_col; msg_col += *t_col;
*t_col = 0; *t_col = 0;
/* If the string starts with a composing character don't increment the /* If the string starts with a composing character don't increment the
@@ -2314,7 +2313,7 @@ static int do_more_prompt(int typed_char)
if (toscroll == -1 if (toscroll == -1
&& grid_ins_lines(&default_grid, 0, 1, (int)Rows, && grid_ins_lines(&default_grid, 0, 1, (int)Rows,
0, (int)Columns) == OK) { 0, (int)Columns) == OK) {
grid_fill(&default_grid, 0, 1, 0, (int)Columns, ' ', ' ', 0); grid_fill(&default_grid, 0, 1, 0, (int)Columns, ' ', ' ', 0);
// display line at top // display line at top
(void)disp_sb_line(0, mp); (void)disp_sb_line(0, mp);
@@ -2335,17 +2334,17 @@ static int do_more_prompt(int typed_char)
msg_scroll_up(); msg_scroll_up();
inc_msg_scrolled(); inc_msg_scrolled();
grid_fill(&default_grid, (int)Rows - 2, (int)Rows - 1, 0, grid_fill(&default_grid, (int)Rows - 2, (int)Rows - 1, 0,
(int)Columns, ' ', ' ', 0); (int)Columns, ' ', ' ', 0);
mp_last = disp_sb_line((int)Rows - 2, mp_last); mp_last = disp_sb_line((int)Rows - 2, mp_last);
--toscroll; --toscroll;
} }
} }
if (toscroll <= 0) { if (toscroll <= 0) {
/* displayed the requested text, more prompt again */ // displayed the requested text, more prompt again
grid_fill(&default_grid, (int)Rows - 1, (int)Rows, 0, grid_fill(&default_grid, (int)Rows - 1, (int)Rows, 0,
(int)Columns, ' ', ' ', 0); (int)Columns, ' ', ' ', 0);
msg_moremsg(FALSE); msg_moremsg(false);
continue; continue;
} }
@@ -2356,8 +2355,9 @@ static int do_more_prompt(int typed_char)
break; break;
} }
/* clear the --more-- message */ // clear the --more-- message
grid_fill(&default_grid, (int)Rows - 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0); grid_fill(&default_grid, (int)Rows - 1, (int)Rows, 0, (int)Columns, ' ', ' ',
0);
State = oldState; State = oldState;
setmouse(); setmouse();
if (quit_more) { if (quit_more) {
@@ -2477,8 +2477,8 @@ void msg_moremsg(int full)
grid_puts(&default_grid, s, (int)Rows - 1, 0, attr); grid_puts(&default_grid, s, (int)Rows - 1, 0, attr);
if (full) { if (full) {
grid_puts(&default_grid, (char_u *) grid_puts(&default_grid, (char_u *)
_(" SPACE/d/j: screen/page/line down, b/u/k: up, q: quit "), _(" SPACE/d/j: screen/page/line down, b/u/k: up, q: quit "),
(int)Rows - 1, vim_strsize(s), attr); (int)Rows - 1, vim_strsize(s), attr);
} }
} }
@@ -2527,13 +2527,13 @@ void msg_clr_eos(void)
*/ */
void msg_clr_eos_force(void) void msg_clr_eos_force(void)
{ {
if (cmdmsg_rl) { int msg_startcol = (cmdmsg_rl) ? 0 : msg_col;
grid_fill(&default_grid, msg_row, msg_row + 1, 0, msg_col + 1, ' ', ' ', 0); int msg_endcol = (cmdmsg_rl) ? msg_col + 1 : (int)Columns;
grid_fill(&default_grid, msg_row + 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0);
} else { grid_fill(&default_grid, msg_row, msg_row + 1, msg_startcol, msg_endcol, ' ',
grid_fill(&default_grid, msg_row, msg_row + 1, msg_col, (int)Columns, ' ', ' ', 0); ' ', 0);
grid_fill(&default_grid, msg_row + 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0); grid_fill(&default_grid, msg_row + 1, (int)Rows, 0, (int)Columns, ' ', ' ',
} 0);
} }
/* /*

View File

@@ -1318,8 +1318,9 @@ int plines_win_col(win_T *wp, linenr_T lnum, long column)
if (!wp->w_p_wrap) if (!wp->w_p_wrap)
return lines + 1; return lines + 1;
if (wp->w_grid.Columns == 0) if (wp->w_grid.Columns == 0) {
return lines + 1; return lines + 1;
}
char_u *line = ml_get_buf(wp->w_buffer, lnum, false); char_u *line = ml_get_buf(wp->w_buffer, lnum, false);
char_u *s = line; char_u *s = line;

View File

@@ -112,7 +112,7 @@ retnomove:
if (row >= 0 && row < Rows && col >= 0 && col <= Columns if (row >= 0 && row < Rows && col >= 0 && col <= Columns
&& default_grid.ScreenLines != NULL) { && default_grid.ScreenLines != NULL) {
mouse_char = default_grid.ScreenLines[default_grid.LineOffset[row] mouse_char = default_grid.ScreenLines[default_grid.LineOffset[row]
+ (unsigned)col][0]; + (unsigned)col][0];
} else { } else {
mouse_char = ' '; mouse_char = ' ';
} }

View File

@@ -83,8 +83,9 @@ static void comp_botline(win_T *wp)
redraw_for_cursorline(wp); redraw_for_cursorline(wp);
wp->w_valid |= (VALID_CROW|VALID_CHEIGHT); wp->w_valid |= (VALID_CROW|VALID_CHEIGHT);
} }
if (done + n > wp->w_grid.Rows) if (done + n > wp->w_grid.Rows) {
break; break;
}
done += n; done += n;
lnum = last; lnum = last;
} }
@@ -204,8 +205,9 @@ void update_topline(void)
if (check_topline) { if (check_topline) {
int halfheight = curwin->w_grid.Rows / 2 - 1; int halfheight = curwin->w_grid.Rows / 2 - 1;
if (halfheight < 2) if (halfheight < 2) {
halfheight = 2; halfheight = 2;
}
long n; long n;
if (hasAnyFolding(curwin)) { if (hasAnyFolding(curwin)) {
/* Count the number of logical lines between the cursor and /* Count the number of logical lines between the cursor and
@@ -292,20 +294,22 @@ void update_topline(void)
* botline - p_so (approximation of how much will be * botline - p_so (approximation of how much will be
* scrolled). */ * scrolled). */
for (linenr_T lnum = curwin->w_cursor.lnum; for (linenr_T lnum = curwin->w_cursor.lnum;
lnum >= curwin->w_botline - p_so; --lnum) { lnum >= curwin->w_botline - p_so; lnum--) {
++line_count; line_count++;
/* stop at end of file or when we know we are far off */ // stop at end of file or when we know we are far off
if (lnum <= 0 || line_count > curwin->w_grid.Rows + 1) if (lnum <= 0 || line_count > curwin->w_grid.Rows + 1) {
break; break;
}
(void)hasFolding(lnum, &lnum, NULL); (void)hasFolding(lnum, &lnum, NULL);
} }
} else } else
line_count = curwin->w_cursor.lnum - curwin->w_botline line_count = curwin->w_cursor.lnum - curwin->w_botline
+ 1 + p_so; + 1 + p_so;
if (line_count <= curwin->w_grid.Rows + 1) if (line_count <= curwin->w_grid.Rows + 1) {
scroll_cursor_bot(scrolljump_value(), false); scroll_cursor_bot(scrolljump_value(), false);
else } else {
scroll_cursor_halfway(false); scroll_cursor_halfway(false);
}
} }
} }
} }
@@ -666,16 +670,17 @@ void validate_cursor_col(void)
col += off; col += off;
int width = curwin->w_grid.Columns - off + curwin_col_off2(); int width = curwin->w_grid.Columns - off + curwin_col_off2();
/* long line wrapping, adjust curwin->w_wrow */ // long line wrapping, adjust curwin->w_wrow
if (curwin->w_p_wrap if (curwin->w_p_wrap && col >= (colnr_T)curwin->w_grid.Columns
&& col >= (colnr_T)curwin->w_grid.Columns && width > 0) {
&& width > 0) // use same formula as what is used in curs_columns()
/* use same formula as what is used in curs_columns() */
col -= ((col - curwin->w_grid.Columns) / width + 1) * width; col -= ((col - curwin->w_grid.Columns) / width + 1) * width;
if (col > (int)curwin->w_leftcol) }
if (col > (int)curwin->w_leftcol) {
col -= curwin->w_leftcol; col -= curwin->w_leftcol;
else } else {
col = 0; col = 0;
}
curwin->w_wcol = col; curwin->w_wcol = col;
curwin->w_valid |= VALID_WCOL; curwin->w_valid |= VALID_WCOL;
@@ -766,7 +771,7 @@ void curs_columns(
int textwidth = curwin->w_grid.Columns - extra; int textwidth = curwin->w_grid.Columns - extra;
if (textwidth <= 0) { if (textwidth <= 0) {
/* No room for text, put cursor in last char of window. */ // No room for text, put cursor in last char of window.
curwin->w_wcol = curwin->w_grid.Columns - 1; curwin->w_wcol = curwin->w_grid.Columns - 1;
curwin->w_wrow = curwin->w_grid.Rows - 1; curwin->w_wrow = curwin->w_grid.Rows - 1;
} else if (curwin->w_p_wrap } else if (curwin->w_p_wrap
@@ -774,9 +779,9 @@ void curs_columns(
) { ) {
width = textwidth + curwin_col_off2(); width = textwidth + curwin_col_off2();
/* long line wrapping, adjust curwin->w_wrow */ // long line wrapping, adjust curwin->w_wrow
if (curwin->w_wcol >= curwin->w_grid.Columns) { if (curwin->w_wcol >= curwin->w_grid.Columns) {
/* this same formula is used in validate_cursor_col() */ // this same formula is used in validate_cursor_col()
n = (curwin->w_wcol - curwin->w_grid.Columns) / width + 1; n = (curwin->w_wcol - curwin->w_grid.Columns) / width + 1;
curwin->w_wcol -= n * width; curwin->w_wcol -= n * width;
curwin->w_wrow += n; curwin->w_wrow += n;
@@ -851,9 +856,8 @@ void curs_columns(
|| ((prev_skipcol > 0 || ((prev_skipcol > 0
|| curwin->w_wrow + p_so >= curwin->w_grid.Rows) || curwin->w_wrow + p_so >= curwin->w_grid.Rows)
&& (p_lines = && (p_lines =
plines_win_nofill plines_win_nofill(curwin, curwin->w_cursor.lnum, false)) - 1
(curwin, curwin->w_cursor.lnum, false)) >= curwin->w_grid.Rows))
- 1 >= curwin->w_grid.Rows))
&& curwin->w_grid.Rows != 0 && curwin->w_grid.Rows != 0
&& curwin->w_cursor.lnum == curwin->w_topline && curwin->w_cursor.lnum == curwin->w_topline
&& width > 0 && width > 0
@@ -879,19 +883,22 @@ void curs_columns(
} }
else else
n = p_lines; n = p_lines;
if ((colnr_T)n >= curwin->w_grid.Rows + curwin->w_skipcol / width) if ((colnr_T)n >= curwin->w_grid.Rows + curwin->w_skipcol / width) {
extra += 2; extra += 2;
}
if (extra == 3 || p_lines < p_so * 2) { if (extra == 3 || p_lines < p_so * 2) {
/* not enough room for 'scrolloff', put cursor in the middle */ // not enough room for 'scrolloff', put cursor in the middle
n = curwin->w_virtcol / width; n = curwin->w_virtcol / width;
if (n > curwin->w_grid.Rows / 2) if (n > curwin->w_grid.Rows / 2) {
n -= curwin->w_grid.Rows / 2; n -= curwin->w_grid.Rows / 2;
else } else {
n = 0; n = 0;
/* don't skip more than necessary */ }
if (n > p_lines - curwin->w_grid.Rows + 1) // don't skip more than necessary
if (n > p_lines - curwin->w_grid.Rows + 1) {
n = p_lines - curwin->w_grid.Rows + 1; n = p_lines - curwin->w_grid.Rows + 1;
}
curwin->w_skipcol = n * width; curwin->w_skipcol = n * width;
} else if (extra == 1) { } else if (extra == 1) {
/* less then 'scrolloff' lines above, decrease skipcol */ /* less then 'scrolloff' lines above, decrease skipcol */
@@ -904,17 +911,19 @@ void curs_columns(
curwin->w_skipcol -= extra * width; curwin->w_skipcol -= extra * width;
} }
} else if (extra == 2) { } else if (extra == 2) {
/* less then 'scrolloff' lines below, increase skipcol */ // less then 'scrolloff' lines below, increase skipcol
endcol = (n - curwin->w_grid.Rows + 1) * width; endcol = (n - curwin->w_grid.Rows + 1) * width;
while (endcol > curwin->w_virtcol) while (endcol > curwin->w_virtcol) {
endcol -= width; endcol -= width;
if (endcol > curwin->w_skipcol) }
if (endcol > curwin->w_skipcol) {
curwin->w_skipcol = endcol; curwin->w_skipcol = endcol;
}
} }
curwin->w_wrow -= curwin->w_skipcol / width; curwin->w_wrow -= curwin->w_skipcol / width;
if (curwin->w_wrow >= curwin->w_grid.Rows) { if (curwin->w_wrow >= curwin->w_grid.Rows) {
/* small window, make sure cursor is in it */ // small window, make sure cursor is in it
extra = curwin->w_wrow - curwin->w_grid.Rows + 1; extra = curwin->w_wrow - curwin->w_grid.Rows + 1;
curwin->w_skipcol += extra * width; curwin->w_skipcol += extra * width;
curwin->w_wrow -= extra; curwin->w_wrow -= extra;
@@ -958,8 +967,8 @@ scrolldown (
while (line_count-- > 0) { while (line_count-- > 0) {
if (curwin->w_topfill < diff_check(curwin, curwin->w_topline) if (curwin->w_topfill < diff_check(curwin, curwin->w_topline)
&& curwin->w_topfill < curwin->w_grid.Rows - 1) { && curwin->w_topfill < curwin->w_grid.Rows - 1) {
++curwin->w_topfill; curwin->w_topfill++;
++done; done++;
} else { } else {
if (curwin->w_topline == 1) if (curwin->w_topline == 1)
break; break;
@@ -1091,8 +1100,9 @@ check_topfill (
wp->w_topfill = 0; wp->w_topfill = 0;
} else { } else {
wp->w_topfill = wp->w_grid.Rows - n; wp->w_topfill = wp->w_grid.Rows - n;
if (wp->w_topfill < 0) if (wp->w_topfill < 0) {
wp->w_topfill = 0; wp->w_topfill = 0;
}
} }
} }
} }
@@ -1105,12 +1115,13 @@ check_topfill (
static void max_topfill(void) static void max_topfill(void)
{ {
int n = plines_nofill(curwin->w_topline); int n = plines_nofill(curwin->w_topline);
if (n >= curwin->w_grid.Rows) if (n >= curwin->w_grid.Rows) {
curwin->w_topfill = 0; curwin->w_topfill = 0;
else { } else {
curwin->w_topfill = diff_check_fill(curwin, curwin->w_topline); curwin->w_topfill = diff_check_fill(curwin, curwin->w_topline);
if (curwin->w_topfill + n > curwin->w_grid.Rows) if (curwin->w_topfill + n > curwin->w_grid.Rows) {
curwin->w_topfill = curwin->w_grid.Rows - n; curwin->w_topfill = curwin->w_grid.Rows - n;
}
} }
} }
@@ -1340,10 +1351,12 @@ void scroll_cursor_top(int min_scroll, int always)
else else
used += plines(bot); used += plines(bot);
} }
if (used > curwin->w_grid.Rows) if (used > curwin->w_grid.Rows) {
break; break;
if (top < curwin->w_topline) }
if (top < curwin->w_topline) {
scrolled += i; scrolled += i;
}
/* /*
* If scrolling is needed, scroll at least 'sj' lines. * If scrolling is needed, scroll at least 'sj' lines.
@@ -1397,9 +1410,9 @@ void scroll_cursor_top(int min_scroll, int always)
void set_empty_rows(win_T *wp, int used) void set_empty_rows(win_T *wp, int used)
{ {
wp->w_filler_rows = 0; wp->w_filler_rows = 0;
if (used == 0) if (used == 0) {
wp->w_empty_rows = 0; /* single line that doesn't fit */ wp->w_empty_rows = 0; // single line that doesn't fit
else { } else {
wp->w_empty_rows = wp->w_grid.Rows - used; wp->w_empty_rows = wp->w_grid.Rows - used;
if (wp->w_botline <= wp->w_buffer->b_ml.ml_line_count) { if (wp->w_botline <= wp->w_buffer->b_ml.ml_line_count) {
wp->w_filler_rows = diff_check_fill(wp, wp->w_botline); wp->w_filler_rows = diff_check_fill(wp, wp->w_botline);
@@ -1443,8 +1456,9 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
curwin->w_topline = loff.lnum) { curwin->w_topline = loff.lnum) {
loff.lnum = curwin->w_topline; loff.lnum = curwin->w_topline;
topline_back(&loff); topline_back(&loff);
if (loff.height == MAXCOL || used + loff.height > curwin->w_grid.Rows) if (loff.height == MAXCOL || used + loff.height > curwin->w_grid.Rows) {
break; break;
}
used += loff.height; used += loff.height;
curwin->w_topfill = loff.fill; curwin->w_topfill = loff.fill;
} }
@@ -1501,12 +1515,14 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
/* Add one line above */ /* Add one line above */
topline_back(&loff); topline_back(&loff);
if (loff.height == MAXCOL) if (loff.height == MAXCOL) {
used = MAXCOL; used = MAXCOL;
else } else {
used += loff.height; used += loff.height;
if (used > curwin->w_grid.Rows) }
if (used > curwin->w_grid.Rows) {
break; break;
}
if (loff.lnum >= curwin->w_botline if (loff.lnum >= curwin->w_botline
&& (loff.lnum > curwin->w_botline && (loff.lnum > curwin->w_botline
|| loff.fill <= fill_below_window) || loff.fill <= fill_below_window)
@@ -1523,8 +1539,9 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
/* Add one line below */ /* Add one line below */
botline_forw(&boff); botline_forw(&boff);
used += boff.height; used += boff.height;
if (used > curwin->w_grid.Rows) if (used > curwin->w_grid.Rows) {
break; break;
}
if (extra < ( if (extra < (
mouse_dragging > 0 ? mouse_dragging - 1 : mouse_dragging > 0 ? mouse_dragging - 1 :
p_so) || scrolled < min_scroll) { p_so) || scrolled < min_scroll) {
@@ -1545,14 +1562,14 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
} }
linenr_T line_count; linenr_T line_count;
/* curwin->w_empty_rows is larger, no need to scroll */ // curwin->w_empty_rows is larger, no need to scroll
if (scrolled <= 0) if (scrolled <= 0) {
line_count = 0; line_count = 0;
/* more than a screenfull, don't scroll but redraw */ // more than a screenfull, don't scroll but redraw
else if (used > curwin->w_grid.Rows) } else if (used > curwin->w_grid.Rows) {
line_count = used; line_count = used;
/* scroll minimal number of lines */ // scroll minimal number of lines
else { } else {
line_count = 0; line_count = 0;
boff.fill = curwin->w_topfill; boff.fill = curwin->w_topfill;
boff.lnum = curwin->w_topline - 1; boff.lnum = curwin->w_topline - 1;
@@ -1570,10 +1587,11 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
* Scroll up if the cursor is off the bottom of the screen a bit. * Scroll up if the cursor is off the bottom of the screen a bit.
* Otherwise put it at 1/2 of the screen. * Otherwise put it at 1/2 of the screen.
*/ */
if (line_count >= curwin->w_grid.Rows && line_count > min_scroll) if (line_count >= curwin->w_grid.Rows && line_count > min_scroll) {
scroll_cursor_halfway(false); scroll_cursor_halfway(false);
else } else {
scrollup(line_count, true); scrollup(line_count, true);
}
/* /*
* If topline didn't change we need to restore w_botline and w_empty_rows * If topline didn't change we need to restore w_botline and w_empty_rows
@@ -1612,8 +1630,9 @@ void scroll_cursor_halfway(int atend)
if (boff.lnum < curbuf->b_ml.ml_line_count) { if (boff.lnum < curbuf->b_ml.ml_line_count) {
botline_forw(&boff); botline_forw(&boff);
used += boff.height; used += boff.height;
if (used > curwin->w_grid.Rows) if (used > curwin->w_grid.Rows) {
break; break;
}
below += boff.height; below += boff.height;
} else { } else {
++below; /* count a "~" line */ ++below; /* count a "~" line */
@@ -1628,8 +1647,9 @@ void scroll_cursor_halfway(int atend)
used = MAXCOL; used = MAXCOL;
else else
used += loff.height; used += loff.height;
if (used > curwin->w_grid.Rows) if (used > curwin->w_grid.Rows) {
break; break;
}
above += loff.height; above += loff.height;
topline = loff.lnum; topline = loff.lnum;
topfill = loff.fill; topfill = loff.fill;
@@ -1638,8 +1658,9 @@ void scroll_cursor_halfway(int atend)
if (!hasFolding(topline, &curwin->w_topline, NULL)) if (!hasFolding(topline, &curwin->w_topline, NULL))
curwin->w_topline = topline; curwin->w_topline = topline;
curwin->w_topfill = topfill; curwin->w_topfill = topfill;
if (old_topline > curwin->w_topline + curwin->w_grid.Rows) if (old_topline > curwin->w_topline + curwin->w_grid.Rows) {
curwin->w_botfill = false; curwin->w_botfill = false;
}
check_topfill(curwin, false); check_topfill(curwin, false);
curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP); curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP);
curwin->w_valid |= VALID_TOPLINE; curwin->w_valid |= VALID_TOPLINE;
@@ -1667,8 +1688,9 @@ void cursor_correct(void)
if (curwin->w_topline == 1) { if (curwin->w_topline == 1) {
above_wanted = 0; above_wanted = 0;
int max_off = curwin->w_grid.Rows / 2; int max_off = curwin->w_grid.Rows / 2;
if (below_wanted > max_off) if (below_wanted > max_off) {
below_wanted = max_off; below_wanted = max_off;
}
} }
validate_botline(); validate_botline();
if (curwin->w_botline == curbuf->b_ml.ml_line_count + 1 if (curwin->w_botline == curbuf->b_ml.ml_line_count + 1
@@ -1676,8 +1698,9 @@ void cursor_correct(void)
) { ) {
below_wanted = 0; below_wanted = 0;
int max_off = (curwin->w_grid.Rows - 1) / 2; int max_off = (curwin->w_grid.Rows - 1) / 2;
if (above_wanted > max_off) if (above_wanted > max_off) {
above_wanted = max_off; above_wanted = max_off;
}
} }
/* /*
@@ -1993,9 +2016,10 @@ void halfpage(bool flag, linenr_T Prenum)
long scrolled = 0; long scrolled = 0;
int i; int i;
if (Prenum) if (Prenum) {
curwin->w_p_scr = (Prenum > curwin->w_grid.Rows) ? curwin->w_p_scr = (Prenum > curwin->w_grid.Rows) ? curwin->w_grid.Rows
curwin->w_grid.Rows : Prenum; : Prenum;
}
assert(curwin->w_p_scr <= INT_MAX); assert(curwin->w_p_scr <= INT_MAX);
int n = curwin->w_p_scr <= curwin->w_grid.Rows ? (int)curwin->w_p_scr int n = curwin->w_p_scr <= curwin->w_grid.Rows ? (int)curwin->w_p_scr
: curwin->w_grid.Rows; : curwin->w_grid.Rows;

View File

@@ -3478,7 +3478,7 @@ static void display_showcmd(void)
* spaces * spaces
*/ */
grid_puts(&default_grid, (char_u *)" " + len, (int)Rows - 1, grid_puts(&default_grid, (char_u *)" " + len, (int)Rows - 1,
sc_col + len, 0); sc_col + len, 0);
setcursor(); /* put cursor back where it belongs */ setcursor(); /* put cursor back where it belongs */
} }
@@ -3914,10 +3914,8 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist)
} }
if (curwin->w_grid.Columns != 0) { if (curwin->w_grid.Columns != 0) {
/* // Instead of sticking at the last character of the buffer line we
* Instead of sticking at the last character of the buffer line we // try to stick in the last column of the screen.
* try to stick in the last column of the screen.
*/
if (curwin->w_curswant == MAXCOL) { if (curwin->w_curswant == MAXCOL) {
atend = true; atend = true;
validate_virtcol(); validate_virtcol();
@@ -4271,7 +4269,7 @@ dozet:
} }
break; break;
/* "zL" - scroll screen left half-page */ // "zL" - scroll screen left half-page
case 'L': cap->count1 *= curwin->w_grid.Columns / 2; case 'L': cap->count1 *= curwin->w_grid.Columns / 2;
FALLTHROUGH; FALLTHROUGH;
@@ -4309,10 +4307,11 @@ dozet:
else else
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col); getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col);
n = curwin->w_grid.Columns - curwin_col_off(); n = curwin->w_grid.Columns - curwin_col_off();
if (col + l_p_siso < n) if (col + l_p_siso < n) {
col = 0; col = 0;
else } else {
col = col + l_p_siso - n + 1; col = col + l_p_siso - n + 1;
}
if (curwin->w_leftcol != col) { if (curwin->w_leftcol != col) {
curwin->w_leftcol = col; curwin->w_leftcol = col;
redraw_later(NOT_VALID); redraw_later(NOT_VALID);
@@ -5017,11 +5016,11 @@ static void nv_scroll(cmdarg_T *cap)
/* Don't count filler lines above the window. */ /* Don't count filler lines above the window. */
used -= diff_check_fill(curwin, curwin->w_topline) used -= diff_check_fill(curwin, curwin->w_topline)
- curwin->w_topfill; - curwin->w_topfill;
validate_botline(); /* make sure w_empty_rows is valid */ validate_botline(); // make sure w_empty_rows is valid
half = (curwin->w_grid.Rows - curwin->w_empty_rows + 1) / 2; half = (curwin->w_grid.Rows - curwin->w_empty_rows + 1) / 2;
for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; ++n) { for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; n++) {
/* Count half he number of filler lines to be "below this // Count half he number of filler lines to be "below this
* line" and half to be "above the next line". */ // line" and half to be "above the next line".
if (n > 0 && used + diff_check_fill(curwin, curwin->w_topline if (n > 0 && used + diff_check_fill(curwin, curwin->w_topline
+ n) / 2 >= half) { + n) / 2 >= half) {
--n; --n;
@@ -5033,9 +5032,10 @@ static void nv_scroll(cmdarg_T *cap)
if (hasFolding(curwin->w_topline + n, NULL, &lnum)) if (hasFolding(curwin->w_topline + n, NULL, &lnum))
n = lnum - curwin->w_topline; n = lnum - curwin->w_topline;
} }
if (n > 0 && used > curwin->w_grid.Rows) if (n > 0 && used > curwin->w_grid.Rows) {
--n; n--;
} else { /* (cap->cmdchar == 'H') */ }
} else { // (cap->cmdchar == 'H')
n = cap->count1 - 1; n = cap->count1 - 1;
if (hasAnyFolding(curwin)) { if (hasAnyFolding(curwin)) {
/* Count a fold for one screen line. */ /* Count a fold for one screen line. */
@@ -6762,10 +6762,11 @@ static void nv_g_cmd(cmdarg_T *cap)
/* Go to the middle of the screen line. When 'number' or /* Go to the middle of the screen line. When 'number' or
* 'relativenumber' is on and lines are wrapping the middle can be more * 'relativenumber' is on and lines are wrapping the middle can be more
* to the left. */ * to the left. */
if (cap->nchar == 'm') if (cap->nchar == 'm') {
i += (curwin->w_grid.Columns - curwin_col_off() i += (curwin->w_grid.Columns - curwin_col_off()
+ ((curwin->w_p_wrap && i > 0) + ((curwin->w_p_wrap && i > 0)
? curwin_col_off2() : 0)) / 2; ? curwin_col_off2() : 0)) / 2;
}
coladvance((colnr_T)i); coladvance((colnr_T)i);
if (flag) { if (flag) {
do do

View File

@@ -423,8 +423,8 @@ void pum_redraw(void)
size++; size++;
} }
} }
grid_puts_len(&default_grid, rt, (int)STRLEN(rt), row, col - size + 1, grid_puts_len(&default_grid, rt, (int)STRLEN(rt), row,
attr); col - size + 1, attr);
xfree(rt_start); xfree(rt_start);
xfree(st); xfree(st);
col -= width; col -= width;
@@ -440,7 +440,8 @@ void pum_redraw(void)
// Display two spaces for a Tab. // Display two spaces for a Tab.
if (curwin->w_p_rl) { if (curwin->w_p_rl) {
grid_puts_len(&default_grid, (char_u *)" ", 2, row, col - 1, attr); grid_puts_len(&default_grid, (char_u *)" ", 2, row, col - 1,
attr);
col -= 2; col -= 2;
} else { } else {
grid_puts_len(&default_grid, (char_u *)" ", 2, row, col, attr); grid_puts_len(&default_grid, (char_u *)" ", 2, row, col, attr);
@@ -475,32 +476,33 @@ void pum_redraw(void)
if (curwin->w_p_rl) { if (curwin->w_p_rl) {
grid_fill(&default_grid, row, row + 1, pum_col - pum_base_width - n + 1, grid_fill(&default_grid, row, row + 1, pum_col - pum_base_width - n + 1,
col + 1, ' ', ' ', attr); col + 1, ' ', ' ', attr);
col = pum_col - pum_base_width - n + 1; col = pum_col - pum_base_width - n + 1;
} else { } else {
grid_fill(&default_grid, row, row + 1, col, pum_col + pum_base_width + n, grid_fill(&default_grid, row, row + 1, col,
' ', ' ', attr); pum_col + pum_base_width + n, ' ', ' ', attr);
col = pum_col + pum_base_width + n; col = pum_col + pum_base_width + n;
} }
totwidth = pum_base_width + n; totwidth = pum_base_width + n;
} }
if (curwin->w_p_rl) { if (curwin->w_p_rl) {
grid_fill(&default_grid, row, row + 1, pum_col - pum_width + 1, col + 1, ' ', ' ', grid_fill(&default_grid, row, row + 1, pum_col - pum_width + 1, col + 1,
attr); ' ', ' ', attr);
} else { } else {
grid_fill(&default_grid, row, row + 1, col, pum_col + pum_width, ' ', ' ', attr); grid_fill(&default_grid, row, row + 1, col, pum_col + pum_width, ' ', ' ',
attr);
} }
if (pum_scrollbar > 0) { if (pum_scrollbar > 0) {
if (curwin->w_p_rl) { if (curwin->w_p_rl) {
grid_putchar(&default_grid, ' ', row, pum_col - pum_width, grid_putchar(&default_grid, ' ', row, pum_col - pum_width,
i >= thumb_pos && i < thumb_pos + thumb_heigth i >= thumb_pos && i < thumb_pos + thumb_heigth
? attr_thumb : attr_scroll); ? attr_thumb : attr_scroll);
} else { } else {
grid_putchar(&default_grid, ' ', row, pum_col + pum_width, grid_putchar(&default_grid, ' ', row, pum_col + pum_width,
i >= thumb_pos && i < thumb_pos + thumb_heigth i >= thumb_pos && i < thumb_pos + thumb_heigth
? attr_thumb : attr_scroll); ? attr_thumb : attr_scroll);
} }
} }
grid_puts_line_flush(&default_grid, false); grid_puts_line_flush(&default_grid, false);

View File

@@ -686,15 +686,15 @@ static void win_update(win_T *wp)
wp->w_lines_valid = 0; wp->w_lines_valid = 0;
} }
/* Window is zero-height: nothing to draw. */ // Window is zero-height: nothing to draw.
if (wp->w_grid.Rows == 0) { if (wp->w_grid.Rows == 0) {
wp->w_redr_type = 0; wp->w_redr_type = 0;
return; return;
} }
/* Window is zero-width: Only need to draw the separator. */ // Window is zero-width: Only need to draw the separator.
if (wp->w_grid.Columns == 0) { if (wp->w_grid.Columns == 0) {
/* draw the vertical separator right of this window */ // draw the vertical separator right of this window
draw_vsep_win(wp, 0); draw_vsep_win(wp, 0);
wp->w_redr_type = 0; wp->w_redr_type = 0;
return; return;
@@ -882,15 +882,16 @@ static void win_update(win_T *wp)
/* count the number of lines we are off, counting a sequence /* count the number of lines we are off, counting a sequence
* of folded lines as one */ * of folded lines as one */
j = 0; j = 0;
for (ln = wp->w_topline; ln < wp->w_lines[0].wl_lnum; ++ln) { for (ln = wp->w_topline; ln < wp->w_lines[0].wl_lnum; ln++) {
++j; j++;
if (j >= wp->w_grid.Rows - 2) if (j >= wp->w_grid.Rows - 2) {
break; break;
}
(void)hasFoldingWin(wp, ln, NULL, &ln, true, NULL); (void)hasFoldingWin(wp, ln, NULL, &ln, true, NULL);
} }
} else } else
j = wp->w_lines[0].wl_lnum - wp->w_topline; j = wp->w_lines[0].wl_lnum - wp->w_topline;
if (j < wp->w_grid.Rows - 2) { /* not too far off */ 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); i = plines_m_win(wp, wp->w_topline, wp->w_lines[0].wl_lnum - 1);
/* insert extra lines for previously invisible filler lines */ /* insert extra lines for previously invisible filler lines */
if (wp->w_lines[0].wl_lnum != wp->w_topline) if (wp->w_lines[0].wl_lnum != wp->w_topline)
@@ -909,12 +910,15 @@ static void win_update(win_T *wp)
/* Move the entries that were scrolled, disable /* Move the entries that were scrolled, disable
* the entries for the lines to be redrawn. */ * the entries for the lines to be redrawn. */
if ((wp->w_lines_valid += j) > wp->w_grid.Rows) if ((wp->w_lines_valid += j) > wp->w_grid.Rows) {
wp->w_lines_valid = wp->w_grid.Rows; wp->w_lines_valid = wp->w_grid.Rows;
for (idx = wp->w_lines_valid; idx - j >= 0; idx--) }
for (idx = wp->w_lines_valid; idx - j >= 0; idx--) {
wp->w_lines[idx] = wp->w_lines[idx - j]; wp->w_lines[idx] = wp->w_lines[idx - j];
while (idx >= 0) }
wp->w_lines[idx--].wl_valid = FALSE; while (idx >= 0) {
wp->w_lines[idx--].wl_valid = false;
}
} }
} else } else
mid_start = 0; /* redraw all lines */ mid_start = 0; /* redraw all lines */
@@ -1159,7 +1163,7 @@ static void win_update(win_T *wp)
} }
srow += mid_start; srow += mid_start;
mid_end = wp->w_grid.Rows; mid_end = wp->w_grid.Rows;
for (; idx < wp->w_lines_valid; ++idx) { /* find end */ for (; idx < wp->w_lines_valid; idx++) { // find end
if (wp->w_lines[idx].wl_valid if (wp->w_lines[idx].wl_valid
&& wp->w_lines[idx].wl_lnum >= to + 1) { && wp->w_lines[idx].wl_lnum >= to + 1) {
/* Only update until first row of this line */ /* Only update until first row of this line */
@@ -1200,7 +1204,7 @@ static void win_update(win_T *wp)
/* stop updating when reached the end of the window (check for _past_ /* stop updating when reached the end of the window (check for _past_
* the end of the window is at the end of the loop) */ * the end of the window is at the end of the loop) */
if (row == wp->w_grid.Rows) { if (row == wp->w_grid.Rows) {
didline = TRUE; didline = true;
break; break;
} }
@@ -1299,7 +1303,7 @@ static void win_update(win_T *wp)
} }
j++; j++;
if (new_rows > wp->w_grid.Rows - row - 2) { if (new_rows > wp->w_grid.Rows - row - 2) {
/* it's getting too much, must redraw the rest */ // it's getting too much, must redraw the rest
new_rows = 9999; new_rows = 9999;
break; break;
} }
@@ -1365,10 +1369,12 @@ static void win_update(win_T *wp)
/* move entries in w_lines[] downwards */ /* move entries in w_lines[] downwards */
j -= i; j -= i;
wp->w_lines_valid += j; wp->w_lines_valid += j;
if (wp->w_lines_valid > wp->w_grid.Rows) if (wp->w_lines_valid > wp->w_grid.Rows) {
wp->w_lines_valid = wp->w_grid.Rows; wp->w_lines_valid = wp->w_grid.Rows;
for (i = wp->w_lines_valid; i - j >= idx; --i) }
for (i = wp->w_lines_valid; i - j >= idx; i--) {
wp->w_lines[i] = wp->w_lines[i - j]; wp->w_lines[i] = wp->w_lines[i - j];
}
/* The w_lines[] entries for inserted lines are /* The w_lines[] entries for inserted lines are
* now invalid, but wl_size may be used above. * now invalid, but wl_size may be used above.
@@ -1448,8 +1454,9 @@ static void win_update(win_T *wp)
// This line does not need to be drawn, advance to the next one. // This line does not need to be drawn, advance to the next one.
row += wp->w_lines[idx++].wl_size; row += wp->w_lines[idx++].wl_size;
if (row > wp->w_grid.Rows) /* past end of screen */ if (row > wp->w_grid.Rows) { // past end of screen
break; break;
}
lnum = wp->w_lines[idx - 1].wl_lastlnum + 1; lnum = wp->w_lines[idx - 1].wl_lastlnum + 1;
did_update = DID_NONE; did_update = DID_NONE;
} }
@@ -1489,7 +1496,7 @@ static void win_update(win_T *wp)
*/ */
wp->w_botline = lnum + 1; wp->w_botline = lnum + 1;
} else if (diff_check_fill(wp, lnum) >= wp->w_grid.Rows - srow) { } else if (diff_check_fill(wp, lnum) >= wp->w_grid.Rows - srow) {
/* Window ends in filler lines. */ // Window ends in filler lines.
wp->w_botline = lnum; wp->w_botline = lnum;
wp->w_filler_rows = wp->w_grid.Rows - srow; wp->w_filler_rows = wp->w_grid.Rows - srow;
} else if (dy_flags & DY_TRUNCATE) { // 'display' has "truncate" } else if (dy_flags & DY_TRUNCATE) { // 'display' has "truncate"
@@ -1524,8 +1531,9 @@ static void win_update(win_T *wp)
i = '-'; i = '-';
else else
i = fill_diff; i = fill_diff;
if (row + j > wp->w_grid.Rows) if (row + j > wp->w_grid.Rows) {
j = wp->w_grid.Rows - row; j = wp->w_grid.Rows - row;
}
win_draw_end(wp, i, i, row, row + (int)j, HLF_DED); win_draw_end(wp, i, i, row, row + (int)j, HLF_DED);
row += j; row += j;
} }
@@ -1613,9 +1621,10 @@ static void win_draw_end(win_T *wp, int c1, int c2, int row, int endrow, hlf_T h
n = fdc; n = fdc;
if (n > 0) { if (n > 0) {
/* draw the fold column at the right */ // draw the fold column at the right
if (n > wp->w_grid.Columns) if (n > wp->w_grid.Columns) {
n = wp->w_grid.Columns; n = wp->w_grid.Columns;
}
grid_fill(&wp->w_grid, row, endrow, wp->w_grid.Columns - n, grid_fill(&wp->w_grid, row, endrow, wp->w_grid.Columns - n,
wp->w_grid.Columns, ' ', ' ', win_hl_attr(wp, HLF_FC)); wp->w_grid.Columns, ' ', ' ', win_hl_attr(wp, HLF_FC));
} }
@@ -1623,7 +1632,7 @@ static void win_draw_end(win_T *wp, int c1, int c2, int row, int endrow, hlf_T h
if (signcolumn_on(wp)) { if (signcolumn_on(wp)) {
int nn = n + win_signcol_width(wp); int nn = n + win_signcol_width(wp);
/* draw the sign column left of the fold column */ // draw the sign column left of the fold column
if (nn > wp->w_grid.Columns) { if (nn > wp->w_grid.Columns) {
nn = wp->w_grid.Columns; nn = wp->w_grid.Columns;
} }
@@ -1641,17 +1650,19 @@ static void win_draw_end(win_T *wp, int c1, int c2, int row, int endrow, hlf_T h
if (cmdwin_type != 0 && wp == curwin) { if (cmdwin_type != 0 && wp == curwin) {
/* draw the cmdline character in the leftmost column */ /* draw the cmdline character in the leftmost column */
n = 1; n = 1;
if (n > wp->w_grid.Columns) if (n > wp->w_grid.Columns) {
n = wp->w_grid.Columns; n = wp->w_grid.Columns;
}
grid_fill(&wp->w_grid, row, endrow, 0, n, cmdwin_type, ' ', grid_fill(&wp->w_grid, row, endrow, 0, n, cmdwin_type, ' ',
win_hl_attr(wp, HLF_AT)); win_hl_attr(wp, HLF_AT));
} }
if (fdc > 0) { if (fdc > 0) {
int nn = n + fdc; int nn = n + fdc;
/* draw the fold column at the left */ // draw the fold column at the left
if (nn > wp->w_grid.Columns) if (nn > wp->w_grid.Columns) {
nn = wp->w_grid.Columns; nn = wp->w_grid.Columns;
}
grid_fill(&wp->w_grid, row, endrow, n, nn, ' ', ' ', grid_fill(&wp->w_grid, row, endrow, n, nn, ' ', ' ',
win_hl_attr(wp, HLF_FC)); win_hl_attr(wp, HLF_FC));
n = nn; n = nn;
@@ -1660,7 +1671,7 @@ static void win_draw_end(win_T *wp, int c1, int c2, int row, int endrow, hlf_T h
if (signcolumn_on(wp)) { if (signcolumn_on(wp)) {
int nn = n + win_signcol_width(wp); int nn = n + win_signcol_width(wp);
/* draw the sign column after the fold column */ // draw the sign column after the fold column
if (nn > wp->w_grid.Columns) { if (nn > wp->w_grid.Columns) {
nn = wp->w_grid.Columns; nn = wp->w_grid.Columns;
} }
@@ -1669,7 +1680,8 @@ static void win_draw_end(win_T *wp, int c1, int c2, int row, int endrow, hlf_T h
n = nn; n = nn;
} }
grid_fill(&wp->w_grid, row, endrow, FDC_OFF, wp->w_grid.Columns, c1, c2, attr); grid_fill(&wp->w_grid, row, endrow, FDC_OFF, wp->w_grid.Columns, c1, c2,
attr);
} }
set_empty_rows(wp, row); set_empty_rows(wp, row);
} }
@@ -1798,7 +1810,8 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
win_hl_attr(wp, HLF_FC)); win_hl_attr(wp, HLF_FC));
// reverse the fold column // reverse the fold column
for (i = 0; i < fdc; i++) { for (i = 0; i < fdc; i++) {
schar_from_ascii(linebuf_char[off + wp->w_grid.Columns - i - 1 - col], buf[i]); schar_from_ascii(linebuf_char[off + wp->w_grid.Columns - i - 1 - col],
buf[i]);
} }
} else { } else {
copy_text_attr(off + col, buf, fdc, win_hl_attr(wp, HLF_FC)); copy_text_attr(off + col, buf, fdc, win_hl_attr(wp, HLF_FC));
@@ -1806,12 +1819,15 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
col += fdc; col += fdc;
} }
# define RL_MEMSET(p, v, l) if (wp->w_p_rl) \ # define RL_MEMSET(p, v, l) if (wp->w_p_rl) { \
for (ri = 0; ri < l; ++ri) \ for (ri = 0; ri < l; ri++) { \
linebuf_attr[off + (wp->w_grid.Columns - (p) - (l)) + ri] = v; \ linebuf_attr[off + (wp->w_grid.Columns - (p) - (l)) + ri] = v; \
else \ } \
for (ri = 0; ri < l; ++ri) \ } else { \
linebuf_attr[off + (p) + ri] = v for (ri = 0; ri < l; ri++) { \
linebuf_attr[off + (p) + ri] = v; \
} \
}
/* Set all attributes of the 'number' or 'relativenumber' column and the /* Set all attributes of the 'number' or 'relativenumber' column and the
* text */ * text */
@@ -1945,14 +1961,15 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
>= (colnr_T)STRLEN(ml_get_buf(wp->w_buffer, lnume, >= (colnr_T)STRLEN(ml_get_buf(wp->w_buffer, lnume,
FALSE))))))) { FALSE))))))) {
if (VIsual_mode == Ctrl_V) { if (VIsual_mode == Ctrl_V) {
/* Visual block mode: highlight the chars part of the block */ // Visual block mode: highlight the chars part of the block
if (wp->w_old_cursor_fcol + txtcol < (colnr_T)wp->w_grid.Columns) { if (wp->w_old_cursor_fcol + txtcol < (colnr_T)wp->w_grid.Columns) {
if (wp->w_old_cursor_lcol != MAXCOL if (wp->w_old_cursor_lcol != MAXCOL
&& wp->w_old_cursor_lcol + txtcol && wp->w_old_cursor_lcol + txtcol
< (colnr_T)wp->w_grid.Columns) < (colnr_T)wp->w_grid.Columns) {
len = wp->w_old_cursor_lcol; len = wp->w_old_cursor_lcol;
else } else {
len = wp->w_grid.Columns - txtcol; len = wp->w_grid.Columns - txtcol;
}
RL_MEMSET(wp->w_old_cursor_fcol + txtcol, win_hl_attr(wp, HLF_V), RL_MEMSET(wp->w_old_cursor_fcol + txtcol, win_hl_attr(wp, HLF_V),
len - (int)wp->w_old_cursor_fcol); len - (int)wp->w_old_cursor_fcol);
} }
@@ -2854,10 +2871,11 @@ win_line (
c_extra = '-'; c_extra = '-';
else else
c_extra = fill_diff; c_extra = fill_diff;
if (wp->w_p_rl) if (wp->w_p_rl) {
n_extra = col + 1; n_extra = col + 1;
else } else {
n_extra = grid->Columns - col; n_extra = grid->Columns - col;
}
char_attr = win_hl_attr(wp, HLF_DED); char_attr = win_hl_attr(wp, HLF_DED);
} }
if (*p_sbr != NUL && need_showbreak) { if (*p_sbr != NUL && need_showbreak) {
@@ -3126,9 +3144,8 @@ win_line (
/* If a double-width char doesn't fit display a '>' in the /* If a double-width char doesn't fit display a '>' in the
* last column. */ * last column. */
if (( if ((wp->w_p_rl ? (col <= 0) :
wp->w_p_rl ? (col <= 0) : (col >= grid->Columns - 1))
(col >= grid->Columns - 1))
&& (*mb_char2cells)(mb_c) == 2) { && (*mb_char2cells)(mb_c) == 2) {
c = '>'; c = '>';
mb_c = c; mb_c = c;
@@ -3268,9 +3285,8 @@ win_line (
/* If a double-width char doesn't fit display a '>' in the /* If a double-width char doesn't fit display a '>' in the
* last column; the character is displayed at the start of the * last column; the character is displayed at the start of the
* next line. */ * next line. */
if (( if ((wp->w_p_rl ? (col <= 0) :
wp->w_p_rl ? (col <= 0) : (col >= grid->Columns - 1))
(col >= grid->Columns - 1))
&& (*mb_char2cells)(mb_c) == 2) { && (*mb_char2cells)(mb_c) == 2) {
c = '>'; c = '>';
mb_c = c; mb_c = c;
@@ -3601,9 +3617,7 @@ win_line (
|| ((fromcol >= 0 || fromcol_prev >= 0) || ((fromcol >= 0 || fromcol_prev >= 0)
&& tocol > vcol && tocol > vcol
&& VIsual_mode != Ctrl_V && VIsual_mode != Ctrl_V
&& ( && (wp->w_p_rl ? (col >= 0) : (col < grid->Columns))
wp->w_p_rl ? (col >= 0) :
(col < grid->Columns))
&& !(noinvcur && !(noinvcur
&& lnum == wp->w_cursor.lnum && lnum == wp->w_cursor.lnum
&& (colnr_T)vcol == wp->w_virtcol))) && (colnr_T)vcol == wp->w_virtcol)))
@@ -3668,14 +3682,11 @@ win_line (
saved_attr2 = char_attr; // save current attr saved_attr2 = char_attr; // save current attr
mb_utf8 = false; // don't draw as UTF-8 mb_utf8 = false; // don't draw as UTF-8
} else if (VIsual_active } else if (VIsual_active
&& (VIsual_mode == Ctrl_V && (VIsual_mode == Ctrl_V || VIsual_mode == 'v')
|| VIsual_mode == 'v')
&& virtual_active() && virtual_active()
&& tocol != MAXCOL && tocol != MAXCOL
&& vcol < tocol && vcol < tocol
&& ( && (wp->w_p_rl ? (col >= 0) : (col < grid->Columns))) {
wp->w_p_rl ? (col >= 0) :
(col < grid->Columns))) {
c = ' '; c = ' ';
ptr--; // put it back at the NUL ptr--; // put it back at the NUL
} }
@@ -3833,8 +3844,9 @@ win_line (
if (col < 0) if (col < 0)
n = 1; n = 1;
} else { } else {
if (col >= grid->Columns) if (col >= grid->Columns) {
n = -1; n = -1;
}
} }
if (n != 0) { if (n != 0) {
/* At the window boundary, highlight the last character /* At the window boundary, highlight the last character
@@ -4023,7 +4035,7 @@ win_line (
} }
} }
grid_put_linebuf(grid, row, 0, col, grid->Columns, wp->w_p_rl, wp, grid_put_linebuf(grid, row, 0, col, grid->Columns, wp->w_p_rl, wp,
wp->w_hl_attr_normal, false); wp->w_hl_attr_normal, false);
row++; row++;
/* /*
@@ -4044,9 +4056,7 @@ win_line (
if (lcs_ext if (lcs_ext
&& !wp->w_p_wrap && !wp->w_p_wrap
&& filler_todo <= 0 && filler_todo <= 0
&& ( && (wp->w_p_rl ? col == 0 : col == grid->Columns - 1)
wp->w_p_rl ? col == 0 :
col == grid->Columns - 1)
&& (*ptr != NUL && (*ptr != NUL
|| (wp->w_p_list && lcs_eol_one > 0) || (wp->w_p_list && lcs_eol_one > 0)
|| (n_extra && (c_extra != NUL || *p_extra != NUL)))) { || (n_extra && (c_extra != NUL || *p_extra != NUL)))) {
@@ -4225,9 +4235,7 @@ win_line (
* At end of screen line and there is more to come: Display the line * At end of screen line and there is more to come: Display the line
* so far. If there is no more to display it is caught above. * so far. If there is no more to display it is caught above.
*/ */
if (( if ((wp->w_p_rl ? (col < 0) : (col >= grid->Columns))
wp->w_p_rl ? (col < 0) :
(col >= grid->Columns))
&& (*ptr != NUL && (*ptr != NUL
|| filler_todo > 0 || filler_todo > 0
|| (wp->w_p_list && lcs_eol != NUL && p_extra != at_end_str) || (wp->w_p_list && lcs_eol != NUL && p_extra != at_end_str)
@@ -4260,7 +4268,7 @@ win_line (
} }
boguscols = 0; boguscols = 0;
++row; row++;
/* When not wrapping and finished diff lines, or when displayed /* When not wrapping and finished diff lines, or when displayed
* '$' and highlighting until last column, break here. */ * '$' and highlighting until last column, break here. */
@@ -4286,7 +4294,7 @@ win_line (
col = 0; col = 0;
off = 0; off = 0;
if (wp->w_p_rl) { if (wp->w_p_rl) {
col = grid->Columns - 1; /* col is not used if breaking! */ col = grid->Columns - 1; // col is not used if breaking!
off += col; off += col;
} }
@@ -4366,15 +4374,13 @@ static void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol,
// 2: occupies two display cells // 2: occupies two display cells
int start_dirty = -1, end_dirty = 0; int start_dirty = -1, end_dirty = 0;
if (grid == NULL) { // Check for illegal row and col, just in case
grid = &default_grid; if (row >= grid->Rows) {
}
/* Check for illegal row and col, just in case. */
if (row >= grid->Rows)
row = grid->Rows - 1; row = grid->Rows - 1;
if (endcol > grid->Columns) }
if (endcol > grid->Columns) {
endcol = grid->Columns; endcol = grid->Columns;
}
// If UI is not externalized, merge the contents of global and window grids // If UI is not externalized, merge the contents of global and window grids
if (!ui_is_external(kUIMultigrid) && grid != &default_grid) { if (!ui_is_external(kUIMultigrid) && grid != &default_grid) {
@@ -4690,7 +4696,8 @@ win_redr_status_matches (
if (matches == NULL) /* interrupted completion? */ if (matches == NULL) /* interrupted completion? */
return; return;
buf = xmalloc(has_mbyte ? default_grid.Columns * MB_MAXBYTES + 1 : default_grid.Columns + 1); buf = xmalloc(has_mbyte ? default_grid.Columns * MB_MAXBYTES + 1
: default_grid.Columns + 1);
if (match == -1) { /* don't show match but original text */ if (match == -1) { /* don't show match but original text */
match = 0; match = 0;
@@ -4710,15 +4717,16 @@ win_redr_status_matches (
clen += status_match_len(xp, L_MATCH(i)) + 2; clen += status_match_len(xp, L_MATCH(i)) + 2;
if (first_match > 0) if (first_match > 0)
clen += 2; clen += 2;
/* jumping right, put match at the left */ // jumping right, put match at the left
if ((long)clen > default_grid.Columns) { if ((long)clen > default_grid.Columns) {
first_match = match; 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; clen = 2;
for (i = match; i < num_matches; ++i) { for (i = match; i < num_matches; ++i) {
clen += status_match_len(xp, L_MATCH(i)) + 2; clen += status_match_len(xp, L_MATCH(i)) + 2;
if ((long)clen >= default_grid.Columns) if ((long)clen >= default_grid.Columns) {
break; break;
}
} }
if (i == num_matches) if (i == num_matches)
add_left = TRUE; add_left = TRUE;
@@ -4727,9 +4735,10 @@ win_redr_status_matches (
if (add_left) if (add_left)
while (first_match > 0) { while (first_match > 0) {
clen += status_match_len(xp, L_MATCH(first_match - 1)) + 2; clen += status_match_len(xp, L_MATCH(first_match - 1)) + 2;
if ((long)clen >= default_grid.Columns) if ((long)clen >= default_grid.Columns) {
break; break;
--first_match; }
first_match--;
} }
fillchar = fillchar_status(&attr, curwin); fillchar = fillchar_status(&attr, curwin);
@@ -4744,7 +4753,8 @@ win_redr_status_matches (
clen = len; clen = len;
i = first_match; i = first_match;
while ((long)(clen + status_match_len(xp, L_MATCH(i)) + 2) < default_grid.Columns) { while ((long)(clen + status_match_len(xp, L_MATCH(i)) + 2)
< default_grid.Columns) {
if (i == match) { if (i == match) {
selstart = buf + len; selstart = buf + len;
selstart_col = clen; selstart_col = clen;
@@ -5109,12 +5119,13 @@ win_redr_custom (
stl = p_ruf; stl = p_ruf;
} }
col = ru_col - (default_grid.Columns - wp->w_width); col = ru_col - (default_grid.Columns - wp->w_width);
if (col < (wp->w_width + 1) / 2) if (col < (wp->w_width + 1) / 2) {
col = (wp->w_width + 1) / 2; col = (wp->w_width + 1) / 2;
}
maxwidth = wp->w_width - col; maxwidth = wp->w_width - col;
if (!wp->w_status_height) { if (!wp->w_status_height) {
row = default_grid.Rows - 1; row = default_grid.Rows - 1;
--maxwidth; /* writing in last column may cause scrolling */ maxwidth--; // writing in last column may cause scrolling
fillchar = ' '; fillchar = ' ';
attr = 0; attr = 0;
} }
@@ -5186,7 +5197,8 @@ win_redr_custom (
curattr = highlight_user[hltab[n].userhl - 1]; curattr = highlight_user[hltab[n].userhl - 1];
} }
// Make sure to use an empty string instead of p, if p is beyond buf + len. // Make sure to use an empty string instead of p, if p is beyond buf + len.
grid_puts(&default_grid, p >= buf + len ? (char_u *)"" : p, row, col, curattr); grid_puts(&default_grid, p >= buf + len ? (char_u *)"" : p, row, col,
curattr);
grid_puts_line_flush(&default_grid, false); grid_puts_line_flush(&default_grid, false);
@@ -5318,7 +5330,7 @@ void grid_putchar(ScreenGrid *grid, int c, int row, int col, int attr)
/// get a single character directly from grid.ScreenLines into "bytes[]". /// get a single character directly from grid.ScreenLines into "bytes[]".
/// Also return its attribute in *attrp; /// Also return its attribute in *attrp;
void grid_getbytes(ScreenGrid *grid, int row, int col, char_u *bytes, void grid_getbytes(ScreenGrid *grid, int row, int col, char_u *bytes,
int *attrp) int *attrp)
{ {
unsigned off; unsigned off;
@@ -5383,10 +5395,6 @@ void grid_puts_len(ScreenGrid *grid, char_u *text, int textlen, int row,
int need_redraw; int need_redraw;
bool do_flush = false; bool do_flush = false;
if (grid == NULL) {
grid = &default_grid;
}
// If UI is not externalized, keep working on the default grid // If UI is not externalized, keep working on the default grid
if (!ui_is_external(kUIMultigrid) && grid != &default_grid) { if (!ui_is_external(kUIMultigrid) && grid != &default_grid) {
row += grid->OffsetRow; row += grid->OffsetRow;
@@ -5536,7 +5544,7 @@ void grid_puts_line_flush(ScreenGrid *grid, bool set_cursor)
ui_grid_cursor_goto(grid, put_dirty_row, put_dirty_last); ui_grid_cursor_goto(grid, put_dirty_row, put_dirty_last);
} }
ui_line(grid, put_dirty_row, put_dirty_first, put_dirty_last, ui_line(grid, put_dirty_row, put_dirty_first, put_dirty_last,
put_dirty_last, 0, false); put_dirty_last, 0, false);
put_dirty_first = -1; put_dirty_first = -1;
put_dirty_last = 0; put_dirty_last = 0;
} }
@@ -5843,14 +5851,10 @@ next_search_hl_pos(
/// with character 'c1' in first column followed by 'c2' in the other columns. /// with character 'c1' in first column followed by 'c2' in the other columns.
/// Use attributes 'attr'. /// Use attributes 'attr'.
void grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col, void grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col,
int end_col, int c1, int c2, int attr) int end_col, int c1, int c2, int attr)
{ {
schar_T sc; schar_T sc;
if (grid == NULL) {
grid = &default_grid;
}
// if grids are not externalized, keep working on the default_grid // if grids are not externalized, keep working on the default_grid
if (!ui_is_external(kUIMultigrid) && grid != &default_grid) { if (!ui_is_external(kUIMultigrid) && grid != &default_grid) {
start_row += grid->OffsetRow; start_row += grid->OffsetRow;
@@ -5860,14 +5864,20 @@ void grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col,
grid = &default_grid; grid = &default_grid;
} }
if (end_row > grid->Rows) // safety check // safety check
if (end_row > grid->Rows) {
end_row = grid->Rows; end_row = grid->Rows;
if (end_col > grid->Columns) // safety check }
if (end_col > grid->Columns) {
end_col = grid->Columns; end_col = grid->Columns;
}
// nothing to do
if (grid->ScreenLines == NULL if (grid->ScreenLines == NULL
|| start_row >= end_row || start_row >= end_row
|| start_col >= end_col) /* nothing to do */ || start_col >= end_col) {
return; return;
}
for (int row = start_row; row < end_row; row++) { for (int row = start_row; row < end_row; row++) {
if (has_mbyte) { if (has_mbyte) {
@@ -5966,7 +5976,7 @@ void check_for_delay(int check_msg_scroll)
*/ */
int screen_valid(int doclear) int screen_valid(int doclear)
{ {
screenalloc(doclear); /* allocate screen buffers if size changed */ screenalloc(doclear); // allocate screen buffers if size changed
return default_grid.ScreenLines != NULL; return default_grid.ScreenLines != NULL;
} }
@@ -6244,11 +6254,11 @@ static void screenclear2(void)
return; return;
} }
/* blank out ScreenLines */ // blank out ScreenLines
for (i = 0; i < default_grid.Rows; ++i) { for (i = 0; i < default_grid.Rows; i++) {
grid_clear_line(&default_grid, default_grid.LineOffset[i], grid_clear_line(&default_grid, default_grid.LineOffset[i],
(int)default_grid.Columns, true); (int)default_grid.Columns, true);
default_grid.LineWraps[i] = FALSE; default_grid.LineWraps[i] = false;
} }
ui_call_grid_clear(1); // clear the display ui_call_grid_clear(1); // clear the display
@@ -6334,7 +6344,7 @@ static int win_do_lines(win_T *wp, int row, int line_count, int del)
} }
// No lines are being moved, just draw over the entire area // No lines are being moved, just draw over the entire area
if (row + line_count >= wp->w_height) { if (row + line_count >= wp->w_grid.Rows) {
return OK; return OK;
} }
@@ -6372,17 +6382,13 @@ static int win_do_lines(win_T *wp, int row, int line_count, int del)
/// 'row', 'col' and 'end' are relative to the start of the region. /// 'row', 'col' and 'end' are relative to the start of the region.
/// ///
/// @return FAIL for failure, OK for success. /// @return FAIL for failure, OK for success.
int grid_ins_lines(ScreenGrid *grid, int row, int line_count, int end, int grid_ins_lines(ScreenGrid *grid, int row, int line_count, int end, int col,
int col, int width) int width)
{ {
int i; int i;
int j; int j;
unsigned temp; unsigned temp;
if (grid == NULL) {
grid = &default_grid;
}
// If UI is not externalized, keep working on default grid // If UI is not externalized, keep working on default grid
if (!ui_is_external(kUIMultigrid) && grid != &default_grid) { if (!ui_is_external(kUIMultigrid) && grid != &default_grid) {
row += grid->OffsetRow; row += grid->OffsetRow;
@@ -6431,17 +6437,13 @@ int grid_ins_lines(ScreenGrid *grid, int row, int line_count, int end,
/// 'row' and 'end' are relative to the start of the region. /// 'row' and 'end' are relative to the start of the region.
/// ///
/// Return OK for success, FAIL if the lines are not deleted. /// Return OK for success, FAIL if the lines are not deleted.
int grid_del_lines(ScreenGrid *grid, int row, int line_count, int end, int grid_del_lines(ScreenGrid *grid, int row, int line_count, int end, int col,
int col, int width) int width)
{ {
int j; int j;
int i; int i;
unsigned temp; unsigned temp;
if (grid == NULL) {
grid = &default_grid;
}
// If UI is not externalized, keep working on default grid // If UI is not externalized, keep working on default grid
if (!ui_is_external(kUIMultigrid) && grid != &default_grid) { if (!ui_is_external(kUIMultigrid) && grid != &default_grid) {
row += grid->OffsetRow; row += grid->OffsetRow;
@@ -6527,8 +6529,9 @@ int showmode(void)
/* 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; need_clear = clear_cmdline;
if (clear_cmdline && cmdline_row < default_grid.Rows - 1) if (clear_cmdline && cmdline_row < default_grid.Rows - 1) {
msg_clr_cmdline(); /* will reset clear_cmdline */ 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(); msg_pos_mode();
@@ -6547,8 +6550,9 @@ int showmode(void)
/* These messages can get long, avoid a wrap in a narrow /* These messages can get long, avoid a wrap in a narrow
* window. Prefer showing edit_submode_extra. */ * window. Prefer showing edit_submode_extra. */
length = (default_grid.Rows - msg_row) * default_grid.Columns - 3; length = (default_grid.Rows - msg_row) * default_grid.Columns - 3;
if (edit_submode_extra != NULL) if (edit_submode_extra != NULL) {
length -= vim_strsize(edit_submode_extra); length -= vim_strsize(edit_submode_extra);
}
if (length > 0) { if (length > 0) {
if (edit_submode_pre != NULL) if (edit_submode_pre != NULL)
length -= vim_strsize(edit_submode_pre); length -= vim_strsize(edit_submode_pre);
@@ -6821,7 +6825,7 @@ static void draw_tabline(void)
break; break;
} }
grid_puts_len(&default_grid, NameBuff, len, 0, col, grid_puts_len(&default_grid, NameBuff, len, 0, col,
hl_combine_attr(attr, win_hl_attr(cwp, HLF_T))); hl_combine_attr(attr, win_hl_attr(cwp, HLF_T)));
col += len; col += len;
} }
if (modified) { if (modified) {
@@ -6846,8 +6850,9 @@ static void draw_tabline(void)
p += len - room; p += len - room;
len = room; len = room;
} }
if (len > default_grid.Columns - col - 1) if (len > default_grid.Columns - col - 1) {
len = default_grid.Columns - col - 1; len = default_grid.Columns - col - 1;
}
grid_puts_len(&default_grid, p, (int)STRLEN(p), 0, col, attr); grid_puts_len(&default_grid, p, (int)STRLEN(p), 0, col, attr);
col += len; col += len;
@@ -6870,11 +6875,13 @@ static void draw_tabline(void)
c = '_'; c = '_';
else else
c = ' '; c = ' ';
grid_fill(&default_grid, 0, 1, col, (int)default_grid.Columns, c, c, attr_fill); grid_fill(&default_grid, 0, 1, col, (int)default_grid.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) { if (first_tabpage->tp_next != NULL) {
grid_putchar(&default_grid, 'X', 0, (int)default_grid.Columns - 1, attr_nosel); grid_putchar(&default_grid, 'X', 0, (int)default_grid.Columns - 1,
attr_nosel);
tab_page_click_defs[default_grid.Columns - 1] = (StlClickDefinition) { tab_page_click_defs[default_grid.Columns - 1] = (StlClickDefinition) {
.type = kStlClickTabClose, .type = kStlClickTabClose,
.tabnr = 999, .tabnr = 999,
@@ -7109,15 +7116,18 @@ static void win_redr_ruler(win_T *wp, int always)
int i = (int)STRLEN(buffer); int i = (int)STRLEN(buffer);
get_rel_pos(wp, buffer + i + 1, RULER_BUF_LEN - i - 1); get_rel_pos(wp, buffer + i + 1, RULER_BUF_LEN - i - 1);
int o = i + vim_strsize(buffer + i + 1); int o = i + vim_strsize(buffer + i + 1);
if (wp->w_status_height == 0) /* can't use last char of screen */ if (wp->w_status_height == 0) { // can't use last char of screen
++o; o++;
}
int this_ru_col = ru_col - (default_grid.Columns - width); int this_ru_col = ru_col - (default_grid.Columns - width);
if (this_ru_col < 0) if (this_ru_col < 0) {
this_ru_col = 0; this_ru_col = 0;
/* Never use more than half the window/screen width, leave the other }
* half for the filename. */ // Never use more than half the window/screen width, leave the other half
if (this_ru_col < (width + 1) / 2) // for the filename.
if (this_ru_col < (width + 1) / 2) {
this_ru_col = (width + 1) / 2; this_ru_col = (width + 1) / 2;
}
if (this_ru_col + o < width) { if (this_ru_col + o < width) {
// Need at least 3 chars left for get_rel_pos() + NUL. // Need at least 3 chars left for get_rel_pos() + NUL.
while (this_ru_col + o < width && RULER_BUF_LEN > i + 4) { while (this_ru_col + o < width && RULER_BUF_LEN > i + 4) {
@@ -7139,10 +7149,9 @@ static void win_redr_ruler(win_T *wp, int always)
grid_puts(&default_grid, buffer, row, this_ru_col + off, attr); grid_puts(&default_grid, buffer, row, this_ru_col + off, attr);
i = redraw_cmdline; i = redraw_cmdline;
grid_fill(&default_grid, row, row + 1, grid_fill(&default_grid, row, row + 1,
this_ru_col + off + (int)STRLEN(buffer), this_ru_col + off + (int)STRLEN(buffer), off + width, fillchar,
off + width, fillchar, attr);
fillchar, fillchar, attr); // don't redraw the cmdline because of showing the ruler
/* don't redraw the cmdline because of showing the ruler */
redraw_cmdline = i; redraw_cmdline = i;
wp->w_ru_cursor = wp->w_cursor; wp->w_ru_cursor = wp->w_cursor;
wp->w_ru_virtcol = wp->w_virtcol; wp->w_ru_virtcol = wp->w_virtcol;
@@ -7163,12 +7172,13 @@ int number_width(win_T *wp)
int n; int n;
linenr_T lnum; linenr_T lnum;
if (wp->w_p_rnu && !wp->w_p_nu) if (wp->w_p_rnu && !wp->w_p_nu) {
/* cursor line shows "0" */ // cursor line shows "0"
lnum = wp->w_grid.Rows; lnum = wp->w_grid.Rows;
else } else {
/* cursor line shows absolute line number */ // cursor line shows absolute line number
lnum = wp->w_buffer->b_ml.ml_line_count; 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; return wp->w_nrwidth_width;

View File

@@ -2166,9 +2166,10 @@ showmatch(
if (!curwin->w_p_wrap) { if (!curwin->w_p_wrap) {
getvcol(curwin, lpos, NULL, &vcol, NULL); getvcol(curwin, lpos, NULL, &vcol, NULL);
} }
if (curwin->w_p_wrap || (vcol >= curwin->w_leftcol if (curwin->w_p_wrap
&& vcol < curwin->w_leftcol + curwin->w_grid.Columns)) { || (vcol >= curwin->w_leftcol
mpos = *lpos; /* save the pos, update_screen() may change it */ && vcol < curwin->w_leftcol + curwin->w_grid.Columns)) {
mpos = *lpos; // save the pos, update_screen() may change it
save_cursor = curwin->w_cursor; save_cursor = curwin->w_cursor;
save_so = p_so; save_so = p_so;
save_siso = p_siso; save_siso = p_siso;

View File

@@ -349,7 +349,8 @@ void ui_grid_cursor_goto(ScreenGrid *grid, int new_row, int new_col)
{ {
new_row += ui_is_external(kUIMultigrid) ? 0 : grid->OffsetRow; new_row += ui_is_external(kUIMultigrid) ? 0 : grid->OffsetRow;
new_col += ui_is_external(kUIMultigrid) ? 0 : grid->OffsetColumn; new_col += ui_is_external(kUIMultigrid) ? 0 : grid->OffsetColumn;
int handle = ui_is_external(kUIMultigrid) ? grid->handle : DEFAULT_GRID_HANDLE; int handle = ui_is_external(kUIMultigrid) ? grid->handle
: DEFAULT_GRID_HANDLE;
if (new_row == row && new_col == col && handle == cursor_grid_handle) { if (new_row == row && new_col == col && handle == cursor_grid_handle) {
return; return;
@@ -451,7 +452,8 @@ void ui_grid_resize(GridHandle grid_handle, int width, int height, Error *error)
win_T *wp = get_win_by_grid_handle(grid_handle); win_T *wp = get_win_by_grid_handle(grid_handle);
if (wp == NULL) { if (wp == NULL) {
api_set_error(error, kErrorTypeValidation, "No window with the given handle"); api_set_error(error, kErrorTypeValidation,
"No window with the given handle");
return; return;
} }

View File

@@ -4230,7 +4230,7 @@ static void frame_comp_pos(frame_T *topfrp, int *row, int *col)
wp->w_winrow = *row; wp->w_winrow = *row;
wp->w_wincol = *col; wp->w_wincol = *col;
redraw_win_later(wp, NOT_VALID); redraw_win_later(wp, NOT_VALID);
wp->w_redr_status = TRUE; wp->w_redr_status = true;
wp->w_pos_changed = true; wp->w_pos_changed = true;
} }
*row += wp->w_height + wp->w_status_height; *row += wp->w_height + wp->w_status_height;
@@ -4285,8 +4285,9 @@ void win_setheight_win(int height, win_T *win)
* If there is extra space created between the last window and the command * If there is extra space created between the last window and the command
* line, clear it. * line, clear it.
*/ */
if (full_screen && msg_scrolled == 0 && row < cmdline_row) if (full_screen && msg_scrolled == 0 && row < cmdline_row) {
grid_fill(&default_grid, row, cmdline_row, 0, (int)Columns, ' ', ' ', 0); grid_fill(&default_grid, row, cmdline_row, 0, (int)Columns, ' ', ' ', 0);
}
cmdline_row = row; cmdline_row = row;
msg_row = row; msg_row = row;
msg_col = 0; msg_col = 0;
@@ -5086,10 +5087,11 @@ void command_height(void)
/* Recompute window positions. */ /* Recompute window positions. */
(void)win_comp_pos(); (void)win_comp_pos();
/* clear the lines added to cmdline */ // clear the lines added to cmdline
if (full_screen) if (full_screen) {
grid_fill(&default_grid, cmdline_row, (int)Rows, 0, grid_fill(&default_grid, cmdline_row, (int)Rows, 0, (int)Columns, ' ',
(int)Columns, ' ', ' ', 0); ' ', 0);
}
msg_row = cmdline_row; msg_row = cmdline_row;
redraw_cmdline = TRUE; redraw_cmdline = TRUE;
return; return;
@@ -6073,7 +6075,7 @@ void win_ui_flush(void)
} }
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
if(wp->w_pos_changed && wp->w_grid.ScreenLines != NULL) { if (wp->w_pos_changed && wp->w_grid.ScreenLines != NULL) {
ui_call_win_position(wp->handle, wp->w_grid.handle, wp->w_winrow, ui_call_win_position(wp->handle, wp->w_grid.handle, wp->w_winrow,
wp->w_wincol, wp->w_width, wp->w_height); wp->w_wincol, wp->w_width, wp->w_height);
wp->w_pos_changed = false; wp->w_pos_changed = false;