patch 7.4.1195
Problem: The channel feature does not work in the MS-Windows console.
Solution: Add win32 console support. (Yasuhiro Matsumoto)
diff --git a/src/channel.c b/src/channel.c
index def6833..46c45b6 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -91,7 +91,7 @@
#ifdef FEAT_GUI_GTK
gint ch_inputHandler; /* Cookie for input */
#endif
-#ifdef FEAT_GUI_W32
+#ifdef WIN32
int ch_inputHandler; /* simply ret.value of WSAAsyncSelect() */
#endif
@@ -279,14 +279,14 @@
int sd;
struct sockaddr_in server;
struct hostent * host;
-#ifdef FEAT_GUI_W32
+#ifdef WIN32
u_short port = port_in;
#else
int port = port_in;
#endif
int idx;
-#ifdef FEAT_GUI_W32
+#ifdef WIN32
channel_init_winsock();
#endif
@@ -861,7 +861,7 @@
return channel_get(idx);
}
-# if defined(FEAT_GUI_W32) || defined(PROTO)
+# if defined(WIN32) || defined(PROTO)
/*
* Lookup the channel index from the socket.
* Returns -1 when the socket isn't found.
@@ -965,7 +965,7 @@
}
# 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.
*/
@@ -1007,6 +1007,6 @@
return ret;
}
-# endif /* UNIX && HAVE_SELECT */
+# endif /* !FEAT_GUI_W32 && HAVE_SELECT */
#endif /* FEAT_CHANNEL */
diff --git a/src/gui_w32.c b/src/gui_w32.c
index ecc1fab..88b89c6 100644
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -553,9 +553,6 @@
static TMonitorFromWindow pMonitorFromWindow = NULL;
static TGetMonitorInfo pGetMonitorInfo = 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
* less fancy GUI APIs.
@@ -844,6 +841,7 @@
const LPWINDOWPOS lpwpos)
{
static int x = 0, y = 0, cx = 0, cy = 0;
+ extern int WSInitialized;
if (WSInitialized && (lpwpos->x != x || lpwpos->y != y
|| lpwpos->cx != cx || lpwpos->cy != cy))
@@ -5049,22 +5047,3 @@
SetPixel(s_hdc, x+2, y, gui.currFgColor);
}
#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
diff --git a/src/os_mswin.c b/src/os_mswin.c
index ed7aa83..1626892 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -161,7 +161,9 @@
static HWND s_hwnd = 0; /* console window handle, set by GetConsoleHwnd() */
#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
* functions. */
@@ -3093,3 +3095,22 @@
}
#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
diff --git a/src/os_win32.c b/src/os_win32.c
index be7bd95..5a84824 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -1443,6 +1443,11 @@
INPUT_RECORD ir;
DWORD cRecords;
WCHAR ch, ch2;
+#ifdef FEAT_CHANNEL
+ int ret;
+ fd_set rfds;
+ int maxfd;
+#endif
if (msec > 0)
/* Wait until the specified time has elapsed. */
@@ -1459,9 +1464,22 @@
#ifdef FEAT_MZSCHEME
mzvim_check_threads();
#endif
+
#ifdef FEAT_CLIENTSERVER
serverProcessPendingMessages();
#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
#ifdef FEAT_MOUSE
|| g_nMouseClick != -1
@@ -1562,6 +1580,7 @@
if (input_available())
return TRUE;
#endif
+
return FALSE;
}
diff --git a/src/proto/gui_w32.pro b/src/proto/gui_w32.pro
index 57c6238..c8411f9 100644
--- a/src/proto/gui_w32.pro
+++ b/src/proto/gui_w32.pro
@@ -96,5 +96,4 @@
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 netbeans_draw_multisign_indicator(int row);
-void channel_init_winsock(void);
/* vim: set ft=c : */
diff --git a/src/proto/os_mswin.pro b/src/proto/os_mswin.pro
index ed2176e..333ba76 100644
--- a/src/proto/os_mswin.pro
+++ b/src/proto/os_mswin.pro
@@ -50,4 +50,5 @@
void serverProcessPendingMessages(void);
char *charset_id2name(int id);
int get_logfont(LOGFONT *lf, char_u *name, HDC printer_dc, int verbose);
+void channel_init_winsock(void);
/* vim: set ft=c : */
diff --git a/src/version.c b/src/version.c
index c246ed4..54a88c8 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1195,
+/**/
1194,
/**/
1193,
diff --git a/src/vim.h b/src/vim.h
index e7a5f58..b8de4ae 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -530,6 +530,8 @@
# ifdef HAVE_SYS_POLL_H
# include <sys/poll.h>
# define HAVE_POLL
+# elif defined(WIN32) && !defined(FEAT_GUI_W32)
+# define HAVE_SELECT
# else
# ifdef HAVE_POLL_H
# include <poll.h>