From a177c7df093f573c4bcb7b422bd615ce239be367 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Tue, 10 Aug 2021 22:32:08 +0200 Subject: refactor(plines): remove implicit curwin plines() function --- src/nvim/mouse.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/nvim/mouse.c') diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index f1ad0ed105..f4da43007d 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -236,12 +236,14 @@ retnomove: if (row < 0) { count = 0; for (first = true; curwin->w_topline > 1; ) { - if (curwin->w_topfill < diff_check(curwin, curwin->w_topline)) - ++count; - else - count += plines(curwin->w_topline - 1); - if (!first && count > -row) + if (curwin->w_topfill < diff_check(curwin, curwin->w_topline)) { + count++; + } else { + count += plines_win(curwin, curwin->w_topline - 1, true); + } + if (!first && count > -row) { break; + } first = false; (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); if (curwin->w_topfill < diff_check(curwin, curwin->w_topline)) { @@ -262,7 +264,7 @@ retnomove: if (curwin->w_topfill > 0) { ++count; } else { - count += plines(curwin->w_topline); + count += plines_win(curwin, curwin->w_topline, true); } if (!first && count > row - curwin->w_height_inner + 1) { -- cgit From 7f71e8a6b3d2ce6257ed24cf74a8f130edc8f0b0 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Tue, 10 Aug 2021 22:59:29 +0200 Subject: refactor(plines): move out plines related code from misc1.c --- src/nvim/mouse.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/mouse.c') diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index f4da43007d..0864dad27d 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -18,6 +18,7 @@ #include "nvim/diff.h" #include "nvim/move.h" #include "nvim/misc1.h" +#include "nvim/plines.h" #include "nvim/cursor.h" #include "nvim/buffer_defs.h" #include "nvim/memline.h" -- cgit From ac56a27a108012b80f5ed61be7370f10bbeb9d41 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Tue, 10 Aug 2021 23:18:12 +0200 Subject: refactor(plines): remove implicit curwin chartabsize() function --- src/nvim/mouse.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/nvim/mouse.c') diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index 0864dad27d..c46222460b 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -525,7 +525,7 @@ static colnr_T scroll_line_len(linenr_T lnum) char_u *line = ml_get(lnum); if (*line != NUL) { for (;;) { - int numchar = chartabsize(line, col); + int numchar = win_chartabsize(curwin, line, col); MB_PTR_ADV(line); if (*line == NUL) { // don't count the last character break; @@ -621,7 +621,7 @@ static int mouse_adjust_click(win_T *wp, int row, int col) // scanned *up to* `col`, nudging it left or right when concealed characters // are encountered. // - // chartabsize() is used to keep track of the virtual column position relative + // win_chartabsize() is used to keep track of the virtual column position relative // to the line's bytes. For example: if col == 9 and the line starts with a // tab that's 8 columns wide, we would want the cursor to be highlighting the // second byte, not the ninth. @@ -648,7 +648,7 @@ static int mouse_adjust_click(win_T *wp, int row, int col) // checked for concealed characters. vcol = 0; while (vcol < offset && *ptr != NUL) { - vcol += chartabsize(ptr, vcol); + vcol += win_chartabsize(curwin, ptr, vcol); ptr += utfc_ptr2len(ptr); } @@ -659,7 +659,7 @@ static int mouse_adjust_click(win_T *wp, int row, int col) vcol = offset; ptr_end = ptr_row_offset; while (vcol < col && *ptr_end != NUL) { - vcol += chartabsize(ptr_end, vcol); + vcol += win_chartabsize(curwin, ptr_end, vcol); ptr_end += utfc_ptr2len(ptr_end); } @@ -674,7 +674,7 @@ static int mouse_adjust_click(win_T *wp, int row, int col) #define decr() nudge--; ptr_end -= utfc_ptr2len(ptr_end) while (ptr < ptr_end && *ptr != NUL) { - cwidth = chartabsize(ptr, vcol); + cwidth = win_chartabsize(curwin, ptr, vcol); vcol += cwidth; if (cwidth > 1 && *ptr == '\t' && nudge > 0) { // A tab will "absorb" any previous adjustments. -- cgit From 28b5c73bf8b5cc92451a4030b4ffbbad6c56374b Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Tue, 10 Aug 2021 23:36:54 +0200 Subject: refactor(plines): move horizontal size functions to plines.c fix style. --- src/nvim/mouse.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/mouse.c') diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index c46222460b..6c25525936 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -621,10 +621,10 @@ static int mouse_adjust_click(win_T *wp, int row, int col) // scanned *up to* `col`, nudging it left or right when concealed characters // are encountered. // - // win_chartabsize() is used to keep track of the virtual column position relative - // to the line's bytes. For example: if col == 9 and the line starts with a - // tab that's 8 columns wide, we would want the cursor to be highlighting the - // second byte, not the ninth. + // win_chartabsize() is used to keep track of the virtual column position + // relative to the line's bytes. For example: if col == 9 and the line + // starts with a tab that's 8 columns wide, we would want the cursor to be + // highlighting the second byte, not the ninth. linenr_T lnum = wp->w_cursor.lnum; char_u *line = ml_get(lnum); -- cgit