aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/edit.c4
-rw-r--r--src/nvim/mbyte.c32
-rw-r--r--src/nvim/screen.c24
3 files changed, 30 insertions, 30 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 0cc64f6965..3558bdea06 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -1508,7 +1508,7 @@ void edit_putchar(int c, int highlight)
if (curwin->w_p_rl) {
pc_col += curwin->w_grid.Columns - 1 - curwin->w_wcol;
if (has_mbyte) {
- int fix_col = mb_fix_col(pc_col, pc_row);
+ int fix_col = mb_fix_col(&curwin->w_grid, pc_col, pc_row);
if (fix_col != pc_col) {
grid_putchar(&curwin->w_grid, ' ', pc_row, fix_col, attr);
@@ -1518,7 +1518,7 @@ void edit_putchar(int c, int highlight)
}
} else {
pc_col += curwin->w_wcol;
- if (mb_lefthalve(pc_row, pc_col))
+ if (mb_lefthalve(&curwin->w_grid, pc_row, pc_col))
pc_status = PC_STATUS_LEFT;
}
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index c0c36717e2..775e5b24fc 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -558,10 +558,10 @@ size_t mb_string2cells(const char_u *str)
/// Return number of display cells for char at ScreenLines[off].
/// We make sure that the offset used is less than "max_off".
-int utf_off2cells(unsigned off, unsigned max_off)
+int utf_off2cells(ScreenGrid *grid, unsigned off, unsigned max_off)
{
return (off + 1 < max_off
- && default_grid.ScreenLines[off + 1][0] == 0) ? 2 : 1;
+ && grid->ScreenLines[off + 1][0] == 0) ? 2 : 1;
}
/// Convert a UTF-8 byte sequence to a wide character
@@ -1828,22 +1828,22 @@ const char *mb_unescape(const char **const pp)
* of a double-width character.
* Caller must make sure "row" and "col" are not invalid!
*/
-bool mb_lefthalve(int row, int col)
+bool mb_lefthalve(ScreenGrid *grid, int row, int col)
{
- return utf_off2cells(default_grid.LineOffset[row] + col,
- default_grid.LineOffset[row] + screen_Columns) > 1;
+ return utf_off2cells(grid, grid->LineOffset[row] + col,
+ grid->LineOffset[row] + grid->Columns) > 1;
}
/*
* Correct a position on the screen, if it's the right half of a double-wide
* char move it to the left half. Returns the corrected column.
*/
-int mb_fix_col(int col, int row)
+int mb_fix_col(ScreenGrid *grid, int col, int row)
{
- col = check_col(col);
- row = check_row(row);
- if (default_grid.ScreenLines != NULL && col > 0
- && default_grid.ScreenLines[default_grid.LineOffset[row] + col][0] == 0) {
+ col = check_col(grid, col);
+ row = check_row(grid, row);
+ if (grid->ScreenLines != NULL && col > 0
+ && grid->ScreenLines[grid->LineOffset[row] + col][0] == 0) {
return col - 1;
}
return col;
@@ -2527,21 +2527,21 @@ char_u * string_convert_ext(const vimconv_T *const vcp, char_u *ptr,
}
// Check bounds for column number
-static int check_col(int col)
+static int check_col(ScreenGrid *grid, int col)
{
if (col < 0)
return 0;
- if (col >= screen_Columns)
- return screen_Columns - 1;
+ if (col >= grid->Columns)
+ return grid->Columns - 1;
return col;
}
// Check bounds for row number
-static int check_row(int row)
+static int check_row(ScreenGrid *grid, int row)
{
if (row < 0)
return 0;
- if (row >= screen_Rows)
- return screen_Rows - 1;
+ if (row >= grid->Rows)
+ return grid->Rows - 1;
return row;
}
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index f00fe5d338..23853ba13a 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -4323,7 +4323,7 @@ static int grid_char_needs_redraw(ScreenGrid *grid, int off_from, int off_to,
return (cols > 0
&& ((schar_cmp(grid->ScreenLines[off_from], grid->ScreenLines[off_to])
|| grid->ScreenAttrs[off_from] != grid->ScreenAttrs[off_to]
- || (utf_off2cells(off_from, off_from + cols) > 1
+ || (utf_off2cells(grid, off_from, off_from + cols) > 1
&& schar_cmp(grid->ScreenLines[off_from + 1],
grid->ScreenLines[off_to + 1])))
|| p_wd < 0));
@@ -4417,7 +4417,7 @@ static void grid_move_line(ScreenGrid *grid, int row, int coloff, int endcol,
while (col < endcol) {
char_cells = 1;
if (col + 1 < endcol) {
- char_cells = utf_off2cells(off_from, max_off_from);
+ char_cells = utf_off2cells(grid, off_from, max_off_from);
}
redraw_this = redraw_next;
redraw_next = grid_char_needs_redraw(grid, off_from + char_cells,
@@ -4436,10 +4436,10 @@ static void grid_move_line(ScreenGrid *grid, int row, int coloff, int endcol,
// char over the left halve of an existing one
if (col + char_cells == endcol
&& ((char_cells == 1
- && utf_off2cells(off_to, max_off_to) > 1)
+ && utf_off2cells(grid, off_to, max_off_to) > 1)
|| (char_cells == 2
- && utf_off2cells(off_to, max_off_to) == 1
- && utf_off2cells(off_to + 1, max_off_to) > 1))) {
+ && utf_off2cells(grid, off_to, max_off_to) == 1
+ && utf_off2cells(grid, off_to + 1, max_off_to) > 1))) {
clear_next = true;
}
@@ -5361,7 +5361,7 @@ void grid_puts_len(ScreenGrid *grid, char_u *text, int textlen, int row,
/* When drawing over the right halve of a double-wide char clear out the
* left halve. Only needed in a terminal. */
- if (col > 0 && col < grid->Columns && mb_fix_col(col, row) != col) {
+ if (col > 0 && col < grid->Columns && mb_fix_col(grid, col, row) != col) {
schar_from_ascii(grid->ScreenLines[off - 1], ' ');
grid->ScreenAttrs[off - 1] = 0;
// redraw the previous cell, make it empty
@@ -5436,10 +5436,10 @@ void grid_puts_len(ScreenGrid *grid, char_u *text, int textlen, int row,
clear_next_cell = false;
} else if ((len < 0 ? ptr[mbyte_blen] == NUL
: ptr + mbyte_blen >= text + len)
- && ((mbyte_cells == 1 && utf_off2cells(off, max_off) > 1)
+ && ((mbyte_cells == 1 && utf_off2cells(grid, off, max_off) > 1)
|| (mbyte_cells == 2
- && utf_off2cells(off, max_off) == 1
- && utf_off2cells(off + 1, max_off) > 1))) {
+ && utf_off2cells(grid, off, max_off) == 1
+ && utf_off2cells(grid, off + 1, max_off) > 1))) {
clear_next_cell = true;
}
@@ -5824,10 +5824,10 @@ void grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col,
// out the left halve. When drawing over the left halve of a
// double wide-char clear out the right halve. Only needed in a
// terminal.
- if (start_col > 0 && mb_fix_col(start_col, row) != start_col) {
+ if (start_col > 0 && mb_fix_col(grid, start_col, row) != start_col) {
grid_puts_len(grid, (char_u *)" ", 1, row, start_col - 1, 0);
}
- if (end_col < grid->Columns && mb_fix_col(end_col, row) != end_col) {
+ if (end_col < grid->Columns && mb_fix_col(grid, end_col, row) != end_col) {
grid_puts_len(grid, (char_u *)" ", 1, row, end_col, 0);
}
}
@@ -7076,7 +7076,7 @@ int number_width(win_T *wp)
if (wp->w_p_rnu && !wp->w_p_nu)
/* cursor line shows "0" */
- lnum = wp->w_height;
+ lnum = wp->w_grid.Rows;
else
/* cursor line shows absolute line number */
lnum = wp->w_buffer->b_ml.ml_line_count;