mirror of
https://github.com/neovim/neovim.git
synced 2025-09-10 21:38:19 +00:00
refactor(plines): remove implicit curwin chartabsize() function
This commit is contained in:
@@ -593,9 +593,9 @@ void ins_char_bytes(char_u *buf, size_t charlen)
|
|||||||
// cells. May result in adding spaces to fill a gap.
|
// cells. May result in adding spaces to fill a gap.
|
||||||
colnr_T vcol;
|
colnr_T vcol;
|
||||||
getvcol(curwin, &curwin->w_cursor, NULL, &vcol, NULL);
|
getvcol(curwin, &curwin->w_cursor, NULL, &vcol, NULL);
|
||||||
colnr_T new_vcol = vcol + chartabsize(buf, vcol);
|
colnr_T new_vcol = vcol + win_chartabsize(curwin, buf, vcol);
|
||||||
while (oldp[col + oldlen] != NUL && vcol < new_vcol) {
|
while (oldp[col + oldlen] != NUL && vcol < new_vcol) {
|
||||||
vcol += chartabsize(oldp + col + oldlen, vcol);
|
vcol += win_chartabsize(curwin, oldp + col + oldlen, vcol);
|
||||||
// Don't need to remove a TAB that takes us to the right
|
// Don't need to remove a TAB that takes us to the right
|
||||||
// position.
|
// position.
|
||||||
if (vcol > new_vcol && oldp[col + oldlen] == TAB) {
|
if (vcol > new_vcol && oldp[col + oldlen] == TAB) {
|
||||||
|
@@ -749,12 +749,7 @@ int vim_strnsize(char_u *s, int len)
|
|||||||
return ptr2cells(p); \
|
return ptr2cells(p); \
|
||||||
}
|
}
|
||||||
|
|
||||||
int chartabsize(char_u *p, colnr_T col)
|
int win_chartabsize(win_T *wp, char_u *p, colnr_T col)
|
||||||
{
|
|
||||||
RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, p, col)
|
|
||||||
}
|
|
||||||
|
|
||||||
static int win_chartabsize(win_T *wp, char_u *p, colnr_T col)
|
|
||||||
{
|
{
|
||||||
RET_WIN_BUF_CHARTABSIZE(wp, wp->w_buffer, p, col)
|
RET_WIN_BUF_CHARTABSIZE(wp, wp->w_buffer, p, col)
|
||||||
}
|
}
|
||||||
@@ -936,7 +931,7 @@ bool vim_isprintc_strict(int c)
|
|||||||
return c > 0 && (g_chartab[c] & CT_PRINT_CHAR);
|
return c > 0 && (g_chartab[c] & CT_PRINT_CHAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// like chartabsize(), but also check for line breaks on the screen
|
/// like win_chartabsize(), but also check for line breaks on the screen
|
||||||
///
|
///
|
||||||
/// @param line
|
/// @param line
|
||||||
/// @param s
|
/// @param s
|
||||||
|
@@ -7187,7 +7187,7 @@ static void replace_do_bs(int limit_col)
|
|||||||
// Get the number of screen cells used by the character we are
|
// Get the number of screen cells used by the character we are
|
||||||
// going to delete.
|
// going to delete.
|
||||||
getvcol(curwin, &curwin->w_cursor, NULL, &start_vcol, NULL);
|
getvcol(curwin, &curwin->w_cursor, NULL, &start_vcol, NULL);
|
||||||
orig_vcols = chartabsize(get_cursor_pos_ptr(), start_vcol);
|
orig_vcols = win_chartabsize(curwin, get_cursor_pos_ptr(), start_vcol);
|
||||||
}
|
}
|
||||||
(void)del_char_after_col(limit_col);
|
(void)del_char_after_col(limit_col);
|
||||||
if (l_State & VREPLACE_FLAG) {
|
if (l_State & VREPLACE_FLAG) {
|
||||||
@@ -7202,7 +7202,7 @@ static void replace_do_bs(int limit_col)
|
|||||||
ins_len = (int)STRLEN(p) - orig_len;
|
ins_len = (int)STRLEN(p) - orig_len;
|
||||||
vcol = start_vcol;
|
vcol = start_vcol;
|
||||||
for (i = 0; i < ins_len; ++i) {
|
for (i = 0; i < ins_len; ++i) {
|
||||||
vcol += chartabsize(p + i, vcol);
|
vcol += win_chartabsize(curwin, p + i, vcol);
|
||||||
i += (*mb_ptr2len)(p) - 1;
|
i += (*mb_ptr2len)(p) - 1;
|
||||||
}
|
}
|
||||||
vcol -= start_vcol;
|
vcol -= start_vcol;
|
||||||
|
@@ -1055,7 +1055,7 @@ static void f_col(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
if (virtual_active() && fp == &curwin->w_cursor) {
|
if (virtual_active() && fp == &curwin->w_cursor) {
|
||||||
char_u *p = get_cursor_pos_ptr();
|
char_u *p = get_cursor_pos_ptr();
|
||||||
|
|
||||||
if (curwin->w_cursor.coladd >= (colnr_T)chartabsize(p,
|
if (curwin->w_cursor.coladd >= (colnr_T)win_chartabsize(curwin, p,
|
||||||
curwin->w_virtcol - curwin->w_cursor.coladd)) {
|
curwin->w_virtcol - curwin->w_cursor.coladd)) {
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
|
@@ -828,7 +828,7 @@ void ex_retab(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
if (ptr[col] == NUL)
|
if (ptr[col] == NUL)
|
||||||
break;
|
break;
|
||||||
vcol += chartabsize(ptr + col, (colnr_T)vcol);
|
vcol += win_chartabsize(curwin, ptr + col, (colnr_T)vcol);
|
||||||
col += utfc_ptr2len(ptr + col);
|
col += utfc_ptr2len(ptr + col);
|
||||||
}
|
}
|
||||||
if (new_line == NULL) /* out of memory */
|
if (new_line == NULL) /* out of memory */
|
||||||
|
@@ -525,7 +525,7 @@ static colnr_T scroll_line_len(linenr_T lnum)
|
|||||||
char_u *line = ml_get(lnum);
|
char_u *line = ml_get(lnum);
|
||||||
if (*line != NUL) {
|
if (*line != NUL) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int numchar = chartabsize(line, col);
|
int numchar = win_chartabsize(curwin, line, col);
|
||||||
MB_PTR_ADV(line);
|
MB_PTR_ADV(line);
|
||||||
if (*line == NUL) { // don't count the last character
|
if (*line == NUL) { // don't count the last character
|
||||||
break;
|
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
|
// scanned *up to* `col`, nudging it left or right when concealed characters
|
||||||
// are encountered.
|
// 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
|
// 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
|
// tab that's 8 columns wide, we would want the cursor to be highlighting the
|
||||||
// second byte, not the ninth.
|
// 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.
|
// checked for concealed characters.
|
||||||
vcol = 0;
|
vcol = 0;
|
||||||
while (vcol < offset && *ptr != NUL) {
|
while (vcol < offset && *ptr != NUL) {
|
||||||
vcol += chartabsize(ptr, vcol);
|
vcol += win_chartabsize(curwin, ptr, vcol);
|
||||||
ptr += utfc_ptr2len(ptr);
|
ptr += utfc_ptr2len(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -659,7 +659,7 @@ static int mouse_adjust_click(win_T *wp, int row, int col)
|
|||||||
vcol = offset;
|
vcol = offset;
|
||||||
ptr_end = ptr_row_offset;
|
ptr_end = ptr_row_offset;
|
||||||
while (vcol < col && *ptr_end != NUL) {
|
while (vcol < col && *ptr_end != NUL) {
|
||||||
vcol += chartabsize(ptr_end, vcol);
|
vcol += win_chartabsize(curwin, ptr_end, vcol);
|
||||||
ptr_end += utfc_ptr2len(ptr_end);
|
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)
|
#define decr() nudge--; ptr_end -= utfc_ptr2len(ptr_end)
|
||||||
|
|
||||||
while (ptr < ptr_end && *ptr != NUL) {
|
while (ptr < ptr_end && *ptr != NUL) {
|
||||||
cwidth = chartabsize(ptr, vcol);
|
cwidth = win_chartabsize(curwin, ptr, vcol);
|
||||||
vcol += cwidth;
|
vcol += cwidth;
|
||||||
if (cwidth > 1 && *ptr == '\t' && nudge > 0) {
|
if (cwidth > 1 && *ptr == '\t' && nudge > 0) {
|
||||||
// A tab will "absorb" any previous adjustments.
|
// A tab will "absorb" any previous adjustments.
|
||||||
|
Reference in New Issue
Block a user