Mercurial > vim
annotate src/channel.c @ 14650:99e45fab9d17 v8.1.0338
patch 8.1.0338: MS-Windows: VTP doesn't work properly with Powershell
commit https://github.com/vim/vim/commit/f6ceaf1e058c64775fd46cbdb8962f5c19ef83e0
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Aug 30 17:47:05 2018 +0200
patch 8.1.0338: MS-Windows: VTP doesn't work properly with Powershell
Problem: MS-Windows: VTP doesn't work properly with Powershell.
Solution: Adjust the color index. (Nobuhiro Takasaki, closes https://github.com/vim/vim/issues/3347)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 30 Aug 2018 18:00:06 +0200 |
parents | 2661d77e440e |
children | 71c17b688bc6 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 * |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 * |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 */ |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 /* |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 * Implements communication through a socket or any file handle. |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 */ |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 #include "vim.h" |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 |
8493
caed4b2d305f
commit https://github.com/vim/vim/commit/509ce2a558e7e0c03242e32e844255af52f1c821
Christian Brabandt <cb@256bit.org>
parents:
8491
diff
changeset
|
15 #if defined(FEAT_JOB_CHANNEL) || defined(PROTO) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
17 /* TRUE when netbeans is running with a GUI. */ |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
18 #ifdef FEAT_GUI |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
19 # define CH_HAS_GUI (gui.in_use || gui.starting) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
20 #endif |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
21 |
10375
2055d3722c5b
commit https://github.com/vim/vim/commit/3f7d0907269558cb3ea184a3083640f9e20bb21e
Christian Brabandt <cb@256bit.org>
parents:
10363
diff
changeset
|
22 /* Note: when making changes here also adjust configure.ac. */ |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
23 #ifdef WIN32 |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
24 /* WinSock API is separated from C API, thus we can't use read(), write(), |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
25 * errno... */ |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
26 # define SOCK_ERRNO errno = WSAGetLastError() |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
27 # undef ECONNREFUSED |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
28 # define ECONNREFUSED WSAECONNREFUSED |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
29 # undef EWOULDBLOCK |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
30 # define EWOULDBLOCK WSAEWOULDBLOCK |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
31 # undef EINPROGRESS |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
32 # define EINPROGRESS WSAEINPROGRESS |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
33 # ifdef EINTR |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
34 # undef EINTR |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
35 # endif |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
36 # define EINTR WSAEINTR |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
37 # define sock_write(sd, buf, len) send((SOCKET)sd, buf, len, 0) |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
38 # define sock_read(sd, buf, len) recv((SOCKET)sd, buf, len, 0) |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
39 # define sock_close(sd) closesocket((SOCKET)sd) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
40 #else |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
41 # include <netdb.h> |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
42 # include <netinet/in.h> |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
43 |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
44 # include <sys/socket.h> |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
45 # ifdef HAVE_LIBGEN_H |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
46 # include <libgen.h> |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
47 # endif |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
48 # define SOCK_ERRNO |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
49 # define sock_write(sd, buf, len) write(sd, buf, len) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
50 # define sock_read(sd, buf, len) read(sd, buf, len) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
51 # define sock_close(sd) close(sd) |
8072
38887bf423ba
commit https://github.com/vim/vim/commit/0943a09db84b036ec550d7f2e5b832f621b400ca
Christian Brabandt <cb@256bit.org>
parents:
8070
diff
changeset
|
52 # define fd_read(fd, buf, len) read(fd, buf, len) |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
53 # define fd_write(sd, buf, len) write(sd, buf, len) |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
54 # define fd_close(sd) close(sd) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
55 #endif |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
56 |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
57 static void channel_read(channel_T *channel, ch_part_T part, char *func); |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
58 |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
59 /* Whether a redraw is needed for appending a line to a buffer. */ |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
60 static int channel_need_redraw = FALSE; |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
61 |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
62 /* Whether we are inside channel_parse_messages() or another situation where it |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
63 * is safe to invoke callbacks. */ |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
64 static int safe_to_invoke_callback = 0; |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
65 |
9089
6bc0a492e8ba
commit https://github.com/vim/vim/commit/de7eb0a47b557eb4656c6b63d421c7e7bae1ef30
Christian Brabandt <cb@256bit.org>
parents:
9087
diff
changeset
|
66 static char *part_names[] = {"sock", "out", "err", "in"}; |
6bc0a492e8ba
commit https://github.com/vim/vim/commit/de7eb0a47b557eb4656c6b63d421c7e7bae1ef30
Christian Brabandt <cb@256bit.org>
parents:
9087
diff
changeset
|
67 |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
68 #ifdef WIN32 |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
69 static int |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
8074
diff
changeset
|
70 fd_read(sock_T fd, char *buf, size_t len) |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
71 { |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
72 HANDLE h = (HANDLE)fd; |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
73 DWORD nread; |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
74 |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
75 if (!ReadFile(h, buf, (DWORD)len, &nread, NULL)) |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
76 return -1; |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
77 return (int)nread; |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
78 } |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
79 |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
80 static int |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
8074
diff
changeset
|
81 fd_write(sock_T fd, char *buf, size_t len) |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
82 { |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
83 HANDLE h = (HANDLE)fd; |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
84 DWORD nwrite; |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
85 |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
86 if (!WriteFile(h, buf, (DWORD)len, &nwrite, NULL)) |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
87 return -1; |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
88 return (int)nwrite; |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
89 } |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
90 |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
91 static void |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
92 fd_close(sock_T fd) |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
93 { |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
94 HANDLE h = (HANDLE)fd; |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
95 |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
96 CloseHandle(h); |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
97 } |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
98 #endif |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
100 /* Log file opened with ch_logfile(). */ |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
101 static FILE *log_fd = NULL; |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
102 #ifdef FEAT_RELTIME |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
103 static proftime_T log_start; |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
104 #endif |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
105 |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
106 void |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
107 ch_logfile(char_u *fname, char_u *opt) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
108 { |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
109 FILE *file = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
110 |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
111 if (log_fd != NULL) |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
112 fclose(log_fd); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
113 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
114 if (*fname != NUL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
115 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
116 file = fopen((char *)fname, *opt == 'w' ? "w" : "a"); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
117 if (file == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
118 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
119 EMSG2(_(e_notopen), fname); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
120 return; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
121 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
122 } |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
123 log_fd = file; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
124 |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
125 if (log_fd != NULL) |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
126 { |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
127 fprintf(log_fd, "==== start log session ====\n"); |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
128 #ifdef FEAT_RELTIME |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
129 profile_start(&log_start); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
130 #endif |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
131 } |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
132 } |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
133 |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
134 int |
9282
9f97a6290c63
commit https://github.com/vim/vim/commit/cf089463492fab53b2a5d81517829d22f882f82e
Christian Brabandt <cb@256bit.org>
parents:
9246
diff
changeset
|
135 ch_log_active(void) |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
136 { |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
137 return log_fd != NULL; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
138 } |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
139 |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
140 static void |
14499
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
141 ch_log_lead(const char *what, channel_T *ch, ch_part_T part) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
142 { |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
143 if (log_fd != NULL) |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
144 { |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
145 #ifdef FEAT_RELTIME |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
146 proftime_T log_now; |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
147 |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
148 profile_start(&log_now); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
149 profile_sub(&log_now, &log_start); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
150 fprintf(log_fd, "%s ", profile_msg(&log_now)); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
151 #endif |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
152 if (ch != NULL) |
14499
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
153 { |
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
154 if (part < PART_COUNT) |
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
155 fprintf(log_fd, "%son %d(%s): ", |
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
156 what, ch->ch_id, part_names[part]); |
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
157 else |
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
158 fprintf(log_fd, "%son %d: ", what, ch->ch_id); |
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
159 } |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
160 else |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
161 fprintf(log_fd, "%s: ", what); |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
162 } |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
163 } |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
164 |
8428
4e22d0e7bfb1
commit https://github.com/vim/vim/commit/d0b6502a7ace39d6cd30874110a572371d10beae
Christian Brabandt <cb@256bit.org>
parents:
8422
diff
changeset
|
165 static int did_log_msg = TRUE; |
4e22d0e7bfb1
commit https://github.com/vim/vim/commit/d0b6502a7ace39d6cd30874110a572371d10beae
Christian Brabandt <cb@256bit.org>
parents:
8422
diff
changeset
|
166 |
13608
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
167 #ifndef PROTO /* prototype is in vim.h */ |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
168 void |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
169 ch_log(channel_T *ch, const char *fmt, ...) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
170 { |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
171 if (log_fd != NULL) |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
172 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
173 va_list ap; |
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
174 |
14499
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
175 ch_log_lead("", ch, PART_COUNT); |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
176 va_start(ap, fmt); |
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
177 vfprintf(log_fd, fmt, ap); |
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
178 va_end(ap); |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
179 fputc('\n', log_fd); |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
180 fflush(log_fd); |
8428
4e22d0e7bfb1
commit https://github.com/vim/vim/commit/d0b6502a7ace39d6cd30874110a572371d10beae
Christian Brabandt <cb@256bit.org>
parents:
8422
diff
changeset
|
181 did_log_msg = TRUE; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
182 } |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
183 } |
13608
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
184 #endif |
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
185 |
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
186 static void |
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
187 ch_error(channel_T *ch, const char *fmt, ...) |
13618
ea4f2a8040b4
patch 8.0.1681: the format attribute fails with MinGW
Christian Brabandt <cb@256bit.org>
parents:
13608
diff
changeset
|
188 #ifdef USE_PRINTF_FORMAT_ATTRIBUTE |
ea4f2a8040b4
patch 8.0.1681: the format attribute fails with MinGW
Christian Brabandt <cb@256bit.org>
parents:
13608
diff
changeset
|
189 __attribute__((format(printf, 2, 3))) |
13608
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
190 #endif |
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
191 ; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
192 |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
193 static void |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
194 ch_error(channel_T *ch, const char *fmt, ...) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
195 { |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
196 if (log_fd != NULL) |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
197 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
198 va_list ap; |
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
199 |
14499
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
200 ch_log_lead("ERR ", ch, PART_COUNT); |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
201 va_start(ap, fmt); |
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
202 vfprintf(log_fd, fmt, ap); |
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
203 va_end(ap); |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
204 fputc('\n', log_fd); |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
205 fflush(log_fd); |
8428
4e22d0e7bfb1
commit https://github.com/vim/vim/commit/d0b6502a7ace39d6cd30874110a572371d10beae
Christian Brabandt <cb@256bit.org>
parents:
8422
diff
changeset
|
206 did_log_msg = TRUE; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
207 } |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
208 } |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
209 |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
210 #ifdef _WIN32 |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
211 # undef PERROR |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
212 # define PERROR(msg) (void)emsg3((char_u *)"%s: %s", \ |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
213 (char_u *)msg, (char_u *)strerror_win32(errno)) |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
214 |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
215 static char * |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
216 strerror_win32(int eno) |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
217 { |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
218 static LPVOID msgbuf = NULL; |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
219 char_u *ptr; |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
220 |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
221 if (msgbuf) |
9355
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
222 { |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
223 LocalFree(msgbuf); |
9355
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
224 msgbuf = NULL; |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
225 } |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
226 FormatMessage( |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
227 FORMAT_MESSAGE_ALLOCATE_BUFFER | |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
228 FORMAT_MESSAGE_FROM_SYSTEM | |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
229 FORMAT_MESSAGE_IGNORE_INSERTS, |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
230 NULL, |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
231 eno, |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
232 MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
233 (LPTSTR) &msgbuf, |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
234 0, |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
235 NULL); |
9355
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
236 if (msgbuf != NULL) |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
237 /* chomp \r or \n */ |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
238 for (ptr = (char_u *)msgbuf; *ptr; ptr++) |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
239 switch (*ptr) |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
240 { |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
241 case '\r': |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
242 STRMOVE(ptr, ptr + 1); |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
243 ptr--; |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
244 break; |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
245 case '\n': |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
246 if (*(ptr + 1) == '\0') |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
247 *ptr = '\0'; |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
248 else |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
249 *ptr = ' '; |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
250 break; |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
251 } |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
252 return msgbuf; |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
253 } |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
254 #endif |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
255 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
256 /* |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
257 * The list of all allocated channels. |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
258 */ |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
259 static channel_T *first_channel = NULL; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
260 static int next_ch_id = 0; |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
261 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
262 /* |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
263 * Allocate a new channel. The refcount is set to 1. |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
264 * The channel isn't actually used until it is opened. |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
265 * Returns NULL if out of memory. |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
266 */ |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
267 channel_T * |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
268 add_channel(void) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
269 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
270 ch_part_T part; |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
271 channel_T *channel = (channel_T *)alloc_clear((int)sizeof(channel_T)); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
272 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
273 if (channel == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
274 return NULL; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
275 |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
276 channel->ch_id = next_ch_id++; |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
277 ch_log(channel, "Created channel"); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
278 |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
279 for (part = PART_SOCK; part < PART_COUNT; ++part) |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
280 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
281 channel->ch_part[part].ch_fd = INVALID_FD; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
282 #ifdef FEAT_GUI_X11 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
283 channel->ch_part[part].ch_inputHandler = (XtInputId)NULL; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
284 #endif |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
285 #ifdef FEAT_GUI_GTK |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
286 channel->ch_part[part].ch_inputHandler = 0; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
287 #endif |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
288 channel->ch_part[part].ch_timeout = 2000; |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
289 } |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
290 |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
291 if (first_channel != NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
292 { |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
293 first_channel->ch_prev = channel; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
294 channel->ch_next = first_channel; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
295 } |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
296 first_channel = channel; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
297 |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
298 channel->ch_refcount = 1; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
299 return channel; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
300 } |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
301 |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10233
diff
changeset
|
302 int |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10233
diff
changeset
|
303 has_any_channel(void) |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10233
diff
changeset
|
304 { |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10233
diff
changeset
|
305 return first_channel != NULL; |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10233
diff
changeset
|
306 } |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10233
diff
changeset
|
307 |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
308 /* |
8310
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
309 * Called when the refcount of a channel is zero. |
8259
99a70c3b902f
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Christian Brabandt <cb@256bit.org>
parents:
8257
diff
changeset
|
310 * Return TRUE if "channel" has a callback and the associated job wasn't |
99a70c3b902f
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Christian Brabandt <cb@256bit.org>
parents:
8257
diff
changeset
|
311 * killed. |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
312 */ |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
313 static int |
8259
99a70c3b902f
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Christian Brabandt <cb@256bit.org>
parents:
8257
diff
changeset
|
314 channel_still_useful(channel_T *channel) |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
315 { |
8332
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
316 int has_sock_msg; |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
317 int has_out_msg; |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
318 int has_err_msg; |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
319 |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
320 /* If the job was killed the channel is not expected to work anymore. */ |
8259
99a70c3b902f
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Christian Brabandt <cb@256bit.org>
parents:
8257
diff
changeset
|
321 if (channel->ch_job_killed && channel->ch_job == NULL) |
99a70c3b902f
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Christian Brabandt <cb@256bit.org>
parents:
8257
diff
changeset
|
322 return FALSE; |
8332
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
323 |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
324 /* If there is a close callback it may still need to be invoked. */ |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
325 if (channel->ch_close_cb != NULL) |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
326 return TRUE; |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
327 |
9081
b2b915c1d311
commit https://github.com/vim/vim/commit/5d96e3ae534ade8ed09a5de9ff8fd7519537ec28
Christian Brabandt <cb@256bit.org>
parents:
9079
diff
changeset
|
328 /* If reading from or a buffer it's still useful. */ |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
329 if (channel->ch_part[PART_IN].ch_bufref.br_buf != NULL) |
9081
b2b915c1d311
commit https://github.com/vim/vim/commit/5d96e3ae534ade8ed09a5de9ff8fd7519537ec28
Christian Brabandt <cb@256bit.org>
parents:
9079
diff
changeset
|
330 return TRUE; |
b2b915c1d311
commit https://github.com/vim/vim/commit/5d96e3ae534ade8ed09a5de9ff8fd7519537ec28
Christian Brabandt <cb@256bit.org>
parents:
9079
diff
changeset
|
331 |
8332
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
332 /* If there is no callback then nobody can get readahead. If the fd is |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
333 * closed and there is no readahead then the callback won't be called. */ |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
334 has_sock_msg = channel->ch_part[PART_SOCK].ch_fd != INVALID_FD |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
335 || channel->ch_part[PART_SOCK].ch_head.rq_next != NULL |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
336 || channel->ch_part[PART_SOCK].ch_json_head.jq_next != NULL; |
8332
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
337 has_out_msg = channel->ch_part[PART_OUT].ch_fd != INVALID_FD |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
338 || channel->ch_part[PART_OUT].ch_head.rq_next != NULL |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
339 || channel->ch_part[PART_OUT].ch_json_head.jq_next != NULL; |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
340 has_err_msg = channel->ch_part[PART_ERR].ch_fd != INVALID_FD |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
341 || channel->ch_part[PART_ERR].ch_head.rq_next != NULL |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
342 || channel->ch_part[PART_ERR].ch_json_head.jq_next != NULL; |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
343 return (channel->ch_callback != NULL && (has_sock_msg |
8493
caed4b2d305f
commit https://github.com/vim/vim/commit/509ce2a558e7e0c03242e32e844255af52f1c821
Christian Brabandt <cb@256bit.org>
parents:
8491
diff
changeset
|
344 || has_out_msg || has_err_msg)) |
9081
b2b915c1d311
commit https://github.com/vim/vim/commit/5d96e3ae534ade8ed09a5de9ff8fd7519537ec28
Christian Brabandt <cb@256bit.org>
parents:
9079
diff
changeset
|
345 || ((channel->ch_part[PART_OUT].ch_callback != NULL |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
346 || channel->ch_part[PART_OUT].ch_bufref.br_buf != NULL) |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
347 && has_out_msg) |
9081
b2b915c1d311
commit https://github.com/vim/vim/commit/5d96e3ae534ade8ed09a5de9ff8fd7519537ec28
Christian Brabandt <cb@256bit.org>
parents:
9079
diff
changeset
|
348 || ((channel->ch_part[PART_ERR].ch_callback != NULL |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
349 || channel->ch_part[PART_ERR].ch_bufref.br_buf != NULL) |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
350 && has_err_msg); |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
351 } |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
352 |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
353 /* |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
354 * Return TRUE if "channel" is closeable (i.e. all readable fds are closed). |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
355 */ |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
356 static int |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
357 channel_can_close(channel_T *channel) |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
358 { |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
359 return channel->ch_to_be_closed == 0; |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
360 } |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
361 |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
362 /* |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
363 * Close a channel and free all its resources. |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
364 */ |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
365 static void |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
366 channel_free_contents(channel_T *channel) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
367 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
368 channel_close(channel, TRUE); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
369 channel_clear(channel); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
370 ch_log(channel, "Freeing channel"); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
371 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
372 |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
373 static void |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
374 channel_free_channel(channel_T *channel) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
375 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
376 if (channel->ch_next != NULL) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
377 channel->ch_next->ch_prev = channel->ch_prev; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
378 if (channel->ch_prev == NULL) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
379 first_channel = channel->ch_next; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
380 else |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
381 channel->ch_prev->ch_next = channel->ch_next; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
382 vim_free(channel); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
383 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
384 |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
385 static void |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
386 channel_free(channel_T *channel) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
387 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
388 if (!in_free_unref_items) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
389 { |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
390 if (safe_to_invoke_callback == 0) |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
391 channel->ch_to_be_freed = TRUE; |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
392 else |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
393 { |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
394 channel_free_contents(channel); |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
395 channel_free_channel(channel); |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
396 } |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
397 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
398 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
399 |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
400 /* |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
401 * Close a channel and free all its resources if there is no further action |
8259
99a70c3b902f
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Christian Brabandt <cb@256bit.org>
parents:
8257
diff
changeset
|
402 * possible, there is no callback to be invoked or the associated job was |
99a70c3b902f
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Christian Brabandt <cb@256bit.org>
parents:
8257
diff
changeset
|
403 * killed. |
8318
190d8084cb3a
commit https://github.com/vim/vim/commit/707659490d35e8d66e8bbdcfd93b12dc1387d86c
Christian Brabandt <cb@256bit.org>
parents:
8310
diff
changeset
|
404 * Return TRUE if the channel was freed. |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
405 */ |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
406 static int |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
407 channel_may_free(channel_T *channel) |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
408 { |
8259
99a70c3b902f
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Christian Brabandt <cb@256bit.org>
parents:
8257
diff
changeset
|
409 if (!channel_still_useful(channel)) |
8318
190d8084cb3a
commit https://github.com/vim/vim/commit/707659490d35e8d66e8bbdcfd93b12dc1387d86c
Christian Brabandt <cb@256bit.org>
parents:
8310
diff
changeset
|
410 { |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
411 channel_free(channel); |
8318
190d8084cb3a
commit https://github.com/vim/vim/commit/707659490d35e8d66e8bbdcfd93b12dc1387d86c
Christian Brabandt <cb@256bit.org>
parents:
8310
diff
changeset
|
412 return TRUE; |
190d8084cb3a
commit https://github.com/vim/vim/commit/707659490d35e8d66e8bbdcfd93b12dc1387d86c
Christian Brabandt <cb@256bit.org>
parents:
8310
diff
changeset
|
413 } |
190d8084cb3a
commit https://github.com/vim/vim/commit/707659490d35e8d66e8bbdcfd93b12dc1387d86c
Christian Brabandt <cb@256bit.org>
parents:
8310
diff
changeset
|
414 return FALSE; |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
415 } |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
416 |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
417 /* |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
418 * Decrement the reference count on "channel" and maybe free it when it goes |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
419 * down to zero. Don't free it if there is a pending action. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
420 * Returns TRUE when the channel is no longer referenced. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
421 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
422 int |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
423 channel_unref(channel_T *channel) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
424 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
425 if (channel != NULL && --channel->ch_refcount <= 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
426 return channel_may_free(channel); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
427 return FALSE; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
428 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
429 |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
430 int |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
431 free_unused_channels_contents(int copyID, int mask) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
432 { |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
433 int did_free = FALSE; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
434 channel_T *ch; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
435 |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
436 /* This is invoked from the garbage collector, which only runs at a safe |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
437 * point. */ |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
438 ++safe_to_invoke_callback; |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
439 |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
440 for (ch = first_channel; ch != NULL; ch = ch->ch_next) |
9011
72a597e9e36d
commit https://github.com/vim/vim/commit/674127e1801fd02ff07dddf0dc3bf0d8cce68997
Christian Brabandt <cb@256bit.org>
parents:
9007
diff
changeset
|
441 if (!channel_still_useful(ch) |
72a597e9e36d
commit https://github.com/vim/vim/commit/674127e1801fd02ff07dddf0dc3bf0d8cce68997
Christian Brabandt <cb@256bit.org>
parents:
9007
diff
changeset
|
442 && (ch->ch_copyID & mask) != (copyID & mask)) |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
443 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
444 /* Free the channel and ordinary items it contains, but don't |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
445 * recurse into Lists, Dictionaries etc. */ |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
446 channel_free_contents(ch); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
447 did_free = TRUE; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
448 } |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
449 |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
450 --safe_to_invoke_callback; |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
451 return did_free; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
452 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
453 |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
454 void |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
455 free_unused_channels(int copyID, int mask) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
456 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
457 channel_T *ch; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
458 channel_T *ch_next; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
459 |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
460 for (ch = first_channel; ch != NULL; ch = ch_next) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
461 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
462 ch_next = ch->ch_next; |
9011
72a597e9e36d
commit https://github.com/vim/vim/commit/674127e1801fd02ff07dddf0dc3bf0d8cce68997
Christian Brabandt <cb@256bit.org>
parents:
9007
diff
changeset
|
463 if (!channel_still_useful(ch) |
72a597e9e36d
commit https://github.com/vim/vim/commit/674127e1801fd02ff07dddf0dc3bf0d8cce68997
Christian Brabandt <cb@256bit.org>
parents:
9007
diff
changeset
|
464 && (ch->ch_copyID & mask) != (copyID & mask)) |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
465 { |
8881
ed0b39dd7fd6
commit https://github.com/vim/vim/commit/ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e
Christian Brabandt <cb@256bit.org>
parents:
8863
diff
changeset
|
466 /* Free the channel struct itself. */ |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
467 channel_free_channel(ch); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
468 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
469 } |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
470 } |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
471 |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
472 #if defined(FEAT_GUI) || defined(PROTO) |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
473 |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
474 #if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
475 static void |
8155
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
476 channel_read_fd(int fd) |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
477 { |
8155
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
478 channel_T *channel; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
479 ch_part_T part; |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
480 |
8155
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
481 channel = channel_fd2channel(fd, &part); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
482 if (channel == NULL) |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
483 ch_error(NULL, "Channel for fd %d not found", fd); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
484 else |
9123
b430d4f2aa79
commit https://github.com/vim/vim/commit/f8df45d84f1d17dced23e185d4835fc23406d73d
Christian Brabandt <cb@256bit.org>
parents:
9089
diff
changeset
|
485 channel_read(channel, part, "channel_read_fd"); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
486 } |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
487 #endif |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
488 |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
489 /* |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
490 * Read a command from netbeans. |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
491 */ |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
492 #ifdef FEAT_GUI_X11 |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
493 static void |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
494 messageFromServerX11(XtPointer clientData, |
9123
b430d4f2aa79
commit https://github.com/vim/vim/commit/f8df45d84f1d17dced23e185d4835fc23406d73d
Christian Brabandt <cb@256bit.org>
parents:
9089
diff
changeset
|
495 int *unused1 UNUSED, |
b430d4f2aa79
commit https://github.com/vim/vim/commit/f8df45d84f1d17dced23e185d4835fc23406d73d
Christian Brabandt <cb@256bit.org>
parents:
9089
diff
changeset
|
496 XtInputId *unused2 UNUSED) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
497 { |
8155
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
498 channel_read_fd((int)(long)clientData); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
499 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
500 #endif |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
501 |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
502 #ifdef FEAT_GUI_GTK |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
503 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
504 static gboolean |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
505 messageFromServerGtk3(GIOChannel *unused1 UNUSED, |
9123
b430d4f2aa79
commit https://github.com/vim/vim/commit/f8df45d84f1d17dced23e185d4835fc23406d73d
Christian Brabandt <cb@256bit.org>
parents:
9089
diff
changeset
|
506 GIOCondition unused2 UNUSED, |
b430d4f2aa79
commit https://github.com/vim/vim/commit/f8df45d84f1d17dced23e185d4835fc23406d73d
Christian Brabandt <cb@256bit.org>
parents:
9089
diff
changeset
|
507 gpointer clientData) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
508 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
509 channel_read_fd(GPOINTER_TO_INT(clientData)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
510 return TRUE; /* Return FALSE instead in case the event source is to |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
511 * be removed after this function returns. */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
512 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
513 # else |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
514 static void |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
515 messageFromServerGtk2(gpointer clientData, |
9123
b430d4f2aa79
commit https://github.com/vim/vim/commit/f8df45d84f1d17dced23e185d4835fc23406d73d
Christian Brabandt <cb@256bit.org>
parents:
9089
diff
changeset
|
516 gint unused1 UNUSED, |
b430d4f2aa79
commit https://github.com/vim/vim/commit/f8df45d84f1d17dced23e185d4835fc23406d73d
Christian Brabandt <cb@256bit.org>
parents:
9089
diff
changeset
|
517 GdkInputCondition unused2 UNUSED) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
518 { |
8155
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
519 channel_read_fd((int)(long)clientData); |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
520 } |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
521 # endif |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
522 #endif |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
523 |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
524 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
525 channel_gui_register_one(channel_T *channel, ch_part_T part) |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
526 { |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
527 if (!CH_HAS_GUI) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
528 return; |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
529 |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
530 /* gets stuck in handling events for a not connected channel */ |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
531 if (channel->ch_keep_open) |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
532 return; |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
533 |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
534 # ifdef FEAT_GUI_X11 |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
535 /* Tell notifier we are interested in being called when there is input on |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
536 * the editor connection socket. */ |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
537 if (channel->ch_part[part].ch_inputHandler == (XtInputId)NULL) |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
538 { |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
539 ch_log(channel, "Registering part %s with fd %d", |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
540 part_names[part], channel->ch_part[part].ch_fd); |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
541 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
542 channel->ch_part[part].ch_inputHandler = XtAppAddInput( |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
543 (XtAppContext)app_context, |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
544 channel->ch_part[part].ch_fd, |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
545 (XtPointer)(XtInputReadMask + XtInputExceptMask), |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
546 messageFromServerX11, |
8155
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
547 (XtPointer)(long)channel->ch_part[part].ch_fd); |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
548 } |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
549 # else |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
550 # ifdef FEAT_GUI_GTK |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
551 /* Tell gdk we are interested in being called when there is input on the |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
552 * editor connection socket. */ |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
553 if (channel->ch_part[part].ch_inputHandler == 0) |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
554 { |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
555 ch_log(channel, "Registering part %s with fd %d", |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
556 part_names[part], channel->ch_part[part].ch_fd); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
557 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
558 GIOChannel *chnnl = g_io_channel_unix_new( |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
559 (gint)channel->ch_part[part].ch_fd); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
560 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
561 channel->ch_part[part].ch_inputHandler = g_io_add_watch( |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
562 chnnl, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
563 G_IO_IN|G_IO_HUP|G_IO_ERR|G_IO_PRI, |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
564 messageFromServerGtk3, |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
565 GINT_TO_POINTER(channel->ch_part[part].ch_fd)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
566 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
567 g_io_channel_unref(chnnl); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
568 # else |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
569 channel->ch_part[part].ch_inputHandler = gdk_input_add( |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
570 (gint)channel->ch_part[part].ch_fd, |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
571 (GdkInputCondition) |
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
572 ((int)GDK_INPUT_READ + (int)GDK_INPUT_EXCEPTION), |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
573 messageFromServerGtk2, |
8155
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
574 (gpointer)(long)channel->ch_part[part].ch_fd); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
575 # endif |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
576 } |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
577 # endif |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
578 # endif |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
579 } |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
580 |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
581 static void |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
582 channel_gui_register(channel_T *channel) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
583 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
584 if (channel->CH_SOCK_FD != INVALID_FD) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
585 channel_gui_register_one(channel, PART_SOCK); |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
586 if (channel->CH_OUT_FD != INVALID_FD |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
587 && channel->CH_OUT_FD != channel->CH_SOCK_FD) |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
588 channel_gui_register_one(channel, PART_OUT); |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
589 if (channel->CH_ERR_FD != INVALID_FD |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
590 && channel->CH_ERR_FD != channel->CH_SOCK_FD |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
591 && channel->CH_ERR_FD != channel->CH_OUT_FD) |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
592 channel_gui_register_one(channel, PART_ERR); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
593 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
594 |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
595 /* |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
596 * Register any of our file descriptors with the GUI event handling system. |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
597 * Called when the GUI has started. |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
598 */ |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
599 void |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
600 channel_gui_register_all(void) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
601 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
602 channel_T *channel; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
603 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
604 for (channel = first_channel; channel != NULL; channel = channel->ch_next) |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
605 channel_gui_register(channel); |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
606 } |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
607 |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
608 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
609 channel_gui_unregister_one(channel_T *channel, ch_part_T part) |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
610 { |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
611 # ifdef FEAT_GUI_X11 |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
612 if (channel->ch_part[part].ch_inputHandler != (XtInputId)NULL) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
613 { |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
614 ch_log(channel, "Unregistering part %s", part_names[part]); |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
615 XtRemoveInput(channel->ch_part[part].ch_inputHandler); |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
616 channel->ch_part[part].ch_inputHandler = (XtInputId)NULL; |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
617 } |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
618 # else |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
619 # ifdef FEAT_GUI_GTK |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
620 if (channel->ch_part[part].ch_inputHandler != 0) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
621 { |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
622 ch_log(channel, "Unregistering part %s", part_names[part]); |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
623 # if GTK_CHECK_VERSION(3,0,0) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
624 g_source_remove(channel->ch_part[part].ch_inputHandler); |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
625 # else |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
626 gdk_input_remove(channel->ch_part[part].ch_inputHandler); |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
627 # endif |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
628 channel->ch_part[part].ch_inputHandler = 0; |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
629 } |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
630 # endif |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
631 # endif |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
632 } |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
633 |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
634 static void |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
635 channel_gui_unregister(channel_T *channel) |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
636 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
637 ch_part_T part; |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
638 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
639 for (part = PART_SOCK; part < PART_IN; ++part) |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
640 channel_gui_unregister_one(channel, part); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
641 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
642 |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
643 #endif |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
644 |
8096
882ba5080c5c
commit https://github.com/vim/vim/commit/e74e8e7d758e9312165a931f176185f07a64231a
Christian Brabandt <cb@256bit.org>
parents:
8094
diff
changeset
|
645 static char *e_cannot_connect = N_("E902: Cannot connect to port"); |
882ba5080c5c
commit https://github.com/vim/vim/commit/e74e8e7d758e9312165a931f176185f07a64231a
Christian Brabandt <cb@256bit.org>
parents:
8094
diff
changeset
|
646 |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
647 /* |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
648 * Open a socket channel to "hostname":"port". |
8096
882ba5080c5c
commit https://github.com/vim/vim/commit/e74e8e7d758e9312165a931f176185f07a64231a
Christian Brabandt <cb@256bit.org>
parents:
8094
diff
changeset
|
649 * "waittime" is the time in msec to wait for the connection. |
882ba5080c5c
commit https://github.com/vim/vim/commit/e74e8e7d758e9312165a931f176185f07a64231a
Christian Brabandt <cb@256bit.org>
parents:
8094
diff
changeset
|
650 * When negative wait forever. |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
651 * Returns the channel for success. |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
652 * Returns NULL for failure. |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
653 */ |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
654 channel_T * |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
655 channel_open( |
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
656 char *hostname, |
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
657 int port_in, |
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
658 int waittime, |
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
659 void (*nb_close_cb)(void)) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
660 { |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
661 int sd = -1; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
662 struct sockaddr_in server; |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
663 struct hostent *host; |
7797
0d46cea25641
commit https://github.com/vim/vim/commit/f12d983deab06b0408781d7a6c2f8970d765b723
Christian Brabandt <cb@256bit.org>
parents:
7795
diff
changeset
|
664 #ifdef WIN32 |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
665 u_short port = port_in; |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
666 u_long val = 1; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
667 #else |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
668 int port = port_in; |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
669 #endif |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
670 channel_T *channel; |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
671 int ret; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
672 |
7797
0d46cea25641
commit https://github.com/vim/vim/commit/f12d983deab06b0408781d7a6c2f8970d765b723
Christian Brabandt <cb@256bit.org>
parents:
7795
diff
changeset
|
673 #ifdef WIN32 |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
674 channel_init_winsock(); |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
675 #endif |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
676 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
677 channel = add_channel(); |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
678 if (channel == NULL) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
679 { |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
680 ch_error(NULL, "Cannot allocate channel."); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
681 return NULL; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
682 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
683 |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
684 /* Get the server internet address and put into addr structure */ |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
685 /* fill in the socket address structure and connect to server */ |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
686 vim_memset((char *)&server, 0, sizeof(server)); |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
687 server.sin_family = AF_INET; |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
688 server.sin_port = htons(port); |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
689 if ((host = gethostbyname(hostname)) == NULL) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
690 { |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
691 ch_error(channel, "in gethostbyname() in channel_open()"); |
9953
9560a2eb7968
commit https://github.com/vim/vim/commit/5b30291785e6b9be1a607504c14bd03c601b59a6
Christian Brabandt <cb@256bit.org>
parents:
9723
diff
changeset
|
692 PERROR(_("E901: gethostbyname() in channel_open()")); |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
693 channel_free(channel); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
694 return NULL; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
695 } |
10587
98ee4f22da6e
patch 8.0.0183: ubsan warns for unaligned address
Christian Brabandt <cb@256bit.org>
parents:
10553
diff
changeset
|
696 { |
98ee4f22da6e
patch 8.0.0183: ubsan warns for unaligned address
Christian Brabandt <cb@256bit.org>
parents:
10553
diff
changeset
|
697 char *p; |
98ee4f22da6e
patch 8.0.0183: ubsan warns for unaligned address
Christian Brabandt <cb@256bit.org>
parents:
10553
diff
changeset
|
698 |
13674
1feeefd8cddb
patch 8.0.1709: some non-C89 code may slip through
Christian Brabandt <cb@256bit.org>
parents:
13626
diff
changeset
|
699 /* When using host->h_addr_list[0] directly ubsan warns for it to not |
1feeefd8cddb
patch 8.0.1709: some non-C89 code may slip through
Christian Brabandt <cb@256bit.org>
parents:
13626
diff
changeset
|
700 * be aligned. First copy the pointer to avoid that. */ |
1feeefd8cddb
patch 8.0.1709: some non-C89 code may slip through
Christian Brabandt <cb@256bit.org>
parents:
13626
diff
changeset
|
701 memcpy(&p, &host->h_addr_list[0], sizeof(p)); |
10587
98ee4f22da6e
patch 8.0.0183: ubsan warns for unaligned address
Christian Brabandt <cb@256bit.org>
parents:
10553
diff
changeset
|
702 memcpy((char *)&server.sin_addr, p, host->h_length); |
98ee4f22da6e
patch 8.0.0183: ubsan warns for unaligned address
Christian Brabandt <cb@256bit.org>
parents:
10553
diff
changeset
|
703 } |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
704 |
8134
8abef552ece7
commit https://github.com/vim/vim/commit/254e00d71429aa4e71b93d3e8c6bb93bfebe4f26
Christian Brabandt <cb@256bit.org>
parents:
8132
diff
changeset
|
705 /* On Mac and Solaris a zero timeout almost never works. At least wait |
8abef552ece7
commit https://github.com/vim/vim/commit/254e00d71429aa4e71b93d3e8c6bb93bfebe4f26
Christian Brabandt <cb@256bit.org>
parents:
8132
diff
changeset
|
706 * one millisecond. Let's do it for all systems, because we don't know why |
8abef552ece7
commit https://github.com/vim/vim/commit/254e00d71429aa4e71b93d3e8c6bb93bfebe4f26
Christian Brabandt <cb@256bit.org>
parents:
8132
diff
changeset
|
707 * this is needed. */ |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
708 if (waittime == 0) |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
709 waittime = 1; |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
710 |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
711 /* |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
712 * For Unix we need to call connect() again after connect() failed. |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
713 * On Win32 one time is sufficient. |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
714 */ |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
715 while (TRUE) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
716 { |
8473
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
717 long elapsed_msec = 0; |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
718 int waitnow; |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
719 |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
720 if (sd >= 0) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
721 sock_close(sd); |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
722 sd = socket(AF_INET, SOCK_STREAM, 0); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
723 if (sd == -1) |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
724 { |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
725 ch_error(channel, "in socket() in channel_open()."); |
9953
9560a2eb7968
commit https://github.com/vim/vim/commit/5b30291785e6b9be1a607504c14bd03c601b59a6
Christian Brabandt <cb@256bit.org>
parents:
9723
diff
changeset
|
726 PERROR(_("E898: socket() in channel_open()")); |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
727 channel_free(channel); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
728 return NULL; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
729 } |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
730 |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
731 if (waittime >= 0) |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
732 { |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
733 /* Make connect() non-blocking. */ |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
734 if ( |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
735 #ifdef _WIN32 |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
736 ioctlsocket(sd, FIONBIO, &val) < 0 |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
737 #else |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
738 fcntl(sd, F_SETFL, O_NONBLOCK) < 0 |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
739 #endif |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
740 ) |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
741 { |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
742 SOCK_ERRNO; |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
743 ch_error(channel, |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
744 "channel_open: Connect failed with errno %d", errno); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
745 sock_close(sd); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
746 channel_free(channel); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
747 return NULL; |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
748 } |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
749 } |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
750 |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
751 /* Try connecting to the server. */ |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
752 ch_log(channel, "Connecting to %s port %d", hostname, port); |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
753 ret = connect(sd, (struct sockaddr *)&server, sizeof(server)); |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
754 |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
755 if (ret == 0) |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
756 /* The connection could be established. */ |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
757 break; |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
758 |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
759 SOCK_ERRNO; |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
760 if (waittime < 0 || (errno != EWOULDBLOCK |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
761 && errno != ECONNREFUSED |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
762 #ifdef EINPROGRESS |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
763 && errno != EINPROGRESS |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
764 #endif |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
765 )) |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
766 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
767 ch_error(channel, |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
768 "channel_open: Connect failed with errno %d", errno); |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
769 PERROR(_(e_cannot_connect)); |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
770 sock_close(sd); |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
771 channel_free(channel); |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
772 return NULL; |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
773 } |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
774 |
8481
8924d7adbc22
commit https://github.com/vim/vim/commit/40e8cb292c36f5057628e570591e8917ac1ca121
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
775 /* Limit the waittime to 50 msec. If it doesn't work within this |
8924d7adbc22
commit https://github.com/vim/vim/commit/40e8cb292c36f5057628e570591e8917ac1ca121
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
776 * time we close the socket and try creating it again. */ |
8924d7adbc22
commit https://github.com/vim/vim/commit/40e8cb292c36f5057628e570591e8917ac1ca121
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
777 waitnow = waittime > 50 ? 50 : waittime; |
8924d7adbc22
commit https://github.com/vim/vim/commit/40e8cb292c36f5057628e570591e8917ac1ca121
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
778 |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
779 /* If connect() didn't finish then try using select() to wait for the |
8473
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
780 * connection to be made. For Win32 always use select() to wait. */ |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
781 #ifndef WIN32 |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
782 if (errno != ECONNREFUSED) |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
783 #endif |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
784 { |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
785 struct timeval tv; |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
786 fd_set rfds; |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
787 fd_set wfds; |
8334
ad4b00bf2984
commit https://github.com/vim/vim/commit/e081e21f760bffc24ca98d5f9bbdb5f02e6aea79
Christian Brabandt <cb@256bit.org>
parents:
8332
diff
changeset
|
788 #ifndef WIN32 |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
789 int so_error = 0; |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
790 socklen_t so_error_len = sizeof(so_error); |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
791 struct timeval start_tv; |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
792 struct timeval end_tv; |
8334
ad4b00bf2984
commit https://github.com/vim/vim/commit/e081e21f760bffc24ca98d5f9bbdb5f02e6aea79
Christian Brabandt <cb@256bit.org>
parents:
8332
diff
changeset
|
793 #endif |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
794 FD_ZERO(&rfds); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
795 FD_SET(sd, &rfds); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
796 FD_ZERO(&wfds); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
797 FD_SET(sd, &wfds); |
8096
882ba5080c5c
commit https://github.com/vim/vim/commit/e74e8e7d758e9312165a931f176185f07a64231a
Christian Brabandt <cb@256bit.org>
parents:
8094
diff
changeset
|
798 |
8473
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
799 tv.tv_sec = waitnow / 1000; |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
800 tv.tv_usec = (waitnow % 1000) * 1000; |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
801 #ifndef WIN32 |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
802 gettimeofday(&start_tv, NULL); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
803 #endif |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
804 ch_log(channel, |
8473
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
805 "Waiting for connection (waiting %d msec)...", waitnow); |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
806 ret = select((int)sd + 1, &rfds, &wfds, NULL, &tv); |
8096
882ba5080c5c
commit https://github.com/vim/vim/commit/e74e8e7d758e9312165a931f176185f07a64231a
Christian Brabandt <cb@256bit.org>
parents:
8094
diff
changeset
|
807 |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
808 if (ret < 0) |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
809 { |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
810 SOCK_ERRNO; |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
811 ch_error(channel, |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
812 "channel_open: Connect failed with errno %d", errno); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
813 PERROR(_(e_cannot_connect)); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
814 sock_close(sd); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
815 channel_free(channel); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
816 return NULL; |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
817 } |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
818 |
8334
ad4b00bf2984
commit https://github.com/vim/vim/commit/e081e21f760bffc24ca98d5f9bbdb5f02e6aea79
Christian Brabandt <cb@256bit.org>
parents:
8332
diff
changeset
|
819 #ifdef WIN32 |
8473
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
820 /* On Win32: select() is expected to work and wait for up to |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
821 * "waitnow" msec for the socket to be open. */ |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
822 if (FD_ISSET(sd, &wfds)) |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
823 break; |
8473
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
824 elapsed_msec = waitnow; |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
825 if (waittime > 1 && elapsed_msec < waittime) |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
826 { |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
827 waittime -= elapsed_msec; |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
828 continue; |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
829 } |
8334
ad4b00bf2984
commit https://github.com/vim/vim/commit/e081e21f760bffc24ca98d5f9bbdb5f02e6aea79
Christian Brabandt <cb@256bit.org>
parents:
8332
diff
changeset
|
830 #else |
ad4b00bf2984
commit https://github.com/vim/vim/commit/e081e21f760bffc24ca98d5f9bbdb5f02e6aea79
Christian Brabandt <cb@256bit.org>
parents:
8332
diff
changeset
|
831 /* On Linux-like systems: See socket(7) for the behavior |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
832 * After putting the socket in non-blocking mode, connect() will |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
833 * return EINPROGRESS, select() will not wait (as if writing is |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
834 * possible), need to use getsockopt() to check if the socket is |
8354
b151c3f9be72
commit https://github.com/vim/vim/commit/42bc6dde46f1b52476cc84ee89277f981b4116c4
Christian Brabandt <cb@256bit.org>
parents:
8348
diff
changeset
|
835 * actually able to connect. |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
836 * We detect a failure to connect when either read and write fds |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
837 * are set. Use getsockopt() to find out what kind of failure. */ |
8354
b151c3f9be72
commit https://github.com/vim/vim/commit/42bc6dde46f1b52476cc84ee89277f981b4116c4
Christian Brabandt <cb@256bit.org>
parents:
8348
diff
changeset
|
838 if (FD_ISSET(sd, &rfds) || FD_ISSET(sd, &wfds)) |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
839 { |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
840 ret = getsockopt(sd, |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
841 SOL_SOCKET, SO_ERROR, &so_error, &so_error_len); |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
842 if (ret < 0 || (so_error != 0 |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
843 && so_error != EWOULDBLOCK |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
844 && so_error != ECONNREFUSED |
8334
ad4b00bf2984
commit https://github.com/vim/vim/commit/e081e21f760bffc24ca98d5f9bbdb5f02e6aea79
Christian Brabandt <cb@256bit.org>
parents:
8332
diff
changeset
|
845 # ifdef EINPROGRESS |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
846 && so_error != EINPROGRESS |
8334
ad4b00bf2984
commit https://github.com/vim/vim/commit/e081e21f760bffc24ca98d5f9bbdb5f02e6aea79
Christian Brabandt <cb@256bit.org>
parents:
8332
diff
changeset
|
847 # endif |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
848 )) |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
849 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
850 ch_error(channel, |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
851 "channel_open: Connect failed with errno %d", |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
852 so_error); |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
853 PERROR(_(e_cannot_connect)); |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
854 sock_close(sd); |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
855 channel_free(channel); |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
856 return NULL; |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
857 } |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
858 } |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
859 |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
860 if (FD_ISSET(sd, &wfds) && so_error == 0) |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
861 /* Did not detect an error, connection is established. */ |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
862 break; |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
863 |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
864 gettimeofday(&end_tv, NULL); |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
865 elapsed_msec = (end_tv.tv_sec - start_tv.tv_sec) * 1000 |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
866 + (end_tv.tv_usec - start_tv.tv_usec) / 1000; |
8334
ad4b00bf2984
commit https://github.com/vim/vim/commit/e081e21f760bffc24ca98d5f9bbdb5f02e6aea79
Christian Brabandt <cb@256bit.org>
parents:
8332
diff
changeset
|
867 #endif |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
868 } |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
869 |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
870 #ifndef WIN32 |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
871 if (waittime > 1 && elapsed_msec < waittime) |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
872 { |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
873 /* The port isn't ready but we also didn't get an error. |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
874 * This happens when the server didn't open the socket |
8473
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
875 * yet. Select() may return early, wait until the remaining |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
876 * "waitnow" and try again. */ |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
877 waitnow -= elapsed_msec; |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
878 waittime -= elapsed_msec; |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
879 if (waitnow > 0) |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
880 { |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
881 mch_delay((long)waitnow, TRUE); |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
882 ui_breakcheck(); |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
883 waittime -= waitnow; |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
884 } |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
885 if (!got_int) |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
886 { |
8473
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
887 if (waittime <= 0) |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
888 /* give it one more try */ |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
889 waittime = 1; |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
890 continue; |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
891 } |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
892 /* we were interrupted, behave as if timed out */ |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
893 } |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
894 #endif |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
895 |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
896 /* We timed out. */ |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
897 ch_error(channel, "Connection timed out"); |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
898 sock_close(sd); |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
899 channel_free(channel); |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
900 return NULL; |
7982
5c30ba57aaea
commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents:
7967
diff
changeset
|
901 } |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
902 |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
903 ch_log(channel, "Connection made"); |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
904 |
7982
5c30ba57aaea
commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents:
7967
diff
changeset
|
905 if (waittime >= 0) |
5c30ba57aaea
commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents:
7967
diff
changeset
|
906 { |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
907 #ifdef _WIN32 |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
908 val = 0; |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
909 ioctlsocket(sd, FIONBIO, &val); |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
910 #else |
7961
a7e58c6e4e9a
commit https://github.com/vim/vim/commit/fbc4b4db3a9690906a96e16724350a6241cf32a5
Christian Brabandt <cb@256bit.org>
parents:
7945
diff
changeset
|
911 (void)fcntl(sd, F_SETFL, 0); |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
912 #endif |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
913 } |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
914 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
915 channel->CH_SOCK_FD = (sock_T)sd; |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
916 channel->ch_nb_close_cb = nb_close_cb; |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
917 channel->ch_hostname = (char *)vim_strsave((char_u *)hostname); |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
918 channel->ch_port = port_in; |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
919 channel->ch_to_be_closed |= (1U << PART_SOCK); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
920 |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
921 #ifdef FEAT_GUI |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
922 channel_gui_register_one(channel, PART_SOCK); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
923 #endif |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
924 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
925 return channel; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
926 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
927 |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
928 /* |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
929 * Implements ch_open(). |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
930 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
931 channel_T * |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
932 channel_open_func(typval_T *argvars) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
933 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
934 char_u *address; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
935 char_u *p; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
936 char *rest; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
937 int port; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
938 jobopt_T opt; |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
939 channel_T *channel = NULL; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
940 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
941 address = get_tv_string(&argvars[0]); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
942 if (argvars[1].v_type != VAR_UNKNOWN |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
943 && (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
944 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
945 EMSG(_(e_invarg)); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
946 return NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
947 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
948 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
949 /* parse address */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
950 p = vim_strchr(address, ':'); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
951 if (p == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
952 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
953 EMSG2(_(e_invarg2), address); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
954 return NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
955 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
956 *p++ = NUL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
957 port = strtol((char *)p, &rest, 10); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
958 if (*address == NUL || port <= 0 || *rest != NUL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
959 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
960 p[-1] = ':'; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
961 EMSG2(_(e_invarg2), address); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
962 return NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
963 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
964 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
965 /* parse options */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
966 clear_job_options(&opt); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
967 opt.jo_mode = MODE_JSON; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
968 opt.jo_timeout = 2000; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
969 if (get_job_options(&argvars[1], &opt, |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
970 JO_MODE_ALL + JO_CB_ALL + JO_WAITTIME + JO_TIMEOUT_ALL, 0) == FAIL) |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
971 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
972 if (opt.jo_timeout < 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
973 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
974 EMSG(_(e_invarg)); |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
975 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
976 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
977 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
978 channel = channel_open((char *)address, port, opt.jo_waittime, NULL); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
979 if (channel != NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
980 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
981 opt.jo_set = JO_ALL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
982 channel_set_options(channel, &opt); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
983 } |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
984 theend: |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
985 free_job_options(&opt); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
986 return channel; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
987 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
988 |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
989 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
990 ch_close_part(channel_T *channel, ch_part_T part) |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
991 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
992 sock_T *fd = &channel->ch_part[part].ch_fd; |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
993 |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
994 if (*fd != INVALID_FD) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
995 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
996 if (part == PART_SOCK) |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
997 sock_close(*fd); |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
998 else |
11723
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
999 { |
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
1000 /* When using a pty the same FD is set on multiple parts, only |
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
1001 * close it when the last reference is closed. */ |
11933
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1002 if ((part == PART_IN || channel->CH_IN_FD != *fd) |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1003 && (part == PART_OUT || channel->CH_OUT_FD != *fd) |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1004 && (part == PART_ERR || channel->CH_ERR_FD != *fd)) |
12389
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
1005 { |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
1006 #ifdef WIN32 |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
1007 if (channel->ch_named_pipe) |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
1008 DisconnectNamedPipe((HANDLE)fd); |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
1009 #endif |
11723
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
1010 fd_close(*fd); |
12389
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
1011 } |
11723
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
1012 } |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1013 *fd = INVALID_FD; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1014 |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
1015 /* channel is closed, may want to end the job if it was the last */ |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
1016 channel->ch_to_be_closed &= ~(1U << part); |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1017 } |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1018 } |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1019 |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1020 void |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
1021 channel_set_pipes(channel_T *channel, sock_T in, sock_T out, sock_T err) |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1022 { |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1023 if (in != INVALID_FD) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1024 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1025 ch_close_part(channel, PART_IN); |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1026 channel->CH_IN_FD = in; |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
1027 # if defined(UNIX) |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
1028 /* Do not end the job when all output channels are closed, wait until |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
1029 * the job ended. */ |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
1030 if (isatty(in)) |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
1031 channel->ch_to_be_closed |= (1U << PART_IN); |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
1032 # endif |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1033 } |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1034 if (out != INVALID_FD) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1035 { |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1036 # if defined(FEAT_GUI) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1037 channel_gui_unregister_one(channel, PART_OUT); |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1038 # endif |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1039 ch_close_part(channel, PART_OUT); |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1040 channel->CH_OUT_FD = out; |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
1041 channel->ch_to_be_closed |= (1U << PART_OUT); |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1042 # if defined(FEAT_GUI) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1043 channel_gui_register_one(channel, PART_OUT); |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1044 # endif |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1045 } |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1046 if (err != INVALID_FD) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1047 { |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1048 # if defined(FEAT_GUI) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1049 channel_gui_unregister_one(channel, PART_ERR); |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1050 # endif |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1051 ch_close_part(channel, PART_ERR); |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1052 channel->CH_ERR_FD = err; |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
1053 channel->ch_to_be_closed |= (1U << PART_ERR); |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1054 # if defined(FEAT_GUI) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1055 channel_gui_register_one(channel, PART_ERR); |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1056 # endif |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1057 } |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
1058 } |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
1059 |
8310
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
1060 /* |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1061 * Sets the job the channel is associated with and associated options. |
8310
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
1062 * This does not keep a refcount, when the job is freed ch_job is cleared. |
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
1063 */ |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
1064 void |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1065 channel_set_job(channel_T *channel, job_T *job, jobopt_T *options) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
1066 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1067 channel->ch_job = job; |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1068 |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1069 channel_set_options(channel, options); |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1070 |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1071 if (job->jv_in_buf != NULL) |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1072 { |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1073 chanpart_T *in_part = &channel->ch_part[PART_IN]; |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1074 |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1075 set_bufref(&in_part->ch_bufref, job->jv_in_buf); |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
1076 ch_log(channel, "reading from buffer '%s'", |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1077 (char *)in_part->ch_bufref.br_buf->b_ffname); |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1078 if (options->jo_set & JO_IN_TOP) |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1079 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1080 if (options->jo_in_top == 0 && !(options->jo_set & JO_IN_BOT)) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1081 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1082 /* Special mode: send last-but-one line when appending a line |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1083 * to the buffer. */ |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1084 in_part->ch_bufref.br_buf->b_write_to_channel = TRUE; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1085 in_part->ch_buf_append = TRUE; |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1086 in_part->ch_buf_top = |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1087 in_part->ch_bufref.br_buf->b_ml.ml_line_count + 1; |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1088 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1089 else |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1090 in_part->ch_buf_top = options->jo_in_top; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1091 } |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1092 else |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1093 in_part->ch_buf_top = 1; |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1094 if (options->jo_set & JO_IN_BOT) |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1095 in_part->ch_buf_bot = options->jo_in_bot; |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1096 else |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1097 in_part->ch_buf_bot = in_part->ch_bufref.br_buf->b_ml.ml_line_count; |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1098 } |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1099 } |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1100 |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1101 /* |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1102 * Find a buffer matching "name" or create a new one. |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1103 * Returns NULL if there is something very wrong (error already reported). |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1104 */ |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1105 static buf_T * |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
1106 find_buffer(char_u *name, int err, int msg) |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1107 { |
8291
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8267
diff
changeset
|
1108 buf_T *buf = NULL; |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1109 buf_T *save_curbuf = curbuf; |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1110 |
8291
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8267
diff
changeset
|
1111 if (name != NULL && *name != NUL) |
9149
18bbf31015c2
commit https://github.com/vim/vim/commit/b127cfd75f59e82580df395b6e2c009774644b16
Christian Brabandt <cb@256bit.org>
parents:
9147
diff
changeset
|
1112 { |
8291
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8267
diff
changeset
|
1113 buf = buflist_findname(name); |
9149
18bbf31015c2
commit https://github.com/vim/vim/commit/b127cfd75f59e82580df395b6e2c009774644b16
Christian Brabandt <cb@256bit.org>
parents:
9147
diff
changeset
|
1114 if (buf == NULL) |
18bbf31015c2
commit https://github.com/vim/vim/commit/b127cfd75f59e82580df395b6e2c009774644b16
Christian Brabandt <cb@256bit.org>
parents:
9147
diff
changeset
|
1115 buf = buflist_findname_exp(name); |
18bbf31015c2
commit https://github.com/vim/vim/commit/b127cfd75f59e82580df395b6e2c009774644b16
Christian Brabandt <cb@256bit.org>
parents:
9147
diff
changeset
|
1116 } |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1117 if (buf == NULL) |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1118 { |
8297
4929eca308b7
commit https://github.com/vim/vim/commit/e26643e6bcd6c6c42f5eae78cee2e7950cd3f629
Christian Brabandt <cb@256bit.org>
parents:
8291
diff
changeset
|
1119 buf = buflist_new(name == NULL || *name == NUL ? NULL : name, |
9149
18bbf31015c2
commit https://github.com/vim/vim/commit/b127cfd75f59e82580df395b6e2c009774644b16
Christian Brabandt <cb@256bit.org>
parents:
9147
diff
changeset
|
1120 NULL, (linenr_T)0, BLN_LISTED | BLN_NEW); |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1121 if (buf == NULL) |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1122 return NULL; |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1123 buf_copy_options(buf, BCO_ENTER); |
8657
c70eea7a7677
commit https://github.com/vim/vim/commit/a4f6ca717b4483eb82c6c71f71a5a5cf70e55d80
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
1124 curbuf = buf; |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1125 #ifdef FEAT_QUICKFIX |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1126 set_option_value((char_u *)"bt", 0L, (char_u *)"nofile", OPT_LOCAL); |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1127 set_option_value((char_u *)"bh", 0L, (char_u *)"hide", OPT_LOCAL); |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1128 #endif |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1129 if (curbuf->b_ml.ml_mfp == NULL) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1130 ml_open(curbuf); |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
1131 if (msg) |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
1132 ml_replace(1, (char_u *)(err ? "Reading from channel error..." |
8463
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8453
diff
changeset
|
1133 : "Reading from channel output..."), TRUE); |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1134 changed_bytes(1, 0); |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1135 curbuf = save_curbuf; |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1136 } |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1137 |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1138 return buf; |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1139 } |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1140 |
9491
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1141 static void |
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1142 set_callback( |
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1143 char_u **cbp, |
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1144 partial_T **pp, |
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1145 char_u *callback, |
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1146 partial_T *partial) |
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1147 { |
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1148 free_callback(*cbp, *pp); |
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1149 if (callback != NULL && *callback != NUL) |
9529
581d5131629f
commit https://github.com/vim/vim/commit/5ef2e762844e0eb1f5b213bd58e6bc38bdb69dac
Christian Brabandt <cb@256bit.org>
parents:
9491
diff
changeset
|
1150 { |
581d5131629f
commit https://github.com/vim/vim/commit/5ef2e762844e0eb1f5b213bd58e6bc38bdb69dac
Christian Brabandt <cb@256bit.org>
parents:
9491
diff
changeset
|
1151 if (partial != NULL) |
9723
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
1152 *cbp = partial_name(partial); |
9529
581d5131629f
commit https://github.com/vim/vim/commit/5ef2e762844e0eb1f5b213bd58e6bc38bdb69dac
Christian Brabandt <cb@256bit.org>
parents:
9491
diff
changeset
|
1153 else |
9723
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
1154 { |
9529
581d5131629f
commit https://github.com/vim/vim/commit/5ef2e762844e0eb1f5b213bd58e6bc38bdb69dac
Christian Brabandt <cb@256bit.org>
parents:
9491
diff
changeset
|
1155 *cbp = vim_strsave(callback); |
9723
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
1156 func_ref(*cbp); |
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
1157 } |
9529
581d5131629f
commit https://github.com/vim/vim/commit/5ef2e762844e0eb1f5b213bd58e6bc38bdb69dac
Christian Brabandt <cb@256bit.org>
parents:
9491
diff
changeset
|
1158 } |
9491
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1159 else |
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1160 *cbp = NULL; |
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1161 *pp = partial; |
9723
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
1162 if (partial != NULL) |
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
1163 ++partial->pt_refcount; |
9491
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1164 } |
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1165 |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1166 /* |
8165
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1167 * Set various properties from an "opt" argument. |
8094
18a3f0f05244
commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents:
8084
diff
changeset
|
1168 */ |
18a3f0f05244
commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents:
8084
diff
changeset
|
1169 void |
8165
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1170 channel_set_options(channel_T *channel, jobopt_T *opt) |
8094
18a3f0f05244
commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents:
8084
diff
changeset
|
1171 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1172 ch_part_T part; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1173 |
8165
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1174 if (opt->jo_set & JO_MODE) |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1175 for (part = PART_SOCK; part < PART_COUNT; ++part) |
8165
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1176 channel->ch_part[part].ch_mode = opt->jo_mode; |
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1177 if (opt->jo_set & JO_IN_MODE) |
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1178 channel->ch_part[PART_IN].ch_mode = opt->jo_in_mode; |
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1179 if (opt->jo_set & JO_OUT_MODE) |
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1180 channel->ch_part[PART_OUT].ch_mode = opt->jo_out_mode; |
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1181 if (opt->jo_set & JO_ERR_MODE) |
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1182 channel->ch_part[PART_ERR].ch_mode = opt->jo_err_mode; |
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1183 |
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1184 if (opt->jo_set & JO_TIMEOUT) |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1185 for (part = PART_SOCK; part < PART_COUNT; ++part) |
8165
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1186 channel->ch_part[part].ch_timeout = opt->jo_timeout; |
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1187 if (opt->jo_set & JO_OUT_TIMEOUT) |
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1188 channel->ch_part[PART_OUT].ch_timeout = opt->jo_out_timeout; |
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1189 if (opt->jo_set & JO_ERR_TIMEOUT) |
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1190 channel->ch_part[PART_ERR].ch_timeout = opt->jo_err_timeout; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1191 if (opt->jo_set & JO_BLOCK_WRITE) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1192 channel->ch_part[PART_IN].ch_block_write = 1; |
8094
18a3f0f05244
commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents:
8084
diff
changeset
|
1193 |
8165
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1194 if (opt->jo_set & JO_CALLBACK) |
9491
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1195 set_callback(&channel->ch_callback, &channel->ch_partial, |
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1196 opt->jo_callback, opt->jo_partial); |
8165
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1197 if (opt->jo_set & JO_OUT_CALLBACK) |
9491
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1198 set_callback(&channel->ch_part[PART_OUT].ch_callback, |
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1199 &channel->ch_part[PART_OUT].ch_partial, |
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1200 opt->jo_out_cb, opt->jo_out_partial); |
8165
973686665238
commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
1201 if (opt->jo_set & JO_ERR_CALLBACK) |
9491
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1202 set_callback(&channel->ch_part[PART_ERR].ch_callback, |
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1203 &channel->ch_part[PART_ERR].ch_partial, |
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1204 opt->jo_err_cb, opt->jo_err_partial); |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
1205 if (opt->jo_set & JO_CLOSE_CALLBACK) |
9491
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1206 set_callback(&channel->ch_close_cb, &channel->ch_close_partial, |
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1207 opt->jo_close_cb, opt->jo_close_partial); |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
1208 channel->ch_drop_never = opt->jo_drop_never; |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1209 |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1210 if ((opt->jo_set & JO_OUT_IO) && opt->jo_io[PART_OUT] == JIO_BUFFER) |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1211 { |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1212 buf_T *buf; |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1213 |
8346
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8334
diff
changeset
|
1214 /* writing output to a buffer. Default mode is NL. */ |
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8334
diff
changeset
|
1215 if (!(opt->jo_set & JO_OUT_MODE)) |
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8334
diff
changeset
|
1216 channel->ch_part[PART_OUT].ch_mode = MODE_NL; |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8473
diff
changeset
|
1217 if (opt->jo_set & JO_OUT_BUF) |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1218 { |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1219 buf = buflist_findnr(opt->jo_io_buf[PART_OUT]); |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1220 if (buf == NULL) |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1221 EMSGN(_(e_nobufnr), (long)opt->jo_io_buf[PART_OUT]); |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1222 } |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8473
diff
changeset
|
1223 else |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1224 { |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
1225 int msg = TRUE; |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
1226 |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
1227 if (opt->jo_set2 & JO2_OUT_MSG) |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
1228 msg = opt->jo_message[PART_OUT]; |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
1229 buf = find_buffer(opt->jo_io_name[PART_OUT], FALSE, msg); |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1230 } |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1231 if (buf != NULL) |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1232 { |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1233 if (opt->jo_set & JO_OUT_MODIFIABLE) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1234 channel->ch_part[PART_OUT].ch_nomodifiable = |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1235 !opt->jo_modifiable[PART_OUT]; |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1236 |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1237 if (!buf->b_p_ma && !channel->ch_part[PART_OUT].ch_nomodifiable) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1238 { |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1239 EMSG(_(e_modifiable)); |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1240 } |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1241 else |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1242 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
1243 ch_log(channel, "writing out to buffer '%s'", |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1244 (char *)buf->b_ffname); |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1245 set_bufref(&channel->ch_part[PART_OUT].ch_bufref, buf); |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1246 } |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1247 } |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
1248 } |
8463
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8453
diff
changeset
|
1249 |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8453
diff
changeset
|
1250 if ((opt->jo_set & JO_ERR_IO) && (opt->jo_io[PART_ERR] == JIO_BUFFER |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8453
diff
changeset
|
1251 || (opt->jo_io[PART_ERR] == JIO_OUT && (opt->jo_set & JO_OUT_IO) |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8453
diff
changeset
|
1252 && opt->jo_io[PART_OUT] == JIO_BUFFER))) |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8453
diff
changeset
|
1253 { |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1254 buf_T *buf; |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1255 |
8463
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8453
diff
changeset
|
1256 /* writing err to a buffer. Default mode is NL. */ |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8453
diff
changeset
|
1257 if (!(opt->jo_set & JO_ERR_MODE)) |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8453
diff
changeset
|
1258 channel->ch_part[PART_ERR].ch_mode = MODE_NL; |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8453
diff
changeset
|
1259 if (opt->jo_io[PART_ERR] == JIO_OUT) |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1260 buf = channel->ch_part[PART_OUT].ch_bufref.br_buf; |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8473
diff
changeset
|
1261 else if (opt->jo_set & JO_ERR_BUF) |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1262 { |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1263 buf = buflist_findnr(opt->jo_io_buf[PART_ERR]); |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1264 if (buf == NULL) |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1265 EMSGN(_(e_nobufnr), (long)opt->jo_io_buf[PART_ERR]); |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1266 } |
8463
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8453
diff
changeset
|
1267 else |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
1268 { |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
1269 int msg = TRUE; |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
1270 |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
1271 if (opt->jo_set2 & JO2_ERR_MSG) |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
1272 msg = opt->jo_message[PART_ERR]; |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
1273 buf = find_buffer(opt->jo_io_name[PART_ERR], TRUE, msg); |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
1274 } |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1275 if (buf != NULL) |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1276 { |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1277 if (opt->jo_set & JO_ERR_MODIFIABLE) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1278 channel->ch_part[PART_ERR].ch_nomodifiable = |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1279 !opt->jo_modifiable[PART_ERR]; |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1280 if (!buf->b_p_ma && !channel->ch_part[PART_ERR].ch_nomodifiable) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1281 { |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1282 EMSG(_(e_modifiable)); |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1283 } |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1284 else |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1285 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
1286 ch_log(channel, "writing err to buffer '%s'", |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1287 (char *)buf->b_ffname); |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1288 set_bufref(&channel->ch_part[PART_ERR].ch_bufref, buf); |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
1289 } |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1290 } |
8463
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8453
diff
changeset
|
1291 } |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
1292 |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
1293 channel->ch_part[PART_OUT].ch_io = opt->jo_io[PART_OUT]; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
1294 channel->ch_part[PART_ERR].ch_io = opt->jo_io[PART_ERR]; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
1295 channel->ch_part[PART_IN].ch_io = opt->jo_io[PART_IN]; |
8094
18a3f0f05244
commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents:
8084
diff
changeset
|
1296 } |
18a3f0f05244
commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents:
8084
diff
changeset
|
1297 |
18a3f0f05244
commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents:
8084
diff
changeset
|
1298 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1299 * Set the callback for "channel"/"part" for the response with "id". |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
1300 */ |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
1301 void |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1302 channel_set_req_callback( |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
1303 channel_T *channel, |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1304 ch_part_T part, |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
1305 char_u *callback, |
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
1306 partial_T *partial, |
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
1307 int id) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
1308 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1309 cbq_T *head = &channel->ch_part[part].ch_cb_head; |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
1310 cbq_T *item = (cbq_T *)alloc((int)sizeof(cbq_T)); |
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
1311 |
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
1312 if (item != NULL) |
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
1313 { |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
1314 item->cq_partial = partial; |
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
1315 if (partial != NULL) |
9711
b74515b8f3d4
commit https://github.com/vim/vim/commit/57e69ff2cca9edee3546373d04e0dde6810309e5
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
1316 { |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
1317 ++partial->pt_refcount; |
9711
b74515b8f3d4
commit https://github.com/vim/vim/commit/57e69ff2cca9edee3546373d04e0dde6810309e5
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
1318 item->cq_callback = callback; |
b74515b8f3d4
commit https://github.com/vim/vim/commit/57e69ff2cca9edee3546373d04e0dde6810309e5
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
1319 } |
b74515b8f3d4
commit https://github.com/vim/vim/commit/57e69ff2cca9edee3546373d04e0dde6810309e5
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
1320 else |
9723
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
1321 { |
9711
b74515b8f3d4
commit https://github.com/vim/vim/commit/57e69ff2cca9edee3546373d04e0dde6810309e5
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
1322 item->cq_callback = vim_strsave(callback); |
9723
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
1323 func_ref(item->cq_callback); |
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
1324 } |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1325 item->cq_seq_nr = id; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1326 item->cq_prev = head->cq_prev; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1327 head->cq_prev = item; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1328 item->cq_next = NULL; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1329 if (item->cq_prev == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1330 head->cq_next = item; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1331 else |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1332 item->cq_prev->cq_next = item; |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
1333 } |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1334 } |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1335 |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1336 static void |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1337 write_buf_line(buf_T *buf, linenr_T lnum, channel_T *channel) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1338 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1339 char_u *line = ml_get_buf(buf, lnum, FALSE); |
8453
fed4e19bd884
commit https://github.com/vim/vim/commit/367aabdbf76f7df00fd18e39d9378d1360a526ab
Christian Brabandt <cb@256bit.org>
parents:
8428
diff
changeset
|
1340 int len = (int)STRLEN(line); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1341 char_u *p; |
9434
8f904a323b3f
commit https://github.com/vim/vim/commit/bf2cc5f36d5ffd5de445e6970602000c7869b65a
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1342 int i; |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1343 |
9143
b9c1a397a8a6
commit https://github.com/vim/vim/commit/655da31a18ef3f888acf10e68b438e2a851f7b14
Christian Brabandt <cb@256bit.org>
parents:
9139
diff
changeset
|
1344 /* Need to make a copy to be able to append a NL. */ |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1345 if ((p = alloc(len + 2)) == NULL) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1346 return; |
9367
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9355
diff
changeset
|
1347 memcpy((char *)p, (char *)line, len); |
9434
8f904a323b3f
commit https://github.com/vim/vim/commit/bf2cc5f36d5ffd5de445e6970602000c7869b65a
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1348 |
12311
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1349 if (channel->ch_write_text_mode) |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1350 p[len] = CAR; |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1351 else |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1352 { |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1353 for (i = 0; i < len; ++i) |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1354 if (p[i] == NL) |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1355 p[i] = NUL; |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1356 |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1357 p[len] = NL; |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1358 } |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1359 p[len + 1] = NUL; |
10363
471b87c3b67d
commit https://github.com/vim/vim/commit/79cbdcb1eeead00bad6fc64ab4a53e5860d5a663
Christian Brabandt <cb@256bit.org>
parents:
10309
diff
changeset
|
1360 channel_send(channel, PART_IN, p, len + 1, "write_buf_line"); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1361 vim_free(p); |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1362 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1363 |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1364 /* |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1365 * Return TRUE if "channel" can be written to. |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1366 * Returns FALSE if the input is closed or the write would block. |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1367 */ |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1368 static int |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1369 can_write_buf_line(channel_T *channel) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1370 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1371 chanpart_T *in_part = &channel->ch_part[PART_IN]; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1372 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1373 if (in_part->ch_fd == INVALID_FD) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1374 return FALSE; /* pipe was closed */ |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1375 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1376 /* for testing: block every other attempt to write */ |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1377 if (in_part->ch_block_write == 1) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1378 in_part->ch_block_write = -1; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1379 else if (in_part->ch_block_write == -1) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1380 in_part->ch_block_write = 1; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1381 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1382 /* TODO: Win32 implementation, probably using WaitForMultipleObjects() */ |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1383 #ifndef WIN32 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1384 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1385 # if defined(HAVE_SELECT) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1386 struct timeval tval; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1387 fd_set wfds; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1388 int ret; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1389 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1390 FD_ZERO(&wfds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1391 FD_SET((int)in_part->ch_fd, &wfds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1392 tval.tv_sec = 0; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1393 tval.tv_usec = 0; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1394 for (;;) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1395 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1396 ret = select((int)in_part->ch_fd + 1, NULL, &wfds, NULL, &tval); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1397 # ifdef EINTR |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1398 SOCK_ERRNO; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1399 if (ret == -1 && errno == EINTR) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1400 continue; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1401 # endif |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1402 if (ret <= 0 || in_part->ch_block_write == 1) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1403 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1404 if (ret > 0) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1405 ch_log(channel, "FAKED Input not ready for writing"); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1406 else |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1407 ch_log(channel, "Input not ready for writing"); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1408 return FALSE; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1409 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1410 break; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1411 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1412 # else |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1413 struct pollfd fds; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1414 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1415 fds.fd = in_part->ch_fd; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1416 fds.events = POLLOUT; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1417 if (poll(&fds, 1, 0) <= 0) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1418 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1419 ch_log(channel, "Input not ready for writing"); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1420 return FALSE; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1421 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1422 if (in_part->ch_block_write == 1) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1423 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1424 ch_log(channel, "FAKED Input not ready for writing"); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1425 return FALSE; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1426 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1427 # endif |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1428 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1429 #endif |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1430 return TRUE; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1431 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1432 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1433 /* |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1434 * Write any buffer lines to the input channel. |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1435 */ |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1436 static void |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1437 channel_write_in(channel_T *channel) |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1438 { |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1439 chanpart_T *in_part = &channel->ch_part[PART_IN]; |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1440 linenr_T lnum; |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1441 buf_T *buf = in_part->ch_bufref.br_buf; |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1442 int written = 0; |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1443 |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1444 if (buf == NULL || in_part->ch_buf_append) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1445 return; /* no buffer or using appending */ |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1446 if (!bufref_valid(&in_part->ch_bufref) || buf->b_ml.ml_mfp == NULL) |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1447 { |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1448 /* buffer was wiped out or unloaded */ |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11416
diff
changeset
|
1449 ch_log(channel, "input buffer has been wiped out"); |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1450 in_part->ch_bufref.br_buf = NULL; |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1451 return; |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1452 } |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1453 |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1454 for (lnum = in_part->ch_buf_top; lnum <= in_part->ch_buf_bot |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1455 && lnum <= buf->b_ml.ml_line_count; ++lnum) |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1456 { |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1457 if (!can_write_buf_line(channel)) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1458 break; |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1459 write_buf_line(buf, lnum, channel); |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1460 ++written; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1461 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1462 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1463 if (written == 1) |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
1464 ch_log(channel, "written line %d to channel", (int)lnum - 1); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1465 else if (written > 1) |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
1466 ch_log(channel, "written %d lines to channel", written); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1467 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1468 in_part->ch_buf_top = lnum; |
10052
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1469 if (lnum > buf->b_ml.ml_line_count || lnum > in_part->ch_buf_bot) |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1470 { |
12313
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
1471 #if defined(FEAT_TERMINAL) |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
1472 /* Send CTRL-D or "eof_chars" to close stdin on MS-Windows. */ |
12309
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
1473 if (channel->ch_job != NULL) |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
1474 term_send_eof(channel); |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
1475 #endif |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
1476 |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1477 /* Writing is done, no longer need the buffer. */ |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1478 in_part->ch_bufref.br_buf = NULL; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1479 ch_log(channel, "Finished writing all lines to channel"); |
10052
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1480 |
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1481 /* Close the pipe/socket, so that the other side gets EOF. */ |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1482 ch_close_part(channel, PART_IN); |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1483 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1484 else |
13608
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
1485 ch_log(channel, "Still %ld more lines to write", |
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
1486 (long)(buf->b_ml.ml_line_count - lnum + 1)); |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1487 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1488 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1489 /* |
9355
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
1490 * Handle buffer "buf" being freed, remove it from any channels. |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1491 */ |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1492 void |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1493 channel_buffer_free(buf_T *buf) |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1494 { |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1495 channel_T *channel; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1496 ch_part_T part; |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1497 |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1498 for (channel = first_channel; channel != NULL; channel = channel->ch_next) |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1499 for (part = PART_SOCK; part < PART_COUNT; ++part) |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1500 { |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1501 chanpart_T *ch_part = &channel->ch_part[part]; |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1502 |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1503 if (ch_part->ch_bufref.br_buf == buf) |
9089
6bc0a492e8ba
commit https://github.com/vim/vim/commit/de7eb0a47b557eb4656c6b63d421c7e7bae1ef30
Christian Brabandt <cb@256bit.org>
parents:
9087
diff
changeset
|
1504 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
1505 ch_log(channel, "%s buffer has been wiped out", |
9089
6bc0a492e8ba
commit https://github.com/vim/vim/commit/de7eb0a47b557eb4656c6b63d421c7e7bae1ef30
Christian Brabandt <cb@256bit.org>
parents:
9087
diff
changeset
|
1506 part_names[part]); |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1507 ch_part->ch_bufref.br_buf = NULL; |
9089
6bc0a492e8ba
commit https://github.com/vim/vim/commit/de7eb0a47b557eb4656c6b63d421c7e7bae1ef30
Christian Brabandt <cb@256bit.org>
parents:
9087
diff
changeset
|
1508 } |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1509 } |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1510 } |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1511 |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1512 /* |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1513 * Write any lines waiting to be written to "channel". |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1514 */ |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1515 static void |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1516 channel_write_input(channel_T *channel) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1517 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1518 chanpart_T *in_part = &channel->ch_part[PART_IN]; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1519 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1520 if (in_part->ch_writeque.wq_next != NULL) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1521 channel_send(channel, PART_IN, (char_u *)"", 0, "channel_write_input"); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1522 else if (in_part->ch_bufref.br_buf != NULL) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1523 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1524 if (in_part->ch_buf_append) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1525 channel_write_new_lines(in_part->ch_bufref.br_buf); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1526 else |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1527 channel_write_in(channel); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1528 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1529 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1530 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1531 /* |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1532 * Write any lines waiting to be written to a channel. |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1533 */ |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1534 void |
9282
9f97a6290c63
commit https://github.com/vim/vim/commit/cf089463492fab53b2a5d81517829d22f882f82e
Christian Brabandt <cb@256bit.org>
parents:
9246
diff
changeset
|
1535 channel_write_any_lines(void) |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1536 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1537 channel_T *channel; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1538 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1539 for (channel = first_channel; channel != NULL; channel = channel->ch_next) |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1540 channel_write_input(channel); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1541 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1542 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1543 /* |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1544 * Write appended lines above the last one in "buf" to the channel. |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1545 */ |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1546 void |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1547 channel_write_new_lines(buf_T *buf) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1548 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1549 channel_T *channel; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1550 int found_one = FALSE; |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1551 |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1552 /* There could be more than one channel for the buffer, loop over all of |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1553 * them. */ |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1554 for (channel = first_channel; channel != NULL; channel = channel->ch_next) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1555 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1556 chanpart_T *in_part = &channel->ch_part[PART_IN]; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1557 linenr_T lnum; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1558 int written = 0; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1559 |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1560 if (in_part->ch_bufref.br_buf == buf && in_part->ch_buf_append) |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1561 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1562 if (in_part->ch_fd == INVALID_FD) |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1563 continue; /* pipe was closed */ |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1564 found_one = TRUE; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1565 for (lnum = in_part->ch_buf_bot; lnum < buf->b_ml.ml_line_count; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1566 ++lnum) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1567 { |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1568 if (!can_write_buf_line(channel)) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1569 break; |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1570 write_buf_line(buf, lnum, channel); |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1571 ++written; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1572 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1573 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1574 if (written == 1) |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
1575 ch_log(channel, "written line %d to channel", (int)lnum - 1); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1576 else if (written > 1) |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
1577 ch_log(channel, "written %d lines to channel", written); |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1578 if (lnum < buf->b_ml.ml_line_count) |
13608
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
1579 ch_log(channel, "Still %ld more lines to write", |
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
1580 (long)(buf->b_ml.ml_line_count - lnum)); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1581 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1582 in_part->ch_buf_bot = lnum; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1583 } |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1584 } |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1585 if (!found_one) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1586 buf->b_write_to_channel = FALSE; |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1587 } |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1588 |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1589 /* |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1590 * Invoke the "callback" on channel "channel". |
8928
e6916e1683bb
commit https://github.com/vim/vim/commit/7f7c3325d3f1baba32263a3457cfc4d90ecd5ff1
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1591 * This does not redraw but sets channel_need_redraw; |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1592 */ |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1593 static void |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
1594 invoke_callback(channel_T *channel, char_u *callback, partial_T *partial, |
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
1595 typval_T *argv) |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1596 { |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1597 typval_T rettv; |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1598 int dummy; |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1599 |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
1600 if (safe_to_invoke_callback == 0) |
10540
ea7fbae33285
patch 8.0.0160: EMSG() is sometimes used where it should be IEMSG()
Christian Brabandt <cb@256bit.org>
parents:
10426
diff
changeset
|
1601 IEMSG("INTERNAL: Invoking callback when it is not safe"); |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
1602 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1603 argv[0].v_type = VAR_CHANNEL; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1604 argv[0].vval.v_channel = channel; |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1605 |
9626
172131507c85
commit https://github.com/vim/vim/commit/df48fb456fb6bf63d94cad9b302ff01d8ee8d311
Christian Brabandt <cb@256bit.org>
parents:
9529
diff
changeset
|
1606 call_func(callback, (int)STRLEN(callback), &rettv, 2, argv, NULL, |
172131507c85
commit https://github.com/vim/vim/commit/df48fb456fb6bf63d94cad9b302ff01d8ee8d311
Christian Brabandt <cb@256bit.org>
parents:
9529
diff
changeset
|
1607 0L, 0L, &dummy, TRUE, partial, NULL); |
8174
f2286ff0c102
commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents:
8172
diff
changeset
|
1608 clear_tv(&rettv); |
8928
e6916e1683bb
commit https://github.com/vim/vim/commit/7f7c3325d3f1baba32263a3457cfc4d90ecd5ff1
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1609 channel_need_redraw = TRUE; |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
1610 } |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
1611 |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
1612 /* |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1613 * Return the first node from "channel"/"part" without removing it. |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1614 * Returns NULL if there is nothing. |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1615 */ |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1616 readq_T * |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1617 channel_peek(channel_T *channel, ch_part_T part) |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1618 { |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1619 readq_T *head = &channel->ch_part[part].ch_head; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1620 |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1621 return head->rq_next; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1622 } |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1623 |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1624 /* |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1625 * Return a pointer to the first NL in "node". |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1626 * Skips over NUL characters. |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1627 * Returns NULL if there is no NL. |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1628 */ |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1629 char_u * |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1630 channel_first_nl(readq_T *node) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1631 { |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1632 char_u *buffer = node->rq_buffer; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1633 long_u i; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1634 |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1635 for (i = 0; i < node->rq_buflen; ++i) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1636 if (buffer[i] == NL) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1637 return buffer + i; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1638 return NULL; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1639 } |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1640 |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1641 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1642 * Return the first buffer from channel "channel"/"part" and remove it. |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1643 * The caller must free it. |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1644 * Returns NULL if there is nothing. |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1645 */ |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1646 char_u * |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1647 channel_get(channel_T *channel, ch_part_T part) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1648 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1649 readq_T *head = &channel->ch_part[part].ch_head; |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1650 readq_T *node = head->rq_next; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1651 char_u *p; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1652 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1653 if (node == NULL) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1654 return NULL; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1655 /* dispose of the node but keep the buffer */ |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1656 p = node->rq_buffer; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1657 head->rq_next = node->rq_next; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1658 if (node->rq_next == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1659 head->rq_prev = NULL; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1660 else |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1661 node->rq_next->rq_prev = NULL; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1662 vim_free(node); |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1663 return p; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1664 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1665 |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1666 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1667 * Returns the whole buffer contents concatenated for "channel"/"part". |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1668 * Replaces NUL bytes with NL. |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1669 */ |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1670 static char_u * |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1671 channel_get_all(channel_T *channel, ch_part_T part) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1672 { |
8759
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1673 readq_T *head = &channel->ch_part[part].ch_head; |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1674 readq_T *node = head->rq_next; |
9367
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9355
diff
changeset
|
1675 long_u len = 0; |
8759
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1676 char_u *res; |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1677 char_u *p; |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1678 |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1679 /* If there is only one buffer just get that one. */ |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1680 if (head->rq_next == NULL || head->rq_next->rq_next == NULL) |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1681 return channel_get(channel, part); |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1682 |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1683 /* Concatenate everything into one buffer. */ |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1684 for (node = head->rq_next; node != NULL; node = node->rq_next) |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1685 len += node->rq_buflen; |
9367
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9355
diff
changeset
|
1686 res = lalloc(len + 1, TRUE); |
8759
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1687 if (res == NULL) |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1688 return NULL; |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1689 p = res; |
8759
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1690 for (node = head->rq_next; node != NULL; node = node->rq_next) |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1691 { |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1692 mch_memmove(p, node->rq_buffer, node->rq_buflen); |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1693 p += node->rq_buflen; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1694 } |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1695 *p = NUL; |
8759
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1696 |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1697 /* Free all buffers */ |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1698 do |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1699 { |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1700 p = channel_get(channel, part); |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1701 vim_free(p); |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1702 } while (p != NULL); |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1703 |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1704 /* turn all NUL into NL */ |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1705 while (len > 0) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1706 { |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1707 --len; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1708 if (res[len] == NUL) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1709 res[len] = NL; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1710 } |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1711 |
8759
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1712 return res; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1713 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1714 |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1715 /* |
9282
9f97a6290c63
commit https://github.com/vim/vim/commit/cf089463492fab53b2a5d81517829d22f882f82e
Christian Brabandt <cb@256bit.org>
parents:
9246
diff
changeset
|
1716 * Consume "len" bytes from the head of "node". |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1717 * Caller must check these bytes are available. |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1718 */ |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1719 void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1720 channel_consume(channel_T *channel, ch_part_T part, int len) |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1721 { |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1722 readq_T *head = &channel->ch_part[part].ch_head; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1723 readq_T *node = head->rq_next; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1724 char_u *buf = node->rq_buffer; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1725 |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1726 mch_memmove(buf, buf + len, node->rq_buflen - len); |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1727 node->rq_buflen -= len; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1728 } |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1729 |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1730 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1731 * Collapses the first and second buffer for "channel"/"part". |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1732 * Returns FAIL if that is not possible. |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1733 * When "want_nl" is TRUE collapse more buffers until a NL is found. |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1734 */ |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1735 int |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1736 channel_collapse(channel_T *channel, ch_part_T part, int want_nl) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1737 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1738 readq_T *head = &channel->ch_part[part].ch_head; |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1739 readq_T *node = head->rq_next; |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1740 readq_T *last_node; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1741 readq_T *n; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1742 char_u *newbuf; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1743 char_u *p; |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1744 long_u len; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1745 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1746 if (node == NULL || node->rq_next == NULL) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1747 return FAIL; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1748 |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1749 last_node = node->rq_next; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1750 len = node->rq_buflen + last_node->rq_buflen + 1; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1751 if (want_nl) |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1752 while (last_node->rq_next != NULL |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1753 && channel_first_nl(last_node) == NULL) |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1754 { |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1755 last_node = last_node->rq_next; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1756 len += last_node->rq_buflen; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1757 } |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1758 |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1759 p = newbuf = alloc(len); |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1760 if (newbuf == NULL) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1761 return FAIL; /* out of memory */ |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1762 mch_memmove(p, node->rq_buffer, node->rq_buflen); |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1763 p += node->rq_buflen; |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1764 vim_free(node->rq_buffer); |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1765 node->rq_buffer = newbuf; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1766 for (n = node; n != last_node; ) |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1767 { |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1768 n = n->rq_next; |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1769 mch_memmove(p, n->rq_buffer, n->rq_buflen); |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1770 p += n->rq_buflen; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1771 vim_free(n->rq_buffer); |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1772 } |
9238
7d13d180a6ae
commit https://github.com/vim/vim/commit/bbe8d91e695184771d7e45315258fab8eb3e6b07
Christian Brabandt <cb@256bit.org>
parents:
9215
diff
changeset
|
1773 node->rq_buflen = (long_u)(p - newbuf); |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1774 |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1775 /* dispose of the collapsed nodes and their buffers */ |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1776 for (n = node->rq_next; n != last_node; ) |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1777 { |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1778 n = n->rq_next; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1779 vim_free(n->rq_prev); |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1780 } |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1781 node->rq_next = last_node->rq_next; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1782 if (last_node->rq_next == NULL) |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1783 head->rq_prev = node; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1784 else |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1785 last_node->rq_next->rq_prev = node; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1786 vim_free(last_node); |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1787 return OK; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1788 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1789 |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1790 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1791 * Store "buf[len]" on "channel"/"part". |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1792 * When "prepend" is TRUE put in front, otherwise append at the end. |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1793 * Returns OK or FAIL. |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1794 */ |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1795 static int |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1796 channel_save(channel_T *channel, ch_part_T part, char_u *buf, int len, |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1797 int prepend, char *lead) |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1798 { |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1799 readq_T *node; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1800 readq_T *head = &channel->ch_part[part].ch_head; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1801 char_u *p; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1802 int i; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1803 |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1804 node = (readq_T *)alloc(sizeof(readq_T)); |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1805 if (node == NULL) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1806 return FAIL; /* out of memory */ |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1807 /* A NUL is added at the end, because netbeans code expects that. |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1808 * Otherwise a NUL may appear inside the text. */ |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1809 node->rq_buffer = alloc(len + 1); |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1810 if (node->rq_buffer == NULL) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1811 { |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1812 vim_free(node); |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1813 return FAIL; /* out of memory */ |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1814 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1815 |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1816 if (channel->ch_part[part].ch_mode == MODE_NL) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1817 { |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1818 /* Drop any CR before a NL. */ |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1819 p = node->rq_buffer; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1820 for (i = 0; i < len; ++i) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1821 if (buf[i] != CAR || i + 1 >= len || buf[i + 1] != NL) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1822 *p++ = buf[i]; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1823 *p = NUL; |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1824 node->rq_buflen = (long_u)(p - node->rq_buffer); |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1825 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1826 else |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1827 { |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1828 mch_memmove(node->rq_buffer, buf, len); |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1829 node->rq_buffer[len] = NUL; |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1830 node->rq_buflen = (long_u)len; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1831 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1832 |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1833 if (prepend) |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1834 { |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1835 /* preend node to the head of the queue */ |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1836 node->rq_next = head->rq_next; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1837 node->rq_prev = NULL; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1838 if (head->rq_next == NULL) |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1839 head->rq_prev = node; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1840 else |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1841 head->rq_next->rq_prev = node; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1842 head->rq_next = node; |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1843 } |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1844 else |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1845 { |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1846 /* append node to the tail of the queue */ |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1847 node->rq_next = NULL; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1848 node->rq_prev = head->rq_prev; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1849 if (head->rq_prev == NULL) |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1850 head->rq_next = node; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1851 else |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1852 head->rq_prev->rq_next = node; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1853 head->rq_prev = node; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1854 } |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1855 |
12443
579faede5d9c
patch 8.0.1101: channel write fails if writing to log fails
Christian Brabandt <cb@256bit.org>
parents:
12407
diff
changeset
|
1856 if (ch_log_active() && lead != NULL) |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1857 { |
14499
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
1858 ch_log_lead(lead, channel, part); |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1859 fprintf(log_fd, "'"); |
12443
579faede5d9c
patch 8.0.1101: channel write fails if writing to log fails
Christian Brabandt <cb@256bit.org>
parents:
12407
diff
changeset
|
1860 ignored = (int)fwrite(buf, len, 1, log_fd); |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1861 fprintf(log_fd, "'\n"); |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1862 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1863 return OK; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1864 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1865 |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1866 /* |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1867 * Try to fill the buffer of "reader". |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1868 * Returns FALSE when nothing was added. |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1869 */ |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1870 static int |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1871 channel_fill(js_read_T *reader) |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1872 { |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1873 channel_T *channel = (channel_T *)reader->js_cookie; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1874 ch_part_T part = reader->js_cookie_arg; |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1875 char_u *next = channel_get(channel, part); |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1876 int keeplen; |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1877 int addlen; |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1878 char_u *p; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1879 |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1880 if (next == NULL) |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1881 return FALSE; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1882 |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1883 keeplen = reader->js_end - reader->js_buf; |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1884 if (keeplen > 0) |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1885 { |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1886 /* Prepend unused text. */ |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1887 addlen = (int)STRLEN(next); |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1888 p = alloc(keeplen + addlen + 1); |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1889 if (p == NULL) |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1890 { |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1891 vim_free(next); |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1892 return FALSE; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1893 } |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1894 mch_memmove(p, reader->js_buf, keeplen); |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1895 mch_memmove(p + keeplen, next, addlen + 1); |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1896 vim_free(next); |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1897 next = p; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1898 } |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1899 |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1900 vim_free(reader->js_buf); |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1901 reader->js_buf = next; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1902 return TRUE; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1903 } |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1904 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1905 /* |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1906 * Use the read buffer of "channel"/"part" and parse a JSON message that is |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1907 * complete. The messages are added to the queue. |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
1908 * Return TRUE if there is more to read. |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1909 */ |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
1910 static int |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1911 channel_parse_json(channel_T *channel, ch_part_T part) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1912 { |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1913 js_read_T reader; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1914 typval_T listtv; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1915 jsonq_T *item; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1916 chanpart_T *chanpart = &channel->ch_part[part]; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1917 jsonq_T *head = &chanpart->ch_json_head; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1918 int status; |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
1919 int ret; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1920 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1921 if (channel_peek(channel, part) == NULL) |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
1922 return FALSE; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1923 |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1924 reader.js_buf = channel_get(channel, part); |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1925 reader.js_used = 0; |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1926 reader.js_fill = channel_fill; |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1927 reader.js_cookie = channel; |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1928 reader.js_cookie_arg = part; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1929 |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1930 /* When a message is incomplete we wait for a short while for more to |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1931 * arrive. After the delay drop the input, otherwise a truncated string |
10553
f83b6a0b6148
patch 8.0.0166: JSON with a duplicate key gives an internal error
Christian Brabandt <cb@256bit.org>
parents:
10540
diff
changeset
|
1932 * or list will make us hang. |
f83b6a0b6148
patch 8.0.0166: JSON with a duplicate key gives an internal error
Christian Brabandt <cb@256bit.org>
parents:
10540
diff
changeset
|
1933 * Do not generate error messages, they will be written in a channel log. */ |
f83b6a0b6148
patch 8.0.0166: JSON with a duplicate key gives an internal error
Christian Brabandt <cb@256bit.org>
parents:
10540
diff
changeset
|
1934 ++emsg_silent; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1935 status = json_decode(&reader, &listtv, |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1936 chanpart->ch_mode == MODE_JS ? JSON_JS : 0); |
10553
f83b6a0b6148
patch 8.0.0166: JSON with a duplicate key gives an internal error
Christian Brabandt <cb@256bit.org>
parents:
10540
diff
changeset
|
1937 --emsg_silent; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1938 if (status == OK) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1939 { |
7937
2e905dfc6999
commit https://github.com/vim/vim/commit/6076fe1986255d32b7a078a28bf9e7bea19d6f30
Christian Brabandt <cb@256bit.org>
parents:
7935
diff
changeset
|
1940 /* Only accept the response when it is a list with at least two |
2e905dfc6999
commit https://github.com/vim/vim/commit/6076fe1986255d32b7a078a28bf9e7bea19d6f30
Christian Brabandt <cb@256bit.org>
parents:
7935
diff
changeset
|
1941 * items. */ |
2e905dfc6999
commit https://github.com/vim/vim/commit/6076fe1986255d32b7a078a28bf9e7bea19d6f30
Christian Brabandt <cb@256bit.org>
parents:
7935
diff
changeset
|
1942 if (listtv.v_type != VAR_LIST || listtv.vval.v_list->lv_len < 2) |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
1943 { |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1944 if (listtv.v_type != VAR_LIST) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1945 ch_error(channel, "Did not receive a list, discarding"); |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1946 else |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
1947 ch_error(channel, "Expected list with two items, got %d", |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1948 listtv.vval.v_list->lv_len); |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1949 clear_tv(&listtv); |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
1950 } |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1951 else |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1952 { |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
1953 item = (jsonq_T *)alloc((unsigned)sizeof(jsonq_T)); |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
1954 if (item == NULL) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1955 clear_tv(&listtv); |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1956 else |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1957 { |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
1958 item->jq_no_callback = FALSE; |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1959 item->jq_value = alloc_tv(); |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1960 if (item->jq_value == NULL) |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
1961 { |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
1962 vim_free(item); |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
1963 clear_tv(&listtv); |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
1964 } |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
1965 else |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
1966 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1967 *item->jq_value = listtv; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1968 item->jq_prev = head->jq_prev; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1969 head->jq_prev = item; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1970 item->jq_next = NULL; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1971 if (item->jq_prev == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1972 head->jq_next = item; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1973 else |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1974 item->jq_prev->jq_next = item; |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
1975 } |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1976 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1977 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1978 } |
7885
6e6f829af138
commit https://github.com/vim/vim/commit/df5b27b20ec023274fb0f5347973d5abcde7ddd6
Christian Brabandt <cb@256bit.org>
parents:
7883
diff
changeset
|
1979 |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1980 if (status == OK) |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1981 chanpart->ch_wait_len = 0; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1982 else if (status == MAYBE) |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
1983 { |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1984 size_t buflen = STRLEN(reader.js_buf); |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1985 |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1986 if (chanpart->ch_wait_len < buflen) |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
1987 { |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1988 /* First time encountering incomplete message or after receiving |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1989 * more (but still incomplete): set a deadline of 100 msec. */ |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
1990 ch_log(channel, |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1991 "Incomplete message (%d bytes) - wait 100 msec for more", |
10996
2f041b367cd9
patch 8.0.0387: compiler warnings
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
1992 (int)buflen); |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1993 reader.js_used = 0; |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
1994 chanpart->ch_wait_len = buflen; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1995 #ifdef WIN32 |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1996 chanpart->ch_deadline = GetTickCount() + 100L; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1997 #else |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1998 gettimeofday(&chanpart->ch_deadline, NULL); |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
1999 chanpart->ch_deadline.tv_usec += 100 * 1000; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2000 if (chanpart->ch_deadline.tv_usec > 1000 * 1000) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2001 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2002 chanpart->ch_deadline.tv_usec -= 1000 * 1000; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2003 ++chanpart->ch_deadline.tv_sec; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2004 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2005 #endif |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2006 } |
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2007 else |
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2008 { |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2009 int timeout; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2010 #ifdef WIN32 |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2011 timeout = GetTickCount() > chanpart->ch_deadline; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2012 #else |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2013 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2014 struct timeval now_tv; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2015 |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2016 gettimeofday(&now_tv, NULL); |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2017 timeout = now_tv.tv_sec > chanpart->ch_deadline.tv_sec |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2018 || (now_tv.tv_sec == chanpart->ch_deadline.tv_sec |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2019 && now_tv.tv_usec > chanpart->ch_deadline.tv_usec); |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2020 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2021 #endif |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2022 if (timeout) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2023 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2024 status = FAIL; |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2025 chanpart->ch_wait_len = 0; |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2026 ch_log(channel, "timed out"); |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2027 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2028 else |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2029 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2030 reader.js_used = 0; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2031 ch_log(channel, "still waiting on incomplete message"); |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2032 } |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2033 } |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2034 } |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2035 |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2036 if (status == FAIL) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2037 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2038 ch_error(channel, "Decoding failed - discarding input"); |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2039 ret = FALSE; |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2040 chanpart->ch_wait_len = 0; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2041 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2042 else if (reader.js_buf[reader.js_used] != NUL) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2043 { |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2044 /* Put the unread part back into the channel. */ |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2045 channel_save(channel, part, reader.js_buf + reader.js_used, |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2046 (int)(reader.js_end - reader.js_buf) - reader.js_used, |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2047 TRUE, NULL); |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2048 ret = status == MAYBE ? FALSE: TRUE; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2049 } |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2050 else |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2051 ret = FALSE; |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2052 |
7885
6e6f829af138
commit https://github.com/vim/vim/commit/df5b27b20ec023274fb0f5347973d5abcde7ddd6
Christian Brabandt <cb@256bit.org>
parents:
7883
diff
changeset
|
2053 vim_free(reader.js_buf); |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2054 return ret; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2055 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2056 |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2057 /* |
8074
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8072
diff
changeset
|
2058 * Remove "node" from the queue that it is in. Does not free it. |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2059 */ |
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2060 static void |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2061 remove_cb_node(cbq_T *head, cbq_T *node) |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2062 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2063 if (node->cq_prev == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2064 head->cq_next = node->cq_next; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2065 else |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2066 node->cq_prev->cq_next = node->cq_next; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2067 if (node->cq_next == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2068 head->cq_prev = node->cq_prev; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2069 else |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2070 node->cq_next->cq_prev = node->cq_prev; |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2071 } |
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2072 |
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2073 /* |
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2074 * Remove "node" from the queue that it is in and free it. |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2075 * Caller should have freed or used node->jq_value. |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2076 */ |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2077 static void |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2078 remove_json_node(jsonq_T *head, jsonq_T *node) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2079 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2080 if (node->jq_prev == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2081 head->jq_next = node->jq_next; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2082 else |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2083 node->jq_prev->jq_next = node->jq_next; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2084 if (node->jq_next == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2085 head->jq_prev = node->jq_prev; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2086 else |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2087 node->jq_next->jq_prev = node->jq_prev; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2088 vim_free(node); |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2089 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2090 |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2091 /* |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2092 * Get a message from the JSON queue for channel "channel". |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2093 * When "id" is positive it must match the first number in the list. |
7997
c1c9ab17e197
commit https://github.com/vim/vim/commit/e56bf15c163a921ce9e1c09c0d5b3a03efc63324
Christian Brabandt <cb@256bit.org>
parents:
7988
diff
changeset
|
2094 * When "id" is zero or negative jut get the first message. But not the one |
c1c9ab17e197
commit https://github.com/vim/vim/commit/e56bf15c163a921ce9e1c09c0d5b3a03efc63324
Christian Brabandt <cb@256bit.org>
parents:
7988
diff
changeset
|
2095 * with id ch_block_id. |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2096 * When "without_callback" is TRUE also get messages that were pushed back. |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2097 * Return OK when found and return the value in "rettv". |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2098 * Return FAIL otherwise. |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2099 */ |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2100 static int |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2101 channel_get_json( |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2102 channel_T *channel, |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2103 ch_part_T part, |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2104 int id, |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2105 int without_callback, |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2106 typval_T **rettv) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2107 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2108 jsonq_T *head = &channel->ch_part[part].ch_json_head; |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2109 jsonq_T *item = head->jq_next; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2110 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2111 while (item != NULL) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2112 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2113 list_T *l = item->jq_value->vval.v_list; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2114 typval_T *tv = &l->lv_first->li_tv; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2115 |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2116 if ((without_callback || !item->jq_no_callback) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2117 && ((id > 0 && tv->v_type == VAR_NUMBER && tv->vval.v_number == id) |
7997
c1c9ab17e197
commit https://github.com/vim/vim/commit/e56bf15c163a921ce9e1c09c0d5b3a03efc63324
Christian Brabandt <cb@256bit.org>
parents:
7988
diff
changeset
|
2118 || (id <= 0 && (tv->v_type != VAR_NUMBER |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2119 || tv->vval.v_number == 0 |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2120 || tv->vval.v_number != channel->ch_part[part].ch_block_id)))) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2121 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2122 *rettv = item->jq_value; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2123 if (tv->v_type == VAR_NUMBER) |
13608
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
2124 ch_log(channel, "Getting JSON message %ld", |
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
2125 (long)tv->vval.v_number); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2126 remove_json_node(head, item); |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2127 return OK; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2128 } |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2129 item = item->jq_next; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2130 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2131 return FAIL; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2132 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2133 |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2134 /* |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2135 * Put back "rettv" into the JSON queue, there was no callback for it. |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2136 * Takes over the values in "rettv". |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2137 */ |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2138 static void |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2139 channel_push_json(channel_T *channel, ch_part_T part, typval_T *rettv) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2140 { |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2141 jsonq_T *head = &channel->ch_part[part].ch_json_head; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2142 jsonq_T *item = head->jq_next; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2143 jsonq_T *newitem; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2144 |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2145 if (head->jq_prev != NULL && head->jq_prev->jq_no_callback) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2146 /* last item was pushed back, append to the end */ |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2147 item = NULL; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2148 else while (item != NULL && item->jq_no_callback) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2149 /* append after the last item that was pushed back */ |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2150 item = item->jq_next; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2151 |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2152 newitem = (jsonq_T *)alloc((unsigned)sizeof(jsonq_T)); |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2153 if (newitem == NULL) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2154 clear_tv(rettv); |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2155 else |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2156 { |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2157 newitem->jq_value = alloc_tv(); |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2158 if (newitem->jq_value == NULL) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2159 { |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2160 vim_free(newitem); |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2161 clear_tv(rettv); |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2162 } |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2163 else |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2164 { |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2165 newitem->jq_no_callback = FALSE; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2166 *newitem->jq_value = *rettv; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2167 if (item == NULL) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2168 { |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2169 /* append to the end */ |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2170 newitem->jq_prev = head->jq_prev; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2171 head->jq_prev = newitem; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2172 newitem->jq_next = NULL; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2173 if (newitem->jq_prev == NULL) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2174 head->jq_next = newitem; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2175 else |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2176 newitem->jq_prev->jq_next = newitem; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2177 } |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2178 else |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2179 { |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2180 /* append after "item" */ |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2181 newitem->jq_prev = item; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2182 newitem->jq_next = item->jq_next; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2183 item->jq_next = newitem; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2184 if (newitem->jq_next == NULL) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2185 head->jq_prev = newitem; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2186 else |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2187 newitem->jq_next->jq_prev = newitem; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2188 } |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2189 } |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2190 } |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2191 } |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2192 |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2193 #define CH_JSON_MAX_ARGS 4 |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2194 |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2195 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2196 * Execute a command received over "channel"/"part" |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2197 * "argv[0]" is the command string. |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2198 * "argv[1]" etc. have further arguments, type is VAR_UNKNOWN if missing. |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2199 */ |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2200 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2201 channel_exe_cmd(channel_T *channel, ch_part_T part, typval_T *argv) |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2202 { |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2203 char_u *cmd = argv[0].vval.v_string; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2204 char_u *arg; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2205 int options = channel->ch_part[part].ch_mode == MODE_JS ? JSON_JS : 0; |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2206 |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2207 if (argv[1].v_type != VAR_STRING) |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2208 { |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2209 ch_error(channel, "received command with non-string argument"); |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2210 if (p_verbose > 2) |
9953
9560a2eb7968
commit https://github.com/vim/vim/commit/5b30291785e6b9be1a607504c14bd03c601b59a6
Christian Brabandt <cb@256bit.org>
parents:
9723
diff
changeset
|
2211 EMSG(_("E903: received command with non-string argument")); |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2212 return; |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2213 } |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2214 arg = argv[1].vval.v_string; |
7872
4b9d4600166f
commit https://github.com/vim/vim/commit/14ad611ca435d97e8fd0d9ab03ddc982843298ac
Christian Brabandt <cb@256bit.org>
parents:
7868
diff
changeset
|
2215 if (arg == NULL) |
4b9d4600166f
commit https://github.com/vim/vim/commit/14ad611ca435d97e8fd0d9ab03ddc982843298ac
Christian Brabandt <cb@256bit.org>
parents:
7868
diff
changeset
|
2216 arg = (char_u *)""; |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2217 |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2218 if (STRCMP(cmd, "ex") == 0) |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2219 { |
8746
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8684
diff
changeset
|
2220 int save_called_emsg = called_emsg; |
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8684
diff
changeset
|
2221 |
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8684
diff
changeset
|
2222 called_emsg = FALSE; |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2223 ch_log(channel, "Executing ex command '%s'", (char *)arg); |
8746
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8684
diff
changeset
|
2224 ++emsg_silent; |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2225 do_cmdline_cmd(arg); |
8746
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8684
diff
changeset
|
2226 --emsg_silent; |
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8684
diff
changeset
|
2227 if (called_emsg) |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2228 ch_log(channel, "Ex command error: '%s'", |
8746
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8684
diff
changeset
|
2229 (char *)get_vim_var_str(VV_ERRMSG)); |
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8684
diff
changeset
|
2230 called_emsg = save_called_emsg; |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2231 } |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2232 else if (STRCMP(cmd, "normal") == 0) |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2233 { |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2234 exarg_T ea; |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2235 |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2236 ch_log(channel, "Executing normal command '%s'", (char *)arg); |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2237 ea.arg = arg; |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2238 ea.addr_count = 0; |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2239 ea.forceit = TRUE; /* no mapping */ |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2240 ex_normal(&ea); |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2241 } |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2242 else if (STRCMP(cmd, "redraw") == 0) |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2243 { |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2244 exarg_T ea; |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2245 |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2246 ch_log(channel, "redraw"); |
7872
4b9d4600166f
commit https://github.com/vim/vim/commit/14ad611ca435d97e8fd0d9ab03ddc982843298ac
Christian Brabandt <cb@256bit.org>
parents:
7868
diff
changeset
|
2247 ea.forceit = *arg != NUL; |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2248 ex_redraw(&ea); |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2249 showruler(FALSE); |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2250 setcursor(); |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
2251 out_flush_cursor(TRUE, FALSE); |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2252 } |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2253 else if (STRCMP(cmd, "expr") == 0 || STRCMP(cmd, "call") == 0) |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2254 { |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2255 int is_call = cmd[0] == 'c'; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2256 int id_idx = is_call ? 3 : 2; |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2257 |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2258 if (argv[id_idx].v_type != VAR_UNKNOWN |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2259 && argv[id_idx].v_type != VAR_NUMBER) |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2260 { |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2261 ch_error(channel, "last argument for expr/call must be a number"); |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2262 if (p_verbose > 2) |
9953
9560a2eb7968
commit https://github.com/vim/vim/commit/5b30291785e6b9be1a607504c14bd03c601b59a6
Christian Brabandt <cb@256bit.org>
parents:
9723
diff
changeset
|
2263 EMSG(_("E904: last argument for expr/call must be a number")); |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2264 } |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2265 else if (is_call && argv[2].v_type != VAR_LIST) |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2266 { |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2267 ch_error(channel, "third argument for call must be a list"); |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2268 if (p_verbose > 2) |
9953
9560a2eb7968
commit https://github.com/vim/vim/commit/5b30291785e6b9be1a607504c14bd03c601b59a6
Christian Brabandt <cb@256bit.org>
parents:
9723
diff
changeset
|
2269 EMSG(_("E904: third argument for call must be a list")); |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2270 } |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2271 else |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2272 { |
10112
90b9898d05a6
commit https://github.com/vim/vim/commit/c8fe338d64cc6183c03d4c12b1e036a7745e2932
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
2273 typval_T *tv = NULL; |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2274 typval_T res_tv; |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2275 typval_T err_tv; |
7965
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2276 char_u *json = NULL; |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2277 |
7906
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7899
diff
changeset
|
2278 /* Don't pollute the display with errors. */ |
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7899
diff
changeset
|
2279 ++emsg_skip; |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2280 if (!is_call) |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2281 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2282 ch_log(channel, "Evaluating expression '%s'", (char *)arg); |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2283 tv = eval_expr(arg, NULL); |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2284 } |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2285 else |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2286 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2287 ch_log(channel, "Calling '%s'", (char *)arg); |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2288 if (func_call(arg, &argv[2], NULL, NULL, &res_tv) == OK) |
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2289 tv = &res_tv; |
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2290 } |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2291 |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2292 if (argv[id_idx].v_type == VAR_NUMBER) |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2293 { |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2294 int id = argv[id_idx].vval.v_number; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2295 |
7965
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2296 if (tv != NULL) |
9969
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
2297 json = json_encode_nr_expr(id, tv, options | JSON_NL); |
7965
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2298 if (tv == NULL || (json != NULL && *json == NUL)) |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2299 { |
7965
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2300 /* If evaluation failed or the result can't be encoded |
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2301 * then return the string "ERROR". */ |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2302 vim_free(json); |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2303 err_tv.v_type = VAR_STRING; |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2304 err_tv.vval.v_string = (char_u *)"ERROR"; |
10112
90b9898d05a6
commit https://github.com/vim/vim/commit/c8fe338d64cc6183c03d4c12b1e036a7745e2932
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
2305 json = json_encode_nr_expr(id, &err_tv, options | JSON_NL); |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2306 } |
7965
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2307 if (json != NULL) |
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2308 { |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2309 channel_send(channel, |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2310 part == PART_SOCK ? PART_SOCK : PART_IN, |
9434
8f904a323b3f
commit https://github.com/vim/vim/commit/bf2cc5f36d5ffd5de445e6970602000c7869b65a
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
2311 json, (int)STRLEN(json), (char *)cmd); |
7965
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2312 vim_free(json); |
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2313 } |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2314 } |
7965
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2315 --emsg_skip; |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2316 if (tv == &res_tv) |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2317 clear_tv(tv); |
10112
90b9898d05a6
commit https://github.com/vim/vim/commit/c8fe338d64cc6183c03d4c12b1e036a7745e2932
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
2318 else |
7906
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7899
diff
changeset
|
2319 free_tv(tv); |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2320 } |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2321 } |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2322 else if (p_verbose > 2) |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2323 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2324 ch_error(channel, "Received unknown command: %s", (char *)cmd); |
9953
9560a2eb7968
commit https://github.com/vim/vim/commit/5b30291785e6b9be1a607504c14bd03c601b59a6
Christian Brabandt <cb@256bit.org>
parents:
9723
diff
changeset
|
2325 EMSG2(_("E905: received unknown command: %s"), cmd); |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2326 } |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2327 } |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2328 |
8928
e6916e1683bb
commit https://github.com/vim/vim/commit/7f7c3325d3f1baba32263a3457cfc4d90ecd5ff1
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
2329 /* |
e6916e1683bb
commit https://github.com/vim/vim/commit/7f7c3325d3f1baba32263a3457cfc4d90ecd5ff1
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
2330 * Invoke the callback at "cbhead". |
e6916e1683bb
commit https://github.com/vim/vim/commit/7f7c3325d3f1baba32263a3457cfc4d90ecd5ff1
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
2331 * Does not redraw but sets channel_need_redraw. |
e6916e1683bb
commit https://github.com/vim/vim/commit/7f7c3325d3f1baba32263a3457cfc4d90ecd5ff1
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
2332 */ |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2333 static void |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2334 invoke_one_time_callback( |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2335 channel_T *channel, |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2336 cbq_T *cbhead, |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2337 cbq_T *item, |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2338 typval_T *argv) |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2339 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2340 ch_log(channel, "Invoking one-time callback %s", |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2341 (char *)item->cq_callback); |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2342 /* Remove the item from the list first, if the callback |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2343 * invokes ch_close() the list will be cleared. */ |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2344 remove_cb_node(cbhead, item); |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
2345 invoke_callback(channel, item->cq_callback, item->cq_partial, argv); |
9491
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2346 free_callback(item->cq_callback, item->cq_partial); |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2347 vim_free(item); |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2348 } |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2349 |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2350 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2351 append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, ch_part_T part) |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2352 { |
11959
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2353 bufref_T save_curbuf = {NULL, 0, 0}; |
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2354 win_T *save_curwin = NULL; |
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2355 tabpage_T *save_curtab = NULL; |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2356 linenr_T lnum = buffer->b_ml.ml_line_count; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2357 int save_write_to = buffer->b_write_to_channel; |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2358 chanpart_T *ch_part = &channel->ch_part[part]; |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2359 int save_p_ma = buffer->b_p_ma; |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11416
diff
changeset
|
2360 int empty = (buffer->b_ml.ml_flags & ML_EMPTY) ? 1 : 0; |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2361 |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2362 if (!buffer->b_p_ma && !ch_part->ch_nomodifiable) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2363 { |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2364 if (!ch_part->ch_nomod_error) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2365 { |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2366 ch_error(channel, "Buffer is not modifiable, cannot append"); |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2367 ch_part->ch_nomod_error = TRUE; |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2368 } |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2369 return; |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2370 } |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2371 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2372 /* If the buffer is also used as input insert above the last |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2373 * line. Don't write these lines. */ |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2374 if (save_write_to) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2375 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2376 --lnum; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2377 buffer->b_write_to_channel = FALSE; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2378 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2379 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2380 /* Append to the buffer */ |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2381 ch_log(channel, "appending line %d to buffer", (int)lnum + 1 - empty); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2382 |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2383 buffer->b_p_ma = TRUE; |
11959
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2384 |
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2385 /* Save curbuf/curwin/curtab and make "buffer" the current buffer. */ |
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2386 switch_to_win_for_buf(buffer, &save_curwin, &save_curtab, &save_curbuf); |
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2387 |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2388 u_sync(TRUE); |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2389 /* ignore undo failure, undo is not very useful here */ |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11416
diff
changeset
|
2390 ignored = u_save(lnum - empty, lnum + 1); |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
2391 |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
2392 if (empty) |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
2393 { |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
2394 /* The buffer is empty, replace the first (dummy) line. */ |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
2395 ml_replace(lnum, msg, TRUE); |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
2396 lnum = 0; |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
2397 } |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
2398 else |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
2399 ml_append(lnum, msg, 0, FALSE); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2400 appended_lines_mark(lnum, 1L); |
11959
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2401 |
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2402 /* Restore curbuf/curwin/curtab */ |
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2403 restore_win_for_buf(save_curwin, save_curtab, &save_curbuf); |
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2404 |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2405 if (ch_part->ch_nomodifiable) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2406 buffer->b_p_ma = FALSE; |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2407 else |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2408 buffer->b_p_ma = save_p_ma; |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2409 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2410 if (buffer->b_nwindows > 0) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2411 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2412 win_T *wp; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2413 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2414 FOR_ALL_WINDOWS(wp) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2415 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2416 if (wp->w_buffer == buffer |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2417 && (save_write_to |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2418 ? wp->w_cursor.lnum == lnum + 1 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2419 : (wp->w_cursor.lnum == lnum |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2420 && wp->w_cursor.col == 0))) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2421 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2422 ++wp->w_cursor.lnum; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2423 save_curwin = curwin; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2424 curwin = wp; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2425 curbuf = curwin->w_buffer; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2426 scroll_cursor_bot(0, FALSE); |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2427 curwin = save_curwin; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2428 curbuf = curwin->w_buffer; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2429 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2430 } |
11416
32aed0993813
patch 8.0.0592: if a job writes to a buffer screen is not updated
Christian Brabandt <cb@256bit.org>
parents:
11408
diff
changeset
|
2431 redraw_buf_and_status_later(buffer, VALID); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2432 channel_need_redraw = TRUE; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2433 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2434 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2435 if (save_write_to) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2436 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2437 channel_T *ch; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2438 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2439 /* Find channels reading from this buffer and adjust their |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2440 * next-to-read line number. */ |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2441 buffer->b_write_to_channel = TRUE; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2442 for (ch = first_channel; ch != NULL; ch = ch->ch_next) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2443 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2444 chanpart_T *in_part = &ch->ch_part[PART_IN]; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2445 |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
2446 if (in_part->ch_bufref.br_buf == buffer) |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2447 in_part->ch_buf_bot = buffer->b_ml.ml_line_count; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2448 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2449 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2450 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2451 |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2452 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2453 drop_messages(channel_T *channel, ch_part_T part) |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2454 { |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2455 char_u *msg; |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2456 |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2457 while ((msg = channel_get(channel, part)) != NULL) |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2458 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2459 ch_log(channel, "Dropping message '%s'", (char *)msg); |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2460 vim_free(msg); |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2461 } |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2462 } |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2463 |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2464 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2465 * Invoke a callback for "channel"/"part" if needed. |
8928
e6916e1683bb
commit https://github.com/vim/vim/commit/7f7c3325d3f1baba32263a3457cfc4d90ecd5ff1
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
2466 * This does not redraw but sets channel_need_redraw when redraw is needed. |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2467 * Return TRUE when a message was handled, there might be another one. |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2468 */ |
7885
6e6f829af138
commit https://github.com/vim/vim/commit/df5b27b20ec023274fb0f5347973d5abcde7ddd6
Christian Brabandt <cb@256bit.org>
parents:
7883
diff
changeset
|
2469 static int |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2470 may_invoke_callback(channel_T *channel, ch_part_T part) |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2471 { |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2472 char_u *msg = NULL; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2473 typval_T *listtv = NULL; |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2474 typval_T argv[CH_JSON_MAX_ARGS]; |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2475 int seq_nr = -1; |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2476 chanpart_T *ch_part = &channel->ch_part[part]; |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2477 ch_mode_T ch_mode = ch_part->ch_mode; |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2478 cbq_T *cbhead = &ch_part->ch_cb_head; |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
2479 cbq_T *cbitem; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2480 char_u *callback = NULL; |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
2481 partial_T *partial = NULL; |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2482 buf_T *buffer = NULL; |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2483 char_u *p; |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2484 |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
2485 if (channel->ch_nb_close_cb != NULL) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2486 /* this channel is handled elsewhere (netbeans) */ |
7885
6e6f829af138
commit https://github.com/vim/vim/commit/df5b27b20ec023274fb0f5347973d5abcde7ddd6
Christian Brabandt <cb@256bit.org>
parents:
7883
diff
changeset
|
2487 return FALSE; |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2488 |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
2489 /* Use a message-specific callback, part callback or channel callback */ |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
2490 for (cbitem = cbhead->cq_next; cbitem != NULL; cbitem = cbitem->cq_next) |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
2491 if (cbitem->cq_seq_nr == 0) |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
2492 break; |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2493 if (cbitem != NULL) |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
2494 { |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2495 callback = cbitem->cq_callback; |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
2496 partial = cbitem->cq_partial; |
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
2497 } |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2498 else if (ch_part->ch_callback != NULL) |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
2499 { |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2500 callback = ch_part->ch_callback; |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2501 partial = ch_part->ch_partial; |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
2502 } |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2503 else |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
2504 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2505 callback = channel->ch_callback; |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
2506 partial = channel->ch_partial; |
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
2507 } |
8291
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8267
diff
changeset
|
2508 |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2509 buffer = ch_part->ch_bufref.br_buf; |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11416
diff
changeset
|
2510 if (buffer != NULL && (!bufref_valid(&ch_part->ch_bufref) |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11416
diff
changeset
|
2511 || buffer->b_ml.ml_mfp == NULL)) |
8291
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8267
diff
changeset
|
2512 { |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11416
diff
changeset
|
2513 /* buffer was wiped out or unloaded */ |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2514 ch_log(channel, "%s buffer has been wiped out", part_names[part]); |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2515 ch_part->ch_bufref.br_buf = NULL; |
8291
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8267
diff
changeset
|
2516 buffer = NULL; |
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8267
diff
changeset
|
2517 } |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2518 |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2519 if (ch_mode == MODE_JSON || ch_mode == MODE_JS) |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2520 { |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2521 listitem_T *item; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2522 int argc = 0; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2523 |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2524 /* Get any json message in the queue. */ |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2525 if (channel_get_json(channel, part, -1, FALSE, &listtv) == FAIL) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2526 { |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2527 /* Parse readahead, return when there is still no message. */ |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2528 channel_parse_json(channel, part); |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2529 if (channel_get_json(channel, part, -1, FALSE, &listtv) == FAIL) |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2530 return FALSE; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2531 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2532 |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2533 for (item = listtv->vval.v_list->lv_first; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2534 item != NULL && argc < CH_JSON_MAX_ARGS; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2535 item = item->li_next) |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2536 argv[argc++] = item->li_tv; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2537 while (argc < CH_JSON_MAX_ARGS) |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2538 argv[argc++].v_type = VAR_UNKNOWN; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2539 |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2540 if (argv[0].v_type == VAR_STRING) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2541 { |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2542 /* ["cmd", arg] or ["cmd", arg, arg] or ["cmd", arg, arg, arg] */ |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2543 channel_exe_cmd(channel, part, argv); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2544 free_tv(listtv); |
7885
6e6f829af138
commit https://github.com/vim/vim/commit/df5b27b20ec023274fb0f5347973d5abcde7ddd6
Christian Brabandt <cb@256bit.org>
parents:
7883
diff
changeset
|
2545 return TRUE; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2546 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2547 |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2548 if (argv[0].v_type != VAR_NUMBER) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2549 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2550 ch_error(channel, |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
2551 "Dropping message with invalid sequence number type"); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2552 free_tv(listtv); |
7885
6e6f829af138
commit https://github.com/vim/vim/commit/df5b27b20ec023274fb0f5347973d5abcde7ddd6
Christian Brabandt <cb@256bit.org>
parents:
7883
diff
changeset
|
2553 return FALSE; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2554 } |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2555 seq_nr = argv[0].vval.v_number; |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2556 } |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2557 else if (channel_peek(channel, part) == NULL) |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2558 { |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2559 /* nothing to read on RAW or NL channel */ |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2560 return FALSE; |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2561 } |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2562 else |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2563 { |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2564 /* If there is no callback or buffer drop the message. */ |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2565 if (callback == NULL && buffer == NULL) |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2566 { |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2567 /* If there is a close callback it may use ch_read() to get the |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2568 * messages. */ |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2569 if (channel->ch_close_cb == NULL && !channel->ch_drop_never) |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2570 drop_messages(channel, part); |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2571 return FALSE; |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2572 } |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2573 |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2574 if (ch_mode == MODE_NL) |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2575 { |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2576 char_u *nl = NULL; |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2577 char_u *buf; |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2578 readq_T *node; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2579 |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2580 /* See if we have a message ending in NL in the first buffer. If |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2581 * not try to concatenate the first and the second buffer. */ |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2582 while (TRUE) |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2583 { |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2584 node = channel_peek(channel, part); |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2585 nl = channel_first_nl(node); |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2586 if (nl != NULL) |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2587 break; |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
2588 if (channel_collapse(channel, part, TRUE) == FAIL) |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2589 { |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2590 if (ch_part->ch_fd == INVALID_FD && node->rq_buflen > 0) |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2591 break; |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2592 return FALSE; /* incomplete message */ |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2593 } |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2594 } |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2595 buf = node->rq_buffer; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2596 |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2597 if (nl == NULL) |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2598 { |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2599 /* Flush remaining message that is missing a NL. */ |
11317
e45c6e4d78af
patch 8.0.0544: cppcheck warnings
Christian Brabandt <cb@256bit.org>
parents:
10996
diff
changeset
|
2600 char_u *new_buf; |
e45c6e4d78af
patch 8.0.0544: cppcheck warnings
Christian Brabandt <cb@256bit.org>
parents:
10996
diff
changeset
|
2601 |
e45c6e4d78af
patch 8.0.0544: cppcheck warnings
Christian Brabandt <cb@256bit.org>
parents:
10996
diff
changeset
|
2602 new_buf = vim_realloc(buf, node->rq_buflen + 1); |
e45c6e4d78af
patch 8.0.0544: cppcheck warnings
Christian Brabandt <cb@256bit.org>
parents:
10996
diff
changeset
|
2603 if (new_buf == NULL) |
e45c6e4d78af
patch 8.0.0544: cppcheck warnings
Christian Brabandt <cb@256bit.org>
parents:
10996
diff
changeset
|
2604 /* This might fail over and over again, should the message |
e45c6e4d78af
patch 8.0.0544: cppcheck warnings
Christian Brabandt <cb@256bit.org>
parents:
10996
diff
changeset
|
2605 * be dropped? */ |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2606 return FALSE; |
11317
e45c6e4d78af
patch 8.0.0544: cppcheck warnings
Christian Brabandt <cb@256bit.org>
parents:
10996
diff
changeset
|
2607 buf = new_buf; |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2608 node->rq_buffer = buf; |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2609 nl = buf + node->rq_buflen++; |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2610 *nl = NUL; |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2611 } |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2612 |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2613 /* Convert NUL to NL, the internal representation. */ |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2614 for (p = buf; p < nl && p < buf + node->rq_buflen; ++p) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2615 if (*p == NUL) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2616 *p = NL; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2617 |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2618 if (nl + 1 == buf + node->rq_buflen) |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2619 { |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2620 /* get the whole buffer, drop the NL */ |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2621 msg = channel_get(channel, part); |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2622 *nl = NUL; |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2623 } |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2624 else |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2625 { |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2626 /* Copy the message into allocated memory (excluding the NL) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2627 * and remove it from the buffer (including the NL). */ |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2628 msg = vim_strnsave(buf, (int)(nl - buf)); |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2629 channel_consume(channel, part, (int)(nl - buf) + 1); |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2630 } |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2631 } |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2632 else |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2633 { |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2634 /* For a raw channel we don't know where the message ends, just |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2635 * get everything we have. |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2636 * Convert NUL to NL, the internal representation. */ |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2637 msg = channel_get_all(channel, part); |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2638 } |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2639 |
8358
49d0e094cb93
commit https://github.com/vim/vim/commit/bf73b91c664488ca57e2b4a8eb9b1f36f6625bc7
Christian Brabandt <cb@256bit.org>
parents:
8356
diff
changeset
|
2640 if (msg == NULL) |
49d0e094cb93
commit https://github.com/vim/vim/commit/bf73b91c664488ca57e2b4a8eb9b1f36f6625bc7
Christian Brabandt <cb@256bit.org>
parents:
8356
diff
changeset
|
2641 return FALSE; /* out of memory (and avoids Coverity warning) */ |
49d0e094cb93
commit https://github.com/vim/vim/commit/bf73b91c664488ca57e2b4a8eb9b1f36f6625bc7
Christian Brabandt <cb@256bit.org>
parents:
8356
diff
changeset
|
2642 |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2643 argv[1].v_type = VAR_STRING; |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2644 argv[1].vval.v_string = msg; |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2645 } |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2646 |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2647 if (seq_nr > 0) |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2648 { |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2649 int done = FALSE; |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2650 |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2651 /* JSON or JS mode: invoke the one-time callback with the matching nr */ |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
2652 for (cbitem = cbhead->cq_next; cbitem != NULL; cbitem = cbitem->cq_next) |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2653 if (cbitem->cq_seq_nr == seq_nr) |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2654 { |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2655 invoke_one_time_callback(channel, cbhead, cbitem, argv); |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2656 done = TRUE; |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2657 break; |
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2658 } |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2659 if (!done) |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2660 { |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2661 if (channel->ch_drop_never) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2662 { |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2663 /* message must be read with ch_read() */ |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2664 channel_push_json(channel, part, listtv); |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2665 listtv = NULL; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2666 } |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2667 else |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2668 ch_log(channel, "Dropping message %d without callback", |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2669 seq_nr); |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2670 } |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2671 } |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2672 else if (callback != NULL || buffer != NULL) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2673 { |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2674 if (buffer != NULL) |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2675 { |
8346
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8334
diff
changeset
|
2676 if (msg == NULL) |
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8334
diff
changeset
|
2677 /* JSON or JS mode: re-encode the message. */ |
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8334
diff
changeset
|
2678 msg = json_encode(listtv, ch_mode); |
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8334
diff
changeset
|
2679 if (msg != NULL) |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
2680 { |
11672
3c6cc2f24645
patch 8.0.0719: build failure without +terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
2681 #ifdef FEAT_TERMINAL |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
2682 if (buffer->b_term != NULL) |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
2683 write_to_term(buffer, msg, channel); |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
2684 else |
11672
3c6cc2f24645
patch 8.0.0719: build failure without +terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
2685 #endif |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
2686 append_to_buffer(buffer, msg, channel, part); |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
2687 } |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2688 } |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2689 |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2690 if (callback != NULL) |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2691 { |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2692 if (cbitem != NULL) |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2693 invoke_one_time_callback(channel, cbhead, cbitem, argv); |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2694 else |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2695 { |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2696 /* invoke the channel callback */ |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2697 ch_log(channel, "Invoking channel callback %s", |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2698 (char *)callback); |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
2699 invoke_callback(channel, callback, partial, argv); |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2700 } |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2701 } |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2702 } |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2703 else |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2704 ch_log(channel, "Dropping message %d", seq_nr); |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2705 |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2706 if (listtv != NULL) |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2707 free_tv(listtv); |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2708 vim_free(msg); |
7885
6e6f829af138
commit https://github.com/vim/vim/commit/df5b27b20ec023274fb0f5347973d5abcde7ddd6
Christian Brabandt <cb@256bit.org>
parents:
7883
diff
changeset
|
2709 |
6e6f829af138
commit https://github.com/vim/vim/commit/df5b27b20ec023274fb0f5347973d5abcde7ddd6
Christian Brabandt <cb@256bit.org>
parents:
7883
diff
changeset
|
2710 return TRUE; |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2711 } |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2712 |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2713 /* |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2714 * Return TRUE when channel "channel" is open for writing to. |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2715 * Also returns FALSE or invalid "channel". |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2716 */ |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2717 int |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2718 channel_can_write_to(channel_T *channel) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2719 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2720 return channel != NULL && (channel->CH_SOCK_FD != INVALID_FD |
8493
caed4b2d305f
commit https://github.com/vim/vim/commit/509ce2a558e7e0c03242e32e844255af52f1c821
Christian Brabandt <cb@256bit.org>
parents:
8491
diff
changeset
|
2721 || channel->CH_IN_FD != INVALID_FD); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2722 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2723 |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2724 /* |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2725 * Return TRUE when channel "channel" is open for reading or writing. |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2726 * Also returns FALSE for invalid "channel". |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2727 */ |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2728 int |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2729 channel_is_open(channel_T *channel) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2730 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2731 return channel != NULL && (channel->CH_SOCK_FD != INVALID_FD |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2732 || channel->CH_IN_FD != INVALID_FD |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2733 || channel->CH_OUT_FD != INVALID_FD |
8493
caed4b2d305f
commit https://github.com/vim/vim/commit/509ce2a558e7e0c03242e32e844255af52f1c821
Christian Brabandt <cb@256bit.org>
parents:
8491
diff
changeset
|
2734 || channel->CH_ERR_FD != INVALID_FD); |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2735 } |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2736 |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2737 /* |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2738 * Return TRUE if "channel" has JSON or other typeahead. |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2739 */ |
10422
e664ee056a84
commit https://github.com/vim/vim/commit/4b785f69c0616dba5d3f38e8ce4b5398cec89407
Christian Brabandt <cb@256bit.org>
parents:
10418
diff
changeset
|
2740 int |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2741 channel_has_readahead(channel_T *channel, ch_part_T part) |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2742 { |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2743 ch_mode_T ch_mode = channel->ch_part[part].ch_mode; |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2744 |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2745 if (ch_mode == MODE_JSON || ch_mode == MODE_JS) |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2746 { |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2747 jsonq_T *head = &channel->ch_part[part].ch_json_head; |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2748 jsonq_T *item = head->jq_next; |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2749 |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2750 return item != NULL; |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2751 } |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2752 return channel_peek(channel, part) != NULL; |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2753 } |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2754 |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2755 /* |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2756 * Return a string indicating the status of the channel. |
10233
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2757 * If "req_part" is not negative check that part. |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2758 */ |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2759 char * |
10233
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2760 channel_status(channel_T *channel, int req_part) |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2761 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2762 ch_part_T part; |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2763 int has_readahead = FALSE; |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2764 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2765 if (channel == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2766 return "fail"; |
10233
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2767 if (req_part == PART_OUT) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2768 { |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2769 if (channel->CH_OUT_FD != INVALID_FD) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2770 return "open"; |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2771 if (channel_has_readahead(channel, PART_OUT)) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2772 has_readahead = TRUE; |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2773 } |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2774 else if (req_part == PART_ERR) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2775 { |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2776 if (channel->CH_ERR_FD != INVALID_FD) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2777 return "open"; |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2778 if (channel_has_readahead(channel, PART_ERR)) |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2779 has_readahead = TRUE; |
10233
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2780 } |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2781 else |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2782 { |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2783 if (channel_is_open(channel)) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2784 return "open"; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2785 for (part = PART_SOCK; part < PART_IN; ++part) |
10233
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2786 if (channel_has_readahead(channel, part)) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2787 { |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2788 has_readahead = TRUE; |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2789 break; |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2790 } |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2791 } |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2792 |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2793 if (has_readahead) |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2794 return "buffered"; |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2795 return "closed"; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2796 } |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2797 |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2798 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2799 channel_part_info(channel_T *channel, dict_T *dict, char *name, ch_part_T part) |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2800 { |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2801 chanpart_T *chanpart = &channel->ch_part[part]; |
8783
23b7f05a7f48
commit https://github.com/vim/vim/commit/925ccfde79bf734bc89269c705cebe2d49fe6444
Christian Brabandt <cb@256bit.org>
parents:
8761
diff
changeset
|
2802 char namebuf[20]; /* longest is "sock_timeout" */ |
8678
a4e7f4a62193
commit https://github.com/vim/vim/commit/3f3fbd3fdb73bdfbfeab22a9dfc7a25e38bdf5f6
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
2803 size_t tail; |
10233
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2804 char *status; |
8684
6e567914f55a
commit https://github.com/vim/vim/commit/573e445664eef399a72b1bfc975260a639605fef
Christian Brabandt <cb@256bit.org>
parents:
8678
diff
changeset
|
2805 char *s = ""; |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2806 |
8783
23b7f05a7f48
commit https://github.com/vim/vim/commit/925ccfde79bf734bc89269c705cebe2d49fe6444
Christian Brabandt <cb@256bit.org>
parents:
8761
diff
changeset
|
2807 vim_strncpy((char_u *)namebuf, (char_u *)name, 4); |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2808 STRCAT(namebuf, "_"); |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2809 tail = STRLEN(namebuf); |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2810 |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2811 STRCPY(namebuf + tail, "status"); |
10233
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2812 if (chanpart->ch_fd != INVALID_FD) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2813 status = "open"; |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2814 else if (channel_has_readahead(channel, part)) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2815 status = "buffered"; |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2816 else |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
2817 status = "closed"; |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
2818 dict_add_string(dict, namebuf, (char_u *)status); |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2819 |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2820 STRCPY(namebuf + tail, "mode"); |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2821 switch (chanpart->ch_mode) |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2822 { |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2823 case MODE_NL: s = "NL"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2824 case MODE_RAW: s = "RAW"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2825 case MODE_JSON: s = "JSON"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2826 case MODE_JS: s = "JS"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2827 } |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
2828 dict_add_string(dict, namebuf, (char_u *)s); |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2829 |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2830 STRCPY(namebuf + tail, "io"); |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2831 if (part == PART_SOCK) |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2832 s = "socket"; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2833 else switch (chanpart->ch_io) |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2834 { |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2835 case JIO_NULL: s = "null"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2836 case JIO_PIPE: s = "pipe"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2837 case JIO_FILE: s = "file"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2838 case JIO_BUFFER: s = "buffer"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2839 case JIO_OUT: s = "out"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2840 } |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
2841 dict_add_string(dict, namebuf, (char_u *)s); |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2842 |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2843 STRCPY(namebuf + tail, "timeout"); |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
2844 dict_add_number(dict, namebuf, chanpart->ch_timeout); |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2845 } |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2846 |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2847 void |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2848 channel_info(channel_T *channel, dict_T *dict) |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2849 { |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
2850 dict_add_number(dict, "id", channel->ch_id); |
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
2851 dict_add_string(dict, "status", (char_u *)channel_status(channel, -1)); |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2852 |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2853 if (channel->ch_hostname != NULL) |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2854 { |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
2855 dict_add_string(dict, "hostname", (char_u *)channel->ch_hostname); |
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
2856 dict_add_number(dict, "port", channel->ch_port); |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2857 channel_part_info(channel, dict, "sock", PART_SOCK); |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2858 } |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2859 else |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2860 { |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2861 channel_part_info(channel, dict, "out", PART_OUT); |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2862 channel_part_info(channel, dict, "err", PART_ERR); |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2863 channel_part_info(channel, dict, "in", PART_IN); |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2864 } |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2865 } |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
2866 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2867 /* |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2868 * Close channel "channel". |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
2869 * Trigger the close callback if "invoke_close_cb" is TRUE. |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2870 * Does not clear the buffers. |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2871 */ |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2872 void |
8240
60586ce747c4
commit https://github.com/vim/vim/commit/8b374215ccd35003b95ba1df8f12e03bf8a8adc3
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
2873 channel_close(channel_T *channel, int invoke_close_cb) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2874 { |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
2875 ch_log(channel, "Closing channel"); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2876 |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
2877 #ifdef FEAT_GUI |
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
2878 channel_gui_unregister(channel); |
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
2879 #endif |
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
2880 |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2881 ch_close_part(channel, PART_SOCK); |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2882 ch_close_part(channel, PART_IN); |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2883 ch_close_part(channel, PART_OUT); |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2884 ch_close_part(channel, PART_ERR); |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
2885 |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2886 if (invoke_close_cb) |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
2887 { |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2888 ch_part_T part; |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2889 |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2890 /* Invoke callbacks and flush buffers before the close callback. */ |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2891 if (channel->ch_close_cb != NULL) |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2892 ch_log(channel, |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2893 "Invoking callbacks and flushing buffers before closing"); |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2894 for (part = PART_SOCK; part < PART_IN; ++part) |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2895 { |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2896 if (channel->ch_close_cb != NULL |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2897 || channel->ch_part[part].ch_bufref.br_buf != NULL) |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2898 { |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2899 /* Increment the refcount to avoid the channel being freed |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2900 * halfway. */ |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2901 ++channel->ch_refcount; |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2902 if (channel->ch_close_cb == NULL) |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2903 ch_log(channel, "flushing %s buffers before closing", |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2904 part_names[part]); |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2905 while (may_invoke_callback(channel, part)) |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2906 ; |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2907 --channel->ch_refcount; |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2908 } |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2909 } |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2910 |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2911 if (channel->ch_close_cb != NULL) |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2912 { |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2913 typval_T argv[1]; |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2914 typval_T rettv; |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2915 int dummy; |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2916 |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2917 /* Increment the refcount to avoid the channel being freed |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2918 * halfway. */ |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2919 ++channel->ch_refcount; |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2920 ch_log(channel, "Invoking close callback %s", |
8310
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
2921 (char *)channel->ch_close_cb); |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
2922 argv[0].v_type = VAR_CHANNEL; |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
2923 argv[0].vval.v_channel = channel; |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
2924 call_func(channel->ch_close_cb, (int)STRLEN(channel->ch_close_cb), |
9626
172131507c85
commit https://github.com/vim/vim/commit/df48fb456fb6bf63d94cad9b302ff01d8ee8d311
Christian Brabandt <cb@256bit.org>
parents:
9529
diff
changeset
|
2925 &rettv, 1, argv, NULL, 0L, 0L, &dummy, TRUE, |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
2926 channel->ch_close_partial, NULL); |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
2927 clear_tv(&rettv); |
9064
a86103d4b356
commit https://github.com/vim/vim/commit/cefe4f994853c2d4866e2aa4ea3e3f36ab2fea13
Christian Brabandt <cb@256bit.org>
parents:
9058
diff
changeset
|
2928 channel_need_redraw = TRUE; |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2929 |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2930 /* the callback is only called once */ |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2931 free_callback(channel->ch_close_cb, channel->ch_close_partial); |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2932 channel->ch_close_cb = NULL; |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2933 channel->ch_close_partial = NULL; |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2934 |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2935 if (channel_need_redraw) |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2936 { |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2937 channel_need_redraw = FALSE; |
12244
d0b039e2ed56
patch 8.0.1002: unnecessarily updating screen after timer callback
Christian Brabandt <cb@256bit.org>
parents:
12240
diff
changeset
|
2938 redraw_after_callback(TRUE); |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2939 } |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2940 |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2941 if (!channel->ch_drop_never) |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2942 /* any remaining messages are useless now */ |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2943 for (part = PART_SOCK; part < PART_IN; ++part) |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2944 drop_messages(channel, part); |
12818
60e1e4cfb21e
patch 8.0.1286: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
12584
diff
changeset
|
2945 |
60e1e4cfb21e
patch 8.0.1286: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
12584
diff
changeset
|
2946 --channel->ch_refcount; |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
2947 } |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
2948 } |
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
2949 |
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
2950 channel->ch_nb_close_cb = NULL; |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2951 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2952 #ifdef FEAT_TERMINAL |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2953 term_channel_closed(channel); |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2954 #endif |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2955 } |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2956 |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2957 /* |
10054
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
2958 * Close the "in" part channel "channel". |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
2959 */ |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
2960 void |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
2961 channel_close_in(channel_T *channel) |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
2962 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2963 ch_close_part(channel, PART_IN); |
10054
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
2964 } |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
2965 |
12403
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
2966 static void |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
2967 remove_from_writeque(writeq_T *wq, writeq_T *entry) |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
2968 { |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
2969 ga_clear(&entry->wq_ga); |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
2970 wq->wq_next = entry->wq_next; |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
2971 if (wq->wq_next == NULL) |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
2972 wq->wq_prev = NULL; |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
2973 else |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
2974 wq->wq_next->wq_prev = NULL; |
12407
e9dbdc4d8279
patch 8.0.1083: leaking memory in input part of channel
Christian Brabandt <cb@256bit.org>
parents:
12403
diff
changeset
|
2975 vim_free(entry); |
12403
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
2976 } |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
2977 |
10054
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
2978 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2979 * Clear the read buffer on "channel"/"part". |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2980 */ |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2981 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2982 channel_clear_one(channel_T *channel, ch_part_T part) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2983 { |
12403
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
2984 chanpart_T *ch_part = &channel->ch_part[part]; |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
2985 jsonq_T *json_head = &ch_part->ch_json_head; |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
2986 cbq_T *cb_head = &ch_part->ch_cb_head; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2987 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2988 while (channel_peek(channel, part) != NULL) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2989 vim_free(channel_get(channel, part)); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2990 |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2991 while (cb_head->cq_next != NULL) |
8074
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8072
diff
changeset
|
2992 { |
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8072
diff
changeset
|
2993 cbq_T *node = cb_head->cq_next; |
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8072
diff
changeset
|
2994 |
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8072
diff
changeset
|
2995 remove_cb_node(cb_head, node); |
9491
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2996 free_callback(node->cq_callback, node->cq_partial); |
8074
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8072
diff
changeset
|
2997 vim_free(node); |
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8072
diff
changeset
|
2998 } |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2999 |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3000 while (json_head->jq_next != NULL) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3001 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3002 free_tv(json_head->jq_next->jq_value); |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3003 remove_json_node(json_head, json_head->jq_next); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3004 } |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
3005 |
12403
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3006 free_callback(ch_part->ch_callback, ch_part->ch_partial); |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3007 ch_part->ch_callback = NULL; |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3008 ch_part->ch_partial = NULL; |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3009 |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3010 while (ch_part->ch_writeque.wq_next != NULL) |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3011 remove_from_writeque(&ch_part->ch_writeque, |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3012 ch_part->ch_writeque.wq_next); |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3013 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3014 |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3015 /* |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3016 * Clear all the read buffers on "channel". |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3017 */ |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3018 void |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3019 channel_clear(channel_T *channel) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3020 { |
8310
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
3021 ch_log(channel, "Clearing channel"); |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
3022 VIM_CLEAR(channel->ch_hostname); |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3023 channel_clear_one(channel, PART_SOCK); |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3024 channel_clear_one(channel, PART_OUT); |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3025 channel_clear_one(channel, PART_ERR); |
12407
e9dbdc4d8279
patch 8.0.1083: leaking memory in input part of channel
Christian Brabandt <cb@256bit.org>
parents:
12403
diff
changeset
|
3026 channel_clear_one(channel, PART_IN); |
9491
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
3027 free_callback(channel->ch_callback, channel->ch_partial); |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
3028 channel->ch_callback = NULL; |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
3029 channel->ch_partial = NULL; |
9491
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
3030 free_callback(channel->ch_close_cb, channel->ch_close_partial); |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
3031 channel->ch_close_cb = NULL; |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
3032 channel->ch_close_partial = NULL; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3033 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3034 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3035 #if defined(EXITFREE) || defined(PROTO) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3036 void |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3037 channel_free_all(void) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3038 { |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3039 channel_T *channel; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3040 |
8310
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
3041 ch_log(NULL, "channel_free_all()"); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3042 for (channel = first_channel; channel != NULL; channel = channel->ch_next) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3043 channel_clear(channel); |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3044 } |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3045 #endif |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3046 |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3047 |
9050
31bba6f25d84
commit https://github.com/vim/vim/commit/715d285d79a1d97928dd717278e25e6de45d1496
Christian Brabandt <cb@256bit.org>
parents:
9044
diff
changeset
|
3048 /* Sent when the netbeans channel is found closed when reading. */ |
8204
08d251a1c178
commit https://github.com/vim/vim/commit/eed284a16977ab81fa6da8c9562990ba498acd8c
Christian Brabandt <cb@256bit.org>
parents:
8200
diff
changeset
|
3049 #define DETACH_MSG_RAW "DETACH\n" |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3050 |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3051 /* Buffer size for reading incoming messages. */ |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3052 #define MAXMSGSIZE 4096 |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3053 |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3054 #if defined(HAVE_SELECT) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3055 /* |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3056 * Add write fds where we are waiting for writing to be possible. |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3057 */ |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3058 static int |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3059 channel_fill_wfds(int maxfd_arg, fd_set *wfds) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3060 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3061 int maxfd = maxfd_arg; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3062 channel_T *ch; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3063 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3064 for (ch = first_channel; ch != NULL; ch = ch->ch_next) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3065 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3066 chanpart_T *in_part = &ch->ch_part[PART_IN]; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3067 |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3068 if (in_part->ch_fd != INVALID_FD |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3069 && (in_part->ch_bufref.br_buf != NULL |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3070 || in_part->ch_writeque.wq_next != NULL)) |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3071 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3072 FD_SET((int)in_part->ch_fd, wfds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3073 if ((int)in_part->ch_fd >= maxfd) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3074 maxfd = (int)in_part->ch_fd + 1; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3075 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3076 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3077 return maxfd; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3078 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3079 #else |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3080 /* |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3081 * Add write fds where we are waiting for writing to be possible. |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3082 */ |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3083 static int |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3084 channel_fill_poll_write(int nfd_in, struct pollfd *fds) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3085 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3086 int nfd = nfd_in; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3087 channel_T *ch; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3088 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3089 for (ch = first_channel; ch != NULL; ch = ch->ch_next) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3090 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3091 chanpart_T *in_part = &ch->ch_part[PART_IN]; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3092 |
12168
51e5a8602624
patch 8.0.0964: channel write buffer does not work with poll()
Christian Brabandt <cb@256bit.org>
parents:
12158
diff
changeset
|
3093 if (in_part->ch_fd != INVALID_FD |
51e5a8602624
patch 8.0.0964: channel write buffer does not work with poll()
Christian Brabandt <cb@256bit.org>
parents:
12158
diff
changeset
|
3094 && (in_part->ch_bufref.br_buf != NULL |
51e5a8602624
patch 8.0.0964: channel write buffer does not work with poll()
Christian Brabandt <cb@256bit.org>
parents:
12158
diff
changeset
|
3095 || in_part->ch_writeque.wq_next != NULL)) |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3096 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3097 in_part->ch_poll_idx = nfd; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3098 fds[nfd].fd = in_part->ch_fd; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3099 fds[nfd].events = POLLOUT; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3100 ++nfd; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3101 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3102 else |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3103 in_part->ch_poll_idx = -1; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3104 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3105 return nfd; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3106 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3107 #endif |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3108 |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3109 typedef enum { |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3110 CW_READY, |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3111 CW_NOT_READY, |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3112 CW_ERROR |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3113 } channel_wait_result; |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3114 |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3115 /* |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3116 * Check for reading from "fd" with "timeout" msec. |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3117 * Return CW_READY when there is something to read. |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3118 * Return CW_NOT_READY when there is nothing to read. |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3119 * Return CW_ERROR when there is an error. |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3120 */ |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3121 static channel_wait_result |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3122 channel_wait(channel_T *channel, sock_T fd, int timeout) |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3123 { |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3124 if (timeout > 0) |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
3125 ch_log(channel, "Waiting for up to %d msec", timeout); |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3126 |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3127 # ifdef WIN32 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3128 if (fd != channel->CH_SOCK_FD) |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3129 { |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3130 DWORD nread; |
8757
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3131 int sleep_time; |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3132 DWORD deadline = GetTickCount() + timeout; |
8757
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3133 int delay = 1; |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3134 |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3135 /* reading from a pipe, not a socket */ |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3136 while (TRUE) |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3137 { |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3138 int r = PeekNamedPipe((HANDLE)fd, NULL, 0, NULL, &nread, NULL); |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3139 |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3140 if (r && nread > 0) |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3141 return CW_READY; |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3142 if (r == 0) |
12389
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3143 { |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3144 DWORD err = GetLastError(); |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3145 |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3146 if (err != ERROR_BAD_PIPE && err != ERROR_BROKEN_PIPE) |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3147 return CW_ERROR; |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3148 |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3149 if (channel->ch_named_pipe) |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3150 { |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3151 DisconnectNamedPipe((HANDLE)fd); |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3152 ConnectNamedPipe((HANDLE)fd, NULL); |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3153 } |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3154 else |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3155 return CW_ERROR; |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3156 } |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3157 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3158 /* perhaps write some buffer lines */ |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3159 channel_write_any_lines(); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3160 |
8757
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3161 sleep_time = deadline - GetTickCount(); |
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3162 if (sleep_time <= 0) |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3163 break; |
8757
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3164 /* Wait for a little while. Very short at first, up to 10 msec |
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3165 * after looping a few times. */ |
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3166 if (sleep_time > delay) |
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3167 sleep_time = delay; |
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3168 Sleep(sleep_time); |
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3169 delay = delay * 2; |
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3170 if (delay > 10) |
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3171 delay = 10; |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3172 } |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3173 } |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3174 else |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3175 #endif |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3176 { |
8222
4f0677020a43
commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents:
8218
diff
changeset
|
3177 #if defined(HAVE_SELECT) |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3178 struct timeval tval; |
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3179 fd_set rfds; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3180 fd_set wfds; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3181 int ret; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3182 int maxfd; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3183 |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3184 tval.tv_sec = timeout / 1000; |
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3185 tval.tv_usec = (timeout % 1000) * 1000; |
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3186 for (;;) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3187 { |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3188 FD_ZERO(&rfds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3189 FD_SET((int)fd, &rfds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3190 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3191 /* Write lines to a pipe when a pipe can be written to. Need to |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3192 * set this every time, some buffers may be done. */ |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3193 maxfd = (int)fd + 1; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3194 FD_ZERO(&wfds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3195 maxfd = channel_fill_wfds(maxfd, &wfds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3196 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3197 ret = select(maxfd, &rfds, &wfds, NULL, &tval); |
8222
4f0677020a43
commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents:
8218
diff
changeset
|
3198 # ifdef EINTR |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3199 SOCK_ERRNO; |
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3200 if (ret == -1 && errno == EINTR) |
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3201 continue; |
8222
4f0677020a43
commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents:
8218
diff
changeset
|
3202 # endif |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3203 if (ret > 0) |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3204 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3205 if (FD_ISSET(fd, &rfds)) |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3206 return CW_READY; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3207 channel_write_any_lines(); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3208 continue; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3209 } |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3210 break; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3211 } |
8222
4f0677020a43
commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents:
8218
diff
changeset
|
3212 #else |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3213 for (;;) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3214 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3215 struct pollfd fds[MAX_OPEN_CHANNELS + 1]; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3216 int nfd = 1; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3217 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3218 fds[0].fd = fd; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3219 fds[0].events = POLLIN; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3220 nfd = channel_fill_poll_write(nfd, fds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3221 if (poll(fds, nfd, timeout) > 0) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3222 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3223 if (fds[0].revents & POLLIN) |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3224 return CW_READY; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3225 channel_write_any_lines(); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3226 continue; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3227 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3228 break; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3229 } |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3230 #endif |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3231 } |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3232 return CW_NOT_READY; |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3233 } |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3234 |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3235 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3236 ch_close_part_on_error( |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3237 channel_T *channel, ch_part_T part, int is_err, char *func) |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3238 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
3239 char msg[] = "%s(): Read %s from ch_part[%d], closing"; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3240 |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3241 if (is_err) |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3242 /* Do not call emsg(), most likely the other end just exited. */ |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
3243 ch_error(channel, msg, func, "error", part); |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3244 else |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
3245 ch_log(channel, msg, func, "EOF", part); |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3246 |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3247 /* Queue a "DETACH" netbeans message in the command queue in order to |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3248 * terminate the netbeans session later. Do not end the session here |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3249 * directly as we may be running in the context of a call to |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3250 * netbeans_parse_messages(): |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3251 * netbeans_parse_messages |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3252 * -> autocmd triggered while processing the netbeans cmd |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3253 * -> ui_breakcheck |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3254 * -> gui event loop or select loop |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3255 * -> channel_read() |
9050
31bba6f25d84
commit https://github.com/vim/vim/commit/715d285d79a1d97928dd717278e25e6de45d1496
Christian Brabandt <cb@256bit.org>
parents:
9044
diff
changeset
|
3256 * Only send "DETACH" for a netbeans channel. |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3257 */ |
9050
31bba6f25d84
commit https://github.com/vim/vim/commit/715d285d79a1d97928dd717278e25e6de45d1496
Christian Brabandt <cb@256bit.org>
parents:
9044
diff
changeset
|
3258 if (channel->ch_nb_close_cb != NULL) |
10253
a92c4abb8c1f
commit https://github.com/vim/vim/commit/8ddef48d1eade1911b946fdda8c73c80856e6273
Christian Brabandt <cb@256bit.org>
parents:
10249
diff
changeset
|
3259 channel_save(channel, PART_SOCK, (char_u *)DETACH_MSG_RAW, |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3260 (int)STRLEN(DETACH_MSG_RAW), FALSE, "PUT "); |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3261 |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3262 /* When reading is not possible close this part of the channel. Don't |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
3263 * close the channel yet, there may be something to read on another part. |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
3264 * When stdout and stderr use the same FD we get the error only on one of |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
3265 * them, also close the other. */ |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
3266 if (part == PART_OUT || part == PART_ERR) |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
3267 { |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
3268 ch_part_T other = part == PART_OUT ? PART_ERR : PART_OUT; |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
3269 |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
3270 if (channel->ch_part[part].ch_fd == channel->ch_part[other].ch_fd) |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
3271 ch_close_part(channel, other); |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
3272 } |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3273 ch_close_part(channel, part); |
9133
dec3b7b977c0
commit https://github.com/vim/vim/commit/bf981eeb6b4ee63ae8543a7f9865ab700159a79c
Christian Brabandt <cb@256bit.org>
parents:
9131
diff
changeset
|
3274 |
dec3b7b977c0
commit https://github.com/vim/vim/commit/bf981eeb6b4ee63ae8543a7f9865ab700159a79c
Christian Brabandt <cb@256bit.org>
parents:
9131
diff
changeset
|
3275 #ifdef FEAT_GUI |
dec3b7b977c0
commit https://github.com/vim/vim/commit/bf981eeb6b4ee63ae8543a7f9865ab700159a79c
Christian Brabandt <cb@256bit.org>
parents:
9131
diff
changeset
|
3276 /* Stop listening to GUI events right away. */ |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3277 channel_gui_unregister_one(channel, part); |
9133
dec3b7b977c0
commit https://github.com/vim/vim/commit/bf981eeb6b4ee63ae8543a7f9865ab700159a79c
Christian Brabandt <cb@256bit.org>
parents:
9131
diff
changeset
|
3278 #endif |
9083
69bb7b230094
commit https://github.com/vim/vim/commit/cf7ff70ca73218d618e7c00ab785bcf5f9120a94
Christian Brabandt <cb@256bit.org>
parents:
9081
diff
changeset
|
3279 } |
69bb7b230094
commit https://github.com/vim/vim/commit/cf7ff70ca73218d618e7c00ab785bcf5f9120a94
Christian Brabandt <cb@256bit.org>
parents:
9081
diff
changeset
|
3280 |
69bb7b230094
commit https://github.com/vim/vim/commit/cf7ff70ca73218d618e7c00ab785bcf5f9120a94
Christian Brabandt <cb@256bit.org>
parents:
9081
diff
changeset
|
3281 static void |
69bb7b230094
commit https://github.com/vim/vim/commit/cf7ff70ca73218d618e7c00ab785bcf5f9120a94
Christian Brabandt <cb@256bit.org>
parents:
9081
diff
changeset
|
3282 channel_close_now(channel_T *channel) |
69bb7b230094
commit https://github.com/vim/vim/commit/cf7ff70ca73218d618e7c00ab785bcf5f9120a94
Christian Brabandt <cb@256bit.org>
parents:
9081
diff
changeset
|
3283 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3284 ch_log(channel, "Closing channel because all readable fds are closed"); |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3285 if (channel->ch_nb_close_cb != NULL) |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3286 (*channel->ch_nb_close_cb)(); |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
3287 channel_close(channel, TRUE); |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3288 } |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3289 |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3290 /* |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3291 * Read from channel "channel" for as long as there is something to read. |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3292 * "part" is PART_SOCK, PART_OUT or PART_ERR. |
9143
b9c1a397a8a6
commit https://github.com/vim/vim/commit/655da31a18ef3f888acf10e68b438e2a851f7b14
Christian Brabandt <cb@256bit.org>
parents:
9139
diff
changeset
|
3293 * The data is put in the read queue. No callbacks are invoked here. |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3294 */ |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3295 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3296 channel_read(channel_T *channel, ch_part_T part, char *func) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3297 { |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3298 static char_u *buf = NULL; |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3299 int len = 0; |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3300 int readlen = 0; |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3301 sock_T fd; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3302 int use_socket = FALSE; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3303 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3304 fd = channel->ch_part[part].ch_fd; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3305 if (fd == INVALID_FD) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3306 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
3307 ch_error(channel, "channel_read() called while %s part is closed", |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3308 part_names[part]); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3309 return; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3310 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3311 use_socket = fd == channel->CH_SOCK_FD; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3312 |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3313 /* Allocate a buffer to read into. */ |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3314 if (buf == NULL) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3315 { |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3316 buf = alloc(MAXMSGSIZE); |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3317 if (buf == NULL) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3318 return; /* out of memory! */ |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3319 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3320 |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3321 /* Keep on reading for as long as there is something to read. |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3322 * Use select() or poll() to avoid blocking on a message that is exactly |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3323 * MAXMSGSIZE long. */ |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3324 for (;;) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3325 { |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3326 if (channel_wait(channel, fd, 0) != CW_READY) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3327 break; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3328 if (use_socket) |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
8074
diff
changeset
|
3329 len = sock_read(fd, (char *)buf, MAXMSGSIZE); |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3330 else |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
8074
diff
changeset
|
3331 len = fd_read(fd, (char *)buf, MAXMSGSIZE); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3332 if (len <= 0) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3333 break; /* error or nothing more to read */ |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3334 |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3335 /* Store the read message in the queue. */ |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
3336 channel_save(channel, part, buf, len, FALSE, "RECV "); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3337 readlen += len; |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3338 if (len < MAXMSGSIZE) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3339 break; /* did read everything that's available */ |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3340 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3341 |
8261
a412b466bedc
commit https://github.com/vim/vim/commit/4cafa6dc7f0728b018979aff0ca039908ecf2ae1
Christian Brabandt <cb@256bit.org>
parents:
8259
diff
changeset
|
3342 /* Reading a disconnection (readlen == 0), or an error. */ |
8200
ee84450e604e
commit https://github.com/vim/vim/commit/bd73ae1bc63a3b0187ffe7fc8f0caee5a4eb66fa
Christian Brabandt <cb@256bit.org>
parents:
8174
diff
changeset
|
3343 if (readlen <= 0) |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3344 { |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3345 if (!channel->ch_keep_open) |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3346 ch_close_part_on_error(channel, part, (len < 0), func); |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3347 } |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3348 #if defined(CH_HAS_GUI) && defined(FEAT_GUI_GTK) |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3349 else if (CH_HAS_GUI && gtk_main_level() > 0) |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3350 /* signal the main loop that there is something to read */ |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3351 gtk_main_quit(); |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3352 #endif |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3353 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3354 |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3355 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3356 * Read from RAW or NL "channel"/"part". Blocks until there is something to |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3357 * read or the timeout expires. |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3358 * When "raw" is TRUE don't block waiting on a NL. |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3359 * Returns what was read in allocated memory. |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3360 * Returns NULL in case of error or timeout. |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3361 */ |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3362 static char_u * |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3363 channel_read_block(channel_T *channel, ch_part_T part, int timeout, int raw) |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3364 { |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3365 char_u *buf; |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3366 char_u *msg; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3367 ch_mode_T mode = channel->ch_part[part].ch_mode; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3368 sock_T fd = channel->ch_part[part].ch_fd; |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3369 char_u *nl; |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3370 readq_T *node; |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3371 |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
3372 ch_log(channel, "Blocking %s read, timeout: %d msec", |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3373 mode == MODE_RAW ? "RAW" : "NL", timeout); |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3374 |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3375 while (TRUE) |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3376 { |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3377 node = channel_peek(channel, part); |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3378 if (node != NULL) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3379 { |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3380 if (mode == MODE_RAW || (mode == MODE_NL |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3381 && channel_first_nl(node) != NULL)) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3382 /* got a complete message */ |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3383 break; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3384 if (channel_collapse(channel, part, mode == MODE_NL) == OK) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3385 continue; |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3386 /* If not blocking or nothing more is coming then return what we |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3387 * have. */ |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3388 if (raw || fd == INVALID_FD) |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3389 break; |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3390 } |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3391 |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
3392 /* Wait for up to the channel timeout. */ |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3393 if (fd == INVALID_FD) |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3394 return NULL; |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3395 if (channel_wait(channel, fd, timeout) != CW_READY) |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3396 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3397 ch_log(channel, "Timed out"); |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3398 return NULL; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3399 } |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3400 channel_read(channel, part, "channel_read_block"); |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3401 } |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3402 |
10996
2f041b367cd9
patch 8.0.0387: compiler warnings
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
3403 /* We have a complete message now. */ |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3404 if (mode == MODE_RAW) |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3405 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3406 msg = channel_get_all(channel, part); |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3407 } |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3408 else |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3409 { |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3410 char_u *p; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3411 |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3412 buf = node->rq_buffer; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3413 nl = channel_first_nl(node); |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3414 |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3415 /* Convert NUL to NL, the internal representation. */ |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3416 for (p = buf; (nl == NULL || p < nl) && p < buf + node->rq_buflen; ++p) |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3417 if (*p == NUL) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3418 *p = NL; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3419 |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3420 if (nl == NULL) |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3421 { |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3422 /* must be a closed channel with missing NL */ |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3423 msg = channel_get(channel, part); |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3424 } |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3425 else if (nl + 1 == buf + node->rq_buflen) |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3426 { |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3427 /* get the whole buffer */ |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3428 msg = channel_get(channel, part); |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3429 *nl = NUL; |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3430 } |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3431 else |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3432 { |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3433 /* Copy the message into allocated memory and remove it from the |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3434 * buffer. */ |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3435 msg = vim_strnsave(buf, (int)(nl - buf)); |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3436 channel_consume(channel, part, (int)(nl - buf) + 1); |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3437 } |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3438 } |
12443
579faede5d9c
patch 8.0.1101: channel write fails if writing to log fails
Christian Brabandt <cb@256bit.org>
parents:
12407
diff
changeset
|
3439 if (ch_log_active()) |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
3440 ch_log(channel, "Returning %d bytes", (int)STRLEN(msg)); |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3441 return msg; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3442 } |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3443 |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3444 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3445 * Read one JSON message with ID "id" from "channel"/"part" and store the |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3446 * result in "rettv". |
8157
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
3447 * When "id" is -1 accept any message; |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
3448 * Blocks until the message is received or the timeout is reached. |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3449 */ |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
3450 static int |
8157
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
3451 channel_read_json_block( |
8310
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
3452 channel_T *channel, |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3453 ch_part_T part, |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3454 int timeout_arg, |
8310
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
3455 int id, |
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
3456 typval_T **rettv) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3457 { |
7997
c1c9ab17e197
commit https://github.com/vim/vim/commit/e56bf15c163a921ce9e1c09c0d5b3a03efc63324
Christian Brabandt <cb@256bit.org>
parents:
7988
diff
changeset
|
3458 int more; |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3459 sock_T fd; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3460 int timeout; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3461 chanpart_T *chanpart = &channel->ch_part[part]; |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
3462 |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
3463 ch_log(channel, "Reading JSON"); |
8157
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
3464 if (id != -1) |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3465 chanpart->ch_block_id = id; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3466 for (;;) |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3467 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3468 more = channel_parse_json(channel, part); |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3469 |
9355
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
3470 /* search for message "id" */ |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
3471 if (channel_get_json(channel, part, id, TRUE, rettv) == OK) |
7997
c1c9ab17e197
commit https://github.com/vim/vim/commit/e56bf15c163a921ce9e1c09c0d5b3a03efc63324
Christian Brabandt <cb@256bit.org>
parents:
7988
diff
changeset
|
3472 { |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3473 chanpart->ch_block_id = 0; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3474 return OK; |
7997
c1c9ab17e197
commit https://github.com/vim/vim/commit/e56bf15c163a921ce9e1c09c0d5b3a03efc63324
Christian Brabandt <cb@256bit.org>
parents:
7988
diff
changeset
|
3475 } |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3476 |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
3477 if (!more) |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
3478 { |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
3479 /* Handle any other messages in the queue. If done some more |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
3480 * messages may have arrived. */ |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
3481 if (channel_parse_messages()) |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
3482 continue; |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
3483 |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3484 /* Wait for up to the timeout. If there was an incomplete message |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3485 * use the deadline for that. */ |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3486 timeout = timeout_arg; |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
3487 if (chanpart->ch_wait_len > 0) |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3488 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3489 #ifdef WIN32 |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3490 timeout = chanpart->ch_deadline - GetTickCount() + 1; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3491 #else |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3492 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3493 struct timeval now_tv; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3494 |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3495 gettimeofday(&now_tv, NULL); |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3496 timeout = (chanpart->ch_deadline.tv_sec |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3497 - now_tv.tv_sec) * 1000 |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3498 + (chanpart->ch_deadline.tv_usec |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3499 - now_tv.tv_usec) / 1000 |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3500 + 1; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3501 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3502 #endif |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3503 if (timeout < 0) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3504 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3505 /* Something went wrong, channel_parse_json() didn't |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3506 * discard message. Cancel waiting. */ |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
3507 chanpart->ch_wait_len = 0; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3508 timeout = timeout_arg; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3509 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3510 else if (timeout > timeout_arg) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3511 timeout = timeout_arg; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3512 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3513 fd = chanpart->ch_fd; |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3514 if (fd == INVALID_FD |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3515 || channel_wait(channel, fd, timeout) != CW_READY) |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3516 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3517 if (timeout == timeout_arg) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3518 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3519 if (fd != INVALID_FD) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3520 ch_log(channel, "Timed out"); |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3521 break; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3522 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3523 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3524 else |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3525 channel_read(channel, part, "channel_read_json_block"); |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
3526 } |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3527 } |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3528 chanpart->ch_block_id = 0; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3529 return FAIL; |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3530 } |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3531 |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3532 /* |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3533 * Common for ch_read() and ch_readraw(). |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3534 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3535 void |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3536 common_channel_read(typval_T *argvars, typval_T *rettv, int raw) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3537 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3538 channel_T *channel; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3539 ch_part_T part = PART_COUNT; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3540 jobopt_T opt; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3541 int mode; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3542 int timeout; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3543 int id = -1; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3544 typval_T *listtv = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3545 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3546 /* return an empty string by default */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3547 rettv->v_type = VAR_STRING; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3548 rettv->vval.v_string = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3549 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3550 clear_job_options(&opt); |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
3551 if (get_job_options(&argvars[1], &opt, JO_TIMEOUT + JO_PART + JO_ID, 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3552 == FAIL) |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
3553 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3554 |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3555 if (opt.jo_set & JO_PART) |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3556 part = opt.jo_part; |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3557 channel = get_channel_arg(&argvars[0], TRUE, TRUE, part); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3558 if (channel != NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3559 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3560 if (part == PART_COUNT) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3561 part = channel_part_read(channel); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3562 mode = channel_get_mode(channel, part); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3563 timeout = channel_get_timeout(channel, part); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3564 if (opt.jo_set & JO_TIMEOUT) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3565 timeout = opt.jo_timeout; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3566 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3567 if (raw || mode == MODE_RAW || mode == MODE_NL) |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3568 rettv->vval.v_string = channel_read_block(channel, part, |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3569 timeout, raw); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3570 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3571 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3572 if (opt.jo_set & JO_ID) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3573 id = opt.jo_id; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3574 channel_read_json_block(channel, part, timeout, id, &listtv); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3575 if (listtv != NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3576 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3577 *rettv = *listtv; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3578 vim_free(listtv); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3579 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3580 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3581 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3582 rettv->v_type = VAR_SPECIAL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3583 rettv->vval.v_number = VVAL_NONE; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3584 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3585 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3586 } |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
3587 |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
3588 theend: |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
3589 free_job_options(&opt); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3590 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3591 |
8155
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
3592 # if defined(WIN32) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) \ |
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
3593 || defined(PROTO) |
7780
e09af43f98f7
commit https://github.com/vim/vim/commit/85be35f33ea848b50e84d57321a45ebfedfad669
Christian Brabandt <cb@256bit.org>
parents:
7774
diff
changeset
|
3594 /* |
8155
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
3595 * Lookup the channel from the socket. Set "partp" to the fd index. |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3596 * Returns NULL when the socket isn't found. |
7780
e09af43f98f7
commit https://github.com/vim/vim/commit/85be35f33ea848b50e84d57321a45ebfedfad669
Christian Brabandt <cb@256bit.org>
parents:
7774
diff
changeset
|
3597 */ |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3598 channel_T * |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3599 channel_fd2channel(sock_T fd, ch_part_T *partp) |
7780
e09af43f98f7
commit https://github.com/vim/vim/commit/85be35f33ea848b50e84d57321a45ebfedfad669
Christian Brabandt <cb@256bit.org>
parents:
7774
diff
changeset
|
3600 { |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
3601 channel_T *channel; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3602 ch_part_T part; |
7780
e09af43f98f7
commit https://github.com/vim/vim/commit/85be35f33ea848b50e84d57321a45ebfedfad669
Christian Brabandt <cb@256bit.org>
parents:
7774
diff
changeset
|
3603 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3604 if (fd != INVALID_FD) |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3605 for (channel = first_channel; channel != NULL; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3606 channel = channel->ch_next) |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
3607 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3608 for (part = PART_SOCK; part < PART_IN; ++part) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3609 if (channel->ch_part[part].ch_fd == fd) |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
3610 { |
8155
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
3611 *partp = part; |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
3612 return channel; |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
3613 } |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
3614 } |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3615 return NULL; |
7780
e09af43f98f7
commit https://github.com/vim/vim/commit/85be35f33ea848b50e84d57321a45ebfedfad669
Christian Brabandt <cb@256bit.org>
parents:
7774
diff
changeset
|
3616 } |
8172
db5c79d93eee
commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
3617 # endif |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3618 |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3619 # if defined(WIN32) || defined(FEAT_GUI) || defined(PROTO) |
8172
db5c79d93eee
commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
3620 /* |
db5c79d93eee
commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
3621 * Check the channels for anything that is ready to be read. |
db5c79d93eee
commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
3622 * The data is put in the read queue. |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3623 * if "only_keep_open" is TRUE only check channels where ch_keep_open is set. |
8172
db5c79d93eee
commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
3624 */ |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3625 void |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3626 channel_handle_events(int only_keep_open) |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3627 { |
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3628 channel_T *channel; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3629 ch_part_T part; |
8172
db5c79d93eee
commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
3630 sock_T fd; |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3631 |
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3632 for (channel = first_channel; channel != NULL; channel = channel->ch_next) |
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3633 { |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3634 if (only_keep_open && !channel->ch_keep_open) |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3635 continue; |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3636 |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3637 /* check the socket and pipes */ |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3638 for (part = PART_SOCK; part < PART_IN; ++part) |
8172
db5c79d93eee
commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
3639 { |
db5c79d93eee
commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
3640 fd = channel->ch_part[part].ch_fd; |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3641 if (fd != INVALID_FD) |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3642 { |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3643 int r = channel_wait(channel, fd, 0); |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3644 |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3645 if (r == CW_READY) |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3646 channel_read(channel, part, "channel_handle_events"); |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3647 else if (r == CW_ERROR) |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3648 ch_close_part_on_error(channel, part, TRUE, |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3649 "channel_handle_events"); |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3650 } |
8172
db5c79d93eee
commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
3651 } |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3652 } |
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3653 } |
7780
e09af43f98f7
commit https://github.com/vim/vim/commit/85be35f33ea848b50e84d57321a45ebfedfad669
Christian Brabandt <cb@256bit.org>
parents:
7774
diff
changeset
|
3654 # endif |
e09af43f98f7
commit https://github.com/vim/vim/commit/85be35f33ea848b50e84d57321a45ebfedfad669
Christian Brabandt <cb@256bit.org>
parents:
7774
diff
changeset
|
3655 |
12250
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3656 # if defined(FEAT_GUI) || defined(PROTO) |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3657 /* |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3658 * Return TRUE when there is any channel with a keep_open flag. |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3659 */ |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3660 int |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3661 channel_any_keep_open() |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3662 { |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3663 channel_T *channel; |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3664 |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3665 for (channel = first_channel; channel != NULL; channel = channel->ch_next) |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3666 if (channel->ch_keep_open) |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3667 return TRUE; |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3668 return FALSE; |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3669 } |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3670 # endif |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3671 |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3672 /* |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3673 * Set "channel"/"part" to non-blocking. |
12158
b3e39486880a
patch 8.0.0959: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12154
diff
changeset
|
3674 * Only works for sockets and pipes. |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3675 */ |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3676 void |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3677 channel_set_nonblock(channel_T *channel, ch_part_T part) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3678 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3679 chanpart_T *ch_part = &channel->ch_part[part]; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3680 int fd = ch_part->ch_fd; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3681 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3682 if (fd != INVALID_FD) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3683 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3684 #ifdef _WIN32 |
12158
b3e39486880a
patch 8.0.0959: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12154
diff
changeset
|
3685 u_long val = 1; |
b3e39486880a
patch 8.0.0959: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12154
diff
changeset
|
3686 |
b3e39486880a
patch 8.0.0959: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12154
diff
changeset
|
3687 ioctlsocket(fd, FIONBIO, &val); |
b3e39486880a
patch 8.0.0959: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12154
diff
changeset
|
3688 #else |
12178
a1014f647b61
patch 8.0.0969: Coverity warning for unused return value
Christian Brabandt <cb@256bit.org>
parents:
12168
diff
changeset
|
3689 (void)fcntl(fd, F_SETFL, O_NONBLOCK); |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3690 #endif |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3691 ch_part->ch_nonblocking = TRUE; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3692 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3693 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3694 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3695 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3696 * Write "buf" (NUL terminated string) to "channel"/"part". |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3697 * When "fun" is not NULL an error message might be given. |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3698 * Return FAIL or OK. |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3699 */ |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3700 int |
10363
471b87c3b67d
commit https://github.com/vim/vim/commit/79cbdcb1eeead00bad6fc64ab4a53e5860d5a663
Christian Brabandt <cb@256bit.org>
parents:
10309
diff
changeset
|
3701 channel_send( |
471b87c3b67d
commit https://github.com/vim/vim/commit/79cbdcb1eeead00bad6fc64ab4a53e5860d5a663
Christian Brabandt <cb@256bit.org>
parents:
10309
diff
changeset
|
3702 channel_T *channel, |
471b87c3b67d
commit https://github.com/vim/vim/commit/79cbdcb1eeead00bad6fc64ab4a53e5860d5a663
Christian Brabandt <cb@256bit.org>
parents:
10309
diff
changeset
|
3703 ch_part_T part, |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3704 char_u *buf_arg, |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3705 int len_arg, |
10363
471b87c3b67d
commit https://github.com/vim/vim/commit/79cbdcb1eeead00bad6fc64ab4a53e5860d5a663
Christian Brabandt <cb@256bit.org>
parents:
10309
diff
changeset
|
3706 char *fun) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3707 { |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3708 int res; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3709 sock_T fd; |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3710 chanpart_T *ch_part = &channel->ch_part[part]; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3711 int did_use_queue = FALSE; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3712 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3713 fd = ch_part->ch_fd; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3714 if (fd == INVALID_FD) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3715 { |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3716 if (!channel->ch_error && fun != NULL) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3717 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
3718 ch_error(channel, "%s(): write while not connected", fun); |
9953
9560a2eb7968
commit https://github.com/vim/vim/commit/5b30291785e6b9be1a607504c14bd03c601b59a6
Christian Brabandt <cb@256bit.org>
parents:
9723
diff
changeset
|
3719 EMSG2(_("E630: %s(): write while not connected"), fun); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3720 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3721 channel->ch_error = TRUE; |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3722 return FAIL; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3723 } |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3724 |
12443
579faede5d9c
patch 8.0.1101: channel write fails if writing to log fails
Christian Brabandt <cb@256bit.org>
parents:
12407
diff
changeset
|
3725 if (ch_log_active()) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3726 { |
14499
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
3727 ch_log_lead("SEND ", channel, part); |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3728 fprintf(log_fd, "'"); |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3729 ignored = (int)fwrite(buf_arg, len_arg, 1, log_fd); |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3730 fprintf(log_fd, "'\n"); |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3731 fflush(log_fd); |
8428
4e22d0e7bfb1
commit https://github.com/vim/vim/commit/d0b6502a7ace39d6cd30874110a572371d10beae
Christian Brabandt <cb@256bit.org>
parents:
8422
diff
changeset
|
3732 did_log_msg = TRUE; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3733 } |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3734 |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3735 for (;;) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3736 { |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3737 writeq_T *wq = &ch_part->ch_writeque; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3738 char_u *buf; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3739 int len; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3740 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3741 if (wq->wq_next != NULL) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3742 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3743 /* first write what was queued */ |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3744 buf = wq->wq_next->wq_ga.ga_data; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3745 len = wq->wq_next->wq_ga.ga_len; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3746 did_use_queue = TRUE; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3747 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3748 else |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3749 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3750 if (len_arg == 0) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3751 /* nothing to write, called from channel_select_check() */ |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3752 return OK; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3753 buf = buf_arg; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3754 len = len_arg; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3755 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3756 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3757 if (part == PART_SOCK) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3758 res = sock_write(fd, (char *)buf, len); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3759 else |
12389
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3760 { |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3761 res = fd_write(fd, (char *)buf, len); |
12389
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3762 #ifdef WIN32 |
12393
128cd982c7b8
patch 8.0.1076: term_start() does not take callbacks
Christian Brabandt <cb@256bit.org>
parents:
12389
diff
changeset
|
3763 if (channel->ch_named_pipe && res < 0) |
12389
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3764 { |
12393
128cd982c7b8
patch 8.0.1076: term_start() does not take callbacks
Christian Brabandt <cb@256bit.org>
parents:
12389
diff
changeset
|
3765 DisconnectNamedPipe((HANDLE)fd); |
128cd982c7b8
patch 8.0.1076: term_start() does not take callbacks
Christian Brabandt <cb@256bit.org>
parents:
12389
diff
changeset
|
3766 ConnectNamedPipe((HANDLE)fd, NULL); |
12389
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3767 } |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3768 #endif |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3769 |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
3770 } |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3771 if (res < 0 && (errno == EWOULDBLOCK |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3772 #ifdef EAGAIN |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3773 || errno == EAGAIN |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3774 #endif |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3775 )) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3776 res = 0; /* nothing got written */ |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3777 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3778 if (res >= 0 && ch_part->ch_nonblocking) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3779 { |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3780 writeq_T *entry = wq->wq_next; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3781 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3782 if (did_use_queue) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3783 ch_log(channel, "Sent %d bytes now", res); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3784 if (res == len) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3785 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3786 /* Wrote all the buf[len] bytes. */ |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3787 if (entry != NULL) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3788 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3789 /* Remove the entry from the write queue. */ |
12403
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3790 remove_from_writeque(wq, entry); |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3791 continue; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3792 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3793 if (did_use_queue) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3794 ch_log(channel, "Write queue empty"); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3795 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3796 else |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3797 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3798 /* Wrote only buf[res] bytes, can't write more now. */ |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3799 if (entry != NULL) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3800 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3801 if (res > 0) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3802 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3803 /* Remove the bytes that were written. */ |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3804 mch_memmove(entry->wq_ga.ga_data, |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3805 (char *)entry->wq_ga.ga_data + res, |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3806 len - res); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3807 entry->wq_ga.ga_len -= res; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3808 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3809 buf = buf_arg; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3810 len = len_arg; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3811 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3812 else |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3813 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3814 buf += res; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3815 len -= res; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3816 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3817 ch_log(channel, "Adding %d bytes to the write queue", len); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3818 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3819 /* Append the not written bytes of the argument to the write |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3820 * buffer. Limit entries to 4000 bytes. */ |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3821 if (wq->wq_prev != NULL |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3822 && wq->wq_prev->wq_ga.ga_len + len < 4000) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3823 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3824 writeq_T *last = wq->wq_prev; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3825 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3826 /* append to the last entry */ |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3827 if (ga_grow(&last->wq_ga, len) == OK) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3828 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3829 mch_memmove((char *)last->wq_ga.ga_data |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3830 + last->wq_ga.ga_len, |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3831 buf, len); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3832 last->wq_ga.ga_len += len; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3833 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3834 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3835 else |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3836 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3837 writeq_T *last = (writeq_T *)alloc((int)sizeof(writeq_T)); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3838 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3839 if (last != NULL) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3840 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3841 last->wq_prev = wq->wq_prev; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3842 last->wq_next = NULL; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3843 if (wq->wq_prev == NULL) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3844 wq->wq_next = last; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3845 else |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3846 wq->wq_prev->wq_next = last; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3847 wq->wq_prev = last; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3848 ga_init2(&last->wq_ga, 1, 1000); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3849 if (ga_grow(&last->wq_ga, len) == OK) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3850 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3851 mch_memmove(last->wq_ga.ga_data, buf, len); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3852 last->wq_ga.ga_len = len; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3853 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3854 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3855 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3856 } |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3857 } |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3858 else if (res != len) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3859 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3860 if (!channel->ch_error && fun != NULL) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3861 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3862 ch_error(channel, "%s(): write failed", fun); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3863 EMSG2(_("E631: %s(): write failed"), fun); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3864 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3865 channel->ch_error = TRUE; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3866 return FAIL; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3867 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3868 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3869 channel->ch_error = FALSE; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3870 return OK; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3871 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3872 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3873 |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3874 /* |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3875 * Common for "ch_sendexpr()" and "ch_sendraw()". |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3876 * Returns the channel if the caller should read the response. |
9355
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
3877 * Sets "part_read" to the read fd. |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3878 * Otherwise returns NULL. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3879 */ |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3880 static channel_T * |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3881 send_common( |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3882 typval_T *argvars, |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3883 char_u *text, |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3884 int id, |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3885 int eval, |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3886 jobopt_T *opt, |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3887 char *fun, |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3888 ch_part_T *part_read) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3889 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3890 channel_T *channel; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3891 ch_part_T part_send; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3892 |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
3893 clear_job_options(opt); |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3894 channel = get_channel_arg(&argvars[0], TRUE, FALSE, 0); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3895 if (channel == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3896 return NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3897 part_send = channel_part_send(channel); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3898 *part_read = channel_part_read(channel); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3899 |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
3900 if (get_job_options(&argvars[2], opt, JO_CALLBACK + JO_TIMEOUT, 0) == FAIL) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3901 return NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3902 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3903 /* Set the callback. An empty callback means no callback and not reading |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3904 * the response. With "ch_evalexpr()" and "ch_evalraw()" a callback is not |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3905 * allowed. */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3906 if (opt->jo_callback != NULL && *opt->jo_callback != NUL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3907 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3908 if (eval) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3909 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3910 EMSG2(_("E917: Cannot use a callback with %s()"), fun); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3911 return NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3912 } |
10030
3b4b2ac811f0
commit https://github.com/vim/vim/commit/6fc8227ebfbdfbbb48b81b679db81f421dbce79b
Christian Brabandt <cb@256bit.org>
parents:
9969
diff
changeset
|
3913 channel_set_req_callback(channel, *part_read, |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
3914 opt->jo_callback, opt->jo_partial, id); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3915 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3916 |
9434
8f904a323b3f
commit https://github.com/vim/vim/commit/bf2cc5f36d5ffd5de445e6970602000c7869b65a
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
3917 if (channel_send(channel, part_send, text, (int)STRLEN(text), fun) == OK |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3918 && opt->jo_callback == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3919 return channel; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3920 return NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3921 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3922 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3923 /* |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3924 * common for "ch_evalexpr()" and "ch_sendexpr()" |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3925 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3926 void |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3927 ch_expr_common(typval_T *argvars, typval_T *rettv, int eval) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3928 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3929 char_u *text; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3930 typval_T *listtv; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3931 channel_T *channel; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3932 int id; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3933 ch_mode_T ch_mode; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3934 ch_part_T part_send; |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3935 ch_part_T part_read; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3936 jobopt_T opt; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3937 int timeout; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3938 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3939 /* return an empty string by default */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3940 rettv->v_type = VAR_STRING; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3941 rettv->vval.v_string = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3942 |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3943 channel = get_channel_arg(&argvars[0], TRUE, FALSE, 0); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3944 if (channel == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3945 return; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3946 part_send = channel_part_send(channel); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3947 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3948 ch_mode = channel_get_mode(channel, part_send); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3949 if (ch_mode == MODE_RAW || ch_mode == MODE_NL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3950 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3951 EMSG(_("E912: cannot use ch_evalexpr()/ch_sendexpr() with a raw or nl channel")); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3952 return; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3953 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3954 |
8667
8c80c21a1885
commit https://github.com/vim/vim/commit/e9d6a298df6108e2044b1f0da5a2712f0c51c7d9
Christian Brabandt <cb@256bit.org>
parents:
8657
diff
changeset
|
3955 id = ++channel->ch_last_msg_id; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3956 text = json_encode_nr_expr(id, &argvars[1], |
9969
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
3957 (ch_mode == MODE_JS ? JSON_JS : 0) | JSON_NL); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3958 if (text == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3959 return; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3960 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3961 channel = send_common(argvars, text, id, eval, &opt, |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3962 eval ? "ch_evalexpr" : "ch_sendexpr", &part_read); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3963 vim_free(text); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3964 if (channel != NULL && eval) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3965 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3966 if (opt.jo_set & JO_TIMEOUT) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3967 timeout = opt.jo_timeout; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3968 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3969 timeout = channel_get_timeout(channel, part_read); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3970 if (channel_read_json_block(channel, part_read, timeout, id, &listtv) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3971 == OK) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3972 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3973 list_T *list = listtv->vval.v_list; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3974 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3975 /* Move the item from the list and then change the type to |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3976 * avoid the value being freed. */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3977 *rettv = list->lv_last->li_tv; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3978 list->lv_last->li_tv.v_type = VAR_NUMBER; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3979 free_tv(listtv); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3980 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3981 } |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
3982 free_job_options(&opt); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3983 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3984 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3985 /* |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3986 * common for "ch_evalraw()" and "ch_sendraw()" |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3987 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3988 void |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3989 ch_raw_common(typval_T *argvars, typval_T *rettv, int eval) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3990 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3991 char_u buf[NUMBUFLEN]; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3992 char_u *text; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3993 channel_T *channel; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3994 ch_part_T part_read; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3995 jobopt_T opt; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3996 int timeout; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3997 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3998 /* return an empty string by default */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3999 rettv->v_type = VAR_STRING; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4000 rettv->vval.v_string = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4001 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4002 text = get_tv_string_buf(&argvars[1], buf); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4003 channel = send_common(argvars, text, 0, eval, &opt, |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4004 eval ? "ch_evalraw" : "ch_sendraw", &part_read); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4005 if (channel != NULL && eval) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4006 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4007 if (opt.jo_set & JO_TIMEOUT) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4008 timeout = opt.jo_timeout; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4009 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4010 timeout = channel_get_timeout(channel, part_read); |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
4011 rettv->vval.v_string = channel_read_block(channel, part_read, |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
4012 timeout, TRUE); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4013 } |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4014 free_job_options(&opt); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4015 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4016 |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4017 # define KEEP_OPEN_TIME 20 /* msec */ |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4018 |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
4019 # if (defined(UNIX) && !defined(HAVE_SELECT)) || defined(PROTO) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4020 /* |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4021 * Add open channels to the poll struct. |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4022 * Return the adjusted struct index. |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4023 * The type of "fds" is hidden to avoid problems with the function proto. |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4024 */ |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4025 int |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4026 channel_poll_setup(int nfd_in, void *fds_in, int *towait) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4027 { |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4028 int nfd = nfd_in; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4029 channel_T *channel; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4030 struct pollfd *fds = fds_in; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4031 ch_part_T part; |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4032 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
4033 for (channel = first_channel; channel != NULL; channel = channel->ch_next) |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4034 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4035 for (part = PART_SOCK; part < PART_IN; ++part) |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4036 { |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4037 chanpart_T *ch_part = &channel->ch_part[part]; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4038 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4039 if (ch_part->ch_fd != INVALID_FD) |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4040 { |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4041 if (channel->ch_keep_open) |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4042 { |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4043 /* For unknown reason poll() returns immediately for a |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4044 * keep-open channel. Instead of adding it to the fds add |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4045 * a short timeout and check, like polling. */ |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4046 if (*towait < 0 || *towait > KEEP_OPEN_TIME) |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4047 *towait = KEEP_OPEN_TIME; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4048 } |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4049 else |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4050 { |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4051 ch_part->ch_poll_idx = nfd; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4052 fds[nfd].fd = ch_part->ch_fd; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4053 fds[nfd].events = POLLIN; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4054 nfd++; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4055 } |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4056 } |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4057 else |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4058 channel->ch_part[part].ch_poll_idx = -1; |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4059 } |
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4060 } |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4061 |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4062 nfd = channel_fill_poll_write(nfd, fds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4063 |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4064 return nfd; |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4065 } |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4066 |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4067 /* |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4068 * The type of "fds" is hidden to avoid problems with the function proto. |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4069 */ |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4070 int |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4071 channel_poll_check(int ret_in, void *fds_in) |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4072 { |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4073 int ret = ret_in; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4074 channel_T *channel; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4075 struct pollfd *fds = fds_in; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4076 ch_part_T part; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4077 int idx; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4078 chanpart_T *in_part; |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4079 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
4080 for (channel = first_channel; channel != NULL; channel = channel->ch_next) |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4081 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4082 for (part = PART_SOCK; part < PART_IN; ++part) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
4083 { |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4084 idx = channel->ch_part[part].ch_poll_idx; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4085 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4086 if (ret > 0 && idx != -1 && (fds[idx].revents & POLLIN)) |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4087 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4088 channel_read(channel, part, "channel_poll_check"); |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4089 --ret; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4090 } |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4091 else if (channel->ch_part[part].ch_fd != INVALID_FD |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4092 && channel->ch_keep_open) |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4093 { |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4094 /* polling a keep-open channel */ |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4095 channel_read(channel, part, "channel_poll_check_keep_open"); |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4096 } |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
4097 } |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4098 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4099 in_part = &channel->ch_part[PART_IN]; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4100 idx = in_part->ch_poll_idx; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4101 if (ret > 0 && idx != -1 && (fds[idx].revents & POLLOUT)) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4102 { |
12168
51e5a8602624
patch 8.0.0964: channel write buffer does not work with poll()
Christian Brabandt <cb@256bit.org>
parents:
12158
diff
changeset
|
4103 channel_write_input(channel); |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4104 --ret; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4105 } |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4106 } |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4107 |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4108 return ret; |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4109 } |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
4110 # endif /* UNIX && !HAVE_SELECT */ |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4111 |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
4112 # if (!defined(WIN32) && defined(HAVE_SELECT)) || defined(PROTO) |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4113 |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4114 /* |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4115 * The "fd_set" type is hidden to avoid problems with the function proto. |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4116 */ |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4117 int |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4118 channel_select_setup( |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4119 int maxfd_in, |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4120 void *rfds_in, |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4121 void *wfds_in, |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4122 struct timeval *tv, |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4123 struct timeval **tvp) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4124 { |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4125 int maxfd = maxfd_in; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4126 channel_T *channel; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4127 fd_set *rfds = rfds_in; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4128 fd_set *wfds = wfds_in; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4129 ch_part_T part; |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4130 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
4131 for (channel = first_channel; channel != NULL; channel = channel->ch_next) |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4132 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4133 for (part = PART_SOCK; part < PART_IN; ++part) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4134 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4135 sock_T fd = channel->ch_part[part].ch_fd; |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4136 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4137 if (fd != INVALID_FD) |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4138 { |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4139 if (channel->ch_keep_open) |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4140 { |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4141 /* For unknown reason select() returns immediately for a |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4142 * keep-open channel. Instead of adding it to the rfds add |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4143 * a short timeout and check, like polling. */ |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4144 if (*tvp == NULL || tv->tv_sec > 0 |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4145 || tv->tv_usec > KEEP_OPEN_TIME * 1000) |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4146 { |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4147 *tvp = tv; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4148 tv->tv_sec = 0; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4149 tv->tv_usec = KEEP_OPEN_TIME * 1000; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4150 } |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4151 } |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4152 else |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4153 { |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4154 FD_SET((int)fd, rfds); |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4155 if (maxfd < (int)fd) |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4156 maxfd = (int)fd; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4157 } |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4158 } |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4159 } |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4160 } |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4161 |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4162 maxfd = channel_fill_wfds(maxfd, wfds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4163 |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4164 return maxfd; |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4165 } |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4166 |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4167 /* |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4168 * The "fd_set" type is hidden to avoid problems with the function proto. |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4169 */ |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4170 int |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4171 channel_select_check(int ret_in, void *rfds_in, void *wfds_in) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4172 { |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4173 int ret = ret_in; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4174 channel_T *channel; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4175 fd_set *rfds = rfds_in; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4176 fd_set *wfds = wfds_in; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4177 ch_part_T part; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4178 chanpart_T *in_part; |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4179 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
4180 for (channel = first_channel; channel != NULL; channel = channel->ch_next) |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4181 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4182 for (part = PART_SOCK; part < PART_IN; ++part) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
4183 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4184 sock_T fd = channel->ch_part[part].ch_fd; |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4185 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4186 if (ret > 0 && fd != INVALID_FD && FD_ISSET(fd, rfds)) |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4187 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4188 channel_read(channel, part, "channel_select_check"); |
12393
128cd982c7b8
patch 8.0.1076: term_start() does not take callbacks
Christian Brabandt <cb@256bit.org>
parents:
12389
diff
changeset
|
4189 FD_CLR(fd, rfds); |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4190 --ret; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4191 } |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4192 else if (fd != INVALID_FD && channel->ch_keep_open) |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4193 { |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4194 /* polling a keep-open channel */ |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4195 channel_read(channel, part, "channel_select_check_keep_open"); |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4196 } |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
4197 } |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4198 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4199 in_part = &channel->ch_part[PART_IN]; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4200 if (ret > 0 && in_part->ch_fd != INVALID_FD |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4201 && FD_ISSET(in_part->ch_fd, wfds)) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4202 { |
13569
97720d9a01d4
patch 8.0.1657: crash when reading a channel
Christian Brabandt <cb@256bit.org>
parents:
13470
diff
changeset
|
4203 /* Clear the flag first, ch_fd may change in channel_write_input(). */ |
97720d9a01d4
patch 8.0.1657: crash when reading a channel
Christian Brabandt <cb@256bit.org>
parents:
13470
diff
changeset
|
4204 FD_CLR(in_part->ch_fd, wfds); |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4205 channel_write_input(channel); |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4206 --ret; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4207 } |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4208 } |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4209 |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4210 return ret; |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4211 } |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
4212 # endif /* !WIN32 && HAVE_SELECT */ |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4213 |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
4214 /* |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
4215 * Execute queued up commands. |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
4216 * Invoked from the main loop when it's safe to execute received commands. |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
4217 * Return TRUE when something was done. |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
4218 */ |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
4219 int |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
4220 channel_parse_messages(void) |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
4221 { |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
4222 channel_T *channel = first_channel; |
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
4223 int ret = FALSE; |
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
4224 int r; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4225 ch_part_T part = PART_SOCK; |
10406
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4226 #ifdef ELAPSED_FUNC |
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4227 ELAPSED_TYPE start_tv; |
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4228 |
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4229 ELAPSED_INIT(start_tv); |
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4230 #endif |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
4231 |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
4232 ++safe_to_invoke_callback; |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
4233 |
8428
4e22d0e7bfb1
commit https://github.com/vim/vim/commit/d0b6502a7ace39d6cd30874110a572371d10beae
Christian Brabandt <cb@256bit.org>
parents:
8422
diff
changeset
|
4234 /* Only do this message when another message was given, otherwise we get |
4e22d0e7bfb1
commit https://github.com/vim/vim/commit/d0b6502a7ace39d6cd30874110a572371d10beae
Christian Brabandt <cb@256bit.org>
parents:
8422
diff
changeset
|
4235 * lots of them. */ |
4e22d0e7bfb1
commit https://github.com/vim/vim/commit/d0b6502a7ace39d6cd30874110a572371d10beae
Christian Brabandt <cb@256bit.org>
parents:
8422
diff
changeset
|
4236 if (did_log_msg) |
4e22d0e7bfb1
commit https://github.com/vim/vim/commit/d0b6502a7ace39d6cd30874110a572371d10beae
Christian Brabandt <cb@256bit.org>
parents:
8422
diff
changeset
|
4237 { |
4e22d0e7bfb1
commit https://github.com/vim/vim/commit/d0b6502a7ace39d6cd30874110a572371d10beae
Christian Brabandt <cb@256bit.org>
parents:
8422
diff
changeset
|
4238 ch_log(NULL, "looking for messages on channels"); |
4e22d0e7bfb1
commit https://github.com/vim/vim/commit/d0b6502a7ace39d6cd30874110a572371d10beae
Christian Brabandt <cb@256bit.org>
parents:
8422
diff
changeset
|
4239 did_log_msg = FALSE; |
4e22d0e7bfb1
commit https://github.com/vim/vim/commit/d0b6502a7ace39d6cd30874110a572371d10beae
Christian Brabandt <cb@256bit.org>
parents:
8422
diff
changeset
|
4240 } |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
4241 while (channel != NULL) |
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
4242 { |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
4243 if (channel_can_close(channel)) |
9083
69bb7b230094
commit https://github.com/vim/vim/commit/cf7ff70ca73218d618e7c00ab785bcf5f9120a94
Christian Brabandt <cb@256bit.org>
parents:
9081
diff
changeset
|
4244 { |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
4245 channel->ch_to_be_closed = (1U << PART_COUNT); |
9083
69bb7b230094
commit https://github.com/vim/vim/commit/cf7ff70ca73218d618e7c00ab785bcf5f9120a94
Christian Brabandt <cb@256bit.org>
parents:
9081
diff
changeset
|
4246 channel_close_now(channel); |
69bb7b230094
commit https://github.com/vim/vim/commit/cf7ff70ca73218d618e7c00ab785bcf5f9120a94
Christian Brabandt <cb@256bit.org>
parents:
9081
diff
changeset
|
4247 /* channel may have been freed, start over */ |
69bb7b230094
commit https://github.com/vim/vim/commit/cf7ff70ca73218d618e7c00ab785bcf5f9120a94
Christian Brabandt <cb@256bit.org>
parents:
9081
diff
changeset
|
4248 channel = first_channel; |
69bb7b230094
commit https://github.com/vim/vim/commit/cf7ff70ca73218d618e7c00ab785bcf5f9120a94
Christian Brabandt <cb@256bit.org>
parents:
9081
diff
changeset
|
4249 continue; |
69bb7b230094
commit https://github.com/vim/vim/commit/cf7ff70ca73218d618e7c00ab785bcf5f9120a94
Christian Brabandt <cb@256bit.org>
parents:
9081
diff
changeset
|
4250 } |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
4251 if (channel->ch_to_be_freed) |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
4252 { |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
4253 channel_free(channel); |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
4254 /* channel has been freed, start over */ |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
4255 channel = first_channel; |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
4256 continue; |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
4257 } |
8259
99a70c3b902f
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Christian Brabandt <cb@256bit.org>
parents:
8257
diff
changeset
|
4258 if (channel->ch_refcount == 0 && !channel_still_useful(channel)) |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
4259 { |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
4260 /* channel is no longer useful, free it */ |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
4261 channel_free(channel); |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
4262 channel = first_channel; |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
4263 part = PART_SOCK; |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
4264 continue; |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
4265 } |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
4266 if (channel->ch_part[part].ch_fd != INVALID_FD |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4267 || channel_has_readahead(channel, part)) |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
4268 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4269 /* Increase the refcount, in case the handler causes the channel |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4270 * to be unreferenced or closed. */ |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4271 ++channel->ch_refcount; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4272 r = may_invoke_callback(channel, part); |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4273 if (r == OK) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4274 ret = TRUE; |
10406
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4275 if (channel_unref(channel) || (r == OK |
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4276 #ifdef ELAPSED_FUNC |
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4277 /* Limit the time we loop here to 100 msec, otherwise |
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4278 * Vim becomes unresponsive when the callback takes |
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4279 * more than a bit of time. */ |
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4280 && ELAPSED_FUNC(start_tv) < 100L |
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4281 #endif |
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4282 )) |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4283 { |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4284 /* channel was freed or something was done, start over */ |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4285 channel = first_channel; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4286 part = PART_SOCK; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4287 continue; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4288 } |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
4289 } |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4290 if (part < PART_ERR) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4291 ++part; |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
4292 else |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4293 { |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
4294 channel = channel->ch_next; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4295 part = PART_SOCK; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4296 } |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
4297 } |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
4298 |
8928
e6916e1683bb
commit https://github.com/vim/vim/commit/7f7c3325d3f1baba32263a3457cfc4d90ecd5ff1
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
4299 if (channel_need_redraw) |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
4300 { |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
4301 channel_need_redraw = FALSE; |
12244
d0b039e2ed56
patch 8.0.1002: unnecessarily updating screen after timer callback
Christian Brabandt <cb@256bit.org>
parents:
12240
diff
changeset
|
4302 redraw_after_callback(TRUE); |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
4303 } |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
4304 |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
4305 --safe_to_invoke_callback; |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
4306 |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
4307 return ret; |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
4308 } |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
4309 |
7961
a7e58c6e4e9a
commit https://github.com/vim/vim/commit/fbc4b4db3a9690906a96e16724350a6241cf32a5
Christian Brabandt <cb@256bit.org>
parents:
7945
diff
changeset
|
4310 /* |
10418
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4311 * Return TRUE if any channel has readahead. That means we should not block on |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4312 * waiting for input. |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4313 */ |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4314 int |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4315 channel_any_readahead(void) |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4316 { |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4317 channel_T *channel = first_channel; |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4318 ch_part_T part = PART_SOCK; |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4319 |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4320 while (channel != NULL) |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4321 { |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4322 if (channel_has_readahead(channel, part)) |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4323 return TRUE; |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4324 if (part < PART_ERR) |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4325 ++part; |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4326 else |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4327 { |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4328 channel = channel->ch_next; |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4329 part = PART_SOCK; |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4330 } |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4331 } |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4332 return FALSE; |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4333 } |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4334 |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4335 /* |
7961
a7e58c6e4e9a
commit https://github.com/vim/vim/commit/fbc4b4db3a9690906a96e16724350a6241cf32a5
Christian Brabandt <cb@256bit.org>
parents:
7945
diff
changeset
|
4336 * Mark references to lists used in channels. |
a7e58c6e4e9a
commit https://github.com/vim/vim/commit/fbc4b4db3a9690906a96e16724350a6241cf32a5
Christian Brabandt <cb@256bit.org>
parents:
7945
diff
changeset
|
4337 */ |
7931
2679e636e862
commit https://github.com/vim/vim/commit/4b6a6dcbe7bd13170c4884cc17acb1eac2c633d1
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
4338 int |
2679e636e862
commit https://github.com/vim/vim/commit/4b6a6dcbe7bd13170c4884cc17acb1eac2c633d1
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
4339 set_ref_in_channel(int copyID) |
2679e636e862
commit https://github.com/vim/vim/commit/4b6a6dcbe7bd13170c4884cc17acb1eac2c633d1
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
4340 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
4341 int abort = FALSE; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
4342 channel_T *channel; |
9058
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
4343 typval_T tv; |
7931
2679e636e862
commit https://github.com/vim/vim/commit/4b6a6dcbe7bd13170c4884cc17acb1eac2c633d1
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
4344 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
4345 for (channel = first_channel; channel != NULL; channel = channel->ch_next) |
9058
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
4346 if (channel_still_useful(channel)) |
7931
2679e636e862
commit https://github.com/vim/vim/commit/4b6a6dcbe7bd13170c4884cc17acb1eac2c633d1
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
4347 { |
9058
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
4348 tv.v_type = VAR_CHANNEL; |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
4349 tv.vval.v_channel = channel; |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
4350 abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL); |
7931
2679e636e862
commit https://github.com/vim/vim/commit/4b6a6dcbe7bd13170c4884cc17acb1eac2c633d1
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
4351 } |
2679e636e862
commit https://github.com/vim/vim/commit/4b6a6dcbe7bd13170c4884cc17acb1eac2c633d1
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
4352 return abort; |
2679e636e862
commit https://github.com/vim/vim/commit/4b6a6dcbe7bd13170c4884cc17acb1eac2c633d1
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
4353 } |
7986
8e0d4cd8157a
commit https://github.com/vim/vim/commit/ae8eb3ca927f1b0ac2a6643da8699538cdc380f6
Christian Brabandt <cb@256bit.org>
parents:
7982
diff
changeset
|
4354 |
8e0d4cd8157a
commit https://github.com/vim/vim/commit/ae8eb3ca927f1b0ac2a6643da8699538cdc380f6
Christian Brabandt <cb@256bit.org>
parents:
7982
diff
changeset
|
4355 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4356 * Return the "part" to write to for "channel". |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4357 */ |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4358 ch_part_T |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4359 channel_part_send(channel_T *channel) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4360 { |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4361 if (channel->CH_SOCK_FD == INVALID_FD) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4362 return PART_IN; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4363 return PART_SOCK; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4364 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4365 |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4366 /* |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4367 * Return the default "part" to read from for "channel". |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4368 */ |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4369 ch_part_T |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4370 channel_part_read(channel_T *channel) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4371 { |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4372 if (channel->CH_SOCK_FD == INVALID_FD) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4373 return PART_OUT; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4374 return PART_SOCK; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4375 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4376 |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4377 /* |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4378 * Return the mode of "channel"/"part" |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
4379 * If "channel" is invalid returns MODE_JSON. |
7986
8e0d4cd8157a
commit https://github.com/vim/vim/commit/ae8eb3ca927f1b0ac2a6643da8699538cdc380f6
Christian Brabandt <cb@256bit.org>
parents:
7982
diff
changeset
|
4380 */ |
8e0d4cd8157a
commit https://github.com/vim/vim/commit/ae8eb3ca927f1b0ac2a6643da8699538cdc380f6
Christian Brabandt <cb@256bit.org>
parents:
7982
diff
changeset
|
4381 ch_mode_T |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4382 channel_get_mode(channel_T *channel, ch_part_T part) |
7986
8e0d4cd8157a
commit https://github.com/vim/vim/commit/ae8eb3ca927f1b0ac2a6643da8699538cdc380f6
Christian Brabandt <cb@256bit.org>
parents:
7982
diff
changeset
|
4383 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
4384 if (channel == NULL) |
7986
8e0d4cd8157a
commit https://github.com/vim/vim/commit/ae8eb3ca927f1b0ac2a6643da8699538cdc380f6
Christian Brabandt <cb@256bit.org>
parents:
7982
diff
changeset
|
4385 return MODE_JSON; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4386 return channel->ch_part[part].ch_mode; |
7986
8e0d4cd8157a
commit https://github.com/vim/vim/commit/ae8eb3ca927f1b0ac2a6643da8699538cdc380f6
Christian Brabandt <cb@256bit.org>
parents:
7982
diff
changeset
|
4387 } |
8e0d4cd8157a
commit https://github.com/vim/vim/commit/ae8eb3ca927f1b0ac2a6643da8699538cdc380f6
Christian Brabandt <cb@256bit.org>
parents:
7982
diff
changeset
|
4388 |
8157
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
4389 /* |
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
4390 * Return the timeout of "channel"/"part" |
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
4391 */ |
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
4392 int |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4393 channel_get_timeout(channel_T *channel, ch_part_T part) |
8157
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
4394 { |
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
4395 return channel->ch_part[part].ch_timeout; |
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
4396 } |
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
4397 |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4398 static int |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4399 handle_mode(typval_T *item, jobopt_T *opt, ch_mode_T *modep, int jo) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4400 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4401 char_u *val = get_tv_string(item); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4402 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4403 opt->jo_set |= jo; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4404 if (STRCMP(val, "nl") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4405 *modep = MODE_NL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4406 else if (STRCMP(val, "raw") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4407 *modep = MODE_RAW; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4408 else if (STRCMP(val, "js") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4409 *modep = MODE_JS; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4410 else if (STRCMP(val, "json") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4411 *modep = MODE_JSON; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4412 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4413 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4414 EMSG2(_(e_invarg2), val); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4415 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4416 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4417 return OK; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4418 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4419 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4420 static int |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4421 handle_io(typval_T *item, ch_part_T part, jobopt_T *opt) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4422 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4423 char_u *val = get_tv_string(item); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4424 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4425 opt->jo_set |= JO_OUT_IO << (part - PART_OUT); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4426 if (STRCMP(val, "null") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4427 opt->jo_io[part] = JIO_NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4428 else if (STRCMP(val, "pipe") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4429 opt->jo_io[part] = JIO_PIPE; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4430 else if (STRCMP(val, "file") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4431 opt->jo_io[part] = JIO_FILE; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4432 else if (STRCMP(val, "buffer") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4433 opt->jo_io[part] = JIO_BUFFER; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4434 else if (STRCMP(val, "out") == 0 && part == PART_ERR) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4435 opt->jo_io[part] = JIO_OUT; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4436 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4437 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4438 EMSG2(_(e_invarg2), val); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4439 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4440 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4441 return OK; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4442 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4443 |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4444 /* |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4445 * Clear a jobopt_T before using it. |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4446 */ |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4447 void |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4448 clear_job_options(jobopt_T *opt) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4449 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4450 vim_memset(opt, 0, sizeof(jobopt_T)); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4451 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4452 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4453 /* |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4454 * Free any members of a jobopt_T. |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4455 */ |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4456 void |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4457 free_job_options(jobopt_T *opt) |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4458 { |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4459 if (opt->jo_partial != NULL) |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4460 partial_unref(opt->jo_partial); |
9723
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
4461 else if (opt->jo_callback != NULL) |
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
4462 func_unref(opt->jo_callback); |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4463 if (opt->jo_out_partial != NULL) |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4464 partial_unref(opt->jo_out_partial); |
9723
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
4465 else if (opt->jo_out_cb != NULL) |
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
4466 func_unref(opt->jo_out_cb); |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4467 if (opt->jo_err_partial != NULL) |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4468 partial_unref(opt->jo_err_partial); |
9723
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
4469 else if (opt->jo_err_cb != NULL) |
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
4470 func_unref(opt->jo_err_cb); |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4471 if (opt->jo_close_partial != NULL) |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4472 partial_unref(opt->jo_close_partial); |
9723
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
4473 else if (opt->jo_close_cb != NULL) |
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
4474 func_unref(opt->jo_close_cb); |
9151
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
4475 if (opt->jo_exit_partial != NULL) |
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
4476 partial_unref(opt->jo_exit_partial); |
9723
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
4477 else if (opt->jo_exit_cb != NULL) |
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
4478 func_unref(opt->jo_exit_cb); |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4479 if (opt->jo_env != NULL) |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4480 dict_unref(opt->jo_env); |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4481 } |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4482 |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4483 /* |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4484 * Get the PART_ number from the first character of an option name. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4485 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4486 static int |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4487 part_from_char(int c) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4488 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4489 return c == 'i' ? PART_IN : c == 'o' ? PART_OUT: PART_ERR; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4490 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4491 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4492 /* |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4493 * Get the option entries from the dict in "tv", parse them and put the result |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4494 * in "opt". |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4495 * Only accept JO_ options in "supported" and JO2_ options in "supported2". |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4496 * If an option value is invalid return FAIL. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4497 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4498 int |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4499 get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4500 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4501 typval_T *item; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4502 char_u *val; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4503 dict_T *dict; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4504 int todo; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4505 hashitem_T *hi; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4506 ch_part_T part; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4507 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4508 if (tv->v_type == VAR_UNKNOWN) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4509 return OK; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4510 if (tv->v_type != VAR_DICT) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4511 { |
13284
a69636c63103
patch 8.0.1516: errors for job options are not very specific
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
4512 EMSG(_(e_dictreq)); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4513 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4514 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4515 dict = tv->vval.v_dict; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4516 if (dict == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4517 return OK; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4518 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4519 todo = (int)dict->dv_hashtab.ht_used; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4520 for (hi = dict->dv_hashtab.ht_array; todo > 0; ++hi) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4521 if (!HASHITEM_EMPTY(hi)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4522 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4523 item = &dict_lookup(hi)->di_tv; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4524 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4525 if (STRCMP(hi->hi_key, "mode") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4526 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4527 if (!(supported & JO_MODE)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4528 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4529 if (handle_mode(item, opt, &opt->jo_mode, JO_MODE) == FAIL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4530 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4531 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4532 else if (STRCMP(hi->hi_key, "in_mode") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4533 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4534 if (!(supported & JO_IN_MODE)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4535 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4536 if (handle_mode(item, opt, &opt->jo_in_mode, JO_IN_MODE) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4537 == FAIL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4538 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4539 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4540 else if (STRCMP(hi->hi_key, "out_mode") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4541 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4542 if (!(supported & JO_OUT_MODE)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4543 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4544 if (handle_mode(item, opt, &opt->jo_out_mode, JO_OUT_MODE) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4545 == FAIL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4546 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4547 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4548 else if (STRCMP(hi->hi_key, "err_mode") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4549 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4550 if (!(supported & JO_ERR_MODE)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4551 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4552 if (handle_mode(item, opt, &opt->jo_err_mode, JO_ERR_MODE) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4553 == FAIL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4554 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4555 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4556 else if (STRCMP(hi->hi_key, "in_io") == 0 |
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4557 || STRCMP(hi->hi_key, "out_io") == 0 |
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4558 || STRCMP(hi->hi_key, "err_io") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4559 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4560 if (!(supported & JO_OUT_IO)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4561 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4562 if (handle_io(item, part_from_char(*hi->hi_key), opt) == FAIL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4563 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4564 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4565 else if (STRCMP(hi->hi_key, "in_name") == 0 |
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4566 || STRCMP(hi->hi_key, "out_name") == 0 |
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4567 || STRCMP(hi->hi_key, "err_name") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4568 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4569 part = part_from_char(*hi->hi_key); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4570 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4571 if (!(supported & JO_OUT_IO)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4572 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4573 opt->jo_set |= JO_OUT_NAME << (part - PART_OUT); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4574 opt->jo_io_name[part] = |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4575 get_tv_string_buf_chk(item, opt->jo_io_name_buf[part]); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4576 } |
11723
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
4577 else if (STRCMP(hi->hi_key, "pty") == 0) |
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
4578 { |
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
4579 if (!(supported & JO_MODE)) |
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
4580 break; |
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
4581 opt->jo_pty = get_tv_number(item); |
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
4582 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4583 else if (STRCMP(hi->hi_key, "in_buf") == 0 |
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4584 || STRCMP(hi->hi_key, "out_buf") == 0 |
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4585 || STRCMP(hi->hi_key, "err_buf") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4586 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4587 part = part_from_char(*hi->hi_key); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4588 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4589 if (!(supported & JO_OUT_IO)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4590 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4591 opt->jo_set |= JO_OUT_BUF << (part - PART_OUT); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4592 opt->jo_io_buf[part] = get_tv_number(item); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4593 if (opt->jo_io_buf[part] <= 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4594 { |
13284
a69636c63103
patch 8.0.1516: errors for job options are not very specific
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
4595 EMSG3(_(e_invargNval), hi->hi_key, get_tv_string(item)); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4596 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4597 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4598 if (buflist_findnr(opt->jo_io_buf[part]) == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4599 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4600 EMSGN(_(e_nobufnr), (long)opt->jo_io_buf[part]); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4601 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4602 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4603 } |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4604 else if (STRCMP(hi->hi_key, "out_modifiable") == 0 |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4605 || STRCMP(hi->hi_key, "err_modifiable") == 0) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4606 { |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4607 part = part_from_char(*hi->hi_key); |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4608 |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4609 if (!(supported & JO_OUT_IO)) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4610 break; |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4611 opt->jo_set |= JO_OUT_MODIFIABLE << (part - PART_OUT); |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4612 opt->jo_modifiable[part] = get_tv_number(item); |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4613 } |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4614 else if (STRCMP(hi->hi_key, "out_msg") == 0 |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4615 || STRCMP(hi->hi_key, "err_msg") == 0) |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4616 { |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4617 part = part_from_char(*hi->hi_key); |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4618 |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4619 if (!(supported & JO_OUT_IO)) |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4620 break; |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4621 opt->jo_set2 |= JO2_OUT_MSG << (part - PART_OUT); |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4622 opt->jo_message[part] = get_tv_number(item); |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4623 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4624 else if (STRCMP(hi->hi_key, "in_top") == 0 |
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4625 || STRCMP(hi->hi_key, "in_bot") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4626 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4627 linenr_T *lp; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4628 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4629 if (!(supported & JO_OUT_IO)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4630 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4631 if (hi->hi_key[3] == 't') |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4632 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4633 lp = &opt->jo_in_top; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4634 opt->jo_set |= JO_IN_TOP; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4635 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4636 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4637 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4638 lp = &opt->jo_in_bot; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4639 opt->jo_set |= JO_IN_BOT; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4640 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4641 *lp = get_tv_number(item); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4642 if (*lp < 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4643 { |
13284
a69636c63103
patch 8.0.1516: errors for job options are not very specific
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
4644 EMSG3(_(e_invargNval), hi->hi_key, get_tv_string(item)); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4645 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4646 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4647 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4648 else if (STRCMP(hi->hi_key, "channel") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4649 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4650 if (!(supported & JO_OUT_IO)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4651 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4652 opt->jo_set |= JO_CHANNEL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4653 if (item->v_type != VAR_CHANNEL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4654 { |
13284
a69636c63103
patch 8.0.1516: errors for job options are not very specific
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
4655 EMSG2(_(e_invargval), "channel"); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4656 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4657 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4658 opt->jo_channel = item->vval.v_channel; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4659 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4660 else if (STRCMP(hi->hi_key, "callback") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4661 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4662 if (!(supported & JO_CALLBACK)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4663 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4664 opt->jo_set |= JO_CALLBACK; |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
4665 opt->jo_callback = get_callback(item, &opt->jo_partial); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4666 if (opt->jo_callback == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4667 { |
13284
a69636c63103
patch 8.0.1516: errors for job options are not very specific
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
4668 EMSG2(_(e_invargval), "callback"); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4669 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4670 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4671 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4672 else if (STRCMP(hi->hi_key, "out_cb") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4673 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4674 if (!(supported & JO_OUT_CALLBACK)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4675 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4676 opt->jo_set |= JO_OUT_CALLBACK; |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
4677 opt->jo_out_cb = get_callback(item, &opt->jo_out_partial); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4678 if (opt->jo_out_cb == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4679 { |
13284
a69636c63103
patch 8.0.1516: errors for job options are not very specific
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
4680 EMSG2(_(e_invargval), "out_cb"); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4681 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4682 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4683 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4684 else if (STRCMP(hi->hi_key, "err_cb") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4685 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4686 if (!(supported & JO_ERR_CALLBACK)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4687 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4688 opt->jo_set |= JO_ERR_CALLBACK; |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
4689 opt->jo_err_cb = get_callback(item, &opt->jo_err_partial); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4690 if (opt->jo_err_cb == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4691 { |
13284
a69636c63103
patch 8.0.1516: errors for job options are not very specific
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
4692 EMSG2(_(e_invargval), "err_cb"); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4693 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4694 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4695 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4696 else if (STRCMP(hi->hi_key, "close_cb") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4697 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4698 if (!(supported & JO_CLOSE_CALLBACK)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4699 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4700 opt->jo_set |= JO_CLOSE_CALLBACK; |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
4701 opt->jo_close_cb = get_callback(item, &opt->jo_close_partial); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4702 if (opt->jo_close_cb == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4703 { |
13284
a69636c63103
patch 8.0.1516: errors for job options are not very specific
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
4704 EMSG2(_(e_invargval), "close_cb"); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4705 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4706 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4707 } |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
4708 else if (STRCMP(hi->hi_key, "drop") == 0) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
4709 { |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
4710 int never = FALSE; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
4711 val = get_tv_string(item); |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
4712 |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
4713 if (STRCMP(val, "never") == 0) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
4714 never = TRUE; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
4715 else if (STRCMP(val, "auto") != 0) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
4716 { |
13284
a69636c63103
patch 8.0.1516: errors for job options are not very specific
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
4717 EMSG3(_(e_invargNval), "drop", val); |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
4718 return FAIL; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
4719 } |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
4720 opt->jo_drop_never = never; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
4721 } |
9151
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
4722 else if (STRCMP(hi->hi_key, "exit_cb") == 0) |
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
4723 { |
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
4724 if (!(supported & JO_EXIT_CB)) |
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
4725 break; |
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
4726 opt->jo_set |= JO_EXIT_CB; |
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
4727 opt->jo_exit_cb = get_callback(item, &opt->jo_exit_partial); |
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
4728 if (opt->jo_exit_cb == NULL) |
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
4729 { |
13284
a69636c63103
patch 8.0.1516: errors for job options are not very specific
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
4730 EMSG2(_(e_invargval), "exit_cb"); |
9151
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
4731 return FAIL; |
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
4732 } |
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
4733 } |
11969
5dc3730de58d
patch 8.0.0865: cannot build with channel but without terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11967
diff
changeset
|
4734 #ifdef FEAT_TERMINAL |
11967
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
4735 else if (STRCMP(hi->hi_key, "term_name") == 0) |
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
4736 { |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4737 if (!(supported2 & JO2_TERM_NAME)) |
11967
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
4738 break; |
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
4739 opt->jo_set2 |= JO2_TERM_NAME; |
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
4740 opt->jo_term_name = get_tv_string_chk(item); |
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
4741 if (opt->jo_term_name == NULL) |
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
4742 { |
13284
a69636c63103
patch 8.0.1516: errors for job options are not very specific
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
4743 EMSG2(_(e_invargval), "term_name"); |
11967
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
4744 return FAIL; |
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
4745 } |
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
4746 } |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
4747 else if (STRCMP(hi->hi_key, "term_finish") == 0) |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
4748 { |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4749 if (!(supported2 & JO2_TERM_FINISH)) |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
4750 break; |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
4751 val = get_tv_string(item); |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
4752 if (STRCMP(val, "open") != 0 && STRCMP(val, "close") != 0) |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
4753 { |
13284
a69636c63103
patch 8.0.1516: errors for job options are not very specific
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
4754 EMSG3(_(e_invargNval), "term_finish", val); |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
4755 return FAIL; |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
4756 } |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
4757 opt->jo_set2 |= JO2_TERM_FINISH; |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
4758 opt->jo_term_finish = *val; |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
4759 } |
12072
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4760 else if (STRCMP(hi->hi_key, "term_opencmd") == 0) |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4761 { |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4762 char_u *p; |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4763 |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4764 if (!(supported2 & JO2_TERM_OPENCMD)) |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4765 break; |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4766 opt->jo_set2 |= JO2_TERM_OPENCMD; |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4767 p = opt->jo_term_opencmd = get_tv_string_chk(item); |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4768 if (p != NULL) |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4769 { |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4770 /* Must have %d and no other %. */ |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4771 p = vim_strchr(p, '%'); |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4772 if (p != NULL && (p[1] != 'd' |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4773 || vim_strchr(p + 2, '%') != NULL)) |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4774 p = NULL; |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4775 } |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4776 if (p == NULL) |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4777 { |
13284
a69636c63103
patch 8.0.1516: errors for job options are not very specific
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
4778 EMSG2(_(e_invargval), "term_opencmd"); |
12072
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4779 return FAIL; |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4780 } |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
4781 } |
12309
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
4782 else if (STRCMP(hi->hi_key, "eof_chars") == 0) |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
4783 { |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
4784 char_u *p; |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
4785 |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
4786 if (!(supported2 & JO2_EOF_CHARS)) |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
4787 break; |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
4788 opt->jo_set2 |= JO2_EOF_CHARS; |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
4789 p = opt->jo_eof_chars = get_tv_string_chk(item); |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
4790 if (p == NULL) |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
4791 { |
13284
a69636c63103
patch 8.0.1516: errors for job options are not very specific
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
4792 EMSG2(_(e_invargval), "eof_chars"); |
12309
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
4793 return FAIL; |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
4794 } |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
4795 } |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4796 else if (STRCMP(hi->hi_key, "term_rows") == 0) |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4797 { |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4798 if (!(supported2 & JO2_TERM_ROWS)) |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4799 break; |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4800 opt->jo_set2 |= JO2_TERM_ROWS; |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4801 opt->jo_term_rows = get_tv_number(item); |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4802 } |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4803 else if (STRCMP(hi->hi_key, "term_cols") == 0) |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4804 { |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4805 if (!(supported2 & JO2_TERM_COLS)) |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4806 break; |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4807 opt->jo_set2 |= JO2_TERM_COLS; |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4808 opt->jo_term_cols = get_tv_number(item); |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4809 } |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4810 else if (STRCMP(hi->hi_key, "vertical") == 0) |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4811 { |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4812 if (!(supported2 & JO2_VERTICAL)) |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4813 break; |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4814 opt->jo_set2 |= JO2_VERTICAL; |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4815 opt->jo_vertical = get_tv_number(item); |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4816 } |
12060
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12058
diff
changeset
|
4817 else if (STRCMP(hi->hi_key, "curwin") == 0) |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12058
diff
changeset
|
4818 { |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12058
diff
changeset
|
4819 if (!(supported2 & JO2_CURWIN)) |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12058
diff
changeset
|
4820 break; |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4821 opt->jo_set2 |= JO2_CURWIN; |
12060
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12058
diff
changeset
|
4822 opt->jo_curwin = get_tv_number(item); |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12058
diff
changeset
|
4823 } |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
4824 else if (STRCMP(hi->hi_key, "hidden") == 0) |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
4825 { |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
4826 if (!(supported2 & JO2_HIDDEN)) |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
4827 break; |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4828 opt->jo_set2 |= JO2_HIDDEN; |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
4829 opt->jo_hidden = get_tv_number(item); |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
4830 } |
13435
fa198b71bab2
patch 8.0.1592: terminal windows in a session are not properly restored
Christian Brabandt <cb@256bit.org>
parents:
13284
diff
changeset
|
4831 else if (STRCMP(hi->hi_key, "norestore") == 0) |
fa198b71bab2
patch 8.0.1592: terminal windows in a session are not properly restored
Christian Brabandt <cb@256bit.org>
parents:
13284
diff
changeset
|
4832 { |
fa198b71bab2
patch 8.0.1592: terminal windows in a session are not properly restored
Christian Brabandt <cb@256bit.org>
parents:
13284
diff
changeset
|
4833 if (!(supported2 & JO2_NORESTORE)) |
fa198b71bab2
patch 8.0.1592: terminal windows in a session are not properly restored
Christian Brabandt <cb@256bit.org>
parents:
13284
diff
changeset
|
4834 break; |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4835 opt->jo_set2 |= JO2_NORESTORE; |
13435
fa198b71bab2
patch 8.0.1592: terminal windows in a session are not properly restored
Christian Brabandt <cb@256bit.org>
parents:
13284
diff
changeset
|
4836 opt->jo_term_norestore = get_tv_number(item); |
fa198b71bab2
patch 8.0.1592: terminal windows in a session are not properly restored
Christian Brabandt <cb@256bit.org>
parents:
13284
diff
changeset
|
4837 } |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4838 else if (STRCMP(hi->hi_key, "term_kill") == 0) |
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4839 { |
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4840 if (!(supported2 & JO2_TERM_KILL)) |
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4841 break; |
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4842 opt->jo_set2 |= JO2_TERM_KILL; |
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4843 opt->jo_term_kill = get_tv_string_chk(item); |
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4844 } |
13626
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4845 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4846 else if (STRCMP(hi->hi_key, "ansi_colors") == 0) |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4847 { |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4848 int n = 0; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4849 listitem_T *li; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4850 long_u rgb[16]; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4851 |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4852 if (!(supported2 & JO2_ANSI_COLORS)) |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4853 break; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4854 |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4855 if (item == NULL || item->v_type != VAR_LIST |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4856 || item->vval.v_list == NULL) |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4857 { |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4858 EMSG2(_(e_invargval), "ansi_colors"); |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4859 return FAIL; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4860 } |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4861 |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4862 li = item->vval.v_list->lv_first; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4863 for (; li != NULL && n < 16; li = li->li_next, n++) |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4864 { |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4865 char_u *color_name; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4866 guicolor_T guicolor; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4867 |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4868 color_name = get_tv_string_chk(&li->li_tv); |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4869 if (color_name == NULL) |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4870 return FAIL; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4871 |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4872 guicolor = GUI_GET_COLOR(color_name); |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4873 if (guicolor == INVALCOLOR) |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4874 return FAIL; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4875 |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4876 rgb[n] = GUI_MCH_GET_RGB(guicolor); |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4877 } |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4878 |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4879 if (n != 16 || li != NULL) |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4880 { |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4881 EMSG2(_(e_invargval), "ansi_colors"); |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4882 return FAIL; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4883 } |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4884 |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4885 opt->jo_set2 |= JO2_ANSI_COLORS; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4886 memcpy(opt->jo_ansi_colors, rgb, sizeof(rgb)); |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4887 } |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
4888 # endif |
11969
5dc3730de58d
patch 8.0.0865: cannot build with channel but without terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11967
diff
changeset
|
4889 #endif |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4890 else if (STRCMP(hi->hi_key, "env") == 0) |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4891 { |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4892 if (!(supported2 & JO2_ENV)) |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4893 break; |
13598
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13569
diff
changeset
|
4894 if (item->v_type != VAR_DICT) |
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13569
diff
changeset
|
4895 { |
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13569
diff
changeset
|
4896 EMSG2(_(e_invargval), "env"); |
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13569
diff
changeset
|
4897 return FAIL; |
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13569
diff
changeset
|
4898 } |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4899 opt->jo_set2 |= JO2_ENV; |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4900 opt->jo_env = item->vval.v_dict; |
13598
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13569
diff
changeset
|
4901 if (opt->jo_env != NULL) |
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13569
diff
changeset
|
4902 ++opt->jo_env->dv_refcount; |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4903 } |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4904 else if (STRCMP(hi->hi_key, "cwd") == 0) |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4905 { |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4906 if (!(supported2 & JO2_CWD)) |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4907 break; |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4908 opt->jo_cwd = get_tv_string_buf_chk(item, opt->jo_cwd_buf); |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4909 if (opt->jo_cwd == NULL || !mch_isdir(opt->jo_cwd)) |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4910 { |
13284
a69636c63103
patch 8.0.1516: errors for job options are not very specific
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
4911 EMSG2(_(e_invargval), "cwd"); |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4912 return FAIL; |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4913 } |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4914 opt->jo_set2 |= JO2_CWD; |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4915 } |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4916 else if (STRCMP(hi->hi_key, "waittime") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4917 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4918 if (!(supported & JO_WAITTIME)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4919 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4920 opt->jo_set |= JO_WAITTIME; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4921 opt->jo_waittime = get_tv_number(item); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4922 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4923 else if (STRCMP(hi->hi_key, "timeout") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4924 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4925 if (!(supported & JO_TIMEOUT)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4926 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4927 opt->jo_set |= JO_TIMEOUT; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4928 opt->jo_timeout = get_tv_number(item); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4929 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4930 else if (STRCMP(hi->hi_key, "out_timeout") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4931 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4932 if (!(supported & JO_OUT_TIMEOUT)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4933 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4934 opt->jo_set |= JO_OUT_TIMEOUT; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4935 opt->jo_out_timeout = get_tv_number(item); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4936 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4937 else if (STRCMP(hi->hi_key, "err_timeout") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4938 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4939 if (!(supported & JO_ERR_TIMEOUT)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4940 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4941 opt->jo_set |= JO_ERR_TIMEOUT; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4942 opt->jo_err_timeout = get_tv_number(item); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4943 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4944 else if (STRCMP(hi->hi_key, "part") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4945 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4946 if (!(supported & JO_PART)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4947 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4948 opt->jo_set |= JO_PART; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4949 val = get_tv_string(item); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4950 if (STRCMP(val, "err") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4951 opt->jo_part = PART_ERR; |
10233
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
4952 else if (STRCMP(val, "out") == 0) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
4953 opt->jo_part = PART_OUT; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4954 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4955 { |
13284
a69636c63103
patch 8.0.1516: errors for job options are not very specific
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
4956 EMSG3(_(e_invargNval), "part", val); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4957 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4958 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4959 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4960 else if (STRCMP(hi->hi_key, "id") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4961 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4962 if (!(supported & JO_ID)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4963 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4964 opt->jo_set |= JO_ID; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4965 opt->jo_id = get_tv_number(item); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4966 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4967 else if (STRCMP(hi->hi_key, "stoponexit") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4968 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4969 if (!(supported & JO_STOPONEXIT)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4970 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4971 opt->jo_set |= JO_STOPONEXIT; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4972 opt->jo_stoponexit = get_tv_string_buf_chk(item, |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4973 opt->jo_soe_buf); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4974 if (opt->jo_stoponexit == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4975 { |
13284
a69636c63103
patch 8.0.1516: errors for job options are not very specific
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
4976 EMSG2(_(e_invargval), "stoponexit"); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4977 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4978 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4979 } |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4980 else if (STRCMP(hi->hi_key, "block_write") == 0) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4981 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4982 if (!(supported & JO_BLOCK_WRITE)) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4983 break; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4984 opt->jo_set |= JO_BLOCK_WRITE; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4985 opt->jo_block_write = get_tv_number(item); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4986 } |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4987 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4988 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4989 --todo; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4990 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4991 if (todo > 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4992 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4993 EMSG2(_(e_invarg2), hi->hi_key); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4994 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4995 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4996 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4997 return OK; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4998 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4999 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5000 /* |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5001 * Get the channel from the argument. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5002 * Returns NULL if the handle is invalid. |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
5003 * When "check_open" is TRUE check that the channel can be used. |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
5004 * When "reading" is TRUE "check_open" considers typeahead useful. |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
5005 * "part" is used to check typeahead, when PART_COUNT use the default part. |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5006 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5007 channel_T * |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
5008 get_channel_arg(typval_T *tv, int check_open, int reading, ch_part_T part) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5009 { |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
5010 channel_T *channel = NULL; |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
5011 int has_readahead = FALSE; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5012 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5013 if (tv->v_type == VAR_JOB) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5014 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5015 if (tv->vval.v_job != NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5016 channel = tv->vval.v_job->jv_channel; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5017 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5018 else if (tv->v_type == VAR_CHANNEL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5019 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5020 channel = tv->vval.v_channel; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5021 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5022 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5023 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5024 EMSG2(_(e_invarg2), get_tv_string(tv)); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5025 return NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5026 } |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
5027 if (channel != NULL && reading) |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
5028 has_readahead = channel_has_readahead(channel, |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
5029 part != PART_COUNT ? part : channel_part_read(channel)); |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
5030 |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
5031 if (check_open && (channel == NULL || (!channel_is_open(channel) |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
5032 && !(reading && has_readahead)))) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5033 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5034 EMSG(_("E906: not an open channel")); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5035 return NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5036 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5037 return channel; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5038 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5039 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5040 static job_T *first_job = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5041 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5042 static void |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5043 job_free_contents(job_T *job) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5044 { |
13740
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5045 int i; |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5046 |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5047 ch_log(job->jv_channel, "Freeing job"); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5048 if (job->jv_channel != NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5049 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5050 /* The link from the channel to the job doesn't count as a reference, |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5051 * thus don't decrement the refcount of the job. The reference from |
9355
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
5052 * the job to the channel does count the reference, decrement it and |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5053 * NULL the reference. We don't set ch_job_killed, unreferencing the |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5054 * job doesn't mean it stops running. */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5055 job->jv_channel->ch_job = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5056 channel_unref(job->jv_channel); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5057 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5058 mch_clear_job(job); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5059 |
12389
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
5060 vim_free(job->jv_tty_in); |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
5061 vim_free(job->jv_tty_out); |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5062 vim_free(job->jv_stoponexit); |
9491
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
5063 free_callback(job->jv_exit_cb, job->jv_exit_partial); |
13746
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5064 if (job->jv_argv != NULL) |
13740
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5065 { |
13746
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5066 for (i = 0; job->jv_argv[i] != NULL; i++) |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5067 vim_free(job->jv_argv[i]); |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5068 vim_free(job->jv_argv); |
13740
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5069 } |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5070 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5071 |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5072 static void |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5073 job_free_job(job_T *job) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5074 { |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5075 if (job->jv_next != NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5076 job->jv_next->jv_prev = job->jv_prev; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5077 if (job->jv_prev == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5078 first_job = job->jv_next; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5079 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5080 job->jv_prev->jv_next = job->jv_next; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5081 vim_free(job); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5082 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5083 |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5084 static void |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5085 job_free(job_T *job) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5086 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5087 if (!in_free_unref_items) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5088 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5089 job_free_contents(job); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5090 job_free_job(job); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5091 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5092 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5093 |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5094 #if defined(EXITFREE) || defined(PROTO) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5095 void |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5096 job_free_all(void) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5097 { |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5098 while (first_job != NULL) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5099 job_free(first_job); |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5100 } |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5101 #endif |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5102 |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5103 /* |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5104 * Return TRUE if we need to check if the process of "job" has ended. |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5105 */ |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5106 static int |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5107 job_need_end_check(job_T *job) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5108 { |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5109 return job->jv_status == JOB_STARTED |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5110 && (job->jv_stoponexit != NULL || job->jv_exit_cb != NULL); |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5111 } |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5112 |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5113 /* |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5114 * Return TRUE if the channel of "job" is still useful. |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5115 */ |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5116 static int |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5117 job_channel_still_useful(job_T *job) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5118 { |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5119 return job->jv_channel != NULL && channel_still_useful(job->jv_channel); |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5120 } |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5121 |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5122 /* |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5123 * Return TRUE if the channel of "job" is closeable. |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5124 */ |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5125 static int |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5126 job_channel_can_close(job_T *job) |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5127 { |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5128 return job->jv_channel != NULL && channel_can_close(job->jv_channel); |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5129 } |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5130 |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5131 /* |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5132 * Return TRUE if the job should not be freed yet. Do not free the job when |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5133 * it has not ended yet and there is a "stoponexit" flag, an exit callback |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5134 * or when the associated channel will do something with the job output. |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5135 */ |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5136 static int |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5137 job_still_useful(job_T *job) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5138 { |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5139 return job_need_end_check(job) || job_channel_still_useful(job); |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5140 } |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5141 |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5142 #if defined(GUI_MAY_FORK) || defined(PROTO) |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5143 /* |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5144 * Return TRUE when there is any running job that we care about. |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5145 */ |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5146 int |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5147 job_any_running() |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5148 { |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5149 job_T *job; |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5150 |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5151 for (job = first_job; job != NULL; job = job->jv_next) |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5152 if (job_still_useful(job)) |
13915
8314bb913e14
patch 8.0.1828: get no clue why :gui does not fork
Christian Brabandt <cb@256bit.org>
parents:
13913
diff
changeset
|
5153 { |
8314bb913e14
patch 8.0.1828: get no clue why :gui does not fork
Christian Brabandt <cb@256bit.org>
parents:
13913
diff
changeset
|
5154 ch_log(NULL, "GUI not forking because a job is running"); |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5155 return TRUE; |
13915
8314bb913e14
patch 8.0.1828: get no clue why :gui does not fork
Christian Brabandt <cb@256bit.org>
parents:
13913
diff
changeset
|
5156 } |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5157 return FALSE; |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5158 } |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5159 #endif |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5160 |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5161 #if !defined(USE_ARGV) || defined(PROTO) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5162 /* |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5163 * Escape one argument for an external command. |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5164 * Returns the escaped string in allocated memory. NULL when out of memory. |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5165 */ |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5166 static char_u * |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5167 win32_escape_arg(char_u *arg) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5168 { |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5169 int slen, dlen; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5170 int escaping = 0; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5171 int i; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5172 char_u *s, *d; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5173 char_u *escaped_arg; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5174 int has_spaces = FALSE; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5175 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5176 /* First count the number of extra bytes required. */ |
12246
337690672bda
patch 8.0.1003: 64 bit compiler warning
Christian Brabandt <cb@256bit.org>
parents:
12244
diff
changeset
|
5177 slen = (int)STRLEN(arg); |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5178 dlen = slen; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5179 for (s = arg; *s != NUL; MB_PTR_ADV(s)) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5180 { |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5181 if (*s == '"' || *s == '\\') |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5182 ++dlen; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5183 if (*s == ' ' || *s == '\t') |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5184 has_spaces = TRUE; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5185 } |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5186 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5187 if (has_spaces) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5188 dlen += 2; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5189 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5190 if (dlen == slen) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5191 return vim_strsave(arg); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5192 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5193 /* Allocate memory for the result and fill it. */ |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5194 escaped_arg = alloc(dlen + 1); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5195 if (escaped_arg == NULL) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5196 return NULL; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5197 memset(escaped_arg, 0, dlen+1); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5198 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5199 d = escaped_arg; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5200 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5201 if (has_spaces) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5202 *d++ = '"'; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5203 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5204 for (s = arg; *s != NUL;) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5205 { |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5206 switch (*s) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5207 { |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5208 case '"': |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5209 for (i = 0; i < escaping; i++) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5210 *d++ = '\\'; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5211 escaping = 0; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5212 *d++ = '\\'; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5213 *d++ = *s++; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5214 break; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5215 case '\\': |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5216 escaping++; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5217 *d++ = *s++; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5218 break; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5219 default: |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5220 escaping = 0; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5221 MB_COPY_CHAR(s, d); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5222 break; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5223 } |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5224 } |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5225 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5226 /* add terminating quote and finish with a NUL */ |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5227 if (has_spaces) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5228 { |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5229 for (i = 0; i < escaping; i++) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5230 *d++ = '\\'; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5231 *d++ = '"'; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5232 } |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5233 *d = NUL; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5234 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5235 return escaped_arg; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5236 } |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5237 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5238 /* |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5239 * Build a command line from a list, taking care of escaping. |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5240 * The result is put in gap->ga_data. |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5241 * Returns FAIL when out of memory. |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5242 */ |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5243 int |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5244 win32_build_cmd(list_T *l, garray_T *gap) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5245 { |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5246 listitem_T *li; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5247 char_u *s; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5248 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5249 for (li = l->lv_first; li != NULL; li = li->li_next) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5250 { |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5251 s = get_tv_string_chk(&li->li_tv); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5252 if (s == NULL) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5253 return FAIL; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5254 s = win32_escape_arg(s); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5255 if (s == NULL) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5256 return FAIL; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5257 ga_concat(gap, s); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5258 vim_free(s); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5259 if (li->li_next != NULL) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5260 ga_append(gap, ' '); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5261 } |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5262 return OK; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5263 } |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5264 #endif |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5265 |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5266 /* |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5267 * NOTE: Must call job_cleanup() only once right after the status of "job" |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5268 * changed to JOB_ENDED (i.e. after job_status() returned "dead" first or |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5269 * mch_detect_ended_job() returned non-NULL). |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5270 */ |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
5271 void |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5272 job_cleanup(job_T *job) |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5273 { |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5274 if (job->jv_status != JOB_ENDED) |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5275 return; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5276 |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5277 /* Ready to cleanup the job. */ |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5278 job->jv_status = JOB_FINISHED; |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5279 |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5280 /* When only channel-in is kept open, close explicitly. */ |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5281 if (job->jv_channel != NULL) |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5282 ch_close_part(job->jv_channel, PART_IN); |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5283 |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5284 if (job->jv_exit_cb != NULL) |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5285 { |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5286 typval_T argv[3]; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5287 typval_T rettv; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5288 int dummy; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5289 |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5290 /* Invoke the exit callback. Make sure the refcount is > 0. */ |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
5291 ch_log(job->jv_channel, "Invoking exit callback %s", job->jv_exit_cb); |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5292 ++job->jv_refcount; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5293 argv[0].v_type = VAR_JOB; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5294 argv[0].vval.v_job = job; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5295 argv[1].v_type = VAR_NUMBER; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5296 argv[1].vval.v_number = job->jv_exitval; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5297 call_func(job->jv_exit_cb, (int)STRLEN(job->jv_exit_cb), |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5298 &rettv, 2, argv, NULL, 0L, 0L, &dummy, TRUE, |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5299 job->jv_exit_partial, NULL); |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5300 clear_tv(&rettv); |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5301 --job->jv_refcount; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5302 channel_need_redraw = TRUE; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5303 } |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5304 |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5305 /* Do not free the job in case the close callback of the associated channel |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5306 * isn't invoked yet and may get information by job_info(). */ |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5307 if (job->jv_refcount == 0 && !job_channel_still_useful(job)) |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5308 { |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5309 /* The job was already unreferenced and the associated channel was |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5310 * detached, now that it ended it can be freed. Careful: caller must |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5311 * not use "job" after this! */ |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5312 job_free(job); |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5313 } |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5314 } |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5315 |
9058
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5316 /* |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5317 * Mark references in jobs that are still useful. |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5318 */ |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5319 int |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5320 set_ref_in_job(int copyID) |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5321 { |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5322 int abort = FALSE; |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5323 job_T *job; |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5324 typval_T tv; |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5325 |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5326 for (job = first_job; job != NULL; job = job->jv_next) |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5327 if (job_still_useful(job)) |
9058
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5328 { |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5329 tv.v_type = VAR_JOB; |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5330 tv.vval.v_job = job; |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5331 abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL); |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5332 } |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5333 return abort; |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5334 } |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5335 |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5336 /* |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5337 * Dereference "job". Note that after this "job" may have been freed. |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5338 */ |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5339 void |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5340 job_unref(job_T *job) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5341 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5342 if (job != NULL && --job->jv_refcount <= 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5343 { |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5344 /* Do not free the job if there is a channel where the close callback |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5345 * may get the job info. */ |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5346 if (!job_channel_still_useful(job)) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5347 { |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5348 /* Do not free the job when it has not ended yet and there is a |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5349 * "stoponexit" flag or an exit callback. */ |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5350 if (!job_need_end_check(job)) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5351 { |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5352 job_free(job); |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5353 } |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5354 else if (job->jv_channel != NULL) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5355 { |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5356 /* Do remove the link to the channel, otherwise it hangs |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5357 * around until Vim exits. See job_free() for refcount. */ |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5358 ch_log(job->jv_channel, "detaching channel from job"); |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5359 job->jv_channel->ch_job = NULL; |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5360 channel_unref(job->jv_channel); |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5361 job->jv_channel = NULL; |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5362 } |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5363 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5364 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5365 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5366 |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5367 int |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5368 free_unused_jobs_contents(int copyID, int mask) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5369 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5370 int did_free = FALSE; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5371 job_T *job; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5372 |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5373 for (job = first_job; job != NULL; job = job->jv_next) |
8881
ed0b39dd7fd6
commit https://github.com/vim/vim/commit/ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e
Christian Brabandt <cb@256bit.org>
parents:
8863
diff
changeset
|
5374 if ((job->jv_copyID & mask) != (copyID & mask) |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5375 && !job_still_useful(job)) |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5376 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5377 /* Free the channel and ordinary items it contains, but don't |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5378 * recurse into Lists, Dictionaries etc. */ |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5379 job_free_contents(job); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5380 did_free = TRUE; |
9079
2cd83c854073
commit https://github.com/vim/vim/commit/36e0f7da9bc4a6ee8a7b17df503542a339e034c8
Christian Brabandt <cb@256bit.org>
parents:
9064
diff
changeset
|
5381 } |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5382 return did_free; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5383 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5384 |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5385 void |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5386 free_unused_jobs(int copyID, int mask) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5387 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5388 job_T *job; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5389 job_T *job_next; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5390 |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5391 for (job = first_job; job != NULL; job = job_next) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5392 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5393 job_next = job->jv_next; |
8881
ed0b39dd7fd6
commit https://github.com/vim/vim/commit/ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e
Christian Brabandt <cb@256bit.org>
parents:
8863
diff
changeset
|
5394 if ((job->jv_copyID & mask) != (copyID & mask) |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5395 && !job_still_useful(job)) |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5396 { |
8881
ed0b39dd7fd6
commit https://github.com/vim/vim/commit/ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e
Christian Brabandt <cb@256bit.org>
parents:
8863
diff
changeset
|
5397 /* Free the job struct itself. */ |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5398 job_free_job(job); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5399 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5400 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5401 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5402 |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5403 /* |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5404 * Allocate a job. Sets the refcount to one and sets options default. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5405 */ |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
5406 job_T * |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5407 job_alloc(void) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5408 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5409 job_T *job; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5410 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5411 job = (job_T *)alloc_clear(sizeof(job_T)); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5412 if (job != NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5413 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5414 job->jv_refcount = 1; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5415 job->jv_stoponexit = vim_strsave((char_u *)"term"); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5416 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5417 if (first_job != NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5418 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5419 first_job->jv_prev = job; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5420 job->jv_next = first_job; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5421 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5422 first_job = job; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5423 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5424 return job; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5425 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5426 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5427 void |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5428 job_set_options(job_T *job, jobopt_T *opt) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5429 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5430 if (opt->jo_set & JO_STOPONEXIT) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5431 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5432 vim_free(job->jv_stoponexit); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5433 if (opt->jo_stoponexit == NULL || *opt->jo_stoponexit == NUL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5434 job->jv_stoponexit = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5435 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5436 job->jv_stoponexit = vim_strsave(opt->jo_stoponexit); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5437 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5438 if (opt->jo_set & JO_EXIT_CB) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5439 { |
9491
404de131cff9
commit https://github.com/vim/vim/commit/1436d8d51cce114be56209924fc71376407e5bad
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
5440 free_callback(job->jv_exit_cb, job->jv_exit_partial); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5441 if (opt->jo_exit_cb == NULL || *opt->jo_exit_cb == NUL) |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
5442 { |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5443 job->jv_exit_cb = NULL; |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
5444 job->jv_exit_partial = NULL; |
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
5445 } |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5446 else |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
5447 { |
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
5448 job->jv_exit_partial = opt->jo_exit_partial; |
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
5449 if (job->jv_exit_partial != NULL) |
9711
b74515b8f3d4
commit https://github.com/vim/vim/commit/57e69ff2cca9edee3546373d04e0dde6810309e5
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
5450 { |
b74515b8f3d4
commit https://github.com/vim/vim/commit/57e69ff2cca9edee3546373d04e0dde6810309e5
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
5451 job->jv_exit_cb = opt->jo_exit_cb; |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
5452 ++job->jv_exit_partial->pt_refcount; |
9711
b74515b8f3d4
commit https://github.com/vim/vim/commit/57e69ff2cca9edee3546373d04e0dde6810309e5
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
5453 } |
b74515b8f3d4
commit https://github.com/vim/vim/commit/57e69ff2cca9edee3546373d04e0dde6810309e5
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
5454 else |
9723
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
5455 { |
9711
b74515b8f3d4
commit https://github.com/vim/vim/commit/57e69ff2cca9edee3546373d04e0dde6810309e5
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
5456 job->jv_exit_cb = vim_strsave(opt->jo_exit_cb); |
9723
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
5457 func_ref(job->jv_exit_cb); |
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9711
diff
changeset
|
5458 } |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
5459 } |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5460 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5461 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5462 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5463 /* |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5464 * Called when Vim is exiting: kill all jobs that have the "stoponexit" flag. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5465 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5466 void |
9282
9f97a6290c63
commit https://github.com/vim/vim/commit/cf089463492fab53b2a5d81517829d22f882f82e
Christian Brabandt <cb@256bit.org>
parents:
9246
diff
changeset
|
5467 job_stop_on_exit(void) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5468 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5469 job_T *job; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5470 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5471 for (job = first_job; job != NULL; job = job->jv_next) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5472 if (job->jv_status == JOB_STARTED && job->jv_stoponexit != NULL) |
12037
85f0f557661e
patch 8.0.0899: function name mch_stop_job() is confusing
Christian Brabandt <cb@256bit.org>
parents:
12033
diff
changeset
|
5473 mch_signal_job(job, job->jv_stoponexit); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5474 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5475 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5476 /* |
10309
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10279
diff
changeset
|
5477 * Return TRUE when there is any job that has an exit callback and might exit, |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10279
diff
changeset
|
5478 * which means job_check_ended() should be called more often. |
9189
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5479 */ |
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5480 int |
9282
9f97a6290c63
commit https://github.com/vim/vim/commit/cf089463492fab53b2a5d81517829d22f882f82e
Christian Brabandt <cb@256bit.org>
parents:
9246
diff
changeset
|
5481 has_pending_job(void) |
9189
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5482 { |
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5483 job_T *job; |
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5484 |
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5485 for (job = first_job; job != NULL; job = job->jv_next) |
10309
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10279
diff
changeset
|
5486 /* Only should check if the channel has been closed, if the channel is |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10279
diff
changeset
|
5487 * open the job won't exit. */ |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5488 if ((job->jv_status == JOB_STARTED && !job_channel_still_useful(job)) |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5489 || (job->jv_status == JOB_FINISHED |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5490 && job_channel_can_close(job))) |
9189
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5491 return TRUE; |
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5492 return FALSE; |
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5493 } |
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5494 |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5495 #define MAX_CHECK_ENDED 8 |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5496 |
9189
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5497 /* |
9079
2cd83c854073
commit https://github.com/vim/vim/commit/36e0f7da9bc4a6ee8a7b17df503542a339e034c8
Christian Brabandt <cb@256bit.org>
parents:
9064
diff
changeset
|
5498 * Called once in a while: check if any jobs that seem useful have ended. |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5499 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5500 void |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5501 job_check_ended(void) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5502 { |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5503 int i; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5504 |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5505 if (first_job == NULL) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5506 return; |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5507 |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5508 for (i = 0; i < MAX_CHECK_ENDED; ++i) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5509 { |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5510 /* NOTE: mch_detect_ended_job() must only return a job of which the |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5511 * status was just set to JOB_ENDED. */ |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5512 job_T *job = mch_detect_ended_job(first_job); |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5513 |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5514 if (job == NULL) |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5515 break; |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5516 job_cleanup(job); /* may free "job" */ |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5517 } |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5518 |
9189
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5519 if (channel_need_redraw) |
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5520 { |
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5521 channel_need_redraw = FALSE; |
12244
d0b039e2ed56
patch 8.0.1002: unnecessarily updating screen after timer callback
Christian Brabandt <cb@256bit.org>
parents:
12240
diff
changeset
|
5522 redraw_after_callback(TRUE); |
9189
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5523 } |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5524 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5525 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5526 /* |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
5527 * Create a job and return it. Implements job_start(). |
13470
6faef782f50b
patch 8.0.1609: shell commands in the GUI use a dumb terminal
Christian Brabandt <cb@256bit.org>
parents:
13438
diff
changeset
|
5528 * "argv_arg" is only for Unix. |
6faef782f50b
patch 8.0.1609: shell commands in the GUI use a dumb terminal
Christian Brabandt <cb@256bit.org>
parents:
13438
diff
changeset
|
5529 * When "argv_arg" is NULL then "argvars" is used. |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
5530 * The returned job has a refcount of one. |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
5531 * Returns NULL when out of memory. |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5532 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5533 job_T * |
14065
e271ca6f32f9
patch 8.1.0050: $VIM_TERMINAL is also set when not in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
5534 job_start( |
e271ca6f32f9
patch 8.1.0050: $VIM_TERMINAL is also set when not in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
5535 typval_T *argvars, |
e271ca6f32f9
patch 8.1.0050: $VIM_TERMINAL is also set when not in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
5536 char **argv_arg, |
e271ca6f32f9
patch 8.1.0050: $VIM_TERMINAL is also set when not in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
5537 jobopt_T *opt_arg, |
e271ca6f32f9
patch 8.1.0050: $VIM_TERMINAL is also set when not in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
5538 int is_terminal UNUSED) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5539 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5540 job_T *job; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5541 char_u *cmd = NULL; |
13746
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5542 char **argv = NULL; |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5543 int argc = 0; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5544 #if defined(UNIX) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5545 # define USE_ARGV |
13806
c01864ecf233
patch 8.0.1775: MS-Windows: warning for unused variable
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
5546 int i; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5547 #else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5548 garray_T ga; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5549 #endif |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5550 jobopt_T opt; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
5551 ch_part_T part; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5552 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5553 job = job_alloc(); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5554 if (job == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5555 return NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5556 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5557 job->jv_status = JOB_FAILED; |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
5558 #ifndef USE_ARGV |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
5559 ga_init2(&ga, (int)sizeof(char*), 20); |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
5560 #endif |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5561 |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
5562 if (opt_arg != NULL) |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
5563 opt = *opt_arg; |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
5564 else |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
5565 { |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
5566 /* Default mode is NL. */ |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
5567 clear_job_options(&opt); |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
5568 opt.jo_mode = MODE_NL; |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
5569 if (get_job_options(&argvars[1], &opt, |
12058
e78fde22faec
patch 8.0.0909: channel test fails
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
5570 JO_MODE_ALL + JO_CB_ALL + JO_TIMEOUT_ALL + JO_STOPONEXIT |
e78fde22faec
patch 8.0.0909: channel test fails
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
5571 + JO_EXIT_CB + JO_OUT_IO + JO_BLOCK_WRITE, |
e78fde22faec
patch 8.0.0909: channel test fails
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
5572 JO2_ENV + JO2_CWD) == FAIL) |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
5573 goto theend; |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
5574 } |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5575 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5576 /* Check that when io is "file" that there is a file name. */ |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
5577 for (part = PART_OUT; part < PART_COUNT; ++part) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5578 if ((opt.jo_set & (JO_OUT_IO << (part - PART_OUT))) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5579 && opt.jo_io[part] == JIO_FILE |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5580 && (!(opt.jo_set & (JO_OUT_NAME << (part - PART_OUT))) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5581 || *opt.jo_io_name[part] == NUL)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5582 { |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
5583 EMSG(_("E920: _io file requires _name to be set")); |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
5584 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5585 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5586 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5587 if ((opt.jo_set & JO_IN_IO) && opt.jo_io[PART_IN] == JIO_BUFFER) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5588 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5589 buf_T *buf = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5590 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5591 /* check that we can find the buffer before starting the job */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5592 if (opt.jo_set & JO_IN_BUF) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5593 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5594 buf = buflist_findnr(opt.jo_io_buf[PART_IN]); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5595 if (buf == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5596 EMSGN(_(e_nobufnr), (long)opt.jo_io_buf[PART_IN]); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5597 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5598 else if (!(opt.jo_set & JO_IN_NAME)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5599 { |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
5600 EMSG(_("E915: in_io buffer requires in_buf or in_name to be set")); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5601 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5602 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5603 buf = buflist_find_by_name(opt.jo_io_name[PART_IN], FALSE); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5604 if (buf == NULL) |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
5605 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5606 if (buf->b_ml.ml_mfp == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5607 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5608 char_u numbuf[NUMBUFLEN]; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5609 char_u *s; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5610 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5611 if (opt.jo_set & JO_IN_BUF) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5612 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5613 sprintf((char *)numbuf, "%d", opt.jo_io_buf[PART_IN]); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5614 s = numbuf; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5615 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5616 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5617 s = opt.jo_io_name[PART_IN]; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5618 EMSG2(_("E918: buffer must be loaded: %s"), s); |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
5619 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5620 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5621 job->jv_in_buf = buf; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5622 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5623 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5624 job_set_options(job, &opt); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5625 |
13470
6faef782f50b
patch 8.0.1609: shell commands in the GUI use a dumb terminal
Christian Brabandt <cb@256bit.org>
parents:
13438
diff
changeset
|
5626 #ifdef USE_ARGV |
6faef782f50b
patch 8.0.1609: shell commands in the GUI use a dumb terminal
Christian Brabandt <cb@256bit.org>
parents:
13438
diff
changeset
|
5627 if (argv_arg != NULL) |
6faef782f50b
patch 8.0.1609: shell commands in the GUI use a dumb terminal
Christian Brabandt <cb@256bit.org>
parents:
13438
diff
changeset
|
5628 { |
13746
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5629 /* Make a copy of argv_arg for job->jv_argv. */ |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5630 for (i = 0; argv_arg[i] != NULL; i++) |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5631 argc++; |
13913
3e5c24ecc313
patch 8.0.1827: compiler warning for signed/unsigned char pointers
Christian Brabandt <cb@256bit.org>
parents:
13847
diff
changeset
|
5632 argv = (char **)alloc(sizeof(char *) * (argc + 1)); |
13746
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5633 if (argv == NULL) |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5634 goto theend; |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5635 for (i = 0; i < argc; i++) |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5636 argv[i] = (char *)vim_strsave((char_u *)argv_arg[i]); |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5637 argv[argc] = NULL; |
13470
6faef782f50b
patch 8.0.1609: shell commands in the GUI use a dumb terminal
Christian Brabandt <cb@256bit.org>
parents:
13438
diff
changeset
|
5638 } |
6faef782f50b
patch 8.0.1609: shell commands in the GUI use a dumb terminal
Christian Brabandt <cb@256bit.org>
parents:
13438
diff
changeset
|
5639 else |
6faef782f50b
patch 8.0.1609: shell commands in the GUI use a dumb terminal
Christian Brabandt <cb@256bit.org>
parents:
13438
diff
changeset
|
5640 #endif |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5641 if (argvars[0].v_type == VAR_STRING) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5642 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5643 /* Command is a string. */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5644 cmd = argvars[0].vval.v_string; |
8753
df91c8263f04
commit https://github.com/vim/vim/commit/8038568722a0aad72d001edf4972c29abab57f8f
Christian Brabandt <cb@256bit.org>
parents:
8746
diff
changeset
|
5645 if (cmd == NULL || *cmd == NUL) |
df91c8263f04
commit https://github.com/vim/vim/commit/8038568722a0aad72d001edf4972c29abab57f8f
Christian Brabandt <cb@256bit.org>
parents:
8746
diff
changeset
|
5646 { |
df91c8263f04
commit https://github.com/vim/vim/commit/8038568722a0aad72d001edf4972c29abab57f8f
Christian Brabandt <cb@256bit.org>
parents:
8746
diff
changeset
|
5647 EMSG(_(e_invarg)); |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
5648 goto theend; |
8753
df91c8263f04
commit https://github.com/vim/vim/commit/8038568722a0aad72d001edf4972c29abab57f8f
Christian Brabandt <cb@256bit.org>
parents:
8746
diff
changeset
|
5649 } |
13750
3ab6198c1f9a
patch 8.0.1747: MS-Windows: term_start() does not set job_info() cmd
Christian Brabandt <cb@256bit.org>
parents:
13748
diff
changeset
|
5650 |
3ab6198c1f9a
patch 8.0.1747: MS-Windows: term_start() does not set job_info() cmd
Christian Brabandt <cb@256bit.org>
parents:
13748
diff
changeset
|
5651 if (build_argv_from_string(cmd, &argv, &argc) == FAIL) |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
5652 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5653 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5654 else if (argvars[0].v_type != VAR_LIST |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5655 || argvars[0].vval.v_list == NULL |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5656 || argvars[0].vval.v_list->lv_len < 1) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5657 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5658 EMSG(_(e_invarg)); |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
5659 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5660 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5661 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5662 { |
13750
3ab6198c1f9a
patch 8.0.1747: MS-Windows: term_start() does not set job_info() cmd
Christian Brabandt <cb@256bit.org>
parents:
13748
diff
changeset
|
5663 list_T *l = argvars[0].vval.v_list; |
3ab6198c1f9a
patch 8.0.1747: MS-Windows: term_start() does not set job_info() cmd
Christian Brabandt <cb@256bit.org>
parents:
13748
diff
changeset
|
5664 |
3ab6198c1f9a
patch 8.0.1747: MS-Windows: term_start() does not set job_info() cmd
Christian Brabandt <cb@256bit.org>
parents:
13748
diff
changeset
|
5665 if (build_argv_from_list(l, &argv, &argc) == FAIL) |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
5666 goto theend; |
13746
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5667 #ifndef USE_ARGV |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5668 if (win32_build_cmd(l, &ga) == FAIL) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5669 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5670 cmd = ga.ga_data; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5671 #endif |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5672 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5673 |
13746
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5674 /* Save the command used to start the job. */ |
13913
3e5c24ecc313
patch 8.0.1827: compiler warning for signed/unsigned char pointers
Christian Brabandt <cb@256bit.org>
parents:
13847
diff
changeset
|
5675 job->jv_argv = argv; |
13740
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5676 |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5677 #ifdef USE_ARGV |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5678 if (ch_log_active()) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5679 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5680 garray_T ga; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5681 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5682 ga_init2(&ga, (int)sizeof(char), 200); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5683 for (i = 0; i < argc; ++i) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5684 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5685 if (i > 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5686 ga_concat(&ga, (char_u *)" "); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5687 ga_concat(&ga, (char_u *)argv[i]); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5688 } |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
5689 ch_log(NULL, "Starting job: %s", (char *)ga.ga_data); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5690 ga_clear(&ga); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5691 } |
14065
e271ca6f32f9
patch 8.1.0050: $VIM_TERMINAL is also set when not in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
5692 mch_job_start(argv, job, &opt, is_terminal); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5693 #else |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
5694 ch_log(NULL, "Starting job: %s", (char *)cmd); |
11723
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
5695 mch_job_start((char *)cmd, job, &opt); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5696 #endif |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5697 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5698 /* If the channel is reading from a buffer, write lines now. */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5699 if (job->jv_channel != NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5700 channel_write_in(job->jv_channel); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5701 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5702 theend: |
13746
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5703 #ifndef USE_ARGV |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5704 vim_free(ga.ga_data); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5705 #endif |
13913
3e5c24ecc313
patch 8.0.1827: compiler warning for signed/unsigned char pointers
Christian Brabandt <cb@256bit.org>
parents:
13847
diff
changeset
|
5706 if (argv != job->jv_argv) |
13746
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5707 vim_free(argv); |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
5708 free_job_options(&opt); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5709 return job; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5710 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5711 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5712 /* |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5713 * Get the status of "job" and invoke the exit callback when needed. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5714 * The returned string is not allocated. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5715 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5716 char * |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5717 job_status(job_T *job) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5718 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5719 char *result; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5720 |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5721 if (job->jv_status >= JOB_ENDED) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5722 /* No need to check, dead is dead. */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5723 result = "dead"; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5724 else if (job->jv_status == JOB_FAILED) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5725 result = "fail"; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5726 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5727 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5728 result = mch_job_status(job); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5729 if (job->jv_status == JOB_ENDED) |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5730 job_cleanup(job); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5731 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5732 return result; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5733 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5734 |
8502
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5735 /* |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5736 * Implementation of job_info(). |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5737 */ |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5738 void |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5739 job_info(job_T *job, dict_T *dict) |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5740 { |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5741 dictitem_T *item; |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5742 varnumber_T nr; |
13740
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5743 list_T *l; |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5744 int i; |
8502
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5745 |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
5746 dict_add_string(dict, "status", (char_u *)job_status(job)); |
8502
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5747 |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5748 item = dictitem_alloc((char_u *)"channel"); |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5749 if (item == NULL) |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5750 return; |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5751 item->di_tv.v_type = VAR_CHANNEL; |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5752 item->di_tv.vval.v_channel = job->jv_channel; |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5753 if (job->jv_channel != NULL) |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5754 ++job->jv_channel->ch_refcount; |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5755 if (dict_add(dict, item) == FAIL) |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5756 dictitem_free(item); |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5757 |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5758 #ifdef UNIX |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5759 nr = job->jv_pid; |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5760 #else |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5761 nr = job->jv_proc_info.dwProcessId; |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5762 #endif |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
5763 dict_add_number(dict, "process", nr); |
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
5764 dict_add_string(dict, "tty_in", job->jv_tty_in); |
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
5765 dict_add_string(dict, "tty_out", job->jv_tty_out); |
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
5766 |
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
5767 dict_add_number(dict, "exitval", job->jv_exitval); |
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
5768 dict_add_string(dict, "exit_cb", job->jv_exit_cb); |
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
5769 dict_add_string(dict, "stoponexit", job->jv_stoponexit); |
13740
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5770 |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5771 l = list_alloc(); |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5772 if (l != NULL) |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5773 { |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5774 dict_add_list(dict, "cmd", l); |
13746
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5775 if (job->jv_argv != NULL) |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5776 for (i = 0; job->jv_argv[i] != NULL; i++) |
13913
3e5c24ecc313
patch 8.0.1827: compiler warning for signed/unsigned char pointers
Christian Brabandt <cb@256bit.org>
parents:
13847
diff
changeset
|
5777 list_append_string(l, (char_u *)job->jv_argv[i], -1); |
13740
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5778 } |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5779 } |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5780 |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5781 /* |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5782 * Implementation of job_info() to return info for all jobs. |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5783 */ |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5784 void |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5785 job_info_all(list_T *l) |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5786 { |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5787 job_T *job; |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5788 typval_T tv; |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5789 |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5790 for (job = first_job; job != NULL; job = job->jv_next) |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5791 { |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5792 tv.v_type = VAR_JOB; |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5793 tv.vval.v_job = job; |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5794 |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5795 if (list_append_tv(l, &tv) != OK) |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5796 return; |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5797 } |
8502
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5798 } |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
5799 |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
5800 /* |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
5801 * Send a signal to "job". Implements job_stop(). |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
5802 * When "type" is not NULL use this for the type. |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
5803 * Otherwise use argvars[1] for the type. |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
5804 */ |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5805 int |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
5806 job_stop(job_T *job, typval_T *argvars, char *type) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5807 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5808 char_u *arg; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5809 |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
5810 if (type != NULL) |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
5811 arg = (char_u *)type; |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
5812 else if (argvars[1].v_type == VAR_UNKNOWN) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5813 arg = (char_u *)""; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5814 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5815 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5816 arg = get_tv_string_chk(&argvars[1]); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5817 if (arg == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5818 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5819 EMSG(_(e_invarg)); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5820 return 0; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5821 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5822 } |
11727
cb1dc90d22cc
patch 8.0.0746: when :term fails the job is not properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
5823 if (job->jv_status == JOB_FAILED) |
cb1dc90d22cc
patch 8.0.0746: when :term fails the job is not properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
5824 { |
cb1dc90d22cc
patch 8.0.0746: when :term fails the job is not properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
5825 ch_log(job->jv_channel, "Job failed to start, job_stop() skipped"); |
cb1dc90d22cc
patch 8.0.0746: when :term fails the job is not properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
5826 return 0; |
cb1dc90d22cc
patch 8.0.0746: when :term fails the job is not properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
5827 } |
11408
c9924ea60cc7
patch 8.0.0588: job_stop() often assumes the channel will be closed
Christian Brabandt <cb@256bit.org>
parents:
11317
diff
changeset
|
5828 if (job->jv_status == JOB_ENDED) |
c9924ea60cc7
patch 8.0.0588: job_stop() often assumes the channel will be closed
Christian Brabandt <cb@256bit.org>
parents:
11317
diff
changeset
|
5829 { |
c9924ea60cc7
patch 8.0.0588: job_stop() often assumes the channel will be closed
Christian Brabandt <cb@256bit.org>
parents:
11317
diff
changeset
|
5830 ch_log(job->jv_channel, "Job has already ended, job_stop() skipped"); |
c9924ea60cc7
patch 8.0.0588: job_stop() often assumes the channel will be closed
Christian Brabandt <cb@256bit.org>
parents:
11317
diff
changeset
|
5831 return 0; |
c9924ea60cc7
patch 8.0.0588: job_stop() often assumes the channel will be closed
Christian Brabandt <cb@256bit.org>
parents:
11317
diff
changeset
|
5832 } |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
5833 ch_log(job->jv_channel, "Stopping job with '%s'", (char *)arg); |
12037
85f0f557661e
patch 8.0.0899: function name mch_stop_job() is confusing
Christian Brabandt <cb@256bit.org>
parents:
12033
diff
changeset
|
5834 if (mch_signal_job(job, arg) == FAIL) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5835 return 0; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5836 |
11408
c9924ea60cc7
patch 8.0.0588: job_stop() often assumes the channel will be closed
Christian Brabandt <cb@256bit.org>
parents:
11317
diff
changeset
|
5837 /* Assume that only "kill" will kill the job. */ |
c9924ea60cc7
patch 8.0.0588: job_stop() often assumes the channel will be closed
Christian Brabandt <cb@256bit.org>
parents:
11317
diff
changeset
|
5838 if (job->jv_channel != NULL && STRCMP(arg, "kill") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5839 job->jv_channel->ch_job_killed = TRUE; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5840 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5841 /* We don't try freeing the job, obviously the caller still has a |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5842 * reference to it. */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5843 return 1; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5844 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5845 |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5846 void |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5847 invoke_prompt_callback(void) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5848 { |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5849 typval_T rettv; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5850 int dummy; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5851 typval_T argv[2]; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5852 char_u *text; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5853 char_u *prompt; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5854 linenr_T lnum = curbuf->b_ml.ml_line_count; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5855 |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5856 // Add a new line for the prompt before invoking the callback, so that |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5857 // text can always be inserted above the last line. |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5858 ml_append(lnum, (char_u *)"", 0, FALSE); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5859 curwin->w_cursor.lnum = lnum + 1; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5860 curwin->w_cursor.col = 0; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5861 |
14103
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5862 if (curbuf->b_prompt_callback == NULL || *curbuf->b_prompt_callback == NUL) |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5863 return; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5864 text = ml_get(lnum); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5865 prompt = prompt_text(); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5866 if (STRLEN(text) >= STRLEN(prompt)) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5867 text += STRLEN(prompt); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5868 argv[0].v_type = VAR_STRING; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5869 argv[0].vval.v_string = vim_strsave(text); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5870 argv[1].v_type = VAR_UNKNOWN; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5871 |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5872 call_func(curbuf->b_prompt_callback, |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5873 (int)STRLEN(curbuf->b_prompt_callback), |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5874 &rettv, 1, argv, NULL, 0L, 0L, &dummy, TRUE, |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5875 curbuf->b_prompt_partial, NULL); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5876 clear_tv(&argv[0]); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5877 clear_tv(&rettv); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5878 } |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
5879 |
14103
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5880 /* |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5881 * Return TRUE when the interrupt callback was invoked. |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5882 */ |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5883 int |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5884 invoke_prompt_interrupt(void) |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5885 { |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5886 typval_T rettv; |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5887 int dummy; |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5888 typval_T argv[1]; |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5889 |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5890 if (curbuf->b_prompt_interrupt == NULL |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5891 || *curbuf->b_prompt_interrupt == NUL) |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5892 return FALSE; |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5893 argv[0].v_type = VAR_UNKNOWN; |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5894 |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5895 got_int = FALSE; // don't skip executing commands |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5896 call_func(curbuf->b_prompt_interrupt, |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5897 (int)STRLEN(curbuf->b_prompt_interrupt), |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5898 &rettv, 0, argv, NULL, 0L, 0L, &dummy, TRUE, |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5899 curbuf->b_prompt_int_partial, NULL); |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5900 clear_tv(&rettv); |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5901 return TRUE; |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5902 } |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
5903 |
8493
caed4b2d305f
commit https://github.com/vim/vim/commit/509ce2a558e7e0c03242e32e844255af52f1c821
Christian Brabandt <cb@256bit.org>
parents:
8491
diff
changeset
|
5904 #endif /* FEAT_JOB_CHANNEL */ |