0
0
mirror of https://github.com/vim/vim.git synced 2025-09-01 21:03:39 -04:00

patch 7.4.1195

Problem:    The channel feature does not work in the MS-Windows console.
Solution:   Add win32 console support. (Yasuhiro Matsumoto)
This commit is contained in:
Bram Moolenaar 2016-01-29 21:11:25 +01:00
parent 83162468b3
commit f12d983dea
8 changed files with 53 additions and 30 deletions

View File

@ -91,7 +91,7 @@ typedef struct {
#ifdef FEAT_GUI_GTK #ifdef FEAT_GUI_GTK
gint ch_inputHandler; /* Cookie for input */ gint ch_inputHandler; /* Cookie for input */
#endif #endif
#ifdef FEAT_GUI_W32 #ifdef WIN32
int ch_inputHandler; /* simply ret.value of WSAAsyncSelect() */ int ch_inputHandler; /* simply ret.value of WSAAsyncSelect() */
#endif #endif
@ -279,14 +279,14 @@ channel_open(char *hostname, int port_in, void (*close_cb)(void))
int sd; int sd;
struct sockaddr_in server; struct sockaddr_in server;
struct hostent * host; struct hostent * host;
#ifdef FEAT_GUI_W32 #ifdef WIN32
u_short port = port_in; u_short port = port_in;
#else #else
int port = port_in; int port = port_in;
#endif #endif
int idx; int idx;
#ifdef FEAT_GUI_W32 #ifdef WIN32
channel_init_winsock(); channel_init_winsock();
#endif #endif
@ -861,7 +861,7 @@ channel_read_block(int idx)
return channel_get(idx); return channel_get(idx);
} }
# if defined(FEAT_GUI_W32) || defined(PROTO) # if defined(WIN32) || defined(PROTO)
/* /*
* Lookup the channel index from the socket. * Lookup the channel index from the socket.
* Returns -1 when the socket isn't found. * Returns -1 when the socket isn't found.
@ -965,7 +965,7 @@ channel_poll_check(int ret_in, void *fds_in)
} }
# endif /* UNIX && !HAVE_SELECT */ # endif /* UNIX && !HAVE_SELECT */
# if (defined(UNIX) && defined(HAVE_SELECT)) || defined(PROTO) # if (!defined(FEAT_GUI_W32) && defined(HAVE_SELECT)) || defined(PROTO)
/* /*
* The type of "rfds" is hidden to avoid problems with the function proto. * The type of "rfds" is hidden to avoid problems with the function proto.
*/ */
@ -1007,6 +1007,6 @@ channel_select_check(int ret_in, void *rfds_in)
return ret; return ret;
} }
# endif /* UNIX && HAVE_SELECT */ # endif /* !FEAT_GUI_W32 && HAVE_SELECT */
#endif /* FEAT_CHANNEL */ #endif /* FEAT_CHANNEL */

View File

@ -553,9 +553,6 @@ typedef BOOL (WINAPI *TGetMonitorInfo)(_HMONITOR, _MONITORINFO *);
static TMonitorFromWindow pMonitorFromWindow = NULL; static TMonitorFromWindow pMonitorFromWindow = NULL;
static TGetMonitorInfo pGetMonitorInfo = NULL; static TGetMonitorInfo pGetMonitorInfo = NULL;
static HANDLE user32_lib = NULL; static HANDLE user32_lib = NULL;
#ifdef FEAT_CHANNEL
int WSInitialized = FALSE; /* WinSock is initialized */
#endif
/* /*
* Return TRUE when running under Windows NT 3.x or Win32s, both of which have * Return TRUE when running under Windows NT 3.x or Win32s, both of which have
* less fancy GUI APIs. * less fancy GUI APIs.
@ -844,6 +841,7 @@ _OnWindowPosChanged(
const LPWINDOWPOS lpwpos) const LPWINDOWPOS lpwpos)
{ {
static int x = 0, y = 0, cx = 0, cy = 0; static int x = 0, y = 0, cx = 0, cy = 0;
extern int WSInitialized;
if (WSInitialized && (lpwpos->x != x || lpwpos->y != y if (WSInitialized && (lpwpos->x != x || lpwpos->y != y
|| lpwpos->cx != cx || lpwpos->cy != cy)) || lpwpos->cx != cx || lpwpos->cy != cy))
@ -5049,22 +5047,3 @@ netbeans_draw_multisign_indicator(int row)
SetPixel(s_hdc, x+2, y, gui.currFgColor); SetPixel(s_hdc, x+2, y, gui.currFgColor);
} }
#endif #endif
#if defined(FEAT_CHANNEL) || defined(PROTO)
/*
* Initialize the Winsock dll.
*/
void
channel_init_winsock()
{
WSADATA wsaData;
int wsaerr;
if (WSInitialized)
return;
wsaerr = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (wsaerr == 0)
WSInitialized = TRUE;
}
#endif

View File

@ -161,7 +161,9 @@ extern HWND s_hwnd;
static HWND s_hwnd = 0; /* console window handle, set by GetConsoleHwnd() */ static HWND s_hwnd = 0; /* console window handle, set by GetConsoleHwnd() */
#endif #endif
extern int WSInitialized; #ifdef FEAT_CHANNEL
int WSInitialized = FALSE; /* WinSock is initialized */
#endif
/* Don't generate prototypes here, because some systems do have these /* Don't generate prototypes here, because some systems do have these
* functions. */ * functions. */
@ -3093,3 +3095,22 @@ theend:
} }
#endif /* defined(FEAT_GUI) || defined(FEAT_PRINTER) */ #endif /* defined(FEAT_GUI) || defined(FEAT_PRINTER) */
#if defined(FEAT_CHANNEL) || defined(PROTO)
/*
* Initialize the Winsock dll.
*/
void
channel_init_winsock()
{
WSADATA wsaData;
int wsaerr;
if (WSInitialized)
return;
wsaerr = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (wsaerr == 0)
WSInitialized = TRUE;
}
#endif

View File

@ -1443,6 +1443,11 @@ WaitForChar(long msec)
INPUT_RECORD ir; INPUT_RECORD ir;
DWORD cRecords; DWORD cRecords;
WCHAR ch, ch2; WCHAR ch, ch2;
#ifdef FEAT_CHANNEL
int ret;
fd_set rfds;
int maxfd;
#endif
if (msec > 0) if (msec > 0)
/* Wait until the specified time has elapsed. */ /* Wait until the specified time has elapsed. */
@ -1459,9 +1464,22 @@ WaitForChar(long msec)
#ifdef FEAT_MZSCHEME #ifdef FEAT_MZSCHEME
mzvim_check_threads(); mzvim_check_threads();
#endif #endif
#ifdef FEAT_CLIENTSERVER #ifdef FEAT_CLIENTSERVER
serverProcessPendingMessages(); serverProcessPendingMessages();
#endif #endif
#ifdef FEAT_CHANNEL
FD_ZERO(&rfds);
maxfd = channel_select_setup(-1, &rfds);
if (maxfd >= 0)
{
ret = select(maxfd + 1, &rfds, NULL, NULL, NULL);
if (ret > 0 && channel_select_check(ret, &rfds) > 0)
return TRUE;
}
#endif
if (0 if (0
#ifdef FEAT_MOUSE #ifdef FEAT_MOUSE
|| g_nMouseClick != -1 || g_nMouseClick != -1
@ -1562,6 +1580,7 @@ WaitForChar(long msec)
if (input_available()) if (input_available())
return TRUE; return TRUE;
#endif #endif
return FALSE; return FALSE;
} }

View File

@ -96,5 +96,4 @@ void gui_mch_post_balloon(BalloonEval *beval, char_u *mesg);
BalloonEval *gui_mch_create_beval_area(void *target, char_u *mesg, void (*mesgCB)(BalloonEval *, int), void *clientData); BalloonEval *gui_mch_create_beval_area(void *target, char_u *mesg, void (*mesgCB)(BalloonEval *, int), void *clientData);
void gui_mch_destroy_beval_area(BalloonEval *beval); void gui_mch_destroy_beval_area(BalloonEval *beval);
void netbeans_draw_multisign_indicator(int row); void netbeans_draw_multisign_indicator(int row);
void channel_init_winsock(void);
/* vim: set ft=c : */ /* vim: set ft=c : */

View File

@ -50,4 +50,5 @@ char_u *serverGetReply(HWND server, int *expr_res, int remove, int wait);
void serverProcessPendingMessages(void); void serverProcessPendingMessages(void);
char *charset_id2name(int id); char *charset_id2name(int id);
int get_logfont(LOGFONT *lf, char_u *name, HDC printer_dc, int verbose); int get_logfont(LOGFONT *lf, char_u *name, HDC printer_dc, int verbose);
void channel_init_winsock(void);
/* vim: set ft=c : */ /* vim: set ft=c : */

View File

@ -746,6 +746,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1195,
/**/ /**/
1194, 1194,
/**/ /**/

View File

@ -530,6 +530,8 @@ typedef unsigned long u8char_T; /* long should be 32 bits or more */
# ifdef HAVE_SYS_POLL_H # ifdef HAVE_SYS_POLL_H
# include <sys/poll.h> # include <sys/poll.h>
# define HAVE_POLL # define HAVE_POLL
# elif defined(WIN32) && !defined(FEAT_GUI_W32)
# define HAVE_SELECT
# else # else
# ifdef HAVE_POLL_H # ifdef HAVE_POLL_H
# include <poll.h> # include <poll.h>