multigrid: Draw fold for the entire width of window grid

This commit is contained in:
Utkarsh Maheshwari
2018-09-14 20:10:06 +05:30
committed by Björn Linse
parent f241930472
commit 8b47b56fc6

View File

@@ -1764,7 +1764,6 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
int txtcol; int txtcol;
int off; int off;
int ri; int ri;
ScreenGrid *grid = &wp->w_grid;
/* Build the fold line: /* Build the fold line:
* 1. Add the cmdwin_type for the command-line window * 1. Add the cmdwin_type for the command-line window
@@ -1795,11 +1794,11 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
if (wp->w_p_rl) { if (wp->w_p_rl) {
int i; int i;
copy_text_attr(off + wp->w_width - fdc - col, buf, fdc, copy_text_attr(off + wp->w_grid.Columns - fdc - col, buf, fdc,
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_width - 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));
@@ -1809,18 +1808,18 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
# 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_width - (p) - (l)) + ri] = v; \ linebuf_attr[off + (wp->w_grid.Columns - (p) - (l)) + ri] = v; \
else \ else \
for (ri = 0; ri < l; ++ri) \ for (ri = 0; ri < l; ++ri) \
linebuf_attr[off + (p) + ri] = v 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 */
RL_MEMSET(col, win_hl_attr(wp, HLF_FL), wp->w_width - col); RL_MEMSET(col, win_hl_attr(wp, HLF_FL), wp->w_grid.Columns - col);
// If signs are being displayed, add spaces. // If signs are being displayed, add spaces.
if (signcolumn_on(wp)) { if (signcolumn_on(wp)) {
len = wp->w_width - col; len = wp->w_grid.Columns - col;
if (len > 0) { if (len > 0) {
int len_max = win_signcol_width(wp); int len_max = win_signcol_width(wp);
if (len > len_max) { if (len > len_max) {
@@ -1836,7 +1835,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
* 3. Add the 'number' or 'relativenumber' column * 3. Add the 'number' or 'relativenumber' column
*/ */
if (wp->w_p_nu || wp->w_p_rnu) { if (wp->w_p_nu || wp->w_p_rnu) {
len = wp->w_width - col; len = wp->w_grid.Columns - col;
if (len > 0) { if (len > 0) {
int w = number_width(wp); int w = number_width(wp);
long num; long num;
@@ -1862,7 +1861,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
snprintf((char *)buf, FOLD_TEXT_LEN, fmt, w, num); snprintf((char *)buf, FOLD_TEXT_LEN, fmt, w, num);
if (wp->w_p_rl) { if (wp->w_p_rl) {
// the line number isn't reversed // the line number isn't reversed
copy_text_attr(off + wp->w_width - len - col, buf, len, copy_text_attr(off + wp->w_grid.Columns - len - col, buf, len,
win_hl_attr(wp, HLF_FL)); win_hl_attr(wp, HLF_FL));
} else { } else {
copy_text_attr(off + col, buf, len, win_hl_attr(wp, HLF_FL)); copy_text_attr(off + col, buf, len, win_hl_attr(wp, HLF_FL));
@@ -1896,7 +1895,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
// if(col + cells > wp->w_width - (wp->w_p_rl ? col : 0)) { break; } // if(col + cells > wp->w_width - (wp->w_p_rl ? col : 0)) { break; }
// This is obvious wrong. If Vim ever fixes this, solve for "cells" again // This is obvious wrong. If Vim ever fixes this, solve for "cells" again
// in the correct condition. // in the correct condition.
int maxcells = grid->Columns - col - (wp->w_p_rl ? col : 0); int maxcells = wp->w_grid.Columns - col - (wp->w_p_rl ? col : 0);
int cells = line_putchar(&s, &linebuf_char[idx], maxcells, wp->w_p_rl); int cells = line_putchar(&s, &linebuf_char[idx], maxcells, wp->w_p_rl);
if (cells == -1) { if (cells == -1) {
break; break;
@@ -1911,7 +1910,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
schar_T sc; schar_T sc;
schar_from_char(sc, fill_fold); schar_from_char(sc, fill_fold);
while (col < wp->w_width while (col < wp->w_grid.Columns
- (wp->w_p_rl ? txtcol : 0) - (wp->w_p_rl ? txtcol : 0)
) { ) {
schar_copy(linebuf_char[off+col++], sc); schar_copy(linebuf_char[off+col++], sc);
@@ -1947,19 +1946,19 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
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_width) { 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_width) < (colnr_T)wp->w_grid.Columns)
len = wp->w_old_cursor_lcol; len = wp->w_old_cursor_lcol;
else else
len = wp->w_width - 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);
} }
} else { } else {
// Set all attributes of the text // Set all attributes of the text
RL_MEMSET(txtcol, win_hl_attr(wp, HLF_V), wp->w_width - txtcol); RL_MEMSET(txtcol, win_hl_attr(wp, HLF_V), wp->w_grid.Columns - txtcol);
} }
} }
} }
@@ -1977,7 +1976,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
} else { } else {
txtcol -= wp->w_leftcol; txtcol -= wp->w_leftcol;
} }
if (txtcol >= 0 && txtcol < wp->w_width) { if (txtcol >= 0 && txtcol < wp->w_grid.Columns) {
linebuf_attr[off + txtcol] = linebuf_attr[off + txtcol] =
hl_combine_attr(linebuf_attr[off + txtcol], win_hl_attr(wp, HLF_MC)); hl_combine_attr(linebuf_attr[off + txtcol], win_hl_attr(wp, HLF_MC));
} }
@@ -1993,14 +1992,14 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
txtcol -= wp->w_skipcol; txtcol -= wp->w_skipcol;
else else
txtcol -= wp->w_leftcol; txtcol -= wp->w_leftcol;
if (txtcol >= 0 && txtcol < wp->w_width) { if (txtcol >= 0 && txtcol < wp->w_grid.Columns) {
linebuf_attr[off + txtcol] = hl_combine_attr( linebuf_attr[off + txtcol] = hl_combine_attr(
linebuf_attr[off + txtcol], win_hl_attr(wp, HLF_CUC)); linebuf_attr[off + txtcol], win_hl_attr(wp, HLF_CUC));
} }
} }
grid_put_linebuf(grid, row, 0, grid->Columns, grid->Columns, false, wp, grid_put_linebuf(&wp->w_grid, row, 0, wp->w_grid.Columns, wp->w_grid.Columns,
wp->w_hl_attr_normal, false); false, wp, wp->w_hl_attr_normal, false);
/* /*
* Update w_cline_height and w_cline_folded if the cursor line was * Update w_cline_height and w_cline_folded if the cursor line was