To: vim_dev@googlegroups.com Subject: Patch 7.4.1195 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1195 Problem: The channel feature does not work in the MS-Windows console. Solution: Add win32 console support. (Yasuhiro Matsumoto) Files: 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/vim.h *** ../vim-7.4.1194/src/channel.c 2016-01-28 23:10:03.222681092 +0100 --- src/channel.c 2016-01-29 20:57:28.503796262 +0100 *************** *** 91,97 **** #ifdef FEAT_GUI_GTK gint ch_inputHandler; /* Cookie for input */ #endif ! #ifdef FEAT_GUI_W32 int ch_inputHandler; /* simply ret.value of WSAAsyncSelect() */ #endif --- 91,97 ---- #ifdef FEAT_GUI_GTK gint ch_inputHandler; /* Cookie for input */ #endif ! #ifdef WIN32 int ch_inputHandler; /* simply ret.value of WSAAsyncSelect() */ #endif *************** *** 279,292 **** int sd; struct sockaddr_in server; struct hostent * host; ! #ifdef FEAT_GUI_W32 u_short port = port_in; #else int port = port_in; #endif int idx; ! #ifdef FEAT_GUI_W32 channel_init_winsock(); #endif --- 279,292 ---- int sd; struct sockaddr_in server; struct hostent * host; ! #ifdef WIN32 u_short port = port_in; #else int port = port_in; #endif int idx; ! #ifdef WIN32 channel_init_winsock(); #endif *************** *** 861,867 **** return channel_get(idx); } ! # if defined(FEAT_GUI_W32) || defined(PROTO) /* * Lookup the channel index from the socket. * Returns -1 when the socket isn't found. --- 861,867 ---- return channel_get(idx); } ! # if defined(WIN32) || defined(PROTO) /* * Lookup the channel index from the socket. * Returns -1 when the socket isn't found. *************** *** 965,971 **** } # endif /* UNIX && !HAVE_SELECT */ ! # if (defined(UNIX) && defined(HAVE_SELECT)) || defined(PROTO) /* * The type of "rfds" is hidden to avoid problems with the function proto. */ --- 965,971 ---- } # endif /* UNIX && !HAVE_SELECT */ ! # if (!defined(FEAT_GUI_W32) && defined(HAVE_SELECT)) || defined(PROTO) /* * The type of "rfds" is hidden to avoid problems with the function proto. */ *************** *** 1007,1012 **** return ret; } ! # endif /* UNIX && HAVE_SELECT */ #endif /* FEAT_CHANNEL */ --- 1007,1012 ---- return ret; } ! # endif /* !FEAT_GUI_W32 && HAVE_SELECT */ #endif /* FEAT_CHANNEL */ *** ../vim-7.4.1194/src/gui_w32.c 2016-01-24 20:36:18.854082474 +0100 --- src/gui_w32.c 2016-01-29 20:57:28.507796221 +0100 *************** *** 553,561 **** 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. --- 553,558 ---- *************** *** 844,849 **** --- 841,847 ---- 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,5070 **** 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 --- 5047,5049 ---- *** ../vim-7.4.1194/src/os_mswin.c 2016-01-24 20:36:18.858082431 +0100 --- src/os_mswin.c 2016-01-29 20:57:28.507796221 +0100 *************** *** 161,167 **** static HWND s_hwnd = 0; /* console window handle, set by GetConsoleHwnd() */ #endif ! extern int WSInitialized; /* Don't generate prototypes here, because some systems do have these * functions. */ --- 161,169 ---- static HWND s_hwnd = 0; /* console window handle, set by GetConsoleHwnd() */ #endif ! #ifdef FEAT_CHANNEL ! int WSInitialized = FALSE; /* WinSock is initialized */ ! #endif /* Don't generate prototypes here, because some systems do have these * functions. */ *************** *** 3093,3095 **** --- 3095,3116 ---- } #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 *** ../vim-7.4.1194/src/os_win32.c 2016-01-28 15:07:35.260449013 +0100 --- src/os_win32.c 2016-01-29 21:08:37.216780684 +0100 *************** *** 1443,1448 **** --- 1443,1453 ---- 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,1467 **** --- 1464,1485 ---- #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,1567 **** --- 1580,1586 ---- if (input_available()) return TRUE; #endif + return FALSE; } *** ../vim-7.4.1194/src/proto/gui_w32.pro 2016-01-25 16:05:52.009653108 +0100 --- src/proto/gui_w32.pro 2016-01-29 20:57:28.507796221 +0100 *************** *** 96,100 **** 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 : */ --- 96,99 ---- *** ../vim-7.4.1194/src/proto/os_mswin.pro 2016-01-19 13:21:55.845334290 +0100 --- src/proto/os_mswin.pro 2016-01-29 20:57:28.507796221 +0100 *************** *** 50,53 **** --- 50,54 ---- 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 : */ *** ../vim-7.4.1194/src/vim.h 2016-01-24 20:36:18.866082348 +0100 --- src/vim.h 2016-01-29 20:57:28.511796179 +0100 *************** *** 530,535 **** --- 530,537 ---- # ifdef HAVE_SYS_POLL_H # include # define HAVE_POLL + # elif defined(WIN32) && !defined(FEAT_GUI_W32) + # define HAVE_SELECT # else # ifdef HAVE_POLL_H # include *** ../vim-7.4.1194/src/version.c 2016-01-28 23:10:03.226681050 +0100 --- src/version.c 2016-01-29 20:57:58.463485122 +0100 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 1195, /**/ -- hundred-and-one symptoms of being an internet addict: 73. You give your dog used motherboards instead of bones /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///