forked from aniani/vim
updated for version 7.2a
This commit is contained in:
171
src/os_unix.c
171
src/os_unix.c
@@ -35,10 +35,6 @@
|
||||
# include "if_mzsch.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include "os_unixx.h" /* unix includes for os_unix.c only */
|
||||
|
||||
#ifdef USE_XSMP
|
||||
@@ -92,6 +88,15 @@ static int gpm_open __ARGS((void));
|
||||
static int mch_gpm_process __ARGS((void));
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_SYSMOUSE
|
||||
# include <sys/consio.h>
|
||||
# include <sys/fbio.h>
|
||||
|
||||
static int sysmouse_open __ARGS((void));
|
||||
static void sysmouse_close __ARGS((void));
|
||||
static RETSIGTYPE sig_sysmouse __ARGS(SIGPROTOARG);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* end of autoconf section. To be extended...
|
||||
*/
|
||||
@@ -289,7 +294,8 @@ static struct signalinfo
|
||||
#ifdef SIGUSR1
|
||||
{SIGUSR1, "USR1", TRUE},
|
||||
#endif
|
||||
#ifdef SIGUSR2
|
||||
#if defined(SIGUSR2) && !defined(FEAT_SYSMOUSE)
|
||||
/* Used for sysmouse handling */
|
||||
{SIGUSR2, "USR2", TRUE},
|
||||
#endif
|
||||
#ifdef SIGINT
|
||||
@@ -2055,6 +2061,21 @@ vim_is_xterm(name)
|
||||
|| STRCMP(name, "builtin_xterm") == 0);
|
||||
}
|
||||
|
||||
#if defined(FEAT_MOUSE_XTERM) || defined(PROTO)
|
||||
/*
|
||||
* Return TRUE if "name" appears to be that of a terminal
|
||||
* known to support the xterm-style mouse protocol.
|
||||
* Relies on term_is_xterm having been set to its correct value.
|
||||
*/
|
||||
int
|
||||
use_xterm_like_mouse(name)
|
||||
char_u *name;
|
||||
{
|
||||
return (name != NULL
|
||||
&& (term_is_xterm || STRNICMP(name, "screen", 6) == 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_MOUSE_TTY) || defined(PROTO)
|
||||
/*
|
||||
* Return non-zero when using an xterm mouse, according to 'ttymouse'.
|
||||
@@ -2279,10 +2300,10 @@ mch_FullName(fname, buf, len, force)
|
||||
char_u *p;
|
||||
int retval = OK;
|
||||
#ifdef __CYGWIN__
|
||||
char_u posix_fname[MAX_PATH];
|
||||
char_u posix_fname[MAXPATHL]; /* Cygwin docs mention MAX_PATH, but
|
||||
it's not always defined */
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VMS
|
||||
fname = vms_fixfilename(fname);
|
||||
#endif
|
||||
@@ -3255,6 +3276,22 @@ mch_setmouse(on)
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef FEAT_SYSMOUSE
|
||||
else
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
if (sysmouse_open() == OK)
|
||||
ison = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
sysmouse_close();
|
||||
ison = FALSE;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef FEAT_MOUSE_JSB
|
||||
else
|
||||
{
|
||||
@@ -3342,6 +3379,15 @@ check_mouse_termcode()
|
||||
set_mouse_termcode(KS_MOUSE, (char_u *)IF_EB("\033MG", ESC_STR "MG"));
|
||||
# endif
|
||||
|
||||
# ifdef FEAT_SYSMOUSE
|
||||
if (!use_xterm_mouse()
|
||||
# ifdef FEAT_GUI
|
||||
&& !gui.in_use
|
||||
# endif
|
||||
)
|
||||
set_mouse_termcode(KS_MOUSE, (char_u *)IF_EB("\033MS", ESC_STR "MS"));
|
||||
# endif
|
||||
|
||||
# ifdef FEAT_MOUSE_JSB
|
||||
/* conflicts with xterm mouse: "\033[" and "\033[M" ??? */
|
||||
if (!use_xterm_mouse()
|
||||
@@ -5170,7 +5216,7 @@ mch_expand_wildcards(num_pat, pat, num_file, file, flags)
|
||||
static int did_find_nul = FALSE;
|
||||
int ampersent = FALSE;
|
||||
/* vimglob() function to define for Posix shell */
|
||||
static char *sh_vimglob_func = "vimglob() { while [ $# -ge 1 ]; do echo -n \"$1\"; echo; shift; done }; vimglob >";
|
||||
static char *sh_vimglob_func = "vimglob() { while [ $# -ge 1 ]; do echo \"$1\"; shift; done }; vimglob >";
|
||||
|
||||
*num_file = 0; /* default: no files found */
|
||||
*file = NULL;
|
||||
@@ -5811,7 +5857,6 @@ gpm_open()
|
||||
|
||||
/*
|
||||
* Closes connection to gpm
|
||||
* returns non-zero if connection successfully closed
|
||||
*/
|
||||
static void
|
||||
gpm_close()
|
||||
@@ -5906,6 +5951,114 @@ mch_gpm_process()
|
||||
}
|
||||
#endif /* FEAT_MOUSE_GPM */
|
||||
|
||||
#ifdef FEAT_SYSMOUSE
|
||||
/*
|
||||
* Initialize connection with sysmouse.
|
||||
* Let virtual console inform us with SIGUSR2 for pending sysmouse
|
||||
* output, any sysmouse output than will be processed via sig_sysmouse().
|
||||
* Return OK if succeeded, FAIL if failed.
|
||||
*/
|
||||
static int
|
||||
sysmouse_open()
|
||||
{
|
||||
struct mouse_info mouse;
|
||||
|
||||
mouse.operation = MOUSE_MODE;
|
||||
mouse.u.mode.mode = 0;
|
||||
mouse.u.mode.signal = SIGUSR2;
|
||||
if (ioctl(1, CONS_MOUSECTL, &mouse) != -1)
|
||||
{
|
||||
signal(SIGUSR2, (RETSIGTYPE (*)())sig_sysmouse);
|
||||
mouse.operation = MOUSE_SHOW;
|
||||
ioctl(1, CONS_MOUSECTL, &mouse);
|
||||
return OK;
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Stop processing SIGUSR2 signals, and also make sure that
|
||||
* virtual console do not send us any sysmouse related signal.
|
||||
*/
|
||||
static void
|
||||
sysmouse_close()
|
||||
{
|
||||
struct mouse_info mouse;
|
||||
|
||||
signal(SIGUSR2, restricted ? SIG_IGN : SIG_DFL);
|
||||
mouse.operation = MOUSE_MODE;
|
||||
mouse.u.mode.mode = 0;
|
||||
mouse.u.mode.signal = 0;
|
||||
ioctl(1, CONS_MOUSECTL, &mouse);
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets info from sysmouse and adds special keys to input buf.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
static RETSIGTYPE
|
||||
sig_sysmouse SIGDEFARG(sigarg)
|
||||
{
|
||||
struct mouse_info mouse;
|
||||
struct video_info video;
|
||||
char_u string[6];
|
||||
int row, col;
|
||||
int button;
|
||||
int buttons;
|
||||
static int oldbuttons = 0;
|
||||
|
||||
#ifdef FEAT_GUI
|
||||
/* Don't put events in the input queue now. */
|
||||
if (hold_gui_events)
|
||||
return;
|
||||
#endif
|
||||
|
||||
mouse.operation = MOUSE_GETINFO;
|
||||
if (ioctl(1, FBIO_GETMODE, &video.vi_mode) != -1
|
||||
&& ioctl(1, FBIO_MODEINFO, &video) != -1
|
||||
&& ioctl(1, CONS_MOUSECTL, &mouse) != -1
|
||||
&& video.vi_cheight > 0 && video.vi_cwidth > 0)
|
||||
{
|
||||
row = mouse.u.data.y / video.vi_cheight;
|
||||
col = mouse.u.data.x / video.vi_cwidth;
|
||||
buttons = mouse.u.data.buttons;
|
||||
string[0] = ESC; /* Our termcode */
|
||||
string[1] = 'M';
|
||||
string[2] = 'S';
|
||||
if (oldbuttons == buttons && buttons != 0)
|
||||
{
|
||||
button = MOUSE_DRAG;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (buttons)
|
||||
{
|
||||
case 0:
|
||||
button = MOUSE_RELEASE;
|
||||
break;
|
||||
case 1:
|
||||
button = MOUSE_LEFT;
|
||||
break;
|
||||
case 2:
|
||||
button = MOUSE_MIDDLE;
|
||||
break;
|
||||
case 4:
|
||||
button = MOUSE_RIGHT;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
oldbuttons = buttons;
|
||||
}
|
||||
string[3] = (char_u)(button);
|
||||
string[4] = (char_u)(col + ' ' + 1);
|
||||
string[5] = (char_u)(row + ' ' + 1);
|
||||
add_to_input_buf(string, 6);
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif /* FEAT_SYSMOUSE */
|
||||
|
||||
#if defined(FEAT_LIBCALL) || defined(PROTO)
|
||||
typedef char_u * (*STRPROCSTR)__ARGS((char_u *));
|
||||
typedef char_u * (*INTPROCSTR)__ARGS((int));
|
||||
|
Reference in New Issue
Block a user