mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 14:08:32 +00:00
refactor: use "csarg" for CharsizeArg variables (#27123)
This commit is contained in:
@@ -141,12 +141,12 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CharsizeArg arg;
|
CharsizeArg csarg;
|
||||||
CSType cstype = init_charsize_arg(&arg, curwin, pos->lnum, line);
|
CSType cstype = init_charsize_arg(&csarg, curwin, pos->lnum, line);
|
||||||
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
||||||
col = 0;
|
col = 0;
|
||||||
while (col <= wcol && *ci.ptr != NUL) {
|
while (col <= wcol && *ci.ptr != NUL) {
|
||||||
CharSize cs = win_charsize(cstype, col, ci.ptr, ci.chr.value, &arg);
|
CharSize cs = win_charsize(cstype, col, ci.ptr, ci.chr.value, &csarg);
|
||||||
csize = cs.width;
|
csize = cs.width;
|
||||||
head = cs.head;
|
head = cs.head;
|
||||||
col += cs.width;
|
col += cs.width;
|
||||||
|
@@ -1338,13 +1338,13 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
|
|||||||
char *prev_ptr = ptr;
|
char *prev_ptr = ptr;
|
||||||
CharSize cs = { 0 };
|
CharSize cs = { 0 };
|
||||||
|
|
||||||
CharsizeArg arg;
|
CharsizeArg csarg;
|
||||||
CSType cstype = init_charsize_arg(&arg, wp, lnum, line);
|
CSType cstype = init_charsize_arg(&csarg, wp, lnum, line);
|
||||||
arg.max_head_vcol = start_col;
|
csarg.max_head_vcol = start_col;
|
||||||
int vcol = wlv.vcol;
|
int vcol = wlv.vcol;
|
||||||
StrCharInfo ci = utf_ptr2StrCharInfo(ptr);
|
StrCharInfo ci = utf_ptr2StrCharInfo(ptr);
|
||||||
while (vcol < start_col && *ci.ptr != NUL) {
|
while (vcol < start_col && *ci.ptr != NUL) {
|
||||||
cs = win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &arg);
|
cs = win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &csarg);
|
||||||
vcol += cs.width;
|
vcol += cs.width;
|
||||||
prev_ptr = ci.ptr;
|
prev_ptr = ci.ptr;
|
||||||
ci = utfc_next(ci);
|
ci = utfc_next(ci);
|
||||||
@@ -2083,11 +2083,11 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
|
|||||||
int mb_off = utf_head_off(line, ptr - 1);
|
int mb_off = utf_head_off(line, ptr - 1);
|
||||||
char *p = ptr - (mb_off + 1);
|
char *p = ptr - (mb_off + 1);
|
||||||
|
|
||||||
CharsizeArg arg;
|
CharsizeArg csarg;
|
||||||
// lnum == 0, do not want virtual text to be counted here
|
// lnum == 0, do not want virtual text to be counted here
|
||||||
CSType cstype = init_charsize_arg(&arg, wp, 0, line);
|
CSType cstype = init_charsize_arg(&csarg, wp, 0, line);
|
||||||
wlv.n_extra = win_charsize(cstype, wlv.vcol, p, utf_ptr2CharInfo(p).value,
|
wlv.n_extra = win_charsize(cstype, wlv.vcol, p, utf_ptr2CharInfo(p).value,
|
||||||
&arg).width - 1;
|
&csarg).width - 1;
|
||||||
|
|
||||||
if (on_last_col && mb_c != TAB) {
|
if (on_last_col && mb_c != TAB) {
|
||||||
// Do not continue search/match highlighting over the
|
// Do not continue search/match highlighting over the
|
||||||
|
@@ -1687,11 +1687,11 @@ void change_indent(int type, int amount, int round, int replaced, bool call_chan
|
|||||||
char *const line = get_cursor_line_ptr();
|
char *const line = get_cursor_line_ptr();
|
||||||
vcol = 0;
|
vcol = 0;
|
||||||
if (*line != NUL) {
|
if (*line != NUL) {
|
||||||
CharsizeArg arg;
|
CharsizeArg csarg;
|
||||||
CSType cstype = init_charsize_arg(&arg, curwin, 0, line);
|
CSType cstype = init_charsize_arg(&csarg, curwin, 0, line);
|
||||||
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
||||||
while (true) {
|
while (true) {
|
||||||
int next_vcol = vcol + win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &arg).width;
|
int next_vcol = vcol + win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &csarg).width;
|
||||||
if (next_vcol > end_vcol) {
|
if (next_vcol > end_vcol) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -4353,13 +4353,13 @@ static bool ins_tab(void)
|
|||||||
char *tab = "\t";
|
char *tab = "\t";
|
||||||
int32_t tab_v = (uint8_t)(*tab);
|
int32_t tab_v = (uint8_t)(*tab);
|
||||||
|
|
||||||
CharsizeArg arg;
|
CharsizeArg csarg;
|
||||||
CSType cstype = init_charsize_arg(&arg, curwin, 0, tab);
|
CSType cstype = init_charsize_arg(&csarg, curwin, 0, tab);
|
||||||
|
|
||||||
// Use as many TABs as possible. Beware of 'breakindent', 'showbreak'
|
// Use as many TABs as possible. Beware of 'breakindent', 'showbreak'
|
||||||
// and 'linebreak' adding extra virtual columns.
|
// and 'linebreak' adding extra virtual columns.
|
||||||
while (ascii_iswhite(*ptr)) {
|
while (ascii_iswhite(*ptr)) {
|
||||||
int i = win_charsize(cstype, vcol, tab, tab_v, &arg).width;
|
int i = win_charsize(cstype, vcol, tab, tab_v, &csarg).width;
|
||||||
if (vcol + i > want_vcol) {
|
if (vcol + i > want_vcol) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -4381,9 +4381,9 @@ static bool ins_tab(void)
|
|||||||
if (change_col >= 0) {
|
if (change_col >= 0) {
|
||||||
int repl_off = 0;
|
int repl_off = 0;
|
||||||
// Skip over the spaces we need.
|
// Skip over the spaces we need.
|
||||||
cstype = init_charsize_arg(&arg, curwin, 0, ptr);
|
cstype = init_charsize_arg(&csarg, curwin, 0, ptr);
|
||||||
while (vcol < want_vcol && *ptr == ' ') {
|
while (vcol < want_vcol && *ptr == ' ') {
|
||||||
vcol += win_charsize(cstype, vcol, ptr, (uint8_t)(' '), &arg).width;
|
vcol += win_charsize(cstype, vcol, ptr, (uint8_t)(' '), &csarg).width;
|
||||||
ptr++;
|
ptr++;
|
||||||
repl_off++;
|
repl_off++;
|
||||||
}
|
}
|
||||||
@@ -4567,12 +4567,12 @@ int ins_copychar(linenr_T lnum)
|
|||||||
int const end_vcol = curwin->w_virtcol;
|
int const end_vcol = curwin->w_virtcol;
|
||||||
char *line = ml_get(lnum);
|
char *line = ml_get(lnum);
|
||||||
|
|
||||||
CharsizeArg arg;
|
CharsizeArg csarg;
|
||||||
CSType cstype = init_charsize_arg(&arg, curwin, lnum, line);
|
CSType cstype = init_charsize_arg(&csarg, curwin, lnum, line);
|
||||||
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
||||||
int vcol = 0;
|
int vcol = 0;
|
||||||
while (vcol < end_vcol && *ci.ptr != NUL) {
|
while (vcol < end_vcol && *ci.ptr != NUL) {
|
||||||
vcol += win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &arg).width;
|
vcol += win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &csarg).width;
|
||||||
if (vcol > end_vcol) {
|
if (vcol > end_vcol) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -2507,15 +2507,15 @@ static int vgetorpeek(bool advance)
|
|||||||
ptr = get_cursor_line_ptr();
|
ptr = get_cursor_line_ptr();
|
||||||
char *endptr = ptr + curwin->w_cursor.col;
|
char *endptr = ptr + curwin->w_cursor.col;
|
||||||
|
|
||||||
CharsizeArg arg;
|
CharsizeArg csarg;
|
||||||
CSType cstype = init_charsize_arg(&arg, curwin, curwin->w_cursor.lnum, ptr);
|
CSType cstype = init_charsize_arg(&csarg, curwin, curwin->w_cursor.lnum, ptr);
|
||||||
StrCharInfo ci = utf_ptr2StrCharInfo(ptr);
|
StrCharInfo ci = utf_ptr2StrCharInfo(ptr);
|
||||||
int vcol = 0;
|
int vcol = 0;
|
||||||
while (ci.ptr < endptr) {
|
while (ci.ptr < endptr) {
|
||||||
if (!ascii_iswhite(ci.chr.value)) {
|
if (!ascii_iswhite(ci.chr.value)) {
|
||||||
curwin->w_wcol = vcol;
|
curwin->w_wcol = vcol;
|
||||||
}
|
}
|
||||||
vcol += win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &arg).width;
|
vcol += win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &csarg).width;
|
||||||
ci = utfc_next(ci);
|
ci = utfc_next(ci);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1248,13 +1248,13 @@ int get_lisp_indent(void)
|
|||||||
|
|
||||||
char *line = get_cursor_line_ptr();
|
char *line = get_cursor_line_ptr();
|
||||||
|
|
||||||
CharsizeArg arg;
|
CharsizeArg csarg;
|
||||||
CSType cstype = init_charsize_arg(&arg, curwin, pos->lnum, line);
|
CSType cstype = init_charsize_arg(&csarg, curwin, pos->lnum, line);
|
||||||
|
|
||||||
StrCharInfo sci = utf_ptr2StrCharInfo(line);
|
StrCharInfo sci = utf_ptr2StrCharInfo(line);
|
||||||
amount = 0;
|
amount = 0;
|
||||||
while (*sci.ptr != NUL && col > 0) {
|
while (*sci.ptr != NUL && col > 0) {
|
||||||
amount += win_charsize(cstype, amount, sci.ptr, sci.chr.value, &arg).width;
|
amount += win_charsize(cstype, amount, sci.ptr, sci.chr.value, &csarg).width;
|
||||||
sci = utfc_next(sci);
|
sci = utfc_next(sci);
|
||||||
col--;
|
col--;
|
||||||
}
|
}
|
||||||
@@ -1274,7 +1274,7 @@ int get_lisp_indent(void)
|
|||||||
colnr_T firsttry = amount;
|
colnr_T firsttry = amount;
|
||||||
|
|
||||||
while (ascii_iswhite(*that)) {
|
while (ascii_iswhite(*that)) {
|
||||||
amount += win_charsize(cstype, amount, that, (uint8_t)(*that), &arg).width;
|
amount += win_charsize(cstype, amount, that, (uint8_t)(*that), &csarg).width;
|
||||||
that++;
|
that++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1303,13 +1303,13 @@ int get_lisp_indent(void)
|
|||||||
parencount--;
|
parencount--;
|
||||||
}
|
}
|
||||||
if ((ci.value == '\\') && (*(that + 1) != NUL)) {
|
if ((ci.value == '\\') && (*(that + 1) != NUL)) {
|
||||||
amount += win_charsize(cstype, amount, that, ci.value, &arg).width;
|
amount += win_charsize(cstype, amount, that, ci.value, &csarg).width;
|
||||||
StrCharInfo next_sci = utfc_next((StrCharInfo){ that, ci });
|
StrCharInfo next_sci = utfc_next((StrCharInfo){ that, ci });
|
||||||
that = next_sci.ptr;
|
that = next_sci.ptr;
|
||||||
ci = next_sci.chr;
|
ci = next_sci.chr;
|
||||||
}
|
}
|
||||||
|
|
||||||
amount += win_charsize(cstype, amount, that, ci.value, &arg).width;
|
amount += win_charsize(cstype, amount, that, ci.value, &csarg).width;
|
||||||
StrCharInfo next_sci = utfc_next((StrCharInfo){ that, ci });
|
StrCharInfo next_sci = utfc_next((StrCharInfo){ that, ci });
|
||||||
that = next_sci.ptr;
|
that = next_sci.ptr;
|
||||||
ci = next_sci.chr;
|
ci = next_sci.chr;
|
||||||
@@ -1317,7 +1317,7 @@ int get_lisp_indent(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (ascii_iswhite(*that)) {
|
while (ascii_iswhite(*that)) {
|
||||||
amount += win_charsize(cstype, amount, that, (uint8_t)(*that), &arg).width;
|
amount += win_charsize(cstype, amount, that, (uint8_t)(*that), &csarg).width;
|
||||||
that++;
|
that++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1755,12 +1755,12 @@ colnr_T vcol2col(win_T *wp, linenr_T lnum, colnr_T vcol, colnr_T *coladdp)
|
|||||||
{
|
{
|
||||||
// try to advance to the specified column
|
// try to advance to the specified column
|
||||||
char *line = ml_get_buf(wp->w_buffer, lnum);
|
char *line = ml_get_buf(wp->w_buffer, lnum);
|
||||||
CharsizeArg arg;
|
CharsizeArg csarg;
|
||||||
CSType cstype = init_charsize_arg(&arg, wp, lnum, line);
|
CSType cstype = init_charsize_arg(&csarg, wp, lnum, line);
|
||||||
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
||||||
int cur_vcol = 0;
|
int cur_vcol = 0;
|
||||||
while (cur_vcol < vcol && *ci.ptr != NUL) {
|
while (cur_vcol < vcol && *ci.ptr != NUL) {
|
||||||
int next_vcol = cur_vcol + win_charsize(cstype, cur_vcol, ci.ptr, ci.chr.value, &arg).width;
|
int next_vcol = cur_vcol + win_charsize(cstype, cur_vcol, ci.ptr, ci.chr.value, &csarg).width;
|
||||||
if (next_vcol > vcol) {
|
if (next_vcol > vcol) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -387,12 +387,12 @@ static void shift_block(oparg_T *oap, int amount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO(vim): is passing bd.textstart for start of the line OK?
|
// TODO(vim): is passing bd.textstart for start of the line OK?
|
||||||
CharsizeArg arg;
|
CharsizeArg csarg;
|
||||||
CSType cstype = init_charsize_arg(&arg, curwin, curwin->w_cursor.lnum, bd.textstart);
|
CSType cstype = init_charsize_arg(&csarg, curwin, curwin->w_cursor.lnum, bd.textstart);
|
||||||
StrCharInfo ci = utf_ptr2StrCharInfo(bd.textstart);
|
StrCharInfo ci = utf_ptr2StrCharInfo(bd.textstart);
|
||||||
int vcol = bd.start_vcol;
|
int vcol = bd.start_vcol;
|
||||||
while (ascii_iswhite(ci.chr.value)) {
|
while (ascii_iswhite(ci.chr.value)) {
|
||||||
incr = win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &arg).width;
|
incr = win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &csarg).width;
|
||||||
ci = utfc_next(ci);
|
ci = utfc_next(ci);
|
||||||
total += incr;
|
total += incr;
|
||||||
vcol += incr;
|
vcol += incr;
|
||||||
@@ -449,10 +449,10 @@ static void shift_block(oparg_T *oap, int amount)
|
|||||||
// The character's column is in "bd.start_vcol".
|
// The character's column is in "bd.start_vcol".
|
||||||
colnr_T non_white_col = bd.start_vcol;
|
colnr_T non_white_col = bd.start_vcol;
|
||||||
|
|
||||||
CharsizeArg arg;
|
CharsizeArg csarg;
|
||||||
CSType cstype = init_charsize_arg(&arg, curwin, curwin->w_cursor.lnum, bd.textstart);
|
CSType cstype = init_charsize_arg(&csarg, curwin, curwin->w_cursor.lnum, bd.textstart);
|
||||||
while (ascii_iswhite(*non_white)) {
|
while (ascii_iswhite(*non_white)) {
|
||||||
incr = win_charsize(cstype, non_white_col, non_white, (uint8_t)(*non_white), &arg).width;
|
incr = win_charsize(cstype, non_white_col, non_white, (uint8_t)(*non_white), &csarg).width;
|
||||||
non_white_col += incr;
|
non_white_col += incr;
|
||||||
non_white++;
|
non_white++;
|
||||||
}
|
}
|
||||||
@@ -476,10 +476,10 @@ static void shift_block(oparg_T *oap, int amount)
|
|||||||
if (bd.startspaces) {
|
if (bd.startspaces) {
|
||||||
verbatim_copy_width -= bd.start_char_vcols;
|
verbatim_copy_width -= bd.start_char_vcols;
|
||||||
}
|
}
|
||||||
cstype = init_charsize_arg(&arg, curwin, 0, bd.textstart);
|
cstype = init_charsize_arg(&csarg, curwin, 0, bd.textstart);
|
||||||
StrCharInfo ci = utf_ptr2StrCharInfo(verbatim_copy_end);
|
StrCharInfo ci = utf_ptr2StrCharInfo(verbatim_copy_end);
|
||||||
while (verbatim_copy_width < destination_col) {
|
while (verbatim_copy_width < destination_col) {
|
||||||
incr = win_charsize(cstype, verbatim_copy_width, ci.ptr, ci.chr.value, &arg).width;
|
incr = win_charsize(cstype, verbatim_copy_width, ci.ptr, ci.chr.value, &csarg).width;
|
||||||
if (verbatim_copy_width + incr > destination_col) {
|
if (verbatim_copy_width + incr > destination_col) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3247,12 +3247,12 @@ void do_put(int regname, yankreg_T *reg, int dir, int count, int flags)
|
|||||||
// get the old line and advance to the position to insert at
|
// get the old line and advance to the position to insert at
|
||||||
char *oldp = get_cursor_line_ptr();
|
char *oldp = get_cursor_line_ptr();
|
||||||
|
|
||||||
CharsizeArg arg;
|
CharsizeArg csarg;
|
||||||
CSType cstype = init_charsize_arg(&arg, curwin, curwin->w_cursor.lnum, oldp);
|
CSType cstype = init_charsize_arg(&csarg, curwin, curwin->w_cursor.lnum, oldp);
|
||||||
StrCharInfo ci = utf_ptr2StrCharInfo(oldp);
|
StrCharInfo ci = utf_ptr2StrCharInfo(oldp);
|
||||||
vcol = 0;
|
vcol = 0;
|
||||||
while (vcol < col && *ci.ptr != NUL) {
|
while (vcol < col && *ci.ptr != NUL) {
|
||||||
incr = win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &arg).width;
|
incr = win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &csarg).width;
|
||||||
vcol += incr;
|
vcol += incr;
|
||||||
ci = utfc_next(ci);
|
ci = utfc_next(ci);
|
||||||
}
|
}
|
||||||
@@ -3285,10 +3285,10 @@ void do_put(int regname, yankreg_T *reg, int dir, int count, int flags)
|
|||||||
// calculate number of spaces required to fill right side of block
|
// calculate number of spaces required to fill right side of block
|
||||||
spaces = y_width + 1;
|
spaces = y_width + 1;
|
||||||
|
|
||||||
cstype = init_charsize_arg(&arg, curwin, 0, y_array[i]);
|
cstype = init_charsize_arg(&csarg, curwin, 0, y_array[i]);
|
||||||
ci = utf_ptr2StrCharInfo(y_array[i]);
|
ci = utf_ptr2StrCharInfo(y_array[i]);
|
||||||
while (*ci.ptr != NUL) {
|
while (*ci.ptr != NUL) {
|
||||||
spaces -= win_charsize(cstype, 0, ci.ptr, ci.chr.value, &arg).width;
|
spaces -= win_charsize(cstype, 0, ci.ptr, ci.chr.value, &csarg).width;
|
||||||
ci = utfc_next(ci);
|
ci = utfc_next(ci);
|
||||||
}
|
}
|
||||||
if (spaces < 0) {
|
if (spaces < 0) {
|
||||||
@@ -4223,12 +4223,12 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum, bool
|
|||||||
char *line = ml_get(lnum);
|
char *line = ml_get(lnum);
|
||||||
char *prev_pstart = line;
|
char *prev_pstart = line;
|
||||||
|
|
||||||
CharsizeArg arg;
|
CharsizeArg csarg;
|
||||||
CSType cstype = init_charsize_arg(&arg, curwin, lnum, line);
|
CSType cstype = init_charsize_arg(&csarg, curwin, lnum, line);
|
||||||
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
||||||
int vcol = bdp->start_vcol;
|
int vcol = bdp->start_vcol;
|
||||||
while (vcol < oap->start_vcol && *ci.ptr != NUL) {
|
while (vcol < oap->start_vcol && *ci.ptr != NUL) {
|
||||||
incr = win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &arg).width;
|
incr = win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &csarg).width;
|
||||||
vcol += incr;
|
vcol += incr;
|
||||||
if (ascii_iswhite(ci.chr.value)) {
|
if (ascii_iswhite(ci.chr.value)) {
|
||||||
bdp->pre_whitesp += incr;
|
bdp->pre_whitesp += incr;
|
||||||
@@ -4278,13 +4278,13 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum, bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cstype = init_charsize_arg(&arg, curwin, lnum, line);
|
cstype = init_charsize_arg(&csarg, curwin, lnum, line);
|
||||||
ci = utf_ptr2StrCharInfo(pend);
|
ci = utf_ptr2StrCharInfo(pend);
|
||||||
vcol = bdp->end_vcol;
|
vcol = bdp->end_vcol;
|
||||||
char *prev_pend = pend;
|
char *prev_pend = pend;
|
||||||
while (vcol <= oap->end_vcol && *ci.ptr != NUL) {
|
while (vcol <= oap->end_vcol && *ci.ptr != NUL) {
|
||||||
prev_pend = ci.ptr;
|
prev_pend = ci.ptr;
|
||||||
incr = win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &arg).width;
|
incr = win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &csarg).width;
|
||||||
vcol += incr;
|
vcol += incr;
|
||||||
ci = utfc_next(ci);
|
ci = utfc_next(ci);
|
||||||
}
|
}
|
||||||
|
@@ -59,12 +59,12 @@ int win_chartabsize(win_T *wp, char *p, colnr_T col)
|
|||||||
/// @return Number of characters the string will take on the screen.
|
/// @return Number of characters the string will take on the screen.
|
||||||
int linetabsize_col(int startvcol, char *s)
|
int linetabsize_col(int startvcol, char *s)
|
||||||
{
|
{
|
||||||
CharsizeArg arg;
|
CharsizeArg csarg;
|
||||||
CSType const cstype = init_charsize_arg(&arg, curwin, 0, s);
|
CSType const cstype = init_charsize_arg(&csarg, curwin, 0, s);
|
||||||
if (cstype == kCharsizeFast) {
|
if (cstype == kCharsizeFast) {
|
||||||
return linesize_fast(&arg, startvcol, MAXCOL);
|
return linesize_fast(&csarg, startvcol, MAXCOL);
|
||||||
} else {
|
} else {
|
||||||
return linesize_regular(&arg, startvcol, MAXCOL);
|
return linesize_regular(&csarg, startvcol, MAXCOL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,26 +79,26 @@ int linetabsize(win_T *wp, linenr_T lnum)
|
|||||||
///
|
///
|
||||||
/// "line" is the start of the line.
|
/// "line" is the start of the line.
|
||||||
/// When "lnum" is zero do not use inline virtual text.
|
/// When "lnum" is zero do not use inline virtual text.
|
||||||
CSType init_charsize_arg(CharsizeArg *cts, win_T *wp, linenr_T lnum, char *line)
|
CSType init_charsize_arg(CharsizeArg *csarg, win_T *wp, linenr_T lnum, char *line)
|
||||||
{
|
{
|
||||||
cts->win = wp;
|
csarg->win = wp;
|
||||||
cts->line = line;
|
csarg->line = line;
|
||||||
cts->max_head_vcol = 0;
|
csarg->max_head_vcol = 0;
|
||||||
cts->cur_text_width_left = 0;
|
csarg->cur_text_width_left = 0;
|
||||||
cts->cur_text_width_right = 0;
|
csarg->cur_text_width_right = 0;
|
||||||
cts->virt_row = -1;
|
csarg->virt_row = -1;
|
||||||
cts->indent_width = INT_MIN;
|
csarg->indent_width = INT_MIN;
|
||||||
cts->use_tabstop = !wp->w_p_list || wp->w_p_lcs_chars.tab1;
|
csarg->use_tabstop = !wp->w_p_list || wp->w_p_lcs_chars.tab1;
|
||||||
|
|
||||||
if (lnum > 0 && wp->w_buffer->b_virt_text_inline > 0) {
|
if (lnum > 0 && wp->w_buffer->b_virt_text_inline > 0) {
|
||||||
marktree_itr_get(wp->w_buffer->b_marktree, lnum - 1, 0, cts->iter);
|
marktree_itr_get(wp->w_buffer->b_marktree, lnum - 1, 0, csarg->iter);
|
||||||
MTKey mark = marktree_itr_current(cts->iter);
|
MTKey mark = marktree_itr_current(csarg->iter);
|
||||||
if (mark.pos.row == lnum - 1) {
|
if (mark.pos.row == lnum - 1) {
|
||||||
cts->virt_row = lnum - 1;
|
csarg->virt_row = lnum - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cts->virt_row >= 0
|
if (csarg->virt_row >= 0
|
||||||
|| (wp->w_p_wrap && (wp->w_p_lbr || wp->w_p_bri || *get_showbreak_value(wp) != NUL))) {
|
|| (wp->w_p_wrap && (wp->w_p_lbr || wp->w_p_bri || *get_showbreak_value(wp) != NUL))) {
|
||||||
return kCharsizeRegular;
|
return kCharsizeRegular;
|
||||||
} else {
|
} else {
|
||||||
@@ -115,16 +115,16 @@ CSType init_charsize_arg(CharsizeArg *cts, win_T *wp, linenr_T lnum, char *line)
|
|||||||
/// of 'showbreak'/'breakindent' before "cts->max_head_vcol".
|
/// of 'showbreak'/'breakindent' before "cts->max_head_vcol".
|
||||||
/// When "cts->max_head_vcol" is negative, only count in "head" the size
|
/// When "cts->max_head_vcol" is negative, only count in "head" the size
|
||||||
/// of 'showbreak'/'breakindent' before where cursor should be placed.
|
/// of 'showbreak'/'breakindent' before where cursor should be placed.
|
||||||
CharSize charsize_regular(CharsizeArg *cts, char *const cur, colnr_T const vcol,
|
CharSize charsize_regular(CharsizeArg *csarg, char *const cur, colnr_T const vcol,
|
||||||
int32_t const cur_char)
|
int32_t const cur_char)
|
||||||
{
|
{
|
||||||
cts->cur_text_width_left = 0;
|
csarg->cur_text_width_left = 0;
|
||||||
cts->cur_text_width_right = 0;
|
csarg->cur_text_width_right = 0;
|
||||||
|
|
||||||
win_T *wp = cts->win;
|
win_T *wp = csarg->win;
|
||||||
buf_T *buf = wp->w_buffer;
|
buf_T *buf = wp->w_buffer;
|
||||||
char *line = cts->line;
|
char *line = csarg->line;
|
||||||
bool const use_tabstop = cur_char == TAB && cts->use_tabstop;
|
bool const use_tabstop = cur_char == TAB && csarg->use_tabstop;
|
||||||
int mb_added = 0;
|
int mb_added = 0;
|
||||||
|
|
||||||
bool has_lcs_eol = wp->w_p_list && wp->w_p_lcs_chars.eol != NUL;
|
bool has_lcs_eol = wp->w_p_list && wp->w_p_lcs_chars.eol != NUL;
|
||||||
@@ -143,12 +143,12 @@ CharSize charsize_regular(CharsizeArg *cts, char *const cur, colnr_T const vcol,
|
|||||||
is_doublewidth = size == 2 && cur_char > 0x80;
|
is_doublewidth = size == 2 && cur_char > 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cts->virt_row >= 0) {
|
if (csarg->virt_row >= 0) {
|
||||||
int tab_size = size;
|
int tab_size = size;
|
||||||
int col = (int)(cur - line);
|
int col = (int)(cur - line);
|
||||||
while (true) {
|
while (true) {
|
||||||
MTKey mark = marktree_itr_current(cts->iter);
|
MTKey mark = marktree_itr_current(csarg->iter);
|
||||||
if (mark.pos.row != cts->virt_row || mark.pos.col > col) {
|
if (mark.pos.row != csarg->virt_row || mark.pos.col > col) {
|
||||||
break;
|
break;
|
||||||
} else if (mark.pos.col == col) {
|
} else if (mark.pos.col == col) {
|
||||||
if (!mt_end(mark) && mark.flags & (MT_FLAG_DECOR_VIRT_TEXT_INLINE)) {
|
if (!mt_end(mark) && mark.flags & (MT_FLAG_DECOR_VIRT_TEXT_INLINE)) {
|
||||||
@@ -157,9 +157,9 @@ CharSize charsize_regular(CharsizeArg *cts, char *const cur, colnr_T const vcol,
|
|||||||
while (vt) {
|
while (vt) {
|
||||||
if (!(vt->flags & kVTIsLines) && vt->pos == kVPosInline) {
|
if (!(vt->flags & kVTIsLines) && vt->pos == kVPosInline) {
|
||||||
if (mt_right(mark)) {
|
if (mt_right(mark)) {
|
||||||
cts->cur_text_width_right += vt->width;
|
csarg->cur_text_width_right += vt->width;
|
||||||
} else {
|
} else {
|
||||||
cts->cur_text_width_left += vt->width;
|
csarg->cur_text_width_left += vt->width;
|
||||||
}
|
}
|
||||||
size += vt->width;
|
size += vt->width;
|
||||||
if (use_tabstop) {
|
if (use_tabstop) {
|
||||||
@@ -173,7 +173,7 @@ CharSize charsize_regular(CharsizeArg *cts, char *const cur, colnr_T const vcol,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
marktree_itr_next(wp->w_buffer->b_marktree, cts->iter);
|
marktree_itr_next(wp->w_buffer->b_marktree, csarg->iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ CharSize charsize_regular(CharsizeArg *cts, char *const cur, colnr_T const vcol,
|
|||||||
int col_off_prev = win_col_off(wp);
|
int col_off_prev = win_col_off(wp);
|
||||||
int width2 = wp->w_width_inner - col_off_prev + win_col_off2(wp);
|
int width2 = wp->w_width_inner - col_off_prev + win_col_off2(wp);
|
||||||
colnr_T wcol = vcol + col_off_prev;
|
colnr_T wcol = vcol + col_off_prev;
|
||||||
colnr_T max_head_vcol = cts->max_head_vcol;
|
colnr_T max_head_vcol = csarg->max_head_vcol;
|
||||||
int added = 0;
|
int added = 0;
|
||||||
|
|
||||||
// cells taken by 'showbreak'/'breakindent' before current char
|
// cells taken by 'showbreak'/'breakindent' before current char
|
||||||
@@ -204,7 +204,7 @@ CharSize charsize_regular(CharsizeArg *cts, char *const cur, colnr_T const vcol,
|
|||||||
if (wcol >= width2 && width2 > 0) {
|
if (wcol >= width2 && width2 > 0) {
|
||||||
wcol %= width2;
|
wcol %= width2;
|
||||||
}
|
}
|
||||||
head_prev = cts->indent_width;
|
head_prev = csarg->indent_width;
|
||||||
if (head_prev == INT_MIN) {
|
if (head_prev == INT_MIN) {
|
||||||
head_prev = 0;
|
head_prev = 0;
|
||||||
if (*sbr != NUL) {
|
if (*sbr != NUL) {
|
||||||
@@ -213,7 +213,7 @@ CharSize charsize_regular(CharsizeArg *cts, char *const cur, colnr_T const vcol,
|
|||||||
if (wp->w_p_bri) {
|
if (wp->w_p_bri) {
|
||||||
head_prev += get_breakindent_win(wp, line);
|
head_prev += get_breakindent_win(wp, line);
|
||||||
}
|
}
|
||||||
cts->indent_width = head_prev;
|
csarg->indent_width = head_prev;
|
||||||
}
|
}
|
||||||
if (wcol < head_prev) {
|
if (wcol < head_prev) {
|
||||||
head_prev -= wcol;
|
head_prev -= wcol;
|
||||||
@@ -230,7 +230,7 @@ CharSize charsize_regular(CharsizeArg *cts, char *const cur, colnr_T const vcol,
|
|||||||
|
|
||||||
if (wcol + size > wp->w_width) {
|
if (wcol + size > wp->w_width) {
|
||||||
// cells taken by 'showbreak'/'breakindent' halfway current char
|
// cells taken by 'showbreak'/'breakindent' halfway current char
|
||||||
int head_mid = cts->indent_width;
|
int head_mid = csarg->indent_width;
|
||||||
if (head_mid == INT_MIN) {
|
if (head_mid == INT_MIN) {
|
||||||
head_mid = 0;
|
head_mid = 0;
|
||||||
if (*sbr != NUL) {
|
if (*sbr != NUL) {
|
||||||
@@ -239,7 +239,7 @@ CharSize charsize_regular(CharsizeArg *cts, char *const cur, colnr_T const vcol,
|
|||||||
if (wp->w_p_bri) {
|
if (wp->w_p_bri) {
|
||||||
head_mid += get_breakindent_win(wp, line);
|
head_mid += get_breakindent_win(wp, line);
|
||||||
}
|
}
|
||||||
cts->indent_width = head_mid;
|
csarg->indent_width = head_mid;
|
||||||
}
|
}
|
||||||
if (head_mid > 0 && wcol + size > wp->w_width_inner) {
|
if (head_mid > 0 && wcol + size > wp->w_width_inner) {
|
||||||
// Calculate effective window width.
|
// Calculate effective window width.
|
||||||
@@ -259,7 +259,7 @@ CharSize charsize_regular(CharsizeArg *cts, char *const cur, colnr_T const vcol,
|
|||||||
head += (max_head_vcol - (vcol + head_prev + prev_rem)
|
head += (max_head_vcol - (vcol + head_prev + prev_rem)
|
||||||
+ width2 - 1) / width2 * head_mid;
|
+ width2 - 1) / width2 * head_mid;
|
||||||
} else if (max_head_vcol < 0) {
|
} else if (max_head_vcol < 0) {
|
||||||
int off = virt_text_cursor_off(cts, *cur == NUL);
|
int off = virt_text_cursor_off(csarg, *cur == NUL);
|
||||||
if (off >= prev_rem) {
|
if (off >= prev_rem) {
|
||||||
if (size > off) {
|
if (size > off) {
|
||||||
head += (1 + (off - prev_rem) / width) * head_mid;
|
head += (1 + (off - prev_rem) / width) * head_mid;
|
||||||
@@ -279,11 +279,11 @@ CharSize charsize_regular(CharsizeArg *cts, char *const cur, colnr_T const vcol,
|
|||||||
// If 'linebreak' set check at a blank before a non-blank if the line
|
// If 'linebreak' set check at a blank before a non-blank if the line
|
||||||
// needs a break here
|
// needs a break here
|
||||||
if (wp->w_p_lbr && wp->w_p_wrap && wp->w_width_inner != 0) {
|
if (wp->w_p_lbr && wp->w_p_wrap && wp->w_width_inner != 0) {
|
||||||
char *t = cts->line;
|
char *t = csarg->line;
|
||||||
while (vim_isbreak((uint8_t)t[0])) {
|
while (vim_isbreak((uint8_t)t[0])) {
|
||||||
t++;
|
t++;
|
||||||
}
|
}
|
||||||
vcol_start = (colnr_T)(t - cts->line);
|
vcol_start = (colnr_T)(t - csarg->line);
|
||||||
}
|
}
|
||||||
if (wp->w_p_lbr && vcol_start <= vcol
|
if (wp->w_p_lbr && vcol_start <= vcol
|
||||||
&& vim_isbreak((uint8_t)s[0])
|
&& vim_isbreak((uint8_t)s[0])
|
||||||
@@ -361,10 +361,10 @@ static inline CharSize charsize_fast_impl(win_T *const wp, bool use_tabstop, col
|
|||||||
/// Like charsize_regular(), except it doesn't handle virtual text,
|
/// Like charsize_regular(), except it doesn't handle virtual text,
|
||||||
/// linebreak, breakindent and showbreak. Handles normal characters, tabs and wrapping.
|
/// linebreak, breakindent and showbreak. Handles normal characters, tabs and wrapping.
|
||||||
/// Can be used if CSType is kCharsizeFast.
|
/// Can be used if CSType is kCharsizeFast.
|
||||||
CharSize charsize_fast(CharsizeArg *cts, colnr_T const vcol, int32_t const cur_char)
|
CharSize charsize_fast(CharsizeArg *csarg, colnr_T const vcol, int32_t const cur_char)
|
||||||
FUNC_ATTR_PURE
|
FUNC_ATTR_PURE
|
||||||
{
|
{
|
||||||
return charsize_fast_impl(cts->win, cts->use_tabstop, vcol, cur_char);
|
return charsize_fast_impl(csarg->win, csarg->use_tabstop, vcol, cur_char);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check that virtual column "vcol" is in the rightmost column of window "wp".
|
/// Check that virtual column "vcol" is in the rightmost column of window "wp".
|
||||||
@@ -403,20 +403,20 @@ static bool in_win_border(win_T *wp, colnr_T vcol)
|
|||||||
///
|
///
|
||||||
/// @return virtual column before the character at 'len',
|
/// @return virtual column before the character at 'len',
|
||||||
/// or full size of the line if 'len' is MAXCOL.
|
/// or full size of the line if 'len' is MAXCOL.
|
||||||
int linesize_regular(CharsizeArg *const arg, int vcol, colnr_T const len)
|
int linesize_regular(CharsizeArg *const csarg, int vcol, colnr_T const len)
|
||||||
{
|
{
|
||||||
char *const line = arg->line;
|
char *const line = csarg->line;
|
||||||
|
|
||||||
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
||||||
while (ci.ptr - line < len && *ci.ptr != NUL) {
|
while (ci.ptr - line < len && *ci.ptr != NUL) {
|
||||||
vcol += charsize_regular(arg, ci.ptr, vcol, ci.chr.value).width;
|
vcol += charsize_regular(csarg, ci.ptr, vcol, ci.chr.value).width;
|
||||||
ci = utfc_next(ci);
|
ci = utfc_next(ci);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for inline virtual text after the end of the line.
|
// Check for inline virtual text after the end of the line.
|
||||||
if (len == MAXCOL && arg->virt_row >= 0) {
|
if (len == MAXCOL && csarg->virt_row >= 0) {
|
||||||
(void)charsize_regular(arg, ci.ptr, vcol, ci.chr.value);
|
(void)charsize_regular(csarg, ci.ptr, vcol, ci.chr.value);
|
||||||
vcol += arg->cur_text_width_left + arg->cur_text_width_right;
|
vcol += csarg->cur_text_width_left + csarg->cur_text_width_right;
|
||||||
}
|
}
|
||||||
|
|
||||||
return vcol;
|
return vcol;
|
||||||
@@ -425,12 +425,12 @@ int linesize_regular(CharsizeArg *const arg, int vcol, colnr_T const len)
|
|||||||
/// Like win_linesize_regular, but can be used when CStype is kCharsizeFast.
|
/// Like win_linesize_regular, but can be used when CStype is kCharsizeFast.
|
||||||
///
|
///
|
||||||
/// @see win_linesize_regular
|
/// @see win_linesize_regular
|
||||||
int linesize_fast(CharsizeArg const *const arg, int vcol, colnr_T const len)
|
int linesize_fast(CharsizeArg const *const csarg, int vcol, colnr_T const len)
|
||||||
{
|
{
|
||||||
win_T *const wp = arg->win;
|
win_T *const wp = csarg->win;
|
||||||
bool const use_tabstop = arg->use_tabstop;
|
bool const use_tabstop = csarg->use_tabstop;
|
||||||
|
|
||||||
char *const line = arg->line;
|
char *const line = csarg->line;
|
||||||
|
|
||||||
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
||||||
while (ci.ptr - line < len && *ci.ptr != NUL) {
|
while (ci.ptr - line < len && *ci.ptr != NUL) {
|
||||||
@@ -443,15 +443,17 @@ int linesize_fast(CharsizeArg const *const arg, int vcol, colnr_T const len)
|
|||||||
|
|
||||||
/// Get how many virtual columns inline virtual text should offset the cursor.
|
/// Get how many virtual columns inline virtual text should offset the cursor.
|
||||||
///
|
///
|
||||||
|
/// @param csarg should contain information stored by charsize_regular()
|
||||||
|
/// about widths of left and right gravity virtual text
|
||||||
/// @param on_NUL whether this is the end of the line
|
/// @param on_NUL whether this is the end of the line
|
||||||
static int virt_text_cursor_off(CharsizeArg *cts, bool on_NUL)
|
static int virt_text_cursor_off(const CharsizeArg *csarg, bool on_NUL)
|
||||||
{
|
{
|
||||||
int off = 0;
|
int off = 0;
|
||||||
if (!on_NUL || !(State & MODE_NORMAL)) {
|
if (!on_NUL || !(State & MODE_NORMAL)) {
|
||||||
off += cts->cur_text_width_left;
|
off += csarg->cur_text_width_left;
|
||||||
}
|
}
|
||||||
if (!on_NUL && (State & MODE_NORMAL)) {
|
if (!on_NUL && (State & MODE_NORMAL)) {
|
||||||
off += cts->cur_text_width_right;
|
off += csarg->cur_text_width_right;
|
||||||
}
|
}
|
||||||
return off;
|
return off;
|
||||||
}
|
}
|
||||||
@@ -473,16 +475,16 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en
|
|||||||
char *const line = ml_get_buf(wp->w_buffer, pos->lnum); // start of the line
|
char *const line = ml_get_buf(wp->w_buffer, pos->lnum); // start of the line
|
||||||
int const end_col = pos->col;
|
int const end_col = pos->col;
|
||||||
|
|
||||||
CharsizeArg arg;
|
CharsizeArg csarg;
|
||||||
bool on_NUL = false;
|
bool on_NUL = false;
|
||||||
CSType const cstype = init_charsize_arg(&arg, wp, pos->lnum, line);
|
CSType const cstype = init_charsize_arg(&csarg, wp, pos->lnum, line);
|
||||||
arg.max_head_vcol = -1;
|
csarg.max_head_vcol = -1;
|
||||||
|
|
||||||
colnr_T vcol = 0;
|
colnr_T vcol = 0;
|
||||||
CharSize char_size;
|
CharSize char_size;
|
||||||
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
||||||
if (cstype == kCharsizeFast) {
|
if (cstype == kCharsizeFast) {
|
||||||
bool const use_tabstop = arg.use_tabstop;
|
bool const use_tabstop = csarg.use_tabstop;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (*ci.ptr == NUL) {
|
if (*ci.ptr == NUL) {
|
||||||
// if cursor is at NUL, it is treated like 1 cell char
|
// if cursor is at NUL, it is treated like 1 cell char
|
||||||
@@ -499,10 +501,10 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (true) {
|
while (true) {
|
||||||
char_size = charsize_regular(&arg, ci.ptr, vcol, ci.chr.value);
|
char_size = charsize_regular(&csarg, ci.ptr, vcol, ci.chr.value);
|
||||||
if (*ci.ptr == NUL) {
|
if (*ci.ptr == NUL) {
|
||||||
// if cursor is at NUL, it is treated like 1 cell char unless there is virtual text
|
// if cursor is at NUL, it is treated like 1 cell char unless there is virtual text
|
||||||
char_size.width = MAX(1, arg.cur_text_width_left + arg.cur_text_width_right);
|
char_size.width = MAX(1, csarg.cur_text_width_left + csarg.cur_text_width_right);
|
||||||
on_NUL = true;
|
on_NUL = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -535,7 +537,7 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en
|
|||||||
// cursor at end
|
// cursor at end
|
||||||
*cursor = vcol + incr - 1;
|
*cursor = vcol + incr - 1;
|
||||||
} else {
|
} else {
|
||||||
vcol += virt_text_cursor_off(&arg, on_NUL);
|
vcol += virt_text_cursor_off(&csarg, on_NUL);
|
||||||
// cursor at start
|
// cursor at start
|
||||||
*cursor = vcol + head;
|
*cursor = vcol + head;
|
||||||
}
|
}
|
||||||
@@ -724,17 +726,17 @@ int plines_win_nofill(win_T *wp, linenr_T lnum, bool limit_winheight)
|
|||||||
int plines_win_nofold(win_T *wp, linenr_T lnum)
|
int plines_win_nofold(win_T *wp, linenr_T lnum)
|
||||||
{
|
{
|
||||||
char *s = ml_get_buf(wp->w_buffer, lnum);
|
char *s = ml_get_buf(wp->w_buffer, lnum);
|
||||||
CharsizeArg arg;
|
CharsizeArg csarg;
|
||||||
CSType const cstype = init_charsize_arg(&arg, wp, lnum, s);
|
CSType const cstype = init_charsize_arg(&csarg, wp, lnum, s);
|
||||||
if (*s == NUL && arg.virt_row < 0) {
|
if (*s == NUL && csarg.virt_row < 0) {
|
||||||
return 1; // be quick for an empty line
|
return 1; // be quick for an empty line
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t col;
|
int64_t col;
|
||||||
if (cstype == kCharsizeFast) {
|
if (cstype == kCharsizeFast) {
|
||||||
col = linesize_fast(&arg, 0, MAXCOL);
|
col = linesize_fast(&csarg, 0, MAXCOL);
|
||||||
} else {
|
} else {
|
||||||
col = linesize_regular(&arg, 0, MAXCOL);
|
col = linesize_regular(&csarg, 0, MAXCOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If list mode is on, then the '$' at the end of the line may take up one
|
// If list mode is on, then the '$' at the end of the line may take up one
|
||||||
@@ -774,20 +776,20 @@ int plines_win_col(win_T *wp, linenr_T lnum, long column)
|
|||||||
|
|
||||||
char *line = ml_get_buf(wp->w_buffer, lnum);
|
char *line = ml_get_buf(wp->w_buffer, lnum);
|
||||||
|
|
||||||
CharsizeArg cts;
|
CharsizeArg csarg;
|
||||||
CSType const cstype = init_charsize_arg(&cts, wp, lnum, line);
|
CSType const cstype = init_charsize_arg(&csarg, wp, lnum, line);
|
||||||
|
|
||||||
colnr_T vcol = 0;
|
colnr_T vcol = 0;
|
||||||
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
StrCharInfo ci = utf_ptr2StrCharInfo(line);
|
||||||
if (cstype == kCharsizeFast) {
|
if (cstype == kCharsizeFast) {
|
||||||
bool const use_tabstop = cts.use_tabstop;
|
bool const use_tabstop = csarg.use_tabstop;
|
||||||
while (*ci.ptr != NUL && --column >= 0) {
|
while (*ci.ptr != NUL && --column >= 0) {
|
||||||
vcol += charsize_fast_impl(wp, use_tabstop, vcol, ci.chr.value).width;
|
vcol += charsize_fast_impl(wp, use_tabstop, vcol, ci.chr.value).width;
|
||||||
ci = utfc_next(ci);
|
ci = utfc_next(ci);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (*ci.ptr != NUL && --column >= 0) {
|
while (*ci.ptr != NUL && --column >= 0) {
|
||||||
vcol += charsize_regular(&cts, ci.ptr, vcol, ci.chr.value).width;
|
vcol += charsize_regular(&csarg, ci.ptr, vcol, ci.chr.value).width;
|
||||||
ci = utfc_next(ci);
|
ci = utfc_next(ci);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -798,8 +800,8 @@ int plines_win_col(win_T *wp, linenr_T lnum, long column)
|
|||||||
// wraps from one screen line to the next (when 'columns' is not a multiple
|
// wraps from one screen line to the next (when 'columns' is not a multiple
|
||||||
// of 'ts') -- webb.
|
// of 'ts') -- webb.
|
||||||
colnr_T col = vcol;
|
colnr_T col = vcol;
|
||||||
if (ci.chr.value == TAB && (State & MODE_NORMAL) && cts.use_tabstop) {
|
if (ci.chr.value == TAB && (State & MODE_NORMAL) && csarg.use_tabstop) {
|
||||||
col += win_charsize(cstype, col, ci.ptr, ci.chr.value, &cts).width - 1;
|
col += win_charsize(cstype, col, ci.ptr, ci.chr.value, &csarg).width - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add column offset for 'number', 'relativenumber', 'foldcolumn', etc.
|
// Add column offset for 'number', 'relativenumber', 'foldcolumn', etc.
|
||||||
|
@@ -42,7 +42,7 @@ typedef struct {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline CharSize win_charsize(CSType cstype, int vcol, char *ptr, int32_t chr,
|
static inline CharSize win_charsize(CSType cstype, int vcol, char *ptr, int32_t chr,
|
||||||
CharsizeArg *arg)
|
CharsizeArg *csarg)
|
||||||
REAL_FATTR_NONNULL_ALL REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE;
|
REAL_FATTR_NONNULL_ALL REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE;
|
||||||
|
|
||||||
/// Get the number of cells taken up on the screen by the given character at vcol.
|
/// Get the number of cells taken up on the screen by the given character at vcol.
|
||||||
@@ -54,12 +54,12 @@ static inline CharSize win_charsize(CSType cstype, int vcol, char *ptr, int32_t
|
|||||||
/// When "arg->max_head_vcol" is negative, only count in "head" the size
|
/// When "arg->max_head_vcol" is negative, only count in "head" the size
|
||||||
/// of 'showbreak'/'breakindent' before where cursor should be placed.
|
/// of 'showbreak'/'breakindent' before where cursor should be placed.
|
||||||
static inline CharSize win_charsize(CSType cstype, int vcol, char *ptr, int32_t chr,
|
static inline CharSize win_charsize(CSType cstype, int vcol, char *ptr, int32_t chr,
|
||||||
CharsizeArg *arg)
|
CharsizeArg *csarg)
|
||||||
{
|
{
|
||||||
if (cstype == kCharsizeFast) {
|
if (cstype == kCharsizeFast) {
|
||||||
return charsize_fast(arg, vcol, chr);
|
return charsize_fast(csarg, vcol, chr);
|
||||||
} else {
|
} else {
|
||||||
return charsize_regular(arg, ptr, vcol, chr);
|
return charsize_regular(csarg, ptr, vcol, chr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,11 +89,11 @@ static inline int win_linetabsize(win_T *wp, linenr_T lnum, char *line, colnr_T
|
|||||||
/// @return Number of characters the string will take on the screen.
|
/// @return Number of characters the string will take on the screen.
|
||||||
static inline int win_linetabsize(win_T *wp, linenr_T lnum, char *line, colnr_T len)
|
static inline int win_linetabsize(win_T *wp, linenr_T lnum, char *line, colnr_T len)
|
||||||
{
|
{
|
||||||
CharsizeArg arg;
|
CharsizeArg csarg;
|
||||||
CSType const cstype = init_charsize_arg(&arg, wp, lnum, line);
|
CSType const cstype = init_charsize_arg(&csarg, wp, lnum, line);
|
||||||
if (cstype == kCharsizeFast) {
|
if (cstype == kCharsizeFast) {
|
||||||
return linesize_fast(&arg, 0, len);
|
return linesize_fast(&csarg, 0, len);
|
||||||
} else {
|
} else {
|
||||||
return linesize_regular(&arg, 0, len);
|
return linesize_regular(&csarg, 0, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user