Skip to content

Commit c0e65e6

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 36739b0 + f416086 commit c0e65e6

File tree

10 files changed

+433
-163
lines changed

10 files changed

+433
-163
lines changed

runtime/doc/channel.txt

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*channel.txt* For Vim version 7.4. Last change: 2016 Feb 04
1+
*channel.txt* For Vim version 7.4. Last change: 2016 Feb 05
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -32,7 +32,7 @@ $VIMRUNTIME/tools/demoserver.py
3232
Run it in one terminal. We will call this T1.
3333

3434
Run Vim in another terminal. Connect to the demo server with: >
35-
let handle = ch_open('localhost:8765', 'json')
35+
let handle = ch_open('localhost:8765')
3636
3737
In T1 you should see:
3838
=== socket opened === ~
@@ -62,40 +62,54 @@ To handle asynchronous communication a callback needs to be used: >
6262
Instead of giving a callback with every send call, it can also be specified
6363
when opening the channel: >
6464
call ch_close(handle)
65-
let handle = ch_open('localhost:8765', 'json', "MyHandler")
65+
let handle = ch_open('localhost:8765', {'callback': "MyHandler"})
6666
call ch_sendexpr(handle, 'hello!', 0)
6767
6868
==============================================================================
6969
2. Opening a channel *channel-open*
7070

7171
To open a channel: >
72-
let handle = ch_open({address}, {mode}, {callback})
72+
let handle = ch_open({address} [, {argdict}])
7373
7474
{address} has the form "hostname:port". E.g., "localhost:8765".
7575

76-
{mode} can be: *channel-mode*
77-
"json" - Use JSON, see below; most convenient way
76+
{argdict} is a dictionary with optional entries:
77+
78+
"mode" can be: *channel-mode*
79+
"json" - Use JSON, see below; most convenient way. Default.
7880
"raw" - Use raw messages
7981

8082
*channel-callback*
81-
{callback} is a function that is called when a message is received that is not
83+
"callback" is a function that is called when a message is received that is not
8284
handled otherwise. It gets two arguments: the channel handle and the received
8385
message. Example: >
8486
func Handle(handle, msg)
8587
echo 'Received: ' . a:msg
8688
endfunc
8789
let handle = ch_open("localhost:8765", 'json', "Handle")
8890
89-
When {mode} is "json" the "msg" argument is the body of the received message,
91+
"waittime" is the time to wait for the connection to be made in milliseconds.
92+
The default is zero, don't wait, which is useful if the server is supposed to
93+
be running already. A negative number waits forever.
94+
95+
"timeout" is the time to wait for a request when blocking, using
96+
ch_sendexpr(). Again in millisecons. The default si 2000 (2 seconds).
97+
98+
When "mode" is "json" the "msg" argument is the body of the received message,
9099
converted to Vim types.
91-
When {mode} is "raw" the "msg" argument is the whole message as a string.
100+
When "mode" is "raw" the "msg" argument is the whole message as a string.
92101

93-
When {mode} is "json" the {callback} is optional. When omitted it is only
102+
When "mode" is "json" the "callback" is optional. When omitted it is only
94103
possible to receive a message after sending one.
95104

96105
The handler can be added or changed later: >
97106
call ch_setcallback(handle, {callback})
98-
When {callback} is empty (zero or an empty string) the handler is removed.
107+
When "callback is empty (zero or an empty string) the handler is removed.
108+
NOT IMPLEMENTED YET
109+
110+
The timeout can be changed later: >
111+
call ch_settimeout(handle, {msec})
112+
NOT IMPLEMENTED YET
99113

100114
Once done with the channel, disconnect it like this: >
101115
call ch_close(handle)

runtime/doc/eval.txt

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*eval.txt* For Vim version 7.4. Last change: 2016 Feb 04
1+
*eval.txt* For Vim version 7.4. Last change: 2016 Feb 05
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1811,8 +1811,7 @@ call( {func}, {arglist} [, {dict}])
18111811
any call {func} with arguments {arglist}
18121812
ceil( {expr}) Float round {expr} up
18131813
ch_close( {handle}) none close a channel
1814-
ch_open( {address}, {mode} [, {callback}])
1815-
Number open a channel
1814+
ch_open( {address} [, {argdict})] Number open a channel to {address}
18161815
ch_sendexpr( {handle}, {expr} [, {callback}])
18171816
any send {expr} over JSON channel {handle}
18181817
ch_sendraw( {handle}, {string} [, {callback}])
@@ -2670,19 +2669,27 @@ confirm({msg} [, {choices} [, {default} [, {type}]]])
26702669
ch_close({handle}) *ch_close()*
26712670
Close channel {handle}. See |channel|.
26722671

2673-
ch_open({address}, {mode} [, {callback}]) *ch_open()*
2672+
ch_open({address} [, {argdict}]) *ch_open()*
26742673
Open a channel to {address}. See |channel|.
26752674
Returns the channel handle on success. Returns a negative
26762675
number for failure.
26772676

26782677
{address} has the form "hostname:port", e.g.,
26792678
"localhost:8765".
26802679

2681-
{mode} is either "json" or "raw". See |channel-mode| for the
2682-
meaning.
2683-
2684-
{callback} is a function that handles received messages on the
2685-
channel. See |channel-callback|.
2680+
If {argdict} is given it must be a |Directory|. The optional
2681+
items are:
2682+
mode "raw" or "json".
2683+
Default "json".
2684+
callback function to call for requests with a zero
2685+
sequence number. See |channel-callback|.
2686+
Default: none.
2687+
waittime Specify connect timeout as milliseconds.
2688+
Negative means forever.
2689+
Default: 0.
2690+
timeout Specify response read timeout value as
2691+
milliseconds.
2692+
Default: 2000.
26862693

26872694
ch_sendexpr({handle}, {expr} [, {callback}]) *ch_sendexpr()*
26882695
Send {expr} over JSON channel {handle}. See |channel-use|.

0 commit comments

Comments
 (0)