]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 7.4.1195 v7.4.1195
authorBram Moolenaar <Bram@vim.org>
Fri, 29 Jan 2016 20:11:25 +0000 (21:11 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 29 Jan 2016 20:11:25 +0000 (21:11 +0100)
Problem:    The channel feature does not work in the MS-Windows console.
Solution:   Add win32 console support. (Yasuhiro Matsumoto)

src/channel.c
src/gui_w32.c
src/os_mswin.c
src/os_win32.c
src/proto/gui_w32.pro
src/proto/os_mswin.pro
src/version.c
src/vim.h

index def6833136a6192cd2b652894be5a7d543793202..46c45b696afcdcb88ae53ffa4e5d7f203a90e607 100644 (file)
@@ -91,7 +91,7 @@ typedef struct {
 #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 @@ channel_open(char *hostname, int port_in, void (*close_cb)(void))
     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 @@ channel_read_block(int idx)
     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 @@ channel_poll_check(int ret_in, void *fds_in)
 }
 # 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 @@ channel_select_check(int ret_in, void *rfds_in)
 
     return ret;
 }
-# endif /* UNIX && HAVE_SELECT */
+# endif /* !FEAT_GUI_W32 && HAVE_SELECT */
 
 #endif /* FEAT_CHANNEL */
index ecc1fab41f2532820d1e243a74082310b202466e..88b89c6b3c823ffe3d6e62208fb62f60e10b1457 100644 (file)
@@ -553,9 +553,6 @@ typedef BOOL (WINAPI *TGetMonitorInfo)(_HMONITOR, _MONITORINFO *);
 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 @@ _OnWindowPosChanged(
     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 @@ netbeans_draw_multisign_indicator(int row)
     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
index ed7aa834d4e471743ba42cce3da5b22d83e366e8..16268920e358362d52c1fcbd9e629283471c5f62 100644 (file)
@@ -161,7 +161,9 @@ extern HWND s_hwnd;
 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 @@ theend:
 }
 
 #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
index be7bd95b587773e6640031d7ada8a93fc64d5aea..5a84824d36d632a6c096e62e995ab851a2d25f6d 100644 (file)
@@ -1443,6 +1443,11 @@ WaitForChar(long msec)
     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 @@ WaitForChar(long msec)
 #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 @@ WaitForChar(long msec)
     if (input_available())
        return TRUE;
 #endif
+
     return FALSE;
 }
 
index 57c6238f87aca5efb386a625082ef7c52bafeec8..c8411f96cfb39a12bc2dc2e0d3a93c851de05c97 100644 (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);
 void gui_mch_destroy_beval_area(BalloonEval *beval);
 void netbeans_draw_multisign_indicator(int row);
-void channel_init_winsock(void);
 /* vim: set ft=c : */
index ed2176eeec4f6bff0b9807d0a6ae0a9d77550cf7..333ba76c53e30216677fef32ac5821802c07e04a 100644 (file)
@@ -50,4 +50,5 @@ char_u *serverGetReply(HWND server, int *expr_res, int remove, int wait);
 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 : */
index c246ed4bcba8c4287adb78f8a4a2e3202724b856..54a88c8130dd1ec686bcd03b70d0127d6a7374b1 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1195,
 /**/
     1194,
 /**/
index e7a5f5842190e3e99b80ac9ac8d45eea657f04ea..b8de4ae3e86d49d4a8b78f333d6476e0e4c3816b 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -530,6 +530,8 @@ typedef unsigned long u8char_T;         /* long should be 32 bits or more */
 # 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>