annotate src/clientserver.c @ 20977:6953733825a7

Added tag v8.2.1039 for changeset 599b29b6e540ff12f9286a93f62d53c447022887
author Bram Moolenaar <Bram@vim.org>
date Mon, 22 Jun 2020 20:45:04 +0200
parents 72b437855299
children 3af71cbcfdbe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19920
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 *
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 *
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 * clientserver.c: functions for Client Server functionality
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 #include "vim.h"
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 #if defined(FEAT_CLIENTSERVER) || defined(PROTO)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 static void cmdsrv_main(int *argc, char **argv, char_u *serverName_arg, char_u **serverStr);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 static char_u *serverMakeName(char_u *arg, char *cmd);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 * Replace termcodes such as <CR> and insert as key presses if there is room.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 void
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 server_to_input_buf(char_u *str)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 char_u *ptr = NULL;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 char_u *cpo_save = p_cpo;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 // Set 'cpoptions' the way we want it.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 // B set - backslashes are *not* treated specially
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 // k set - keycodes are *not* reverse-engineered
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 // < unset - <Key> sequences *are* interpreted
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 // The last but one parameter of replace_termcodes() is TRUE so that the
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 // <lt> sequence is recognised - needed for a real backslash.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 p_cpo = (char_u *)"Bk";
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 str = replace_termcodes((char_u *)str, &ptr, REPTERM_DO_LT, NULL);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 p_cpo = cpo_save;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 if (*ptr != NUL) // trailing CTRL-V results in nothing
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 * Add the string to the input stream.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 * Can't use add_to_input_buf() here, we now have K_SPECIAL bytes.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 *
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 * First clear typed characters from the typeahead buffer, there could
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 * be half a mapping there. Then append to the existing string, so
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 * that multiple commands from a client are concatenated.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 if (typebuf.tb_maplen < typebuf.tb_len)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 del_typebuf(typebuf.tb_len - typebuf.tb_maplen, typebuf.tb_maplen);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 (void)ins_typebuf(str, REMAP_NONE, typebuf.tb_len, TRUE, FALSE);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 // Let input_available() know we inserted text in the typeahead
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 // buffer.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 typebuf_was_filled = TRUE;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 vim_free((char_u *)ptr);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 * Evaluate an expression that the client sent to a string.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 char_u *
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 eval_client_expr_to_string(char_u *expr)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 char_u *res;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 int save_dbl = debug_break_level;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 int save_ro = redir_off;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 funccal_entry_T funccal_entry;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 int did_save_funccal = FALSE;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 // Evaluate the expression at the toplevel, don't use variables local to
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 // the calling function. Except when in debug mode.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 if (!debug_mode)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 save_funccal(&funccal_entry);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 did_save_funccal = TRUE;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 // Disable debugging, otherwise Vim hangs, waiting for "cont" to be
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 // typed.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 debug_break_level = -1;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 redir_off = 0;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 // Do not display error message, otherwise Vim hangs, waiting for "cont"
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 // to be typed. Do generate errors so that try/catch works.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 ++emsg_silent;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 res = eval_to_string(expr, NULL, TRUE);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 debug_break_level = save_dbl;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 redir_off = save_ro;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 --emsg_silent;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 if (emsg_silent < 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 emsg_silent = 0;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 if (did_save_funccal)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 restore_funccal();
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 // A client can tell us to redraw, but not to display the cursor, so do
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 // that here.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 setcursor();
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 out_flush_cursor(FALSE, FALSE);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 return res;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 * Evaluate a command or expression sent to ourselves.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 int
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 sendToLocalVim(char_u *cmd, int asExpr, char_u **result)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 if (asExpr)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 char_u *ret;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 ret = eval_client_expr_to_string(cmd);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 if (result != NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 if (ret == NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 char *err = _(e_invexprmsg);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 size_t len = STRLEN(cmd) + STRLEN(err) + 5;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 char_u *msg;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 msg = alloc(len);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 if (msg != NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 vim_snprintf((char *)msg, len, "%s: \"%s\"", err, cmd);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 *result = msg;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 *result = ret;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 vim_free(ret);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 return ret == NULL ? -1 : 0;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 server_to_input_buf(cmd);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 return 0;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 * If conversion is needed, convert "data" from "client_enc" to 'encoding' and
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 * return an allocated string. Otherwise return "data".
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 * "*tofree" is set to the result when it needs to be freed later.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 char_u *
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 serverConvert(
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 char_u *client_enc UNUSED,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 char_u *data,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 char_u **tofree)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 char_u *res = data;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 *tofree = NULL;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 if (client_enc != NULL && p_enc != NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 vimconv_T vimconv;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 vimconv.vc_type = CONV_NONE;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 if (convert_setup(&vimconv, client_enc, p_enc) != FAIL
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 && vimconv.vc_type != CONV_NONE)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164 res = string_convert(&vimconv, data, NULL);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 if (res == NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 res = data;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 *tofree = res;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 convert_setup(&vimconv, NULL, NULL);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172 return res;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 #endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 #if (defined(FEAT_CLIENTSERVER) && !defined(NO_VIM_MAIN)) || defined(PROTO)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 * Common code for the X command server and the Win32 command server.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 static char_u *build_drop_cmd(int filec, char **filev, int tabs, int sendReply);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 * Do the client-server stuff, unless "--servername ''" was used.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 void
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 exec_on_server(mparm_T *parmp)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 if (parmp->serverName_arg == NULL || *parmp->serverName_arg != NUL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 # ifdef MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 // Initialise the client/server messaging infrastructure.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194 serverInitMessaging();
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198 * When a command server argument was found, execute it. This may
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199 * exit Vim when it was successful. Otherwise it's executed further
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 * on. Remember the encoding used here in "serverStrEnc".
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 if (parmp->serverArg)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 cmdsrv_main(&parmp->argc, parmp->argv,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 parmp->serverName_arg, &parmp->serverStr);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 parmp->serverStrEnc = vim_strsave(p_enc);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 // If we're still running, get the name to register ourselves.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 // On Win32 can register right now, for X11 need to setup the
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211 // clipboard first, it's further down.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212 parmp->servername = serverMakeName(parmp->serverName_arg,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 parmp->argv[0]);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 # ifdef MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 if (parmp->servername != NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 serverSetName(parmp->servername);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 vim_free(parmp->servername);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 * Prepare for running as a Vim server.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 void
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 prepare_server(mparm_T *parmp)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 # if defined(FEAT_X11)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232 * Register for remote command execution with :serversend and --remote
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233 * unless there was a -X or a --servername '' on the command line.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 * Only register nongui-vim's with an explicit --servername argument,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 * or when compiling with autoservername.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 * When running as root --servername is also required.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238 if (X_DISPLAY != NULL && parmp->servername != NULL && (
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 # if defined(FEAT_AUTOSERVERNAME) || defined(FEAT_GUI)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 (
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241 # if defined(FEAT_AUTOSERVERNAME)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242 1
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 # else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244 gui.in_use
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 # ifdef UNIX
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247 && getuid() != ROOT_UID
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249 ) ||
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 parmp->serverName_arg != NULL))
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 (void)serverRegisterName(X_DISPLAY, parmp->servername);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254 vim_free(parmp->servername);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 TIME_MSG("register server name");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258 serverDelayedStartName = parmp->servername;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262 * Execute command ourselves if we're here because the send failed (or
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 * else we would have exited above).
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 if (parmp->serverStr != NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267 char_u *p;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 server_to_input_buf(serverConvert(parmp->serverStrEnc,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270 parmp->serverStr, &p));
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 vim_free(p);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 static void
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276 cmdsrv_main(
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277 int *argc,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278 char **argv,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 char_u *serverName_arg,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280 char_u **serverStr)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282 char_u *res;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 int i;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 char_u *sname;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 int ret;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286 int didone = FALSE;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 int exiterr = 0;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288 char **newArgV = argv + 1;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
289 int newArgC = 1,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 Argc = *argc;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291 int argtype;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292 #define ARGTYPE_OTHER 0
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 #define ARGTYPE_EDIT 1
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294 #define ARGTYPE_EDIT_WAIT 2
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295 #define ARGTYPE_SEND 3
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
296 int silent = FALSE;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
297 int tabs = FALSE;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 # ifndef FEAT_X11
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
299 HWND srv;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300 # else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301 Window srv;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
303 setup_term_clip();
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
304 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306 sname = serverMakeName(serverName_arg, argv[0]);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307 if (sname == NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 return;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311 * Execute the command server related arguments and remove them
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 * from the argc/argv array; We may have to return into main()
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314 for (i = 1; i < Argc; i++)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 res = NULL;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 if (STRCMP(argv[i], "--") == 0) // end of option arguments
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319 for (; i < *argc; i++)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321 *newArgV++ = argv[i];
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322 newArgC++;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
323 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324 break;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327 if (STRICMP(argv[i], "--remote-send") == 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
328 argtype = ARGTYPE_SEND;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
329 else if (STRNICMP(argv[i], "--remote", 8) == 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
330 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
331 char *p = argv[i] + 8;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
332
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
333 argtype = ARGTYPE_EDIT;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
334 while (*p != NUL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
335 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
336 if (STRNICMP(p, "-wait", 5) == 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
338 argtype = ARGTYPE_EDIT_WAIT;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339 p += 5;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
340 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341 else if (STRNICMP(p, "-silent", 7) == 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343 silent = TRUE;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344 p += 7;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
345 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346 else if (STRNICMP(p, "-tab", 4) == 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
347 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348 tabs = TRUE;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349 p += 4;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
350 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
351 else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
352 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353 argtype = ARGTYPE_OTHER;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354 break;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
355 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
358 else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
359 argtype = ARGTYPE_OTHER;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
360
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361 if (argtype != ARGTYPE_OTHER)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
362 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
363 if (i == *argc - 1)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
364 mainerr_arg_missing((char_u *)argv[i]);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365 if (argtype == ARGTYPE_SEND)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
366 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 *serverStr = (char_u *)argv[i + 1];
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368 i++;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
370 else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
371 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372 *serverStr = build_drop_cmd(*argc - i - 1, argv + i + 1,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
373 tabs, argtype == ARGTYPE_EDIT_WAIT);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
374 if (*serverStr == NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
376 // Probably out of memory, exit.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
377 didone = TRUE;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
378 exiterr = 1;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
379 break;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
380 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
381 Argc = i;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 # ifdef FEAT_X11
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384 if (xterm_dpy == NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 mch_errmsg(_("No display"));
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 ret = -1;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 ret = serverSendToVim(xterm_dpy, sname, *serverStr,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 NULL, &srv, 0, 0, 0, silent);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392 # else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 // Win32 always works?
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 ret = serverSendToVim(sname, *serverStr, NULL, &srv, 0, 0, silent);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396 if (ret < 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398 if (argtype == ARGTYPE_SEND)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400 // Failed to send, abort.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401 mch_errmsg(_(": Send failed.\n"));
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
402 didone = TRUE;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403 exiterr = 1;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405 else if (!silent)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406 // Let vim start normally.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407 mch_errmsg(_(": Send failed. Trying to execute locally\n"));
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
408 break;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411 # ifdef FEAT_GUI_MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412 // Guess that when the server name starts with "g" it's a GUI
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413 // server, which we can bring to the foreground here.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 // Foreground() in the server doesn't work very well.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 if (argtype != ARGTYPE_SEND && TOUPPER_ASC(*sname) == 'G')
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 SetForegroundWindow(srv);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 * For --remote-wait: Wait until the server did edit each
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 * file. Also detect that the server no longer runs.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 if (ret >= 0 && argtype == ARGTYPE_EDIT_WAIT)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 int numFiles = *argc - i - 1;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 int j;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427 char_u *done = alloc(numFiles);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 char_u *p;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 # ifdef FEAT_GUI_MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430 NOTIFYICONDATA ni;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
431 int count = 0;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 extern HWND message_window;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
433 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
434
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435 if (numFiles > 0 && argv[i + 1][0] == '+')
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436 // Skip "+cmd" argument, don't wait for it to be edited.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 --numFiles;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
438
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
439 # ifdef FEAT_GUI_MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
440 ni.cbSize = sizeof(ni);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
441 ni.hWnd = message_window;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442 ni.uID = 0;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443 ni.uFlags = NIF_ICON|NIF_TIP;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444 ni.hIcon = LoadIcon((HINSTANCE)GetModuleHandle(0), "IDR_VIM");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445 sprintf(ni.szTip, _("%d of %d edited"), count, numFiles);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446 Shell_NotifyIcon(NIM_ADD, &ni);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
449 // Wait for all files to unload in remote
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
450 vim_memset(done, 0, numFiles);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
451 while (memchr(done, 0, numFiles) != NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
452 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453 # ifdef MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454 p = serverGetReply(srv, NULL, TRUE, TRUE, 0);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455 if (p == NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456 break;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457 # else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
458 if (serverReadReply(xterm_dpy, srv, &p, TRUE, -1) < 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459 break;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 j = atoi((char *)p);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462 if (j >= 0 && j < numFiles)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 # ifdef FEAT_GUI_MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 ++count;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466 sprintf(ni.szTip, _("%d of %d edited"),
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 count, numFiles);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
468 Shell_NotifyIcon(NIM_MODIFY, &ni);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470 done[j] = 1;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
473 # ifdef FEAT_GUI_MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474 Shell_NotifyIcon(NIM_DELETE, &ni);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475 # endif
20174
72b437855299 patch 8.2.0642: Vim9: using invalid index
Bram Moolenaar <Bram@vim.org>
parents: 19920
diff changeset
476 vim_free(done);
19920
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479 else if (STRICMP(argv[i], "--remote-expr") == 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481 if (i == *argc - 1)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482 mainerr_arg_missing((char_u *)argv[i]);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
483 # ifdef MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
484 // Win32 always works?
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
485 if (serverSendToVim(sname, (char_u *)argv[i + 1],
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486 &res, NULL, 1, 0, FALSE) < 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487 # else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488 if (xterm_dpy == NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 mch_errmsg(_("No display: Send expression failed.\n"));
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 else if (serverSendToVim(xterm_dpy, sname, (char_u *)argv[i + 1],
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491 &res, NULL, 1, 0, 1, FALSE) < 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494 if (res != NULL && *res != NUL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
495 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496 // Output error from remote
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497 mch_errmsg((char *)res);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
498 VIM_CLEAR(res);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500 mch_errmsg(_(": Send expression failed.\n"));
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
503 else if (STRICMP(argv[i], "--serverlist") == 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
504 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505 # ifdef MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506 // Win32 always works?
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
507 res = serverGetVimNames();
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
508 # else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
509 if (xterm_dpy != NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
510 res = serverGetVimNames(xterm_dpy);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
512 if (did_emsg)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
513 mch_errmsg("\n");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
514 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
515 else if (STRICMP(argv[i], "--servername") == 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517 // Already processed. Take it out of the command line
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518 i++;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519 continue;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
521 else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
522 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
523 *newArgV++ = argv[i];
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
524 newArgC++;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
525 continue;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
526 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
527 didone = TRUE;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
528 if (res != NULL && *res != NUL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
529 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
530 mch_msg((char *)res);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
531 if (res[STRLEN(res) - 1] != '\n')
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
532 mch_msg("\n");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
533 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
534 vim_free(res);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
535 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
536
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
537 if (didone)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
538 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
539 display_errors(); // display any collected messages
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
540 exit(exiterr); // Mission accomplished - get out
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
541 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
542
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543 // Return back into main()
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
544 *argc = newArgC;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
545 vim_free(sname);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
546 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
547
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
548 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
549 * Build a ":drop" command to send to a Vim server.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
550 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
551 static char_u *
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
552 build_drop_cmd(
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
553 int filec,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
554 char **filev,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
555 int tabs, // Use ":tab drop" instead of ":drop".
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
556 int sendReply)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
557 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
558 garray_T ga;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
559 int i;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
560 char_u *inicmd = NULL;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
561 char_u *p;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
562 char_u *cdp;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
563 char_u *cwd;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
564
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
565 if (filec > 0 && filev[0][0] == '+')
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
566 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
567 inicmd = (char_u *)filev[0] + 1;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
568 filev++;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
569 filec--;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
570 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571 // Check if we have at least one argument.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
572 if (filec <= 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
573 mainerr_arg_missing((char_u *)filev[-1]);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
574
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
575 // Temporarily cd to the current directory to handle relative file names.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
576 cwd = alloc(MAXPATHL);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
577 if (cwd == NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
578 return NULL;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
579 if (mch_dirname(cwd, MAXPATHL) != OK)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
580 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
581 vim_free(cwd);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
582 return NULL;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
583 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
584 cdp = vim_strsave_escaped_ext(cwd,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
585 #ifdef BACKSLASH_IN_FILENAME
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
586 (char_u *)"", // rem_backslash() will tell what chars to escape
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
587 #else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
588 PATH_ESC_CHARS,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
589 #endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
590 '\\', TRUE);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
591 vim_free(cwd);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
592 if (cdp == NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
593 return NULL;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
594 ga_init2(&ga, 1, 100);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
595 ga_concat(&ga, (char_u *)"<C-\\><C-N>:cd ");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
596 ga_concat(&ga, cdp);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
597
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
598 // Call inputsave() so that a prompt for an encryption key works.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
599 ga_concat(&ga, (char_u *)"<CR>:if exists('*inputsave')|call inputsave()|endif|");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
600 if (tabs)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
601 ga_concat(&ga, (char_u *)"tab ");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
602 ga_concat(&ga, (char_u *)"drop");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
603 for (i = 0; i < filec; i++)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
604 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
605 // On Unix the shell has already expanded the wildcards, don't want to
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
606 // do it again in the Vim server. On MS-Windows only escape
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
607 // non-wildcard characters.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
608 p = vim_strsave_escaped((char_u *)filev[i],
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
609 #ifdef UNIX
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
610 PATH_ESC_CHARS
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
611 #else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
612 (char_u *)" \t%#"
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
613 #endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
614 );
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
615 if (p == NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
616 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
617 vim_free(ga.ga_data);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
618 return NULL;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
619 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
620 ga_concat(&ga, (char_u *)" ");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
621 ga_concat(&ga, p);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
622 vim_free(p);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
623 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
624 ga_concat(&ga, (char_u *)"|if exists('*inputrestore')|call inputrestore()|endif<CR>");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
625
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
626 // The :drop commands goes to Insert mode when 'insertmode' is set, use
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
627 // CTRL-\ CTRL-N again.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
628 ga_concat(&ga, (char_u *)"<C-\\><C-N>");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
629
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
630 // Switch back to the correct current directory (prior to temporary path
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
631 // switch) unless 'autochdir' is set, in which case it will already be
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
632 // correct after the :drop command. With line breaks and spaces:
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
633 // if !exists('+acd') || !&acd
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
634 // if haslocaldir()
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
635 // cd -
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
636 // lcd -
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
637 // elseif getcwd() ==# 'current path'
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
638 // cd -
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
639 // endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
640 // endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
641 ga_concat(&ga, (char_u *)":if !exists('+acd')||!&acd|if haslocaldir()|");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
642 ga_concat(&ga, (char_u *)"cd -|lcd -|elseif getcwd() ==# '");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
643 ga_concat(&ga, cdp);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
644 ga_concat(&ga, (char_u *)"'|cd -|endif|endif<CR>");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
645 vim_free(cdp);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
646
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
647 if (sendReply)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
648 ga_concat(&ga, (char_u *)":call SetupRemoteReplies()<CR>");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
649 ga_concat(&ga, (char_u *)":");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
650 if (inicmd != NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
651 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
652 // Can't use <CR> after "inicmd", because an "startinsert" would cause
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
653 // the following commands to be inserted as text. Use a "|",
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
654 // hopefully "inicmd" does allow this...
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
655 ga_concat(&ga, inicmd);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
656 ga_concat(&ga, (char_u *)"|");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
657 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
658 // Bring the window to the foreground, goto Insert mode when 'im' set and
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
659 // clear command line.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
660 ga_concat(&ga, (char_u *)"cal foreground()|if &im|star|en|redr|f<CR>");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
661 ga_append(&ga, NUL);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
662 return ga.ga_data;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
663 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
664
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
665 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
666 * Make our basic server name: use the specified "arg" if given, otherwise use
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
667 * the tail of the command "cmd" we were started with.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
668 * Return the name in allocated memory. This doesn't include a serial number.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
669 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
670 static char_u *
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
671 serverMakeName(char_u *arg, char *cmd)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
672 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
673 char_u *p;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
674
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
675 if (arg != NULL && *arg != NUL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
676 p = vim_strsave_up(arg);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
677 else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
678 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
679 p = vim_strsave_up(gettail((char_u *)cmd));
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
680 // Remove .exe or .bat from the name.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
681 if (p != NULL && vim_strchr(p, '.') != NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
682 *vim_strchr(p, '.') = NUL;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
683 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
684 return p;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
685 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
686 #endif // FEAT_CLIENTSERVER
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
687
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
688 #if defined(FEAT_CLIENTSERVER) && defined(FEAT_X11)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
689 static void
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
690 make_connection(void)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
691 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
692 if (X_DISPLAY == NULL
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
693 # ifdef FEAT_GUI
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
694 && !gui.in_use
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
695 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
696 )
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
697 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
698 x_force_connect = TRUE;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
699 setup_term_clip();
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
700 x_force_connect = FALSE;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
701 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
702 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
703
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
704 static int
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
705 check_connection(void)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
706 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
707 make_connection();
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
708 if (X_DISPLAY == NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
709 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
710 emsg(_("E240: No connection to the X server"));
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
711 return FAIL;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
712 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
713 return OK;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
714 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
715 #endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
716
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
717 #ifdef FEAT_CLIENTSERVER
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
718 static void
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
719 remote_common(typval_T *argvars, typval_T *rettv, int expr)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
720 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
721 char_u *server_name;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
722 char_u *keys;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
723 char_u *r = NULL;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
724 char_u buf[NUMBUFLEN];
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
725 int timeout = 0;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
726 # ifdef MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
727 HWND w;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
728 # else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
729 Window w;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
730 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
731
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
732 if (check_restricted() || check_secure())
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
733 return;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
734
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
735 # ifdef FEAT_X11
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
736 if (check_connection() == FAIL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
737 return;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
738 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
739 if (argvars[2].v_type != VAR_UNKNOWN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
740 && argvars[3].v_type != VAR_UNKNOWN)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
741 timeout = tv_get_number(&argvars[3]);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
742
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
743 server_name = tv_get_string_chk(&argvars[0]);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
744 if (server_name == NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
745 return; // type error; errmsg already given
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
746 keys = tv_get_string_buf(&argvars[1], buf);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
747 # ifdef MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
748 if (serverSendToVim(server_name, keys, &r, &w, expr, timeout, TRUE) < 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
749 # else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
750 if (serverSendToVim(X_DISPLAY, server_name, keys, &r, &w, expr, timeout,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
751 0, TRUE) < 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
752 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
753 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
754 if (r != NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
755 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
756 emsg((char *)r); // sending worked but evaluation failed
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
757 vim_free(r);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
758 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
759 else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
760 semsg(_("E241: Unable to send to %s"), server_name);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
761 return;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
762 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
763
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
764 rettv->vval.v_string = r;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
765
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
766 if (argvars[2].v_type != VAR_UNKNOWN)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
767 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
768 dictitem_T v;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
769 char_u str[30];
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
770 char_u *idvar;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
771
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
772 idvar = tv_get_string_chk(&argvars[2]);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
773 if (idvar != NULL && *idvar != NUL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
774 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
775 sprintf((char *)str, PRINTF_HEX_LONG_U, (long_u)w);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
776 v.di_tv.v_type = VAR_STRING;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
777 v.di_tv.vval.v_string = vim_strsave(str);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
778 set_var(idvar, &v.di_tv, FALSE);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
779 vim_free(v.di_tv.vval.v_string);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
780 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
781 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
782 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
783 #endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
784
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
785 #if defined(FEAT_EVAL) || defined(PROTO)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
786 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
787 * "remote_expr()" function
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
788 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
789 void
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
790 f_remote_expr(typval_T *argvars UNUSED, typval_T *rettv)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
791 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
792 rettv->v_type = VAR_STRING;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
793 rettv->vval.v_string = NULL;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
794 #ifdef FEAT_CLIENTSERVER
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
795 remote_common(argvars, rettv, TRUE);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
796 #endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
797 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
798
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
799 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
800 * "remote_foreground()" function
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
801 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
802 void
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
803 f_remote_foreground(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
804 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
805 #ifdef FEAT_CLIENTSERVER
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
806 # ifdef MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
807 // On Win32 it's done in this application.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
808 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
809 char_u *server_name = tv_get_string_chk(&argvars[0]);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
810
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
811 if (server_name != NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
812 serverForeground(server_name);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
813 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
814 # else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
815 // Send a foreground() expression to the server.
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
816 argvars[1].v_type = VAR_STRING;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
817 argvars[1].vval.v_string = vim_strsave((char_u *)"foreground()");
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
818 argvars[2].v_type = VAR_UNKNOWN;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
819 rettv->v_type = VAR_STRING;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
820 rettv->vval.v_string = NULL;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
821 remote_common(argvars, rettv, TRUE);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
822 vim_free(argvars[1].vval.v_string);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
823 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
824 #endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
825 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
826
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
827 void
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
828 f_remote_peek(typval_T *argvars UNUSED, typval_T *rettv)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
829 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
830 #ifdef FEAT_CLIENTSERVER
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
831 dictitem_T v;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
832 char_u *s = NULL;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
833 # ifdef MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
834 long_u n = 0;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
835 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
836 char_u *serverid;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
837
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
838 if (check_restricted() || check_secure())
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
839 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
840 rettv->vval.v_number = -1;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
841 return;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
842 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
843 serverid = tv_get_string_chk(&argvars[0]);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
844 if (serverid == NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
845 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
846 rettv->vval.v_number = -1;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
847 return; // type error; errmsg already given
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
848 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
849 # ifdef MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
850 sscanf((const char *)serverid, SCANF_HEX_LONG_U, &n);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
851 if (n == 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
852 rettv->vval.v_number = -1;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
853 else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
854 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
855 s = serverGetReply((HWND)n, FALSE, FALSE, FALSE, 0);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
856 rettv->vval.v_number = (s != NULL);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
857 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
858 # else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
859 if (check_connection() == FAIL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
860 return;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
861
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
862 rettv->vval.v_number = serverPeekReply(X_DISPLAY,
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
863 serverStrToWin(serverid), &s);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
864 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
865
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
866 if (argvars[1].v_type != VAR_UNKNOWN && rettv->vval.v_number > 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
867 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
868 char_u *retvar;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
869
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
870 v.di_tv.v_type = VAR_STRING;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
871 v.di_tv.vval.v_string = vim_strsave(s);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
872 retvar = tv_get_string_chk(&argvars[1]);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
873 if (retvar != NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
874 set_var(retvar, &v.di_tv, FALSE);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
875 vim_free(v.di_tv.vval.v_string);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
876 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
877 #else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
878 rettv->vval.v_number = -1;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
879 #endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
880 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
881
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
882 void
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
883 f_remote_read(typval_T *argvars UNUSED, typval_T *rettv)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
884 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
885 char_u *r = NULL;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
886
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
887 #ifdef FEAT_CLIENTSERVER
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
888 char_u *serverid = tv_get_string_chk(&argvars[0]);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
889
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
890 if (serverid != NULL && !check_restricted() && !check_secure())
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
891 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
892 int timeout = 0;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
893 # ifdef MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
894 // The server's HWND is encoded in the 'id' parameter
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
895 long_u n = 0;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
896 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
897
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
898 if (argvars[1].v_type != VAR_UNKNOWN)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
899 timeout = tv_get_number(&argvars[1]);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
900
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
901 # ifdef MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
902 sscanf((char *)serverid, SCANF_HEX_LONG_U, &n);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
903 if (n != 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
904 r = serverGetReply((HWND)n, FALSE, TRUE, TRUE, timeout);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
905 if (r == NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
906 # else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
907 if (check_connection() == FAIL
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
908 || serverReadReply(X_DISPLAY, serverStrToWin(serverid),
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
909 &r, FALSE, timeout) < 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
910 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
911 emsg(_("E277: Unable to read a server reply"));
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
912 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
913 #endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
914 rettv->v_type = VAR_STRING;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
915 rettv->vval.v_string = r;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
916 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
917
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
918 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
919 * "remote_send()" function
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
920 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
921 void
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
922 f_remote_send(typval_T *argvars UNUSED, typval_T *rettv)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
923 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
924 rettv->v_type = VAR_STRING;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
925 rettv->vval.v_string = NULL;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
926 #ifdef FEAT_CLIENTSERVER
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
927 remote_common(argvars, rettv, FALSE);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
928 #endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
929 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
930
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
931 /*
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
932 * "remote_startserver()" function
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
933 */
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
934 void
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
935 f_remote_startserver(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
936 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
937 #ifdef FEAT_CLIENTSERVER
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
938 char_u *server = tv_get_string_chk(&argvars[0]);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
939
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
940 if (server == NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
941 return; // type error; errmsg already given
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
942 if (serverName != NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
943 emsg(_("E941: already started a server"));
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
944 else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
945 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
946 # ifdef FEAT_X11
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
947 if (check_connection() == OK)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
948 serverRegisterName(X_DISPLAY, server);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
949 # else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
950 serverSetName(server);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
951 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
952 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
953 #else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
954 emsg(_("E942: +clientserver feature not available"));
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
955 #endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
956 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
957
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
958 void
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
959 f_server2client(typval_T *argvars UNUSED, typval_T *rettv)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
960 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
961 #ifdef FEAT_CLIENTSERVER
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
962 char_u buf[NUMBUFLEN];
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
963 char_u *server = tv_get_string_chk(&argvars[0]);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
964 char_u *reply = tv_get_string_buf_chk(&argvars[1], buf);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
965
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
966 rettv->vval.v_number = -1;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
967 if (server == NULL || reply == NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
968 return;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
969 if (check_restricted() || check_secure())
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
970 return;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
971 # ifdef FEAT_X11
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
972 if (check_connection() == FAIL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
973 return;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
974 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
975
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
976 if (serverSendReply(server, reply) < 0)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
977 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
978 emsg(_("E258: Unable to send to client"));
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
979 return;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
980 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
981 rettv->vval.v_number = 0;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
982 #else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
983 rettv->vval.v_number = -1;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
984 #endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
985 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
986
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
987 void
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
988 f_serverlist(typval_T *argvars UNUSED, typval_T *rettv)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
989 {
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
990 char_u *r = NULL;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
991
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
992 #ifdef FEAT_CLIENTSERVER
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
993 # ifdef MSWIN
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
994 r = serverGetVimNames();
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
995 # else
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
996 make_connection();
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
997 if (X_DISPLAY != NULL)
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
998 r = serverGetVimNames(X_DISPLAY);
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
999 # endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1000 #endif
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1001 rettv->v_type = VAR_STRING;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1002 rettv->vval.v_string = r;
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1003 }
5e41b2e63c73 patch 8.2.0516: client-server code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1004 #endif