vim-patch:8.1.2062: the mouse code is spread out (#24817)

Problem:    The mouse code is spread out.
Solution:   Move all the mouse code to mouse.c. (Yegappan Lakshmanan,
            closes vim/vim#4959)

b20b9e14dd

Also move getmousepos() there.

N/A patches for version.c:

vim-patch:8.1.2070: mouse code is spread out

Problem:    Mouse code is spread out.
Solution:   Move mouse terminal code parsing to mouse.c. (Yegappan Lakshmanan,
            closes vim/vim#4966)

b8ff5c271e

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2023-08-21 15:23:32 +08:00
committed by GitHub
parent 3b0515e674
commit cc35352f65
5 changed files with 172 additions and 169 deletions

View File

@@ -3995,82 +3995,6 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
return did_backspace;
}
static void ins_mouse(int c)
{
pos_T tpos;
win_T *old_curwin = curwin;
undisplay_dollar();
tpos = curwin->w_cursor;
if (do_mouse(NULL, c, BACKWARD, 1, 0)) {
win_T *new_curwin = curwin;
if (curwin != old_curwin && win_valid(old_curwin)) {
// Mouse took us to another window. We need to go back to the
// previous one to stop insert there properly.
curwin = old_curwin;
curbuf = curwin->w_buffer;
if (bt_prompt(curbuf)) {
// Restart Insert mode when re-entering the prompt buffer.
curbuf->b_prompt_insert = 'A';
}
}
start_arrow(curwin == old_curwin ? &tpos : NULL);
if (curwin != new_curwin && win_valid(new_curwin)) {
curwin = new_curwin;
curbuf = curwin->w_buffer;
}
can_cindent = true;
}
// redraw status lines (in case another window became active)
redraw_statuslines();
}
static void ins_mousescroll(int dir)
{
win_T *const old_curwin = curwin;
pos_T tpos = curwin->w_cursor;
if (mouse_row >= 0 && mouse_col >= 0) {
int row = mouse_row, col = mouse_col, grid = mouse_grid;
// find the window at the pointer coordinates
win_T *wp = mouse_find_win(&grid, &row, &col);
if (wp == NULL) {
return;
}
curwin = wp;
curbuf = curwin->w_buffer;
}
if (curwin == old_curwin) {
undisplay_dollar();
}
// Don't scroll the window in which completion is being done.
if (!pum_visible() || curwin != old_curwin) {
if (dir == MSCR_DOWN || dir == MSCR_UP) {
if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) {
scroll_redraw(dir, curwin->w_botline - curwin->w_topline);
} else if (p_mousescroll_vert > 0) {
scroll_redraw(dir, (linenr_T)p_mousescroll_vert);
}
} else {
mouse_scroll_horiz(dir);
}
}
curwin->w_redr_status = true;
curwin = old_curwin;
curbuf = curwin->w_buffer;
if (!equalpos(curwin->w_cursor, tpos)) {
start_arrow(&tpos);
can_cindent = true;
}
}
static void ins_left(void)
{
pos_T tpos;