mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 14:28:18 +00:00
term: Move more mouse functions to mouse.c
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
#include "nvim/garray.h"
|
||||
#include "nvim/memory.h"
|
||||
#include "nvim/move.h"
|
||||
#include "nvim/mouse.h"
|
||||
#include "nvim/normal.h"
|
||||
#include "nvim/ops.h"
|
||||
#include "nvim/option.h"
|
||||
|
@@ -48,6 +48,7 @@
|
||||
#include "nvim/keymap.h"
|
||||
#include "nvim/garray.h"
|
||||
#include "nvim/move.h"
|
||||
#include "nvim/mouse.h"
|
||||
#include "nvim/ops.h"
|
||||
#include "nvim/option.h"
|
||||
#include "nvim/os_unix.h"
|
||||
|
@@ -43,6 +43,7 @@
|
||||
#include "nvim/log.h"
|
||||
#include "nvim/memory.h"
|
||||
#include "nvim/move.h"
|
||||
#include "nvim/mouse.h"
|
||||
#include "nvim/normal.h"
|
||||
#include "nvim/ops.h"
|
||||
#include "nvim/option.h"
|
||||
|
@@ -42,6 +42,7 @@
|
||||
#include "nvim/misc2.h"
|
||||
#include "nvim/garray.h"
|
||||
#include "nvim/move.h"
|
||||
#include "nvim/mouse.h"
|
||||
#include "nvim/option.h"
|
||||
#include "nvim/os_unix.h"
|
||||
#include "nvim/path.h"
|
||||
|
@@ -2,8 +2,12 @@
|
||||
|
||||
#include "nvim/mouse.h"
|
||||
#include "nvim/vim.h"
|
||||
#include "nvim/screen.h"
|
||||
#include "nvim/ascii.h"
|
||||
#include "nvim/window.h"
|
||||
#include "nvim/strings.h"
|
||||
#include "nvim/screen.h"
|
||||
#include "nvim/ui.h"
|
||||
#include "nvim/os_unix.h"
|
||||
#include "nvim/term.h"
|
||||
#include "nvim/fold.h"
|
||||
#include "nvim/diff.h"
|
||||
@@ -436,3 +440,62 @@ win_T *mouse_find_win(int *rowp, int *colp)
|
||||
}
|
||||
return fp->fr_win;
|
||||
}
|
||||
|
||||
/*
|
||||
* setmouse() - switch mouse on/off depending on current mode and 'mouse'
|
||||
*/
|
||||
void setmouse(void)
|
||||
{
|
||||
int checkfor;
|
||||
|
||||
|
||||
/* be quick when mouse is off */
|
||||
if (*p_mouse == NUL)
|
||||
return;
|
||||
|
||||
/* don't switch mouse on when not in raw mode (Ex mode) */
|
||||
if (cur_tmode != TMODE_RAW) {
|
||||
mch_setmouse(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (VIsual_active)
|
||||
checkfor = MOUSE_VISUAL;
|
||||
else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE)
|
||||
checkfor = MOUSE_RETURN;
|
||||
else if (State & INSERT)
|
||||
checkfor = MOUSE_INSERT;
|
||||
else if (State & CMDLINE)
|
||||
checkfor = MOUSE_COMMAND;
|
||||
else if (State == CONFIRM || State == EXTERNCMD)
|
||||
checkfor = ' '; /* don't use mouse for ":confirm" or ":!cmd" */
|
||||
else
|
||||
checkfor = MOUSE_NORMAL; /* assume normal mode */
|
||||
|
||||
if (mouse_has(checkfor))
|
||||
mch_setmouse(true);
|
||||
else
|
||||
mch_setmouse(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return true if
|
||||
* - "c" is in 'mouse', or
|
||||
* - 'a' is in 'mouse' and "c" is in MOUSE_A, or
|
||||
* - the current buffer is a help file and 'h' is in 'mouse' and we are in a
|
||||
* normal editing mode (not at hit-return message).
|
||||
*/
|
||||
int mouse_has(int c)
|
||||
{
|
||||
for (char_u *p = p_mouse; *p; ++p)
|
||||
switch (*p) {
|
||||
case 'a': if (vim_strchr((char_u *)MOUSE_A, c) != NULL)
|
||||
return true;
|
||||
break;
|
||||
case MOUSE_HELP: if (c != MOUSE_RETURN && curbuf->b_help)
|
||||
return true;
|
||||
break;
|
||||
default: if (c == *p) return true; break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -46,6 +46,7 @@
|
||||
#include "nvim/misc2.h"
|
||||
#include "nvim/keymap.h"
|
||||
#include "nvim/move.h"
|
||||
#include "nvim/mouse.h"
|
||||
#include "nvim/ops.h"
|
||||
#include "nvim/option.h"
|
||||
#include "nvim/quickfix.h"
|
||||
@@ -7374,3 +7375,11 @@ static void nv_cursorhold(cmdarg_T *cap)
|
||||
did_cursorhold = true;
|
||||
cap->retval |= CA_COMMAND_BUSY; /* don't call edit() now */
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE when 'mousemodel' is set to "popup" or "popup_setpos".
|
||||
*/
|
||||
static int mouse_model_popup(void)
|
||||
{
|
||||
return p_mousem[0] == 'p';
|
||||
}
|
||||
|
@@ -66,6 +66,7 @@
|
||||
#include "nvim/garray.h"
|
||||
#include "nvim/cursor_shape.h"
|
||||
#include "nvim/move.h"
|
||||
#include "nvim/mouse.h"
|
||||
#include "nvim/normal.h"
|
||||
#include "nvim/os_unix.h"
|
||||
#include "nvim/path.h"
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#include "nvim/message.h"
|
||||
#include "nvim/misc1.h"
|
||||
#include "nvim/misc2.h"
|
||||
#include "nvim/mouse.h"
|
||||
#include "nvim/garray.h"
|
||||
#include "nvim/path.h"
|
||||
#include "nvim/screen.h"
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#include "nvim/misc1.h"
|
||||
#include "nvim/misc2.h"
|
||||
#include "nvim/move.h"
|
||||
#include "nvim/mouse.h"
|
||||
#include "nvim/normal.h"
|
||||
#include "nvim/option.h"
|
||||
#include "nvim/path.h"
|
||||
|
@@ -43,6 +43,7 @@
|
||||
#include "nvim/keymap.h"
|
||||
#include "nvim/memory.h"
|
||||
#include "nvim/move.h"
|
||||
#include "nvim/mouse.h"
|
||||
#include "nvim/normal.h"
|
||||
#include "nvim/option.h"
|
||||
#include "nvim/os_unix.h"
|
||||
@@ -1506,7 +1507,6 @@ int set_termname(char_u *term)
|
||||
# define HMT_PTERM 8
|
||||
# define HMT_URXVT 16
|
||||
# define HMT_SGR 32
|
||||
static int has_mouse_termcode = 0;
|
||||
|
||||
void
|
||||
set_mouse_termcode (
|
||||
@@ -1517,16 +1517,6 @@ set_mouse_termcode (
|
||||
char_u name[2] = { n, KE_FILLER };
|
||||
|
||||
add_termcode(name, s, FALSE);
|
||||
if (n == KS_NETTERM_MOUSE)
|
||||
has_mouse_termcode |= HMT_NETTERM;
|
||||
else if (n == KS_DEC_MOUSE)
|
||||
has_mouse_termcode |= HMT_DEC;
|
||||
else if (n == KS_URXVT_MOUSE)
|
||||
has_mouse_termcode |= HMT_URXVT;
|
||||
else if (n == KS_SGR_MOUSE)
|
||||
has_mouse_termcode |= HMT_SGR;
|
||||
else
|
||||
has_mouse_termcode |= HMT_NORMAL;
|
||||
}
|
||||
|
||||
# if (defined(UNIX) && defined(FEAT_MOUSE_TTY)) || defined(PROTO)
|
||||
@@ -1538,16 +1528,6 @@ del_mouse_termcode (
|
||||
char_u name[2] = { n, KE_FILLER };
|
||||
|
||||
del_termcode(name);
|
||||
if (n == KS_NETTERM_MOUSE)
|
||||
has_mouse_termcode &= ~HMT_NETTERM;
|
||||
else if (n == KS_DEC_MOUSE)
|
||||
has_mouse_termcode &= ~HMT_DEC;
|
||||
else if (n == KS_URXVT_MOUSE)
|
||||
has_mouse_termcode &= ~HMT_URXVT;
|
||||
else if (n == KS_SGR_MOUSE)
|
||||
has_mouse_termcode &= ~HMT_SGR;
|
||||
else
|
||||
has_mouse_termcode &= ~HMT_NORMAL;
|
||||
}
|
||||
# endif
|
||||
|
||||
@@ -2544,73 +2524,6 @@ int swapping_screen(void)
|
||||
return full_screen && *T_TI != NUL;
|
||||
}
|
||||
|
||||
/*
|
||||
* setmouse() - switch mouse on/off depending on current mode and 'mouse'
|
||||
*/
|
||||
void setmouse(void)
|
||||
{
|
||||
int checkfor;
|
||||
|
||||
|
||||
/* be quick when mouse is off */
|
||||
if (*p_mouse == NUL || has_mouse_termcode == 0)
|
||||
return;
|
||||
|
||||
/* don't switch mouse on when not in raw mode (Ex mode) */
|
||||
if (cur_tmode != TMODE_RAW) {
|
||||
mch_setmouse(FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (VIsual_active)
|
||||
checkfor = MOUSE_VISUAL;
|
||||
else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE)
|
||||
checkfor = MOUSE_RETURN;
|
||||
else if (State & INSERT)
|
||||
checkfor = MOUSE_INSERT;
|
||||
else if (State & CMDLINE)
|
||||
checkfor = MOUSE_COMMAND;
|
||||
else if (State == CONFIRM || State == EXTERNCMD)
|
||||
checkfor = ' '; /* don't use mouse for ":confirm" or ":!cmd" */
|
||||
else
|
||||
checkfor = MOUSE_NORMAL; /* assume normal mode */
|
||||
|
||||
if (mouse_has(checkfor))
|
||||
mch_setmouse(TRUE);
|
||||
else
|
||||
mch_setmouse(FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE if
|
||||
* - "c" is in 'mouse', or
|
||||
* - 'a' is in 'mouse' and "c" is in MOUSE_A, or
|
||||
* - the current buffer is a help file and 'h' is in 'mouse' and we are in a
|
||||
* normal editing mode (not at hit-return message).
|
||||
*/
|
||||
int mouse_has(int c)
|
||||
{
|
||||
for (char_u *p = p_mouse; *p; ++p)
|
||||
switch (*p) {
|
||||
case 'a': if (vim_strchr((char_u *)MOUSE_A, c) != NULL)
|
||||
return TRUE;
|
||||
break;
|
||||
case MOUSE_HELP: if (c != MOUSE_RETURN && curbuf->b_help)
|
||||
return TRUE;
|
||||
break;
|
||||
default: if (c == *p) return TRUE; break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE when 'mousemodel' is set to "popup" or "popup_setpos".
|
||||
*/
|
||||
int mouse_model_popup(void)
|
||||
{
|
||||
return p_mousem[0] == 'p';
|
||||
}
|
||||
|
||||
/*
|
||||
* By outputting the 'cursor very visible' termcap code, for some windowed
|
||||
* terminals this makes the screen scrolled to the correct position.
|
||||
|
@@ -41,6 +41,7 @@
|
||||
#include "nvim/file_search.h"
|
||||
#include "nvim/garray.h"
|
||||
#include "nvim/move.h"
|
||||
#include "nvim/mouse.h"
|
||||
#include "nvim/normal.h"
|
||||
#include "nvim/option.h"
|
||||
#include "nvim/os_unix.h"
|
||||
|
Reference in New Issue
Block a user