aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-09-20 12:17:10 +0200
committerGitHub <noreply@github.com>2023-09-20 12:17:10 +0200
commit50d5fcc0bc1a3a67b9c3cc7066d97593ea3cc22d (patch)
tree5d13244d83f5687f77eeffc2d59594e9d51e24fd
parent351dda5e26313f88edea2a01b687f12f4fd1c790 (diff)
parentee20e9e66942ce38c8d4a8f4387ac1ec00d1d64f (diff)
downloadrneovim-50d5fcc0bc1a3a67b9c3cc7066d97593ea3cc22d.tar.gz
rneovim-50d5fcc0bc1a3a67b9c3cc7066d97593ea3cc22d.tar.bz2
rneovim-50d5fcc0bc1a3a67b9c3cc7066d97593ea3cc22d.zip
Merge pull request #25261 from bfredl/nolinewrap
refactor(grid): unused grid->line_wraps delenda est
-rw-r--r--src/nvim/drawline.c3
-rw-r--r--src/nvim/drawscreen.c1
-rw-r--r--src/nvim/grid.c20
-rw-r--r--src/nvim/grid_defs.h7
-rw-r--r--src/nvim/ui_compositor.c4
5 files changed, 2 insertions, 33 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 8b4786a98e..5fda200a43 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -3172,9 +3172,6 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
// Force a redraw of the first column of the next line.
current_grid->attrs[current_grid->line_offset[current_row + 1]] = -1;
-
- // Remember that the line wraps, used for modeless copy.
- current_grid->line_wraps[current_row] = true;
}
wlv.boguscols = 0;
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c
index 681a5e2a02..854c8590e4 100644
--- a/src/nvim/drawscreen.c
+++ b/src/nvim/drawscreen.c
@@ -215,7 +215,6 @@ void screenclear(void)
for (int i = 0; i < default_grid.rows; i++) {
grid_clear_line(&default_grid, default_grid.line_offset[i],
default_grid.cols, true);
- default_grid.line_wraps[i] = false;
}
ui_call_grid_clear(1); // clear the display
diff --git a/src/nvim/grid.c b/src/nvim/grid.c
index cf6cd2f04e..dc42ab7a89 100644
--- a/src/nvim/grid.c
+++ b/src/nvim/grid.c
@@ -574,10 +574,6 @@ void grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col, int
ui_line(grid, row, dirty_first, last, dirty_last, attr, false);
}
}
-
- if (end_col == grid->cols) {
- grid->line_wraps[row] = false;
- }
}
}
@@ -777,12 +773,6 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int cle
}
}
- if (clear_width > 0 || wp->w_width != grid->cols) {
- // If we cleared after the end of the line, it did not wrap.
- // For vsplit, line wrapping is not possible.
- grid->line_wraps[row] = false;
- }
-
if (clear_end < end_dirty) {
clear_end = end_dirty;
}
@@ -806,14 +796,12 @@ void grid_alloc(ScreenGrid *grid, int rows, int columns, bool copy, bool valid)
ngrid.vcols = xmalloc(ncells * sizeof(colnr_T));
memset(ngrid.vcols, -1, ncells * sizeof(colnr_T));
ngrid.line_offset = xmalloc((size_t)rows * sizeof(*ngrid.line_offset));
- ngrid.line_wraps = xmalloc((size_t)rows * sizeof(*ngrid.line_wraps));
ngrid.rows = rows;
ngrid.cols = columns;
for (new_row = 0; new_row < ngrid.rows; new_row++) {
ngrid.line_offset[new_row] = (size_t)new_row * (size_t)ngrid.cols;
- ngrid.line_wraps[new_row] = false;
grid_clear_line(&ngrid, ngrid.line_offset[new_row], columns, valid);
@@ -858,13 +846,11 @@ void grid_free(ScreenGrid *grid)
xfree(grid->attrs);
xfree(grid->vcols);
xfree(grid->line_offset);
- xfree(grid->line_wraps);
grid->chars = NULL;
grid->attrs = NULL;
grid->vcols = NULL;
grid->line_offset = NULL;
- grid->line_wraps = NULL;
}
/// Doesn't allow reinit, so must only be called by free_all_mem!
@@ -987,16 +973,13 @@ void grid_ins_lines(ScreenGrid *grid, int row, int line_count, int end, int col,
}
j += line_count;
grid_clear_line(grid, grid->line_offset[j] + (size_t)col, width, false);
- grid->line_wraps[j] = false;
} else {
j = end - 1 - i;
temp = (unsigned)grid->line_offset[j];
while ((j -= line_count) >= row) {
grid->line_offset[j + line_count] = grid->line_offset[j];
- grid->line_wraps[j + line_count] = grid->line_wraps[j];
}
grid->line_offset[j + line_count] = temp;
- grid->line_wraps[j + line_count] = false;
grid_clear_line(grid, temp, grid->cols, false);
}
}
@@ -1035,17 +1018,14 @@ void grid_del_lines(ScreenGrid *grid, int row, int line_count, int end, int col,
}
j -= line_count;
grid_clear_line(grid, grid->line_offset[j] + (size_t)col, width, false);
- grid->line_wraps[j] = false;
} else {
// whole width, moving the line pointers is faster
j = row + i;
temp = (unsigned)grid->line_offset[j];
while ((j += line_count) <= end - 1) {
grid->line_offset[j - line_count] = grid->line_offset[j];
- grid->line_wraps[j - line_count] = grid->line_wraps[j];
}
grid->line_offset[j - line_count] = temp;
- grid->line_wraps[j - line_count] = false;
grid_clear_line(grid, temp, grid->cols, false);
}
}
diff --git a/src/nvim/grid_defs.h b/src/nvim/grid_defs.h
index b0d1dafd29..207bf72816 100644
--- a/src/nvim/grid_defs.h
+++ b/src/nvim/grid_defs.h
@@ -52,10 +52,6 @@ enum {
/// line_offset[n] is the offset from chars[], attrs[] and vcols[] for the start
/// of line 'n'. These offsets are in general not linear, as full screen scrolling
/// is implemented by rotating the offsets in the line_offset array.
-///
-/// line_wraps[] is an array of boolean flags indicating if the screen line
-/// wraps to the next line. It can only be true if a window occupies the entire
-/// screen width.
typedef struct ScreenGrid ScreenGrid;
struct ScreenGrid {
handle_T handle;
@@ -64,7 +60,6 @@ struct ScreenGrid {
sattr_T *attrs;
colnr_T *vcols;
size_t *line_offset;
- char *line_wraps;
// last column that was drawn (not cleared with the default background).
// only used when "throttled" is set. Not allocated by grid_alloc!
@@ -120,7 +115,7 @@ struct ScreenGrid {
bool comp_disabled;
};
-#define SCREEN_GRID_INIT { 0, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, false, \
+#define SCREEN_GRID_INIT { 0, NULL, NULL, NULL, NULL, NULL, 0, 0, false, \
false, 0, 0, NULL, false, true, 0, \
0, 0, 0, 0, 0, false }
diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c
index fcb63801e5..b88c355f42 100644
--- a/src/nvim/ui_compositor.c
+++ b/src/nvim/ui_compositor.c
@@ -413,9 +413,7 @@ static void compose_line(Integer row, Integer startcol, Integer endcol, LineFlag
assert(endcol <= chk_width);
assert(row < chk_height);
- if (!(grid && grid == &default_grid)) {
- // TODO(bfredl): too conservative, need check
- // grid->line_wraps if grid->Width == Width
+ if (!(grid && (grid == &default_grid || (grid->comp_col == 0 && grid->cols == Columns)))) {
flags = flags & ~kLineFlagWrap;
}