if (mouse_comp_pos(curwin, &row, &col, &mpos->lnum, NULL))
return IN_STATUS_LINE; // past bottom
- mpos->col = vcol2col(wp, mpos->lnum, col);
-
- mpos->coladd = 0;
+ mpos->col = vcol2col(wp, mpos->lnum, col, &mpos->coladd);
return IN_BUFFER;
}
#endif
* The first column is zero.
*/
int
-vcol2col(win_T *wp, linenr_T lnum, int vcol)
+vcol2col(win_T *wp, linenr_T lnum, int vcol, colnr_T *coladdp)
{
char_u *line;
chartabsize_T cts;
}
clear_chartabsize_arg(&cts);
+ if (coladdp != NULL)
+ *coladdp = vcol - cts.cts_vcol;
return (int)(cts.cts_ptr - line);
}
#endif
varnumber_T wincol = 0;
linenr_T lnum = 0;
varnumber_T column = 0;
+ colnr_T coladd = 0;
if (rettv_dict_alloc(rettv) == FAIL)
return;
if (row >= 0 && row < wp->w_height && col >= 0 && col < wp->w_width)
{
(void)mouse_comp_pos(wp, &row, &col, &lnum, NULL);
- col = vcol2col(wp, lnum, col);
+ col = vcol2col(wp, lnum, col, &coladd);
column = col + 1;
}
}
dict_add_number(d, "wincol", wincol);
dict_add_number(d, "line", (varnumber_T)lnum);
dict_add_number(d, "column", column);
+ dict_add_number(d, "coladd", coladd);
}
#endif
eval a:tests->add(#{clickrow: a:row, clickcol: a:col, result: #{
\ screenrow: a:row, screencol: a:col,
\ winid: win_getid(), winrow: a:row, wincol: a:col,
- \ line: a:row, column: a:col,
+ \ line: a:row, column: a:col, coladd: 0,
\ }})
endfunc
func AddItemInPopupBorder(tests, winid, row, col)
eval a:tests->add(#{clickrow: a:row, clickcol: a:col, result: #{
\ screenrow: a:row, screencol: a:col,
\ winid: a:winid, winrow: a:row - 1, wincol: a:col - 3,
- \ line: 0, column: 0,
+ \ line: 0, column: 0, coladd: 0,
\ }})
endfunc
- func AddItemInPopupText(tests, winid, row, col, textline, textcol)
+ func AddItemInPopupText(tests, winid, row, col, textline, textcol, coladd = 0)
eval a:tests->add(#{clickrow: a:row, clickcol: a:col, result: #{
\ screenrow: a:row, screencol: a:col,
\ winid: a:winid, winrow: a:row - 1, wincol: a:col - 3,
- \ line: a:textline, column: a:textcol,
+ \ line: a:textline, column: a:textcol, coladd: a:coladd,
\ }})
endfunc
call AddItemInPopupText(tests, winid, 4, 6, 1, 1)
call AddItemInPopupText(tests, winid, 4, 10, 1, 5)
call AddItemInPopupText(tests, winid, 4, 11, 1, 6)
- call AddItemInPopupText(tests, winid, 4, 17, 1, 6)
+ call AddItemInPopupText(tests, winid, 4, 17, 1, 6, 6)
" text "long line th"
call AddItemInPopupText(tests, winid, 5, 6, 2, 1)
call AddItemInPopupText(tests, winid, 5, 10, 2, 5)
call AddItemInPopupText(tests, winid, 7, 6, 3, 1)
call AddItemInPopupText(tests, winid, 7, 10, 3, 5)
call AddItemInPopupText(tests, winid, 7, 11, 3, 6)
- call AddItemInPopupText(tests, winid, 7, 17, 3, 6)
+ call AddItemInPopupText(tests, winid, 7, 17, 3, 6, 6)
for item in tests
call test_setmouse(item.clickrow, item.clickcol)