mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 8.1.2062: the mouse code is spread out
Problem: The mouse code is spread out. Solution: Move all the mouse code to mouse.c. (Yegappan Lakshmanan, closes #4959)
This commit is contained in:
147
src/edit.c
147
src/edit.c
@@ -27,7 +27,6 @@ static void ins_ctrl_v(void);
|
||||
#ifdef FEAT_JOB_CHANNEL
|
||||
static void init_prompt(int cmdchar_todo);
|
||||
#endif
|
||||
static void undisplay_dollar(void);
|
||||
static void insert_special(int, int, int);
|
||||
static void internal_format(int textwidth, int second_indent, int flags, int format_only, int c);
|
||||
static void check_auto_format(int);
|
||||
@@ -56,10 +55,6 @@ static void ins_ctrl_o(void);
|
||||
static void ins_shift(int c, int lastc);
|
||||
static void ins_del(void);
|
||||
static int ins_bs(int c, int mode, int *inserted_space_p);
|
||||
#ifdef FEAT_MOUSE
|
||||
static void ins_mouse(int c);
|
||||
static void ins_mousescroll(int dir);
|
||||
#endif
|
||||
#if defined(FEAT_GUI_TABLINE) || defined(PROTO)
|
||||
static void ins_tabline(int c);
|
||||
#endif
|
||||
@@ -322,9 +317,7 @@ edit(
|
||||
im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MOUSE
|
||||
setmouse();
|
||||
#endif
|
||||
#ifdef FEAT_CMDL_INFO
|
||||
clear_showcmd();
|
||||
#endif
|
||||
@@ -1759,7 +1752,7 @@ display_dollar(colnr_T col)
|
||||
* Call this function before moving the cursor from the normal insert position
|
||||
* in insert mode.
|
||||
*/
|
||||
static void
|
||||
void
|
||||
undisplay_dollar(void)
|
||||
{
|
||||
if (dollar_vcol >= 0)
|
||||
@@ -4508,9 +4501,7 @@ ins_esc(
|
||||
/* need to position cursor again (e.g. when on a TAB ) */
|
||||
changed_cline_bef_curs();
|
||||
|
||||
#ifdef FEAT_MOUSE
|
||||
setmouse();
|
||||
#endif
|
||||
#ifdef CURSOR_SHAPE
|
||||
ui_cursor_shape(); /* may show different cursor shape */
|
||||
#endif
|
||||
@@ -5157,134 +5148,6 @@ ins_bs(
|
||||
return did_backspace;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MOUSE
|
||||
static void
|
||||
ins_mouse(int c)
|
||||
{
|
||||
pos_T tpos;
|
||||
win_T *old_curwin = curwin;
|
||||
|
||||
# ifdef FEAT_GUI
|
||||
/* When GUI is active, also move/paste when 'mouse' is empty */
|
||||
if (!gui.in_use)
|
||||
# endif
|
||||
if (!mouse_has(MOUSE_INSERT))
|
||||
return;
|
||||
|
||||
undisplay_dollar();
|
||||
tpos = curwin->w_cursor;
|
||||
if (do_mouse(NULL, c, BACKWARD, 1L, 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;
|
||||
#ifdef FEAT_JOB_CHANNEL
|
||||
if (bt_prompt(curbuf))
|
||||
// Restart Insert mode when re-entering the prompt buffer.
|
||||
curbuf->b_prompt_insert = 'A';
|
||||
#endif
|
||||
}
|
||||
start_arrow(curwin == old_curwin ? &tpos : NULL);
|
||||
if (curwin != new_curwin && win_valid(new_curwin))
|
||||
{
|
||||
curwin = new_curwin;
|
||||
curbuf = curwin->w_buffer;
|
||||
}
|
||||
# ifdef FEAT_CINDENT
|
||||
can_cindent = TRUE;
|
||||
# endif
|
||||
}
|
||||
|
||||
/* redraw status lines (in case another window became active) */
|
||||
redraw_statuslines();
|
||||
}
|
||||
|
||||
static void
|
||||
ins_mousescroll(int dir)
|
||||
{
|
||||
pos_T tpos;
|
||||
win_T *old_curwin = curwin, *wp;
|
||||
int did_scroll = FALSE;
|
||||
|
||||
tpos = curwin->w_cursor;
|
||||
|
||||
if (mouse_row >= 0 && mouse_col >= 0)
|
||||
{
|
||||
int row, col;
|
||||
|
||||
row = mouse_row;
|
||||
col = mouse_col;
|
||||
|
||||
/* find the window at the pointer coordinates */
|
||||
wp = mouse_find_win(&row, &col, FIND_POPUP);
|
||||
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,
|
||||
(long)(curwin->w_botline - curwin->w_topline));
|
||||
else
|
||||
scroll_redraw(dir, 3L);
|
||||
# ifdef FEAT_TEXT_PROP
|
||||
if (WIN_IS_POPUP(curwin))
|
||||
popup_set_firstline(curwin);
|
||||
# endif
|
||||
}
|
||||
#ifdef FEAT_GUI
|
||||
else
|
||||
{
|
||||
int val, step = 6;
|
||||
|
||||
if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))
|
||||
step = curwin->w_width;
|
||||
val = curwin->w_leftcol + (dir == MSCR_RIGHT ? -step : step);
|
||||
if (val < 0)
|
||||
val = 0;
|
||||
gui_do_horiz_scroll(val, TRUE);
|
||||
}
|
||||
#endif
|
||||
did_scroll = TRUE;
|
||||
}
|
||||
|
||||
curwin->w_redr_status = TRUE;
|
||||
|
||||
curwin = old_curwin;
|
||||
curbuf = curwin->w_buffer;
|
||||
|
||||
/* The popup menu may overlay the window, need to redraw it.
|
||||
* TODO: Would be more efficient to only redraw the windows that are
|
||||
* overlapped by the popup menu. */
|
||||
if (pum_visible() && did_scroll)
|
||||
{
|
||||
redraw_all_later(NOT_VALID);
|
||||
ins_compl_show_pum();
|
||||
}
|
||||
|
||||
if (!EQUAL_POS(curwin->w_cursor, tpos))
|
||||
{
|
||||
start_arrow(&tpos);
|
||||
# ifdef FEAT_CINDENT
|
||||
can_cindent = TRUE;
|
||||
# endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Handle receiving P_PS: start paste mode. Inserts the following text up to
|
||||
* P_PE literally.
|
||||
@@ -6401,10 +6264,16 @@ do_insert_char_pre(int c)
|
||||
|
||||
#if defined(FEAT_CINDENT) || defined(PROTO)
|
||||
int
|
||||
can_cindent_get(void)
|
||||
get_can_cindent(void)
|
||||
{
|
||||
return can_cindent;
|
||||
}
|
||||
|
||||
void
|
||||
set_can_cindent(int val)
|
||||
{
|
||||
can_cindent = val;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user